diff --git a/.github/workflows/PR-check-cmake.yml b/.github/workflows/PR-check-cmake.yml index e7b40d123..f4237ae3b 100644 --- a/.github/workflows/PR-check-cmake.yml +++ b/.github/workflows/PR-check-cmake.yml @@ -10,11 +10,6 @@ on: - master - experimental - staged - paths-ignore: - - "docs/**" - - "*.md" - - "locale/**" - - "website/**" jobs: job_ubuntu_build_check: name: ubuntu Build and analyze @@ -108,6 +103,7 @@ jobs: New-Item -Path './build_dir' -ItemType Directory cmake -S . -B "./build_dir" ` -G Ninja ` + -DWITH_VCPKG_BREAKPAD=ON ` -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" ` -DWITH_FFMPEG_PLAYER=OFF cmake --build "./build_dir" diff --git a/.github/workflows/create-vcpkg-export-archive.yml b/.github/workflows/create-vcpkg-export-archive.yml new file mode 100644 index 000000000..8e45c0e5b --- /dev/null +++ b/.github/workflows/create-vcpkg-export-archive.yml @@ -0,0 +1,56 @@ +name: Create vcpkg export archive +on: + workflow_dispatch: + + +env: + outputName: goldendict-ng-vcpkg-export + +jobs: + create_new_cache: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create export + run: | + # ensure always up to date + vcpkg x-update-baseline + + vcpkg install --x-feature=breakpad + vcpkg export --raw --output-dir=.\exports --output=${{ env.outputName }} + echo "Starts compressing..." + cd .\exports + cmake -E tar c ${{ env.outputName }}.tar.zst --zstd .\${{ env.outputName }} + + - name: Upload as release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + $vcpkgBaselineVersion = $(Get-Content .\vcpkg-configuration.json | ConvertFrom-Json).'default-registry'.'baseline' + $dateString = Get-Date -Format "yyMMdd" + + $tagName = "vcpkg_${dateString}_${vcpkgBaselineVersion}" + + cd .\exports\ + $fileHash = $(Get-FileHash ${{ env.outputName }}.tar.zst SHA512).Hash + + + $notes=@" + GoldenDict-ng's windows build artifacts created with vcpkg, for development purpose only. + + vcpkg baseline version: + SHA512: + `````` + ${fileHash} + `````` + packages: + `````` + "@ + Add-Content -Path .\note.txt -Value ${notes} + vcpkg list | Add-Content .\note.txt + Add-Content -Path .\note.txt -Value "``````" + Get-Content .\note.txt + + + gh release create "${tagName}" --notes-file=.\note.txt --title "vcpkg package export archive" --latest=false + gh release upload "${tagName}" ${{ env.outputName }}.tar.zst --clobber \ No newline at end of file diff --git a/.github/workflows/release-windows-vcpkg-cmake.yml b/.github/workflows/release-windows-vcpkg-cmake.yml index 26bcacde9..29c68c120 100644 --- a/.github/workflows/release-windows-vcpkg-cmake.yml +++ b/.github/workflows/release-windows-vcpkg-cmake.yml @@ -106,16 +106,8 @@ jobs: } ] } - - name: setup vcpkg github caches variables - uses: actions/github-script@v7 - with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - name: Build binaries id: build - env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" run: | # Launch-VsDevShell also provides Ninja & 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1' ` @@ -128,8 +120,6 @@ jobs: -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" ` -DCMAKE_BUILD_TYPE=RelWithDebInfo ` -DWITH_FFMPEG_PLAYER=OFF ` - -DUSE_VCPKG=ON ` - -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" ` -DWITH_VCPKG_BREAKPAD=ON cmake --build "./build_dir" - name: CPack create package @@ -160,7 +150,7 @@ jobs: ${{steps.build_changelog.outputs.changelog}} '@ - $tagExist = gh api --silent "repos/:owner/:repo/git/refs/tags/${{github.ref_name}}" + $tagExist = gh api --silent "repos/:owner/:repo/git/refs/tags/${tagName}" if (-not $?) { if ($env:prerelease -eq "true") { gh release create ${tagName} --target ${{github.ref_name}} --notes-file=./change_note.txt --latest=false --prerelease diff --git a/CMakeLists.txt b/CMakeLists.txt index 49a671aaa..29327d38b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,14 +3,12 @@ cmake_minimum_required(VERSION 3.25) # ubuntu 23.04 Fedora 36 option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON) option(WITH_EPWING_SUPPORT "Enable epwing support" ON) option(WITH_ZIM "enable zim support" ON) -option(WITH_TTS "enable QTexttoSpeech support" ON) +option(WITH_TTS "enable QTexttoSpeech support" OFF) # options for linux packaging option(USE_SYSTEM_FMT "use system fmt instead of bundled one" OFF) option(USE_SYSTEM_TOML "use system toml++ instead of bundled one" OFF) -# vcpkg build - only tested on Windows, does not support FFMPEG -option(USE_VCPKG "uses VCPKG for providing dependencies" OFF) option(WITH_VCPKG_BREAKPAD "build with Breakpad support for VCPKG build only" OFF) ## Change binary & resources folder to parallel install with original GD. @@ -22,9 +20,29 @@ option(USE_ALTERNATIVE_NAME "Force the name goldendict-ng " OFF) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") # to put staff in the ./cmake folder -if(WITH_VCPKG_BREAKPAD) - list(APPEND VCPKG_MANIFEST_FEATURES "breakpad") -endif() + +# vcpkg handling code, must be placed before project() +if (WIN32) + if (DEFINED CMAKE_TOOLCHAIN_FILE) + message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}") + else () + message(STATUS "CMAKE_TOOLCHAIN_FILE is not set. Try fetching cached vcpkg.") + include(FetchContent) + FetchContent_Declare( + vcpkg-export + URL https://github.com/xiaoyifang/goldendict-ng/releases/download/vcpkg_240711_3d72d8c930e1b6a1b2432b262c61af7d3287dcd0/goldendict-ng-vcpkg-export.tar.zst + URL_HASH SHA512=CB7AB20F03CE1BB1D46FE5DF25C9B9F4E365B72CE0A817B3C9E39BD0C85DC571F992363A1A5E8DD1E31C44FF88C51E9A88A537688C6070B4E58FF8FA2585EAB7 + ) + FetchContent_MakeAvailable(vcpkg-export) + set(VCPKG_MANIFEST_MODE OFF CACHE BOOL "disable existing manifest mode caused by the existrance of vcpkg.json" FORCE) + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/_deps/vcpkg-export-src/scripts/buildsystems/vcpkg.cmake") + endif () +endif () + + +if (WITH_VCPKG_BREAKPAD) + list(APPEND VCPKG_MANIFEST_FEATURES "breakpad") +endif () include(FeatureSummary) @@ -203,10 +221,8 @@ endif () #### libraries linking && includes for Win or Unix -if (USE_VCPKG) +if (WIN32) include(Deps_Vcpkg) -elseif (WIN32) - include(Deps_Win) else () include(Deps_Unix) endif () @@ -313,36 +329,23 @@ if (WIN32) LIBRARY_OUTPUT_DIRECTORY "${GD_WIN_OUTPUT_DIR}" ) - if (NOT USE_VCPKG) - add_custom_target(windeploy - COMMENT "Deploy everything to the output dir" - DEPENDS ${GOLDENDICT} # build this target will check if Goldendict.exe is already built - COMMAND ${WINDEPLOYQT_EXECUTABLE} --no-quick-import "${GD_WIN_OUTPUT_DIR}/${GOLDENDICT}.exe" --plugindir "${GD_WIN_OUTPUT_DIR}/plugins" - COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/opencc" "${GD_WIN_OUTPUT_DIR}/opencc" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/LICENSE.txt" "${GD_WIN_OUTPUT_DIR}/LICENSE.txt" - COMMAND ${CMAKE_COMMAND} -E rm -f "${GD_WIN_OUTPUT_DIR}/goldendict.exe.manifest" "${GD_WIN_OUTPUT_DIR}/eb.dll.manifest" - WORKING_DIRECTORY ${GD_WIN_OUTPUT_DIR} - ) - - else () # VCPKG deploy - set(CMAKE_INSTALL_PREFIX "${GD_WIN_OUTPUT_DIR}" CACHE PATH "If you see this message, don't change this unless you want look into CMake build script. If you are an expert, yes, this is wrong. Help welcomed." FORCE) + set(CMAKE_INSTALL_PREFIX "${GD_WIN_OUTPUT_DIR}" CACHE PATH "If you see this message, don't change this unless you want look into CMake build script. If you are an expert, yes, this is wrong. Help welcomed." FORCE) - qt_generate_deploy_script( - TARGET ${GOLDENDICT} - OUTPUT_SCRIPT deploy_script - CONTENT "qt_deploy_runtime_dependencies( - EXECUTABLE \"${CMAKE_INSTALL_PREFIX}/goldendict.exe\" - BIN_DIR . - LIB_DIR . - )" - ) + qt_generate_deploy_script( + TARGET ${GOLDENDICT} + OUTPUT_SCRIPT deploy_script + CONTENT "qt_deploy_runtime_dependencies( + EXECUTABLE \"${CMAKE_INSTALL_PREFIX}/goldendict.exe\" + BIN_DIR . + LIB_DIR . + )" + ) - install(SCRIPT ${deploy_script}) - install(DIRECTORY "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/opencc" DESTINATION .) - # TODO: do we really need to carry a copy of openSSL? - install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libssl-3-x64.dll" DESTINATION .) - install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libcrypto-3-x64.dll" DESTINATION .) - endif () + install(SCRIPT ${deploy_script}) + install(DIRECTORY "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/opencc" DESTINATION .) + # TODO: do we really need to carry a copy of openSSL? + install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libssl-3-x64.dll" DESTINATION .) + install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libcrypto-3-x64.dll" DESTINATION .) # trick CPack to make the output folder as NSIS installer install(DIRECTORY "${GD_WIN_OUTPUT_DIR}/" diff --git a/cmake/Deps_Win.cmake b/cmake/Deps_Win.cmake deleted file mode 100644 index d0f33353a..000000000 --- a/cmake/Deps_Win.cmake +++ /dev/null @@ -1,50 +0,0 @@ -target_include_directories(${GOLDENDICT} PUBLIC - ${CMAKE_SOURCE_DIR}/winlibs/include/ - ) - -set_property(TARGET ${BIN_NAME} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - -file(GLOB WINLIBS_FILES "${CMAKE_SOURCE_DIR}/winlibs/lib/msvc/*.lib") -foreach (A_WIN_LIB ${WINLIBS_FILES}) - target_link_libraries(${GOLDENDICT} PRIVATE ${A_WIN_LIB}) -endforeach () - -set(THIRD_PARTY_LIBARY - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/lzma.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/lzma.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/zstd.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/zstd.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/xapian.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/xapian.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/hunspell-1.7.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/hunspell-1.7.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/zim.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/zim.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/opencc.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/opencc.lib - debug ${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/zlibd.lib optimized ${CMAKE_SOURCE_DIR}/winlibs/lib/zlib.lib - ) -target_link_libraries(${GOLDENDICT} PRIVATE ${THIRD_PARTY_LIBARY}) - -# Copy .dlls to output dir - -file(GLOB DLL_FILES LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/winlibs/lib/msvc/*.dll" "${Qt6_ROOT}/bin/av*.dll" "${Qt6_ROOT}/bin/sw*.dll") -foreach (A_DLL_FILE ${DLL_FILES}) - get_filename_component(TEMP_VAR_HOLDING_DLL_FILENAME ${A_DLL_FILE} NAME) - configure_file("${A_DLL_FILE}" "${GD_WIN_OUTPUT_DIR}/${TEMP_VAR_HOLDING_DLL_FILENAME}" COPYONLY) -endforeach () - -if (CMAKE_BUILD_TYPE MATCHES Debug) - file(GLOB DLL_FILES LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/winlibs/lib/dbg/*.dll") -else () - file(GLOB DLL_FILES LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/winlibs/lib/*.dll") -endif () -foreach (A_DLL_FILE ${DLL_FILES}) - get_filename_component(TEMP_VAR_HOLDING_DLL_FILENAME ${A_DLL_FILE} NAME) - configure_file("${A_DLL_FILE}" "${GD_WIN_OUTPUT_DIR}/${TEMP_VAR_HOLDING_DLL_FILENAME}" COPYONLY) -endforeach () - -if (WITH_EPWING_SUPPORT) - add_subdirectory(thirdparty/eb EXCLUDE_FROM_ALL) - target_include_directories(${GOLDENDICT} PRIVATE - thirdparty - ) - target_link_libraries(${GOLDENDICT} PRIVATE eb) - - set_target_properties(eb PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${GD_WIN_OUTPUT_DIR}) -endif () diff --git a/website/docs/developer.md b/website/docs/developer.md index 71267d4fb..fc552fd50 100644 --- a/website/docs/developer.md +++ b/website/docs/developer.md @@ -1,34 +1,104 @@ -Developing GoldenDict is not hard. +If you know some C++ and optionally some Qt, you can start to modify GoldenDict right now. -If you know some C++ and optionally some Qt, you can start to modify GoldenDict right now: +This page is a brief introduction on how to get started. -## Install Qt and QtCreator - (On Linux, install dependencies) +For technical details see [how to build from source](howto/build_from_source.md). + +## 1. Install Qt + +To install Qt on macOS or Windows, uses the [Qt Online Installer](https://doc.qt.io/qt-6/get-and-install-qt.html). It can be downloaded from [Qt for Open Source](https://www.qt.io/download-open-source). + +Those Qt components are needed + ++ Qt + + 6.7.2 (Or another version) + + MSVC 2019 (or MSVC 2022) + + Qt5 Compatible Module + + Additional Libraries + + Qt Image formats + + Qt MultiMedia + + Qt Positioning + + Qt SerialPort (? super weird here, but it is needed.) + + Qt Speech + + Qt Webchannel + + Qt Webengine + + Qt Creator (optional) + + CMake + + Ninja + +Note that MinGW is not supported. + +CMake and Ninja are needed. + +## 2. Install a compiler + +For windows, MSVC can be obtained by [installing Visual Studio's "Desktop development with C++"](https://learn.microsoft.com/cpp/build/vscpp-step-0-installation). + +For macOS, install [XCode](https://developer.apple.com/xcode/). + +## 3. Obtain dependencies + +For Windows, prebuilt libraries will be automatically downloaded. + +For macOS, install [Homebrew](https://brew.sh/) and install related packages as described in [how to build from source](howto/build_from_source.md) or search `brew install` command in [macOS release's build file](https://github.com/xiaoyifang/goldendict-ng/blob/staged/.github/workflows/release-macos-homebrew.yml). + +## 4. Build + +First, get GoldenDict's source code by [Cloning a repository](https://docs.github.com/repositories/creating-and-managing-repositories/cloning-a-repository). + +Then choose your favorite IDE/editor and load the `CMakeLists.txt`. If unsure, just use Qt Creator. + +### Qt Creator + +Open `CMakeLists.txt` from Qt Creator, then you wil choose a "Kit" which is pretty much a Qt installation. + +Qt Creator usually can auto detect your Qt installation. In case it doesn't, check out "Kit" settings. Note that, the compiler must be set to MSVC on Windows. + +By default everything will be built, you can disable ffmpeg, epwing... + +![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/49f6a85e-50ec-4467-b0e4-cf088d218053) + +Then, hit the "Run" button at bottom-right corner should build and run GoldenDict. + +### Command Line only +See [how to build from source](howto/build_from_source.md). + +[Qt's doc: Building projects on the command line](https://doc.qt.io/qt-6/cmake-build-on-cmdline.html) + +### Visual Studio +VS2022 has CMake support. After opening the source code folder, VS will starts to configure CMake but likely won't succeed. + +You need to add Qt's path and other options to "CMake command arguments". Then, "save" the dialog with Ctrl+S or click one of the many "(re)configure cache" buttons. + +![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/33a52c52-2e8a-4b8c-bb05-4a753f95ff7e) + +Click run will build the project, but the `.exe` would not run, because the dependencies are not copied. + +Simply click "install", which is actually copying dependencies. + +![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/02e843b1-0842-445c-919c-75618346aaaf) + +### Visual Studio Code + +Install [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). + +Then open GoldenDict's folder, and the CMake extension will kicks in. + +Then add Qt's path and various other options to configure arguments. - Windows(qtcreator for example) -### Prerequisite -Install visual studio community ,choose C++ component. - -QtCreator Packages: ``` -[x]qtX.X.X version -[x]MSVC2019 /GCC -[x]Qt5 Compatible Module -[*]Additional - [x]Qt Image formats - [x]Qt MultiMedia - [x]Qt Positioning - [x]Qt speech - [x]Qt webchannel - [x]Qt webengine +-DCMAKE_PREFIX_PATH={Your Qt install path}\6.7.2\msvc2019_64 ``` -## Coding Standards +![](https://github.com/xiaoyifang/goldendict-ng/assets/20123683/bd87155e-2e61-41d5-81e2-7bfb1f13c4c4) -Please follow [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and write modern C++ code. +### CLion +### XCode +### CMake GUI +### LSP + Editor? -Commit messages should follow [Conventional Commits](https://www.conventionalcommits.org) +## Related Things -Reformat changes with `clang-format` [how to use clang-format](https://github.com/xiaoyifang/goldendict/blob/staged/howto/how%20to%20use%20.clang-format%20to%20format%20the%20code.md) +Please follow [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and write modern C++ code. -Remember to enable `clang-tidy` support on your editor so that `.clang-tidy` will be respected. +[Qt's documentation](https://doc.qt.io/) diff --git a/website/docs/howto/build_from_source.md b/website/docs/howto/build_from_source.md index 68aecd23f..24df58389 100644 --- a/website/docs/howto/build_from_source.md +++ b/website/docs/howto/build_from_source.md @@ -1,9 +1,9 @@ +The `release-*` and `PR-check-*` workflow files under `.github` in the source code has actual build & commands for reference. + ## Dependencies -* C++17 compiler +* C++17 compiler (For windows it must be MSVC) * Latest QT6 -* Various libraries for Linux & macOS, see below -* On Windows all the libraries are included in the repository For debian/ubuntu, those packages are needed @@ -18,7 +18,6 @@ qt6-webengine-dev x11proto-record-dev zlib1g-dev In other words, those libraries -* Qt6 (with webengine) * ffmpeg * libzim * xapian @@ -35,68 +34,52 @@ And a few compression libraries: * lzo2 * zlib -## CMake Build +## Build Basically, you need those commands: ```shell cd goldendict-ng && mkdir build_dir # config step -cmake -S . -B build_dir \ - --install-prefix=/usr/local/ \ - -DCMAKE_BUILD_TYPE=Release +cmake -S . -B build_dir -G Ninja # actual build -cmake --build build_dir --parallel 7 +cmake --build build_dir cmake --install ./build_dir/ ``` ### Feature flags -Append `-D{flag_names}=ON/OFF` to cmake's config step +Append `-D{flag_names}=ON/OFF` to cmake's config step. Available flags can be found on the top of `CMakeLists.txt` ### Windows -Install Qt6(msvc) through the standard installer and pass Qt's path to CMake +Install Qt6 (MSVC) through [Qt Online Installer](https://doc.qt.io/qt-6/get-and-install-qt.html) and add Qt's path to CMake ``` -DCMAKE_PREFIX_PATH=F:\Qt\6.4.1\msvc2019_64 ``` -The built artifacts will end up in `build_dir/goldendict` -#### Using pre-built winlibs +#### Make the `.exe` runable -Use `windeploy` target to copy necessary runtime files. +Call `cmake --install {the cmake output folder}` will copy all necessary dependencies to correct locations. -``` -cmake --build . --target windeploy -``` +TODO: (untested) you can also `${Qt's install path}\Qt\6.5.2\msvc2019_64\bin` and vcpkg's bin paths to your PATH environment variable -Or you can also manually run `windeployqt.exe {your_build_dir}/goldendict.exe` which will copy the qt related things to `build_dir`. +Note that using `-G Ninja` in CMake is assumed to be used. TODO: MSBuild has minor bugs for being "Multi-Config". -#### Using Vcpkg +#### Vcpkg -The dependencies can be built via Vcpkg instead of using the pre-built ones. +vcpkg is the primary method to build GoldenDict-ng's dependencies. -Vcpkg CMake build utilize the "manifest mode", all you need to do is basically -set `CMAKE_TOOLCHAIN_FILE` as described [here](https://learn.microsoft.com/en-us/vcpkg/consume/manifest-mode?tabs=cmake%2Cbuild-MSBuild#2---integrate-vcpkg-with-your-build-system). +There are a few ways to use it. -Add this to cmake command: -```sh --DUSE_VCPKG=ON -``` +First, just do nothing. Without any additional CMake config options, a pre-built cached version of vcpkg will be automatically obtained and setup. -Most `.dll` built by vcpkg will be automatically copied, but the Qt ones won't. +Second, install vcpkg on your local machine, then set `CMAKE_TOOLCHAIN_FILE` as described [here](https://learn.microsoft.com/vcpkg/consume/manifest-mode?tabs=cmake%2Cbuild-MSBuild#2---integrate-vcpkg-with-your-build-system), which says append `-DCMAKE_TOOLCHAIN_FILE={Your vcpkg install location}/scripts/buildsystems/vcpkg.cmake` to CMake's config step. Note that this cost long time to build -You can - -* run `cmake --install .` (recommended) -* manually run windeployqt -* add `${Qt's install path}\Qt\6.5.2\msvc2019_64\bin` to your PATH environment variable - -Note that `-G Ninja` in CMake is assumed to be used. MSBuild has minor bugs for being "Multi-Config". ### macOS @@ -105,4 +88,3 @@ If you build in an IDE, then the created `GoldenDict.app` will be runnable from To make the `.app` runnable elsewhere, you can run `cmake --install build_dir/` which will invoke macdeployqt, ad-hoc code signing and various other things. The produced app will end up in `build_dir/redist/goldendict-ng.app` To create `.dmg` installer, you have to have [create-dmg](https://github.com/create-dmg/create-dmg) installed on your machine, then also `cmake --install build_dir/`. - diff --git a/website/mkdocs.yml b/website/mkdocs.yml index 0d6606a5b..3f6b6910e 100644 --- a/website/mkdocs.yml +++ b/website/mkdocs.yml @@ -51,8 +51,8 @@ nav: - Report Bugs & Feedbacks: feedbacks.md - Development Info: - Start develop: developer.md - - Architecture: architecture.md - Build from source: howto/build_from_source.md + - Architecture: architecture.md - Customize the opencc: howto/how to customize the opencc.md - Use .clang-format: howto/how to use .clang-format to format the code.md - Breadpad crash analysis: howto/how to use breadpad crash analysis.md diff --git a/winlibs/.clang-format b/winlibs/.clang-format deleted file mode 100644 index f54a540f5..000000000 --- a/winlibs/.clang-format +++ /dev/null @@ -1,4 +0,0 @@ ---- -DisableFormat: true -SortIncludes: Never -... diff --git a/winlibs/include/bzlib.h b/winlibs/include/bzlib.h deleted file mode 100644 index c5b75d6d8..000000000 --- a/winlibs/include/bzlib.h +++ /dev/null @@ -1,282 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Public header file for the library. ---*/ -/*--- bzlib.h ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#ifndef _BZLIB_H -#define _BZLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define BZ_RUN 0 -#define BZ_FLUSH 1 -#define BZ_FINISH 2 - -#define BZ_OK 0 -#define BZ_RUN_OK 1 -#define BZ_FLUSH_OK 2 -#define BZ_FINISH_OK 3 -#define BZ_STREAM_END 4 -#define BZ_SEQUENCE_ERROR (-1) -#define BZ_PARAM_ERROR (-2) -#define BZ_MEM_ERROR (-3) -#define BZ_DATA_ERROR (-4) -#define BZ_DATA_ERROR_MAGIC (-5) -#define BZ_IO_ERROR (-6) -#define BZ_UNEXPECTED_EOF (-7) -#define BZ_OUTBUFF_FULL (-8) -#define BZ_CONFIG_ERROR (-9) - -typedef - struct { - char *next_in; - unsigned int avail_in; - unsigned int total_in_lo32; - unsigned int total_in_hi32; - - char *next_out; - unsigned int avail_out; - unsigned int total_out_lo32; - unsigned int total_out_hi32; - - void *state; - - void *(*bzalloc)(void *,int,int); - void (*bzfree)(void *,void *); - void *opaque; - } - bz_stream; - - -#ifndef BZ_IMPORT -#define BZ_EXPORT -#endif - -#ifndef BZ_NO_STDIO -/* Need a definitition for FILE */ -#include -#endif - -#ifdef _WIN32 -# include -# ifdef small - /* windows.h define small to char */ -# undef small -# endif -# ifdef BZ_EXPORT -# define BZ_API(func) WINAPI func -# define BZ_EXTERN extern -# else - /* import windows dll dynamically */ -# define BZ_API(func) (WINAPI * func) -# define BZ_EXTERN -# endif -#else -# define BZ_API(func) func -# define BZ_EXTERN extern -#endif - - -/*-- Core (low-level) library functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, - int small - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm - ); - - - -/*-- High(er) level library functions --*/ - -#ifndef BZ_NO_STDIO -#define BZ_MAX_UNUSED 5000 - -typedef void BZFILE; - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, - int small, - void* unused, - int nUnused - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused - ); - -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, - unsigned int* nbytes_out_hi32 - ); -#endif - - -/*-- Utility functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int small, - int verbosity - ); - - -/*-- - Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) - to support better zlib compatibility. - This code is not _officially_ part of libbzip2 (yet); - I haven't tested it, documented it, or considered the - threading-safeness of it. - If this code breaks, please contact both Yoshioka and me. ---*/ - -BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( - void - ); - -#ifndef BZ_NO_STDIO -BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( - const char *path, - const char *mode - ); - -BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( - int fd, - const char *mode - ); - -BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzflush) ( - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzclose) ( - BZFILE* b - ); - -BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, - int *errnum - ); -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -/*-------------------------------------------------------------*/ -/*--- end bzlib.h ---*/ -/*-------------------------------------------------------------*/ diff --git a/winlibs/include/hunspell/atypes.hxx b/winlibs/include/hunspell/atypes.hxx deleted file mode 100644 index 1b78d4724..000000000 --- a/winlibs/include/hunspell/atypes.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2022 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef ATYPES_HXX_ -#define ATYPES_HXX_ - -#ifndef HUNSPELL_WARNING -#include -#ifdef HUNSPELL_WARNING_ON -#define HUNSPELL_WARNING fprintf -#else -// empty inline function to switch off warnings (instead of the C99 standard -// variadic macros) -static inline void HUNSPELL_WARNING(FILE*, const char*, ...) {} -#endif -#endif - -// HUNSTEM def. -#define HUNSTEM - -#include "w_char.hxx" -#include -#include -#include - -#define SETSIZE 256 -#define CONTSIZE 65536 - -// AffEntry options -#define aeXPRODUCT (1 << 0) -#define aeUTF8 (1 << 1) -#define aeALIASF (1 << 2) -#define aeALIASM (1 << 3) -#define aeLONGCOND (1 << 4) - -// compound options -#define IN_CPD_NOT 0 -#define IN_CPD_BEGIN 1 -#define IN_CPD_END 2 -#define IN_CPD_OTHER 3 - -// info options -#define SPELL_COMPOUND (1 << 0) -#define SPELL_FORBIDDEN (1 << 1) -#define SPELL_ALLCAP (1 << 2) -#define SPELL_NOCAP (1 << 3) -#define SPELL_INITCAP (1 << 4) -#define SPELL_ORIGCAP (1 << 5) -#define SPELL_WARN (1 << 6) - -#define MINCPDLEN 3 -#define MAXCOMPOUND 10 -#define MAXCONDLEN 20 -#define MAXCONDLEN_1 (MAXCONDLEN - sizeof(char*)) - -#define MAXACC 1000 - -#define FLAG unsigned short -#define FLAG_NULL 0x00 -#define FREE_FLAG(a) a = 0 - -#define TESTAFF(a, b, c) (std::binary_search(a, a + c, b)) - -// timelimit: max. ~1/4 sec (process time on Linux) for -// for a suggestion, including max. ~/10 sec for a case -// sensitive plain or compound word suggestion, within -// ~1/20 sec long time consuming suggestion functions -#define TIMELIMIT_GLOBAL (CLOCKS_PER_SEC / 4) -#define TIMELIMIT_SUGGESTION (CLOCKS_PER_SEC / 10) -#define TIMELIMIT (CLOCKS_PER_SEC / 20) -#define MINTIMER 100 -#define MAXPLUSTIMER 100 - -struct guessword { - char* word; - bool allow; - char* orig; -}; - -typedef std::vector mapentry; -typedef std::vector flagentry; - -struct patentry { - std::string pattern; - std::string pattern2; - std::string pattern3; - FLAG cond; - FLAG cond2; - patentry() - : cond(FLAG_NULL) - , cond2(FLAG_NULL) { - } -}; - -#endif diff --git a/winlibs/include/hunspell/hunspell.h b/winlibs/include/hunspell/hunspell.h deleted file mode 100644 index 3aca30ab2..000000000 --- a/winlibs/include/hunspell/hunspell.h +++ /dev/null @@ -1,162 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Hunspell, based on MySpell. - * - * The Initial Developers of the Original Code are - * Kevin Hendricks (MySpell) and Németh László (Hunspell). - * Portions created by the Initial Developers are Copyright (C) 2002-2005 - * the Initial Developers. All Rights Reserved. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef MYSPELLMGR_H_ -#define MYSPELLMGR_H_ - -#include "hunvisapi.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct Hunhandle Hunhandle; - -LIBHUNSPELL_DLL_EXPORTED Hunhandle* Hunspell_create(const char* affpath, - const char* dpath); - -LIBHUNSPELL_DLL_EXPORTED Hunhandle* Hunspell_create_key(const char* affpath, - const char* dpath, - const char* key); - -LIBHUNSPELL_DLL_EXPORTED void Hunspell_destroy(Hunhandle* pHunspell); - -/* load extra dictionaries (only dic files) - * output: 0 = additional dictionary slots available, 1 = slots are now full*/ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add_dic(Hunhandle* pHunspell, - const char* dpath); - -/* spell(word) - spellcheck word - * output: 0 = bad word, not 0 = good word - */ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_spell(Hunhandle* pHunspell, const char*); - -LIBHUNSPELL_DLL_EXPORTED char* Hunspell_get_dic_encoding(Hunhandle* pHunspell); - -/* suggest(suggestions, word) - search suggestions - * input: pointer to an array of strings pointer and the (bad) word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_suggest(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* morphological functions */ - -/* analyze(result, word) - morphological analysis of the word */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_analyze(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* stem(result, word) - stemmer function */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* stem(result, analysis, n) - get stems from a morph. analysis - * example: - * char ** result, result2; - * int n1 = Hunspell_analyze(result, "words"); - * int n2 = Hunspell_stem2(result2, result, n1); - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem2(Hunhandle* pHunspell, - char*** slst, - char** desc, - int n); - -/* generate(result, word, word2) - morphological generation by example(s) */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate(Hunhandle* pHunspell, - char*** slst, - const char* word, - const char* word2); - -/* generate(result, word, desc, n) - generation by morph. description(s) - * example: - * char ** result; - * char * affix = "is:plural"; // description depends from dictionaries, too - * int n = Hunspell_generate2(result, "word", &affix, 1); - * for (int i = 0; i < n; i++) printf("%s\n", result[i]); - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate2(Hunhandle* pHunspell, - char*** slst, - const char* word, - char** desc, - int n); - -/* functions for run-time modification of the dictionary */ - -/* add word to the run-time dictionary */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add(Hunhandle* pHunspell, - const char* word); - -/* add word to the run-time dictionary with affix flags of - * the example (a dictionary word): Hunspell will recognize - * affixed forms of the new word, too. - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add_with_affix(Hunhandle* pHunspell, - const char* word, - const char* example); - -/* remove word from the run-time dictionary */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_remove(Hunhandle* pHunspell, - const char* word); - -/* free suggestion lists */ - -LIBHUNSPELL_DLL_EXPORTED void Hunspell_free_list(Hunhandle* pHunspell, - char*** slst, - int n); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/winlibs/include/hunspell/hunspell.hxx b/winlibs/include/hunspell/hunspell.hxx deleted file mode 100644 index 8640a35ca..000000000 --- a/winlibs/include/hunspell/hunspell.hxx +++ /dev/null @@ -1,232 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2022 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS 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 - * KEVIN B. HENDRICKS 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. - */ -#ifndef MYSPELLMGR_HXX_ -#define MYSPELLMGR_HXX_ - -#include "hunvisapi.h" -#include "w_char.hxx" -#include "atypes.hxx" -#include -#include - -#define SPELL_XML "" - -#ifndef MAXSUGGESTION -#define MAXSUGGESTION 15 -#endif - -#define MAXSHARPS 5 - -#ifndef MAXWORDLEN -#define MAXWORDLEN 100 -#endif - -#if defined __GNUC__ && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -# define H_DEPRECATED __attribute__((__deprecated__)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1300) -# define H_DEPRECATED __declspec(deprecated) -#else -# define H_DEPRECATED -#endif - -class HunspellImpl; - -class LIBHUNSPELL_DLL_EXPORTED Hunspell { - private: - Hunspell(const Hunspell&); - Hunspell& operator=(const Hunspell&); - - private: - HunspellImpl* m_Impl; - - public: - /* Hunspell(aff, dic) - constructor of Hunspell class - * input: path of affix file and dictionary file - * - * In WIN32 environment, use UTF-8 encoded paths started with the long path - * prefix \\\\?\\ to handle system-independent character encoding and very - * long path names (without the long path prefix Hunspell will use fopen() - * with system-dependent character encoding instead of _wfopen()). - */ - Hunspell(const char* affpath, const char* dpath, const char* key = NULL); - ~Hunspell(); - - /* load extra dictionaries (only dic files) */ - int add_dic(const char* dpath, const char* key = NULL); - - /* spell(word) - spellcheck word - * output: false = bad word, true = good word - * - * plus output: - * info: information bit array, fields: - * SPELL_COMPOUND = a compound word - * SPELL_FORBIDDEN = an explicit forbidden word - * root: root (stem), when input is a word with affix(es) - */ - bool spell(const std::string& word, int* info = NULL, std::string* root = NULL); - H_DEPRECATED int spell(const char* word, int* info = NULL, char** root = NULL); - - /* suggest(suggestions, word) - search suggestions - * input: pointer to an array of strings pointer and the (bad) word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ - std::vector suggest(const std::string& word); - H_DEPRECATED int suggest(char*** slst, const char* word); - - /* Suggest words from suffix rules - * suffix_suggest(suggestions, root_word) - * input: pointer to an array of strings pointer and the word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ - std::vector suffix_suggest(const std::string& root_word); - H_DEPRECATED int suffix_suggest(char*** slst, const char* root_word); - - /* deallocate suggestion lists */ - H_DEPRECATED void free_list(char*** slst, int n); - - const std::string& get_dict_encoding() const; - char* get_dic_encoding(); - - /* morphological functions */ - - /* analyze(result, word) - morphological analysis of the word */ - std::vector analyze(const std::string& word); - H_DEPRECATED int analyze(char*** slst, const char* word); - - /* stem(word) - stemmer function */ - std::vector stem(const std::string& word); - H_DEPRECATED int stem(char*** slst, const char* word); - - /* stem(analysis, n) - get stems from a morph. analysis - * example: - * char ** result, result2; - * int n1 = analyze(&result, "words"); - * int n2 = stem(&result2, result, n1); - */ - std::vector stem(const std::vector& morph); - H_DEPRECATED int stem(char*** slst, char** morph, int n); - - /* generate(result, word, word2) - morphological generation by example(s) */ - std::vector generate(const std::string& word, const std::string& word2); - H_DEPRECATED int generate(char*** slst, const char* word, const char* word2); - - /* generate(result, word, desc, n) - generation by morph. description(s) - * example: - * char ** result; - * char * affix = "is:plural"; // description depends from dictionaries, too - * int n = generate(&result, "word", &affix, 1); - * for (int i = 0; i < n; i++) printf("%s\n", result[i]); - */ - std::vector generate(const std::string& word, const std::vector& pl); - H_DEPRECATED int generate(char*** slst, const char* word, char** desc, int n); - - /* functions for run-time modification of the dictionary */ - - /* add word to the run-time dictionary */ - - int add(const std::string& word); - - /* add word to the run-time dictionary with affix flags of - * the example (a dictionary word): Hunspell will recognize - * affixed forms of the new word, too. - */ - - int add_with_affix(const std::string& word, const std::string& example); - - /* remove word from the run-time dictionary */ - - int remove(const std::string& word); - - /* other */ - - /* get extra word characters definied in affix file for tokenization */ - const char* get_wordchars() const; - const std::string& get_wordchars_cpp() const; - const std::vector& get_wordchars_utf16() const; - - struct cs_info* get_csconv(); - - const char* get_version() const; - const std::string& get_version_cpp() const; - - int get_langnum() const; - - /* need for putdic */ - bool input_conv(const std::string& word, std::string& dest); - H_DEPRECATED int input_conv(const char* word, char* dest, size_t destsize); -}; - -#endif diff --git a/winlibs/include/hunspell/hunvisapi.h b/winlibs/include/hunspell/hunvisapi.h deleted file mode 100644 index 4db2414ad..000000000 --- a/winlibs/include/hunspell/hunvisapi.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef HUNSPELL_VISIBILITY_H_ -#define HUNSPELL_VISIBILITY_H_ - -#if defined(HUNSPELL_STATIC) -# define LIBHUNSPELL_DLL_EXPORTED -#elif defined(_WIN32) -# if defined(BUILDING_LIBHUNSPELL) -# define LIBHUNSPELL_DLL_EXPORTED __declspec(dllexport) -# else -# define LIBHUNSPELL_DLL_EXPORTED __declspec(dllimport) -# endif -#elif defined(BUILDING_LIBHUNSPELL) && 0 -# define LIBHUNSPELL_DLL_EXPORTED __attribute__((__visibility__("default"))) -#else -# define LIBHUNSPELL_DLL_EXPORTED -#endif - -#endif diff --git a/winlibs/include/hunspell/w_char.hxx b/winlibs/include/hunspell/w_char.hxx deleted file mode 100644 index 7e71d0468..000000000 --- a/winlibs/include/hunspell/w_char.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2022 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef W_CHAR_HXX_ -#define W_CHAR_HXX_ - -#include - -#ifndef GCC -struct w_char { -#else -struct __attribute__((packed)) w_char { -#endif - unsigned char l; - unsigned char h; - - friend bool operator<(const w_char a, const w_char b) { - unsigned short a_idx = (a.h << 8) + a.l; - unsigned short b_idx = (b.h << 8) + b.l; - return a_idx < b_idx; - } - - friend bool operator==(const w_char a, const w_char b) { - return (((a).l == (b).l) && ((a).h == (b).h)); - } - - friend bool operator!=(const w_char a, const w_char b) { - return !(a == b);; - } -}; - -// two character arrays -struct replentry { - std::string pattern; - std::string outstrings[4]; // med, ini, fin, isol -}; - -#endif diff --git a/winlibs/include/iconv.h b/winlibs/include/iconv.h deleted file mode 100644 index fdf3c537c..000000000 --- a/winlibs/include/iconv.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 1999-2022 Free Software Foundation, Inc. - This file is part of the GNU LIBICONV Library. - - The GNU LIBICONV Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 2.1 - of the License, or (at your option) any later version. - - The GNU LIBICONV Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU LIBICONV Library; see the file COPYING.LIB. - If not, see . */ - -/* When installed, this file is called "iconv.h". */ - -#ifndef _LIBICONV_H -#define _LIBICONV_H - -#define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */ -extern __declspec (dllimport) int _libiconv_version; /* Likewise */ - -/* We would like to #include any system header file which could define - iconv_t, 1. in order to eliminate the risk that the user gets compilation - errors because some other system header file includes /usr/include/iconv.h - which defines iconv_t or declares iconv after this file, 2. when compiling - for LIBICONV_PLUG, we need the proper iconv_t type in order to produce - binary compatible code. - But gcc's #include_next is not portable. Thus, once libiconv's iconv.h - has been installed in /usr/local/include, there is no way any more to - include the original /usr/include/iconv.h. We simply have to get away - without it. - Ad 1. The risk that a system header file does - #include "iconv.h" or #include_next "iconv.h" - is small. They all do #include . - Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It - has to be a scalar type because (iconv_t)(-1) is a possible return value - from iconv_open().) */ - -/* Define iconv_t ourselves. */ -#undef iconv_t -#define iconv_t libiconv_t -typedef void* iconv_t; - -/* Get size_t declaration. - Get wchar_t declaration if it exists. */ -#include - -/* Get errno declaration and values. */ -#include -/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, - have EILSEQ in a different header. On these systems, define EILSEQ - ourselves. */ -#ifndef EILSEQ -#define EILSEQ -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’. */ -#ifndef LIBICONV_PLUG -#define iconv_open libiconv_open -#endif -extern iconv_t iconv_open (const char* tocode, const char* fromcode); - -/* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes - starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at - ‘*outbuf’. - Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount. - Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */ -#ifndef LIBICONV_PLUG -#define iconv libiconv -#endif -extern size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); - -/* Frees resources allocated for conversion descriptor ‘cd’. */ -#ifndef LIBICONV_PLUG -#define iconv_close libiconv_close -#endif -extern int iconv_close (iconv_t cd); - - -#ifdef __cplusplus -} -#endif - - -#ifndef LIBICONV_PLUG - -/* Nonstandard extensions. */ - -#if 1 -#if 0 -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#endif -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* A type that holds all memory needed by a conversion descriptor. - A pointer to such an object can be used as an iconv_t. */ -typedef struct { - void* dummy1[28]; -#if 1 - mbstate_t dummy2; -#endif -} iconv_allocation_t; - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’ into preallocated memory. Returns an error indicator - (0 or -1 with errno set). */ -#define iconv_open_into libiconv_open_into -extern int iconv_open_into (const char* tocode, const char* fromcode, - iconv_allocation_t* resultp); - -/* Control of attributes. */ -#define iconvctl libiconvctl -extern int iconvctl (iconv_t cd, int request, void* argument); - -/* Hook performed after every successful conversion of a Unicode character. */ -typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data); -/* Hook performed after every successful conversion of a wide character. */ -typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data); -/* Set of hooks. */ -struct iconv_hooks { - iconv_unicode_char_hook uc_hook; - iconv_wide_char_hook wc_hook; - void* data; -}; - -/* Fallback function. Invoked when a small number of bytes could not be - converted to a Unicode character. This function should process all - bytes from inbuf and may produce replacement Unicode characters by calling - the write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_mb_to_uc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const unsigned int *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a Unicode character could not be converted - to the target encoding. This function should process the character and - may produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_uc_to_mb_fallback) - (unsigned int code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#if 1 -/* Fallback function. Invoked when a number of bytes could not be converted to - a wide character. This function should process all bytes from inbuf and may - produce replacement wide characters by calling the write_replacement - callback repeatedly. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const wchar_t *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a wide character could not be converted to - the target encoding. This function should process the character and may - produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_wchar_wc_to_mb_fallback) - (wchar_t code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#else -/* If the wchar_t type does not exist, these two fallback functions are never - invoked. Their argument list therefore does not matter. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) (); -typedef void (*iconv_wchar_wc_to_mb_fallback) (); -#endif -/* Set of fallbacks. */ -struct iconv_fallbacks { - iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; - iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; - iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; - iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; - void* data; -}; - -/* Requests for iconvctl. */ -#define ICONV_TRIVIALP 0 /* int *argument */ -#define ICONV_GET_TRANSLITERATE 1 /* int *argument */ -#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ -#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ -#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ -#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */ -#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */ - -/* Listing of locale independent encodings. */ -#define iconvlist libiconvlist -extern void iconvlist (int (*do_one) (unsigned int namescount, - const char * const * names, - void* data), - void* data); - -/* Canonicalize an encoding name. - The result is either a canonical encoding name, or name itself. */ -extern const char * iconv_canonicalize (const char * name); - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -extern void libiconv_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - -#ifdef __cplusplus -} -#endif - -#endif - - -#endif /* _LIBICONV_H */ diff --git a/winlibs/include/lzma.h b/winlibs/include/lzma.h deleted file mode 100644 index af3a48db4..000000000 --- a/winlibs/include/lzma.h +++ /dev/null @@ -1,325 +0,0 @@ -/** - * \file api/lzma.h - * \brief The public API of liblzma data compression library - * - * liblzma is a public domain general-purpose data compression library with - * a zlib-like API. The native file format is .xz, but also the old .lzma - * format and raw (no headers) streams are supported. Multiple compression - * algorithms (filters) are supported. Currently LZMA2 is the primary filter. - * - * liblzma is part of XZ Utils . XZ Utils includes - * a gzip-like command line tool named xz and some other tools. XZ Utils - * is developed and maintained by Lasse Collin. - * - * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK - * . - * - * The SHA-256 implementation is based on the public domain code found from - * 7-Zip , which has a modified version of the public - * domain SHA-256 code found from Crypto++ . - * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - */ - -#ifndef LZMA_H -#define LZMA_H - -/***************************** - * Required standard headers * - *****************************/ - -/* - * liblzma API headers need some standard types and macros. To allow - * including lzma.h without requiring the application to include other - * headers first, lzma.h includes the required standard headers unless - * they already seem to be included already or if LZMA_MANUAL_HEADERS - * has been defined. - * - * Here's what types and macros are needed and from which headers: - * - stddef.h: size_t, NULL - * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n), - * UINT32_MAX, UINT64_MAX - * - * However, inttypes.h is a little more portable than stdint.h, although - * inttypes.h declares some unneeded things compared to plain stdint.h. - * - * The hacks below aren't perfect, specifically they assume that inttypes.h - * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t, - * and that, in case of incomplete inttypes.h, unsigned int is 32-bit. - * If the application already takes care of setting up all the types and - * macros properly (for example by using gnulib's stdint.h or inttypes.h), - * we try to detect that the macros are already defined and don't include - * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to - * force this file to never include any system headers. - * - * Some could argue that liblzma API should provide all the required types, - * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was - * seen as an unnecessary mess, since most systems already provide all the - * necessary types and macros in the standard headers. - * - * Note that liblzma API still has lzma_bool, because using stdbool.h would - * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't - * necessarily the same as sizeof(bool) in C++. - */ - -#ifndef LZMA_MANUAL_HEADERS - /* - * I suppose this works portably also in C++. Note that in C++, - * we need to get size_t into the global namespace. - */ -# include - - /* - * Skip inttypes.h if we already have all the required macros. If we - * have the macros, we assume that we have the matching typedefs too. - */ -# if !defined(UINT32_C) || !defined(UINT64_C) \ - || !defined(UINT32_MAX) || !defined(UINT64_MAX) - /* - * MSVC versions older than 2013 have no C99 support, and - * thus they cannot be used to compile liblzma. Using an - * existing liblzma.dll with old MSVC can work though(*), - * but we need to define the required standard integer - * types here in a MSVC-specific way. - * - * (*) If you do this, the existing liblzma.dll probably uses - * a different runtime library than your MSVC-built - * application. Mixing runtimes is generally bad, but - * in this case it should work as long as you avoid - * the few rarely-needed liblzma functions that allocate - * memory and expect the caller to free it using free(). - */ -# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; -# else - /* Use the standard inttypes.h. */ -# ifdef __cplusplus - /* - * C99 sections 7.18.2 and 7.18.4 specify - * that C++ implementations define the limit - * and constant macros only if specifically - * requested. Note that if you want the - * format macros (PRIu64 etc.) too, you need - * to define __STDC_FORMAT_MACROS before - * including lzma.h, since re-including - * inttypes.h with __STDC_FORMAT_MACROS - * defined doesn't necessarily work. - */ -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -# endif -# ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS 1 -# endif -# endif - -# include -# endif - - /* - * Some old systems have only the typedefs in inttypes.h, and - * lack all the macros. For those systems, we need a few more - * hacks. We assume that unsigned int is 32-bit and unsigned - * long is either 32-bit or 64-bit. If these hacks aren't - * enough, the application has to setup the types manually - * before including lzma.h. - */ -# ifndef UINT32_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT32_C(n) n ## UI32 -# else -# define UINT32_C(n) n ## U -# endif -# endif - -# ifndef UINT64_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT64_C(n) n ## UI64 -# else - /* Get ULONG_MAX. */ -# include -# if ULONG_MAX == 4294967295UL -# define UINT64_C(n) n ## ULL -# else -# define UINT64_C(n) n ## UL -# endif -# endif -# endif - -# ifndef UINT32_MAX -# define UINT32_MAX (UINT32_C(4294967295)) -# endif - -# ifndef UINT64_MAX -# define UINT64_MAX (UINT64_C(18446744073709551615)) -# endif -# endif -#endif /* ifdef LZMA_MANUAL_HEADERS */ - - -/****************** - * LZMA_API macro * - ******************/ - -/* - * Some systems require that the functions and function pointers are - * declared specially in the headers. LZMA_API_IMPORT is for importing - * symbols and LZMA_API_CALL is to specify the calling convention. - * - * By default it is assumed that the application will link dynamically - * against liblzma. #define LZMA_API_STATIC in your application if you - * want to link against static liblzma. If you don't care about portability - * to operating systems like Windows, or at least don't care about linking - * against static liblzma on them, don't worry about LZMA_API_STATIC. That - * is, most developers will never need to use LZMA_API_STATIC. - * - * The GCC variants are a special case on Windows (Cygwin and MinGW). - * We rely on GCC doing the right thing with its auto-import feature, - * and thus don't use __declspec(dllimport). This way developers don't - * need to worry about LZMA_API_STATIC. Also the calling convention is - * omitted on Cygwin but not on MinGW. - */ -#ifndef LZMA_API_IMPORT - #if !0 && defined( _WIN32 ) && !defined( __GNUC__ ) - #define LZMA_API_IMPORT __declspec( dllimport ) - #else - #define LZMA_API_IMPORT - #endif -#endif - -#ifndef LZMA_API_CALL -# if defined(_WIN32) && !defined(__CYGWIN__) -# define LZMA_API_CALL __cdecl -# else -# define LZMA_API_CALL -# endif -#endif - -#ifndef LZMA_API -# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL -#endif - - -/*********** - * nothrow * - ***********/ - -/* - * None of the functions in liblzma may throw an exception. Even - * the functions that use callback functions won't throw exceptions, - * because liblzma would break if a callback function threw an exception. - */ -#ifndef lzma_nothrow -# if defined(__cplusplus) - #if __cplusplus >= 201103L || ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201103L ) - #define lzma_nothrow noexcept - #else - #define lzma_nothrow throw() - #endif - #elif defined( __GNUC__ ) && ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 3 ) ) - #define lzma_nothrow __attribute__( ( __nothrow__ ) ) - #else - #define lzma_nothrow - #endif -#endif - - -/******************** - * GNU C extensions * - ********************/ - -/* - * GNU C extensions are used conditionally in the public API. It doesn't - * break anything if these are sometimes enabled and sometimes not, only - * affects warnings and optimizations. - */ -#if defined( __GNUC__ ) && __GNUC__ >= 3 - #ifndef lzma_attribute - #define lzma_attribute( attr ) __attribute__( attr ) - #endif - - /* warn_unused_result was added in GCC 3.4. */ - #ifndef lzma_attr_warn_unused_result - #if __GNUC__ == 3 && __GNUC_MINOR__ < 4 - #define lzma_attr_warn_unused_result - #endif - #endif - -#else -# ifndef lzma_attribute -# define lzma_attribute(attr) -# endif -#endif - - -#ifndef lzma_attr_pure -# define lzma_attr_pure lzma_attribute((__pure__)) -#endif - -#ifndef lzma_attr_const -# define lzma_attr_const lzma_attribute((__const__)) -#endif - -#ifndef lzma_attr_warn_unused_result -# define lzma_attr_warn_unused_result \ - lzma_attribute((__warn_unused_result__)) -#endif - - -/************** - * Subheaders * - **************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Subheaders check that this is defined. It is to prevent including - * them directly from applications. - */ -#define LZMA_H_INTERNAL 1 - -/* Basic features */ -#include "lzma/version.h" -#include "lzma/base.h" -#include "lzma/vli.h" -#include "lzma/check.h" - -/* Filters */ -#include "lzma/filter.h" -#include "lzma/bcj.h" -#include "lzma/delta.h" -#include "lzma/lzma12.h" - -/* Container formats */ -#include "lzma/container.h" - -/* Advanced features */ -#include "lzma/stream_flags.h" -#include "lzma/block.h" -#include "lzma/index.h" -#include "lzma/index_hash.h" - -/* Hardware information */ -#include "lzma/hardware.h" - -/* - * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications - * re-including the subheaders. - */ -#undef LZMA_H_INTERNAL - -#ifdef __cplusplus -} -#endif - -#endif /* ifndef LZMA_H */ diff --git a/winlibs/include/lzma/base.h b/winlibs/include/lzma/base.h deleted file mode 100644 index c452f8d6a..000000000 --- a/winlibs/include/lzma/base.h +++ /dev/null @@ -1,712 +0,0 @@ -/** - * \file lzma/base.h - * \brief Data types and functions used in many places in liblzma API - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Boolean - * - * This is here because C89 doesn't have stdbool.h. To set a value for - * variables having type lzma_bool, you can use - * - C99's `true' and `false' from stdbool.h; - * - C++'s internal `true' and `false'; or - * - integers one (true) and zero (false). - */ -typedef unsigned char lzma_bool; - - -/** - * \brief Type of reserved enumeration variable in structures - * - * To avoid breaking library ABI when new features are added, several - * structures contain extra variables that may be used in future. Since - * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may - * even vary depending on the range of enumeration constants, we specify - * a separate type to be used for reserved enumeration variables. All - * enumeration constants in liblzma API will be non-negative and less - * than 128, which should guarantee that the ABI won't break even when - * new constants are added to existing enumerations. - */ -typedef enum { - LZMA_RESERVED_ENUM = 0 -} lzma_reserved_enum; - - -/** - * \brief Return values used by several functions in liblzma - * - * Check the descriptions of specific functions to find out which return - * values they can return. With some functions the return values may have - * more specific meanings than described here; those differences are - * described per-function basis. - */ -typedef enum { - LZMA_OK = 0, - /**< - * \brief Operation completed successfully - */ - - LZMA_STREAM_END = 1, - /**< - * \brief End of stream was reached - * - * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or - * LZMA_FINISH was finished. In decoder, this indicates - * that all the data was successfully decoded. - * - * In all cases, when LZMA_STREAM_END is returned, the last - * output bytes should be picked from strm->next_out. - */ - - LZMA_NO_CHECK = 2, - /**< - * \brief Input stream has no integrity check - * - * This return value can be returned only if the - * LZMA_TELL_NO_CHECK flag was used when initializing - * the decoder. LZMA_NO_CHECK is just a warning, and - * the decoding can be continued normally. - * - * It is possible to call lzma_get_check() immediately after - * lzma_code has returned LZMA_NO_CHECK. The result will - * naturally be LZMA_CHECK_NONE, but the possibility to call - * lzma_get_check() may be convenient in some applications. - */ - - LZMA_UNSUPPORTED_CHECK = 3, - /**< - * \brief Cannot calculate the integrity check - * - * The usage of this return value is different in encoders - * and decoders. - * - * Encoders can return this value only from the initialization - * function. If initialization fails with this value, the - * encoding cannot be done, because there's no way to produce - * output with the correct integrity check. - * - * Decoders can return this value only from lzma_code() and - * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when - * initializing the decoder. The decoding can still be - * continued normally even if the check type is unsupported, - * but naturally the check will not be validated, and possible - * errors may go undetected. - * - * With decoder, it is possible to call lzma_get_check() - * immediately after lzma_code() has returned - * LZMA_UNSUPPORTED_CHECK. This way it is possible to find - * out what the unsupported Check ID was. - */ - - LZMA_GET_CHECK = 4, - /**< - * \brief Integrity check type is now available - * - * This value can be returned only by the lzma_code() function - * and only if the decoder was initialized with the - * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the - * application that it may now call lzma_get_check() to find - * out the Check ID. This can be used, for example, to - * implement a decoder that accepts only files that have - * strong enough integrity check. - */ - - LZMA_MEM_ERROR = 5, - /**< - * \brief Cannot allocate memory - * - * Memory allocation failed, or the size of the allocation - * would be greater than SIZE_MAX. - * - * Due to internal implementation reasons, the coding cannot - * be continued even if more memory were made available after - * LZMA_MEM_ERROR. - */ - - LZMA_MEMLIMIT_ERROR = 6, - /** - * \brief Memory usage limit was reached - * - * Decoder would need more memory than allowed by the - * specified memory usage limit. To continue decoding, - * the memory usage limit has to be increased with - * lzma_memlimit_set(). - * - * liblzma 5.2.6 and earlier had a bug in single-threaded .xz - * decoder (lzma_stream_decoder()) which made it impossible - * to continue decoding after LZMA_MEMLIMIT_ERROR even if - * the limit was increased using lzma_memlimit_set(). - * Other decoders worked correctly. - */ - - LZMA_FORMAT_ERROR = 7, - /**< - * \brief File format not recognized - * - * The decoder did not recognize the input as supported file - * format. This error can occur, for example, when trying to - * decode .lzma format file with lzma_stream_decoder, - * because lzma_stream_decoder accepts only the .xz format. - */ - - LZMA_OPTIONS_ERROR = 8, - /**< - * \brief Invalid or unsupported options - * - * Invalid or unsupported options, for example - * - unsupported filter(s) or filter options; or - * - reserved bits set in headers (decoder only). - * - * Rebuilding liblzma with more features enabled, or - * upgrading to a newer version of liblzma may help. - */ - - LZMA_DATA_ERROR = 9, - /**< - * \brief Data is corrupt - * - * The usage of this return value is different in encoders - * and decoders. In both encoder and decoder, the coding - * cannot continue after this error. - * - * Encoders return this if size limits of the target file - * format would be exceeded. These limits are huge, thus - * getting this error from an encoder is mostly theoretical. - * For example, the maximum compressed and uncompressed - * size of a .xz Stream is roughly 8 EiB (2^63 bytes). - * - * Decoders return this error if the input data is corrupt. - * This can mean, for example, invalid CRC32 in headers - * or invalid check of uncompressed data. - */ - - LZMA_BUF_ERROR = 10, - /**< - * \brief No progress is possible - * - * This error code is returned when the coder cannot consume - * any new input and produce any new output. The most common - * reason for this error is that the input stream being - * decoded is truncated or corrupt. - * - * This error is not fatal. Coding can be continued normally - * by providing more input and/or more output space, if - * possible. - * - * Typically the first call to lzma_code() that can do no - * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only - * the second consecutive call doing no progress will return - * LZMA_BUF_ERROR. This is intentional. - * - * With zlib, Z_BUF_ERROR may be returned even if the - * application is doing nothing wrong, so apps will need - * to handle Z_BUF_ERROR specially. The above hack - * guarantees that liblzma never returns LZMA_BUF_ERROR - * to properly written applications unless the input file - * is truncated or corrupt. This should simplify the - * applications a little. - */ - - LZMA_PROG_ERROR = 11, - /**< - * \brief Programming error - * - * This indicates that the arguments given to the function are - * invalid or the internal state of the decoder is corrupt. - * - Function arguments are invalid or the structures - * pointed by the argument pointers are invalid - * e.g. if strm->next_out has been set to NULL and - * strm->avail_out > 0 when calling lzma_code(). - * - lzma_* functions have been called in wrong order - * e.g. lzma_code() was called right after lzma_end(). - * - If errors occur randomly, the reason might be flaky - * hardware. - * - * If you think that your code is correct, this error code - * can be a sign of a bug in liblzma. See the documentation - * how to report bugs. - */ - - LZMA_SEEK_NEEDED = 12, - /**< - * \brief Request to change the input file position - * - * Some coders can do random access in the input file. The - * initialization functions of these coders take the file size - * as an argument. No other coders can return LZMA_SEEK_NEEDED. - * - * When this value is returned, the application must seek to - * the file position given in lzma_stream.seek_pos. This value - * is guaranteed to never exceed the file size that was - * specified at the coder initialization. - * - * After seeking the application should read new input and - * pass it normally via lzma_stream.next_in and .avail_in. - */ - - /* - * These eumerations may be used internally by liblzma - * but they will never be returned to applications. - */ - LZMA_RET_INTERNAL1 = 101, - LZMA_RET_INTERNAL2 = 102, - LZMA_RET_INTERNAL3 = 103, - LZMA_RET_INTERNAL4 = 104, - LZMA_RET_INTERNAL5 = 105, - LZMA_RET_INTERNAL6 = 106, - LZMA_RET_INTERNAL7 = 107, - LZMA_RET_INTERNAL8 = 108 -} lzma_ret; - - -/** - * \brief The `action' argument for lzma_code() - * - * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER, - * or LZMA_FINISH, the same `action' must is used until lzma_code() returns - * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must - * not be modified by the application until lzma_code() returns - * LZMA_STREAM_END. Changing the `action' or modifying the amount of input - * will make lzma_code() return LZMA_PROG_ERROR. - */ -typedef enum { - LZMA_RUN = 0, - /**< - * \brief Continue coding - * - * Encoder: Encode as much input as possible. Some internal - * buffering will probably be done (depends on the filter - * chain in use), which causes latency: the input used won't - * usually be decodeable from the output of the same - * lzma_code() call. - * - * Decoder: Decode as much input as possible and produce as - * much output as possible. - */ - - LZMA_SYNC_FLUSH = 1, - /**< - * \brief Make all the input available at output - * - * Normally the encoder introduces some latency. - * LZMA_SYNC_FLUSH forces all the buffered data to be - * available at output without resetting the internal - * state of the encoder. This way it is possible to use - * compressed stream for example for communication over - * network. - * - * Only some filters support LZMA_SYNC_FLUSH. Trying to use - * LZMA_SYNC_FLUSH with filters that don't support it will - * make lzma_code() return LZMA_OPTIONS_ERROR. For example, - * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. - * - * Using LZMA_SYNC_FLUSH very often can dramatically reduce - * the compression ratio. With some filters (for example, - * LZMA2), fine-tuning the compression options may help - * mitigate this problem significantly (for example, - * match finder with LZMA2). - * - * Decoders don't support LZMA_SYNC_FLUSH. - */ - - LZMA_FULL_FLUSH = 2, - /**< - * \brief Finish encoding of the current Block - * - * All the input data going to the current Block must have - * been given to the encoder (the last bytes can still be - * pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH - * until it returns LZMA_STREAM_END. Then continue normally - * with LZMA_RUN or finish the Stream with LZMA_FINISH. - * - * This action is currently supported only by Stream encoder - * and easy encoder (which uses Stream encoder). If there is - * no unfinished Block, no empty Block is created. - */ - - LZMA_FULL_BARRIER = 4, - /**< - * \brief Finish encoding of the current Block - * - * This is like LZMA_FULL_FLUSH except that this doesn't - * necessarily wait until all the input has been made - * available via the output buffer. That is, lzma_code() - * might return LZMA_STREAM_END as soon as all the input - * has been consumed (avail_in == 0). - * - * LZMA_FULL_BARRIER is useful with a threaded encoder if - * one wants to split the .xz Stream into Blocks at specific - * offsets but doesn't care if the output isn't flushed - * immediately. Using LZMA_FULL_BARRIER allows keeping - * the threads busy while LZMA_FULL_FLUSH would make - * lzma_code() wait until all the threads have finished - * until more data could be passed to the encoder. - * - * With a lzma_stream initialized with the single-threaded - * lzma_stream_encoder() or lzma_easy_encoder(), - * LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH. - */ - - LZMA_FINISH = 3 - /**< - * \brief Finish the coding operation - * - * All the input data must have been given to the encoder - * (the last bytes can still be pending in next_in). - * Call lzma_code() with LZMA_FINISH until it returns - * LZMA_STREAM_END. Once LZMA_FINISH has been used, - * the amount of input must no longer be changed by - * the application. - * - * When decoding, using LZMA_FINISH is optional unless the - * LZMA_CONCATENATED flag was used when the decoder was - * initialized. When LZMA_CONCATENATED was not used, the only - * effect of LZMA_FINISH is that the amount of input must not - * be changed just like in the encoder. - */ -} lzma_action; - - -/** - * \brief Custom functions for memory handling - * - * A pointer to lzma_allocator may be passed via lzma_stream structure - * to liblzma, and some advanced functions take a pointer to lzma_allocator - * as a separate function argument. The library will use the functions - * specified in lzma_allocator for memory handling instead of the default - * malloc() and free(). C++ users should note that the custom memory - * handling functions must not throw exceptions. - * - * Single-threaded mode only: liblzma doesn't make an internal copy of - * lzma_allocator. Thus, it is OK to change these function pointers in - * the middle of the coding process, but obviously it must be done - * carefully to make sure that the replacement `free' can deallocate - * memory allocated by the earlier `alloc' function(s). - * - * Multithreaded mode: liblzma might internally store pointers to the - * lzma_allocator given via the lzma_stream structure. The application - * must not change the allocator pointer in lzma_stream or the contents - * of the pointed lzma_allocator structure until lzma_end() has been used - * to free the memory associated with that lzma_stream. The allocation - * functions might be called simultaneously from multiple threads, and - * thus they must be thread safe. - */ -typedef struct { - /** - * \brief Pointer to a custom memory allocation function - * - * If you don't want a custom allocator, but still want - * custom free(), set this to NULL and liblzma will use - * the standard malloc(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param nmemb Number of elements like in calloc(). liblzma - * will always set nmemb to 1, so it is safe to - * ignore nmemb in a custom allocator if you like. - * The nmemb argument exists only for - * compatibility with zlib and libbzip2. - * \param size Size of an element in bytes. - * liblzma never sets this to zero. - * - * \return Pointer to the beginning of a memory block of - * `size' bytes, or NULL if allocation fails - * for some reason. When allocation fails, functions - * of liblzma return LZMA_MEM_ERROR. - * - * The allocator should not waste time zeroing the allocated buffers. - * This is not only about speed, but also memory usage, since the - * operating system kernel doesn't necessarily allocate the requested - * memory in physical memory until it is actually used. With small - * input files, liblzma may actually need only a fraction of the - * memory that it requested for allocation. - * - * \note LZMA_MEM_ERROR is also used when the size of the - * allocation would be greater than SIZE_MAX. Thus, - * don't assume that the custom allocator must have - * returned NULL if some function from liblzma - * returns LZMA_MEM_ERROR. - */ - void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size); - - /** - * \brief Pointer to a custom memory freeing function - * - * If you don't want a custom freeing function, but still - * want a custom allocator, set this to NULL and liblzma - * will use the standard free(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param ptr Pointer returned by lzma_allocator.alloc(), - * or when it is set to NULL, a pointer returned - * by the standard malloc(). - */ - void (LZMA_API_CALL *free)(void *opaque, void *ptr); - - /** - * \brief Pointer passed to .alloc() and .free() - * - * opaque is passed as the first argument to lzma_allocator.alloc() - * and lzma_allocator.free(). This intended to ease implementing - * custom memory allocation functions for use with liblzma. - * - * If you don't need this, you should set this to NULL. - */ - void *opaque; - -} lzma_allocator; - - -/** - * \brief Internal data structure - * - * The contents of this structure is not visible outside the library. - */ -typedef struct lzma_internal_s lzma_internal; - - -/** - * \brief Passing data to and from liblzma - * - * The lzma_stream structure is used for - * - passing pointers to input and output buffers to liblzma; - * - defining custom memory handler functions; and - * - holding a pointer to coder-specific internal data structures. - * - * Typical usage: - * - * - After allocating lzma_stream (on stack or with malloc()), it must be - * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details). - * - * - Initialize a coder to the lzma_stream, for example by using - * lzma_easy_encoder() or lzma_auto_decoder(). Some notes: - * - In contrast to zlib, strm->next_in and strm->next_out are - * ignored by all initialization functions, thus it is safe - * to not initialize them yet. - * - The initialization functions always set strm->total_in and - * strm->total_out to zero. - * - If the initialization function fails, no memory is left allocated - * that would require freeing with lzma_end() even if some memory was - * associated with the lzma_stream structure when the initialization - * function was called. - * - * - Use lzma_code() to do the actual work. - * - * - Once the coding has been finished, the existing lzma_stream can be - * reused. It is OK to reuse lzma_stream with different initialization - * function without calling lzma_end() first. Old allocations are - * automatically freed. - * - * - Finally, use lzma_end() to free the allocated memory. lzma_end() never - * frees the lzma_stream structure itself. - * - * Application may modify the values of total_in and total_out as it wants. - * They are updated by liblzma to match the amount of data read and - * written but aren't used for anything else except as a possible return - * values from lzma_get_progress(). - */ -typedef struct { - const uint8_t *next_in; /**< Pointer to the next input byte. */ - size_t avail_in; /**< Number of available input bytes in next_in. */ - uint64_t total_in; /**< Total number of bytes read by liblzma. */ - - uint8_t *next_out; /**< Pointer to the next output position. */ - size_t avail_out; /**< Amount of free space in next_out. */ - uint64_t total_out; /**< Total number of bytes written by liblzma. */ - - /** - * \brief Custom memory allocation functions - * - * In most cases this is NULL which makes liblzma use - * the standard malloc() and free(). - * - * \note In 5.0.x this is not a const pointer. - */ - const lzma_allocator *allocator; - - /** Internal state is not visible to applications. */ - lzma_internal *internal; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. Excluding the initialization of this structure, - * you should not touch these, because the names of these variables - * may change. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - void *reserved_ptr4; - - /** - * \brief New seek input position for LZMA_SEEK_NEEDED - * - * When lzma_code() returns LZMA_SEEK_NEEDED, the new input position - * needed by liblzma will be available seek_pos. The value is - * guaranteed to not exceed the file size that was specified when - * this lzma_stream was initialized. - * - * In all other situations the value of this variable is undefined. - */ - uint64_t seek_pos; - - uint64_t reserved_int2; - size_t reserved_int3; - size_t reserved_int4; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - -} lzma_stream; - - -/** - * \brief Initialization for lzma_stream - * - * When you declare an instance of lzma_stream, you can immediately - * initialize it so that initialization functions know that no memory - * has been allocated yet: - * - * lzma_stream strm = LZMA_STREAM_INIT; - * - * If you need to initialize a dynamically allocated lzma_stream, you can use - * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this - * violates the C standard since NULL may have different internal - * representation than zero, but it should be portable enough in practice. - * Anyway, for maximum portability, you can use something like this: - * - * lzma_stream tmp = LZMA_STREAM_INIT; - * *strm = tmp; - */ -#define LZMA_STREAM_INIT \ - { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ - NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ - LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } - - -/** - * \brief Encode or decode data - * - * Once the lzma_stream has been successfully initialized (e.g. with - * lzma_stream_encoder()), the actual encoding or decoding is done - * using this function. The application has to update strm->next_in, - * strm->avail_in, strm->next_out, and strm->avail_out to pass input - * to and get output from liblzma. - * - * See the description of the coder-specific initialization function to find - * out what `action' values are supported by the coder. - */ -extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Free memory allocated for the coder data structures - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * - * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other - * members of the lzma_stream structure are touched. - * - * \note zlib indicates an error if application end()s unfinished - * stream structure. liblzma doesn't do this, and assumes that - * application knows what it is doing. - */ -extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; - - -/** - * \brief Get progress information - * - * In single-threaded mode, applications can get progress information from - * strm->total_in and strm->total_out. In multi-threaded mode this is less - * useful because a significant amount of both input and output data gets - * buffered internally by liblzma. This makes total_in and total_out give - * misleading information and also makes the progress indicator updates - * non-smooth. - * - * This function gives realistic progress information also in multi-threaded - * mode by taking into account the progress made by each thread. In - * single-threaded mode *progress_in and *progress_out are set to - * strm->total_in and strm->total_out, respectively. - */ -extern LZMA_API(void) lzma_get_progress(lzma_stream *strm, - uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow; - - -/** - * \brief Get the memory usage of decoder filter chain - * - * This function is currently supported only when *strm has been initialized - * with a function that takes a memlimit argument. With other functions, you - * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() - * to estimate the memory requirements. - * - * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big - * the memory usage limit should have been to decode the input. Note that - * this may give misleading information if decoding .xz Streams that have - * multiple Blocks, because each Block can have different memory requirements. - * - * \return How much memory is currently allocated for the filter - * decoders. If no filter chain is currently allocated, - * some non-zero value is still returned, which is less than - * or equal to what any filter chain would indicate as its - * memory requirement. - * - * If this function isn't supported by *strm or some other error - * occurs, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the current memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * \return On success, the current memory usage limit is returned - * (always non-zero). On error, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes - * this function to do nothing (leaving the limit unchanged) and still - * return LZMA_OK. Later versions treat 0 as if 1 had been specified (so - * lzma_memlimit_get() will return 1 even if you specify 0 here). - * - * liblzma 5.2.6 and earlier had a bug in single-threaded .xz decoder - * (lzma_stream_decoder()) which made it impossible to continue decoding - * after LZMA_MEMLIMIT_ERROR even if the limit was increased using - * lzma_memlimit_set(). Other decoders worked correctly. - * - * \return - LZMA_OK: New memory usage limit successfully set. - * - LZMA_MEMLIMIT_ERROR: The new limit is too small. - * The limit was not changed. - * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't - * support memory usage limit. - */ -extern LZMA_API(lzma_ret) lzma_memlimit_set( - lzma_stream *strm, uint64_t memlimit) lzma_nothrow; diff --git a/winlibs/include/lzma/bcj.h b/winlibs/include/lzma/bcj.h deleted file mode 100644 index 4215147d7..000000000 --- a/winlibs/include/lzma/bcj.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * \file lzma/bcj.h - * \brief Branch/Call/Jump conversion filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* Filter IDs for lzma_filter.id */ - -#define LZMA_FILTER_X86 LZMA_VLI_C(0x04) - /**< - * Filter for x86 binaries - */ - -#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) - /**< - * Filter for Big endian PowerPC binaries - */ - -#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) - /**< - * Filter for IA-64 (Itanium) binaries. - */ - -#define LZMA_FILTER_ARM LZMA_VLI_C(0x07) - /**< - * Filter for ARM binaries. - */ - -#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) - /**< - * Filter for ARM-Thumb binaries. - */ - -#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) - /**< - * Filter for SPARC binaries. - */ - -#define LZMA_FILTER_ARM64 LZMA_VLI_C( 0x0A ) -/**< - * Filter for ARM64 binaries. - */ - -/** - * \brief Options for BCJ filters (except ARM64) - * - * The BCJ filters never change the size of the data. Specifying options - * for them is optional: if pointer to options is NULL, default value is - * used. You probably never need to specify options to BCJ filters, so just - * set the options pointer to NULL and be happy. - * - * If options with non-default values have been specified when encoding, - * the same options must also be specified when decoding. - * - * \note At the moment, none of the BCJ filters support - * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, - * LZMA_OPTIONS_ERROR will be returned. If there is need, - * partial support for LZMA_SYNC_FLUSH can be added in future. - * Partial means that flushing would be possible only at - * offsets that are multiple of 2, 4, or 16 depending on - * the filter, except x86 which cannot be made to support - * LZMA_SYNC_FLUSH predictably. - */ -typedef struct { - /** - * \brief Start offset for conversions - * - * This setting is useful only when the same filter is used - * _separately_ for multiple sections of the same executable file, - * and the sections contain cross-section branch/call/jump - * instructions. In that case it is beneficial to set the start - * offset of the non-first sections so that the relative addresses - * of the cross-section branch/call/jump instructions will use the - * same absolute addresses as in the first section. - * - * When the pointer to options is NULL, the default value (zero) - * is used. - */ - uint32_t start_offset; - -} lzma_options_bcj; diff --git a/winlibs/include/lzma/block.h b/winlibs/include/lzma/block.h deleted file mode 100644 index 082e55833..000000000 --- a/winlibs/include/lzma/block.h +++ /dev/null @@ -1,578 +0,0 @@ -/** - * \file lzma/block.h - * \brief .xz Block handling - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Options for the Block and Block Header encoders and decoders - * - * Different Block handling functions use different parts of this structure. - * Some read some members, other functions write, and some do both. Only the - * members listed for reading need to be initialized when the specified - * functions are called. The members marked for writing will be assigned - * new values at some point either by calling the given function or by - * later calls to lzma_code(). - */ -typedef struct { - /** - * \brief Block format version - * - * To prevent API and ABI breakages when new features are needed, - * a version number is used to indicate which fields in this - * structure are in use: - * - liblzma >= 5.0.0: version = 0 is supported. - * - liblzma >= 5.1.4beta: Support for version = 1 was added, - * which adds the ignore_check field. - * - * If version is greater than one, most Block related functions - * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works - * with any version value). - * - * Read by: - * - All functions that take pointer to lzma_block as argument, - * including lzma_block_header_decode(). - * - * Written by: - * - lzma_block_header_decode() - */ - uint32_t version; - - /** - * \brief Size of the Block Header field - * - * This is always a multiple of four. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_size() - * - lzma_block_buffer_encode() - */ - uint32_t header_size; -# define LZMA_BLOCK_HEADER_SIZE_MIN 8 -# define LZMA_BLOCK_HEADER_SIZE_MAX 1024 - - /** - * \brief Type of integrity Check - * - * The Check ID is not stored into the Block Header, thus its value - * must be provided also when decoding. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_check check; - - /** - * \brief Size of the Compressed Data in bytes - * - * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder - * will store this value to the Block Header. Block encoder doesn't - * care about this value, but will set it once the encoding has been - * finished. - * - * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will - * verify that the size of the Compressed Data field matches - * compressed_size. - * - * Usually you don't know this value when encoding in streamed mode, - * and thus cannot write this field into the Block Header. - * - * In non-streamed mode you can reserve space for this field before - * encoding the actual Block. After encoding the data, finish the - * Block by encoding the Block Header. Steps in detail: - * - * - Set compressed_size to some big enough value. If you don't know - * better, use LZMA_VLI_MAX, but remember that bigger values take - * more space in Block Header. - * - * - Call lzma_block_header_size() to see how much space you need to - * reserve for the Block Header. - * - * - Encode the Block using lzma_block_encoder() and lzma_code(). - * It sets compressed_size to the correct value. - * - * - Use lzma_block_header_encode() to encode the Block Header. - * Because space was reserved in the first step, you don't need - * to call lzma_block_header_size() anymore, because due to - * reserving, header_size has to be big enough. If it is "too big", - * lzma_block_header_encode() will add enough Header Padding to - * make Block Header to match the size specified by header_size. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed Size in bytes - * - * This is handled very similarly to compressed_size above. - * - * uncompressed_size is needed by fewer functions than - * compressed_size. This is because uncompressed_size isn't - * needed to validate that Block stays within proper limits. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli uncompressed_size; - - /** - * \brief Array of filters - * - * There can be 1-4 filters. The end of the array is marked with - * .id = LZMA_VLI_UNKNOWN. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode(): Note that this does NOT free() - * the old filter options structures. All unused filters[] will - * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If - * decoding fails, all filters[] are guaranteed to be - * LZMA_VLI_UNKNOWN and NULL. - * - * \note Because of the array is terminated with - * .id = LZMA_VLI_UNKNOWN, the actual array must - * have LZMA_FILTERS_MAX + 1 members or the Block - * Header decoder will overflow the buffer. - */ - lzma_filter *filters; - - /** - * \brief Raw value stored in the Check field - * - * After successful coding, the first lzma_check_size(check) bytes - * of this array contain the raw value stored in the Check field. - * - * Note that CRC32 and CRC64 are stored in little endian byte order. - * Take it into account if you display the Check values to the user. - * - * Written by: - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - uint32_t reserved_int1; - uint32_t reserved_int2; - lzma_vli reserved_int3; - lzma_vli reserved_int4; - lzma_vli reserved_int5; - lzma_vli reserved_int6; - lzma_vli reserved_int7; - lzma_vli reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - - /** - * \brief A flag to Block decoder to not verify the Check field - * - * This field is supported by liblzma >= 5.1.4beta if .version >= 1. - * - * If this is set to true, the integrity check won't be calculated - * and verified. Unless you know what you are doing, you should - * leave this to false. (A reason to set this to true is when the - * file integrity is verified externally anyway and you want to - * speed up the decompression, which matters mostly when using - * SHA-256 as the integrity check.) - * - * If .version >= 1, read by: - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by (.version is ignored): - * - lzma_block_header_decode() always sets this to false - */ - lzma_bool ignore_check; - - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - -} lzma_block; - - -/** - * \brief Decode the Block Header Size field - * - * To decode Block Header using lzma_block_header_decode(), the size of the - * Block Header has to be known and stored into lzma_block.header_size. - * The size can be calculated from the first byte of a Block using this macro. - * Note that if the first byte is 0x00, it indicates beginning of Index; use - * this macro only when the byte is not 0x00. - * - * There is no encoding macro, because Block Header encoder is enough for that. - */ -#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) - - -/** - * \brief Calculate Block Header Size - * - * Calculate the minimum size needed for the Block Header field using the - * settings specified in the lzma_block structure. Note that it is OK to - * increase the calculated header_size value as long as it is a multiple of - * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size - * just means that lzma_block_header_encode() will add Header Padding. - * - * \return - LZMA_OK: Size calculated successfully and stored to - * block->header_size. - * - LZMA_OPTIONS_ERROR: Unsupported version, filters or - * filter options. - * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. - * - * \note This doesn't check that all the options are valid i.e. this - * may return LZMA_OK even if lzma_block_header_encode() or - * lzma_block_encoder() would fail. If you want to validate the - * filter chain, consider using lzma_memlimit_encoder() which as - * a side-effect validates the filter chain. - */ -extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Block Header - * - * The caller must have calculated the size of the Block Header already with - * lzma_block_header_size(). If a value larger than the one calculated by - * lzma_block_header_size() is used, the Block Header will be padded to the - * specified size. - * - * \param out Beginning of the output buffer. This must be - * at least block->header_size bytes. - * \param block Block options to be encoded. - * - * \return - LZMA_OK: Encoding was successful. block->header_size - * bytes were written to output buffer. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_encode( - const lzma_block *block, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Block Header - * - * block->version should (usually) be set to the highest value supported - * by the application. If the application sets block->version to a value - * higher than supported by the current liblzma version, this function will - * downgrade block->version to the highest value supported by it. Thus one - * should check the value of block->version after calling this function if - * block->version was set to a non-zero value and the application doesn't - * otherwise know that the liblzma version being used is new enough to - * support the specified block->version. - * - * The size of the Block Header must have already been decoded with - * lzma_block_header_size_decode() macro and stored to block->header_size. - * - * The integrity check type from Stream Header must have been stored - * to block->check. - * - * block->filters must have been allocated, but they don't need to be - * initialized (possible existing filter options are not freed). - * - * \param block Destination for Block options. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() (and also free() - * if an error occurs). - * \param in Beginning of the input buffer. This must be - * at least block->header_size bytes. - * - * \return - LZMA_OK: Decoding was successful. block->header_size - * bytes were read from the input buffer. - * - LZMA_OPTIONS_ERROR: The Block Header specifies some - * unsupported options such as unsupported filters. This can - * happen also if block->version was set to a too low value - * compared to what would be required to properly represent - * the information stored in the Block Header. - * - LZMA_DATA_ERROR: Block Header is corrupt, for example, - * the CRC32 doesn't match. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, - const lzma_allocator *allocator, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Validate and set Compressed Size according to Unpadded Size - * - * Block Header stores Compressed Size, but Index has Unpadded Size. If the - * application has already parsed the Index and is now decoding Blocks, - * it can calculate Compressed Size from Unpadded Size. This function does - * exactly that with error checking: - * - * - Compressed Size calculated from Unpadded Size must be positive integer, - * that is, Unpadded Size must be big enough that after Block Header and - * Check fields there's still at least one byte for Compressed Size. - * - * - If Compressed Size was present in Block Header, the new value - * calculated from Unpadded Size is compared against the value - * from Block Header. - * - * \note This function must be called _after_ decoding the Block Header - * field so that it can properly validate Compressed Size if it - * was present in Block Header. - * - * \return - LZMA_OK: block->compressed_size was set successfully. - * - LZMA_DATA_ERROR: unpadded_size is too small compared to - * block->header_size and lzma_check_size(block->check). - * - LZMA_PROG_ERROR: Some values are invalid. For example, - * block->header_size must be a multiple of four and - * between 8 and 1024 inclusive. - */ -extern LZMA_API(lzma_ret) lzma_block_compressed_size( - lzma_block *block, lzma_vli unpadded_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate Unpadded Size - * - * The Index field stores Unpadded Size and Uncompressed Size. The latter - * can be taken directly from the lzma_block structure after coding a Block, - * but Unpadded Size needs to be calculated from Block Header Size, - * Compressed Size, and size of the Check field. This is where this function - * is needed. - * - * \return Unpadded Size on success, or zero on error. - */ -extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate the total encoded size of a Block - * - * This is equivalent to lzma_block_unpadded_size() except that the returned - * value includes the size of the Block Padding field. - * - * \return On success, total encoded size of the Block. On error, - * zero is returned. - */ -extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Block encoder - * - * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the - * filter chain supports it), and LZMA_FINISH. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID - * that is not supported by this build of liblzma. Initializing - * the encoder failed. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_encoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Block decoder - * - * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using - * LZMA_FINISH is not required. It is supported only for convenience. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_PROG_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_decoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate maximum output size for single-call Block encoding - * - * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. - * See the documentation of lzma_stream_buffer_bound(). - */ -extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Block encoder - * - * In contrast to the multi-call encoder initialized with - * lzma_block_encoder(), this function encodes also the Block Header. This - * is required to make it possible to write appropriate Block Header also - * in case the data isn't compressible, and different filter chain has to be - * used to encode the data in uncompressed form using uncompressed chunks - * of the LZMA2 filter. - * - * When the data isn't compressible, header_size, compressed_size, and - * uncompressed_size are set just like when the data was compressible, but - * it is possible that header_size is too small to hold the filter chain - * specified in block->filters, because that isn't necessarily the filter - * chain that was actually used to encode the data. lzma_block_unpadded_size() - * still works normally, because it doesn't read the filters array. - * - * \param block Block options: block->version, block->check, - * and block->filters must have been initialized. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_encode( - lzma_block *block, const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call uncompressed .xz Block encoder - * - * This is like lzma_block_buffer_encode() except this doesn't try to - * compress the data and instead encodes the data using LZMA2 uncompressed - * chunks. The required output buffer size can be determined with - * lzma_block_buffer_bound(). - * - * Since the data won't be compressed, this function ignores block->filters. - * This function doesn't take lzma_allocator because this function doesn't - * allocate any memory from the heap. - */ -extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Block decoder - * - * This is single-call equivalent of lzma_block_decoder(), and requires that - * the caller has already decoded Block Header and checked its memory usage. - * - * \param block Block options just like with lzma_block_decoder(). - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_MEM_ERROR - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_decode( - lzma_block *block, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow; diff --git a/winlibs/include/lzma/check.h b/winlibs/include/lzma/check.h deleted file mode 100644 index 6a243db0d..000000000 --- a/winlibs/include/lzma/check.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * \file lzma/check.h - * \brief Integrity checks - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Type of the integrity check (Check ID) - * - * The .xz format supports multiple types of checks that are calculated - * from the uncompressed data. They vary in both speed and ability to - * detect errors. - */ -typedef enum { - LZMA_CHECK_NONE = 0, - /**< - * No Check is calculated. - * - * Size of the Check field: 0 bytes - */ - - LZMA_CHECK_CRC32 = 1, - /**< - * CRC32 using the polynomial from the IEEE 802.3 standard - * - * Size of the Check field: 4 bytes - */ - - LZMA_CHECK_CRC64 = 4, - /**< - * CRC64 using the polynomial from the ECMA-182 standard - * - * Size of the Check field: 8 bytes - */ - - LZMA_CHECK_SHA256 = 10 - /**< - * SHA-256 - * - * Size of the Check field: 32 bytes - */ -} lzma_check; - - -/** - * \brief Maximum valid Check ID - * - * The .xz file format specification specifies 16 Check IDs (0-15). Some - * of them are only reserved, that is, no actual Check algorithm has been - * assigned. When decoding, liblzma still accepts unknown Check IDs for - * future compatibility. If a valid but unsupported Check ID is detected, - * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, - * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h. - */ -#define LZMA_CHECK_ID_MAX 15 - - -/** - * \brief Test if the given Check ID is supported - * - * Return true if the given Check ID is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * is not in the range [0, 15]; in that case the return value is always false. - * - * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always - * supported (even if liblzma is built with limited features). - */ -extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Get the size of the Check field with the given Check ID - * - * Although not all Check IDs have a check algorithm associated, the size of - * every Check is already frozen. This function returns the size (in bytes) of - * the Check field with the specified Check ID. The values are: - * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } - * - * If the argument is not in the range [0, 15], UINT32_MAX is returned. - */ -extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Maximum size of a Check field - */ -#define LZMA_CHECK_SIZE_MAX 64 - - -/** - * \brief Calculate CRC32 - * - * Calculate CRC32 using the polynomial from the IEEE 802.3 standard. - * - * \param buf Pointer to the input buffer - * \param size Size of the input buffer - * \param crc Previously returned CRC value. This is used to - * calculate the CRC of a big buffer in smaller chunks. - * Set to zero when starting a new calculation. - * - * \return Updated CRC value, which can be passed to this function - * again to continue CRC calculation. - */ -extern LZMA_API(uint32_t) lzma_crc32( - const uint8_t *buf, size_t size, uint32_t crc) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate CRC64 - * - * Calculate CRC64 using the polynomial from the ECMA-182 standard. - * - * This function is used similarly to lzma_crc32(). See its documentation. - */ -extern LZMA_API(uint64_t) lzma_crc64( - const uint8_t *buf, size_t size, uint64_t crc) - lzma_nothrow lzma_attr_pure; - - -/* - * SHA-256 functions are currently not exported to public API. - * Contact Lasse Collin if you think it should be. - */ - - -/** - * \brief Get the type of the integrity check - * - * This function can be called only immediately after lzma_code() has - * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. - * Calling this function in any other situation has undefined behavior. - */ -extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) - lzma_nothrow; diff --git a/winlibs/include/lzma/container.h b/winlibs/include/lzma/container.h deleted file mode 100644 index f02560a91..000000000 --- a/winlibs/include/lzma/container.h +++ /dev/null @@ -1,899 +0,0 @@ -/** - * \file lzma/container.h - * \brief File formats - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/************ - * Encoding * - ************/ - -/** - * \brief Default compression preset - * - * It's not straightforward to recommend a default preset, because in some - * cases keeping the resource usage relatively low is more important that - * getting the maximum compression ratio. - */ -#define LZMA_PRESET_DEFAULT UINT32_C(6) - - -/** - * \brief Mask for preset level - * - * This is useful only if you need to extract the level from the preset - * variable. That should be rare. - */ -#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F) - - -/* - * Preset flags - * - * Currently only one flag is defined. - */ - -/** - * \brief Extreme compression preset - * - * This flag modifies the preset to make the encoding significantly slower - * while improving the compression ratio only marginally. This is useful - * when you don't mind wasting time to get as small result as possible. - * - * This flag doesn't affect the memory usage requirements of the decoder (at - * least not significantly). The memory usage of the encoder may be increased - * a little but only at the lowest preset levels (0-3). - */ -#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) - - -/** - * \brief Multithreading options - */ -typedef struct { - /** - * \brief Flags - * - * Set this to zero if no flags are wanted. - * - * Encoder: No flags are currently supported. - * - * Decoder: Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, - * LZMA_CONCATENATED, LZMA_FAIL_FAST - */ - uint32_t flags; - - /** - * \brief Number of worker threads to use - */ - uint32_t threads; - - /** - * \brief Encoder only: Maximum uncompressed size of a Block - * - * The encoder will start a new .xz Block every block_size bytes. - * Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code() - * the caller may tell liblzma to start a new Block earlier. - * - * With LZMA2, a recommended block size is 2-4 times the LZMA2 - * dictionary size. With very small dictionaries, it is recommended - * to use at least 1 MiB block size for good compression ratio, even - * if this is more than four times the dictionary size. Note that - * these are only recommendations for typical use cases; feel free - * to use other values. Just keep in mind that using a block size - * less than the LZMA2 dictionary size is waste of RAM. - * - * Set this to 0 to let liblzma choose the block size depending - * on the compression options. For LZMA2 it will be 3*dict_size - * or 1 MiB, whichever is more. - * - * For each thread, about 3 * block_size bytes of memory will be - * allocated. This may change in later liblzma versions. If so, - * the memory usage will probably be reduced, not increased. - */ - uint64_t block_size; - - /** - * \brief Timeout to allow lzma_code() to return early - * - * Multithreading can make liblzma to consume input and produce - * output in a very bursty way: it may first read a lot of input - * to fill internal buffers, then no input or output occurs for - * a while. - * - * In single-threaded mode, lzma_code() won't return until it has - * either consumed all the input or filled the output buffer. If - * this is done in multithreaded mode, it may cause a call - * lzma_code() to take even tens of seconds, which isn't acceptable - * in all applications. - * - * To avoid very long blocking times in lzma_code(), a timeout - * (in milliseconds) may be set here. If lzma_code() would block - * longer than this number of milliseconds, it will return with - * LZMA_OK. Reasonable values are 100 ms or more. The xz command - * line tool uses 300 ms. - * - * If long blocking times are fine for you, set timeout to a special - * value of 0, which will disable the timeout mechanism and will make - * lzma_code() block until all the input is consumed or the output - * buffer has been filled. - * - * \note Even with a timeout, lzma_code() might sometimes take - * somewhat long time to return. No timing guarantees - * are made. - */ - uint32_t timeout; - - /** - * \brief Encoder only: Compression preset - * - * The preset is set just like with lzma_easy_encoder(). - * The preset is ignored if filters below is non-NULL. - */ - uint32_t preset; - - /** - * \brief Encoder only: Filter chain (alternative to a preset) - * - * If this is NULL, the preset above is used. Otherwise the preset - * is ignored and the filter chain specified here is used. - */ - const lzma_filter * filters; - - /** - * \brief Encoder only: Integrity check type - * - * See check.h for available checks. The xz command line tool - * defaults to LZMA_CHECK_CRC64, which is a good choice if you - * are unsure. - */ - lzma_check check; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - - /** - * \brief Memory usage limit to reduce the number of threads - * - * Encoder: Ignored. - * - * Decoder: - * - * If the number of threads has been set so high that more than - * memlimit_threading bytes of memory would be needed, the number - * of threads will be reduced so that the memory usage will not exceed - * memlimit_threading bytes. However, if memlimit_threading cannot - * be met even in single-threaded mode, then decoding will continue - * in single-threaded mode and memlimit_threading may be exceeded - * even by a large amount. That is, memlimit_threading will never make - * lzma_code() return LZMA_MEMLIMIT_ERROR. To truly cap the memory - * usage, see memlimit_stop below. - * - * Setting memlimit_threading to UINT64_MAX or a similar huge value - * means that liblzma is allowed to keep the whole compressed file - * and the whole uncompressed file in memory in addition to the memory - * needed by the decompressor data structures used by each thread! - * In other words, a reasonable value limit must be set here or it - * will cause problems sooner or later. If you have no idea what - * a reasonable value could be, try lzma_physmem() / 4 as a starting - * point. Setting this limit will never prevent decompression of - * a file; this will only reduce the number of threads. - * - * If memlimit_threading is greater than memlimit_stop, then the value - * of memlimit_stop will be used for both. - */ - uint64_t memlimit_threading; - - /** - * \brief Memory usage limit that should never be exceeded - * - * Encoder: Ignored. - * - * Decoder: If decompressing will need more than this amount of - * memory even in the single-threaded mode, then lzma_code() will - * return LZMA_MEMLIMIT_ERROR. - */ - uint64_t memlimit_stop; - - uint64_t reserved_int7; - uint64_t reserved_int8; - void * reserved_ptr1; - void * reserved_ptr2; - void * reserved_ptr3; - void * reserved_ptr4; - -} lzma_mt; - - -/** - * \brief Calculate approximate memory usage of easy encoder - * - * This function is a wrapper for lzma_raw_encoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required for the given - * preset when encoding. If an error occurs, for example - * due to unsupported preset, UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate decoder memory usage of a preset - * - * This function is a wrapper for lzma_raw_decoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required to decompress a file - * that was compressed using the given preset. If an error - * occurs, for example due to unsupported preset, UINT64_MAX - * is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Stream encoder using a preset number - * - * This function is intended for those who just want to use the basic features - * if liblzma (that is, most developers out there). - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * \param preset Compression preset to use. A preset consist of level - * number and zero or more flags. Usually flags aren't - * used, so preset is simply a number [0, 9] which match - * the options -0 ... -9 of the xz command line tool. - * Additional flags can be be set using bitwise-or with - * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. - * \param check Integrity check type to use. See check.h for available - * checks. The xz command line tool defaults to - * LZMA_CHECK_CRC64, which is a good choice if you are - * unsure. LZMA_CHECK_CRC32 is good too as long as the - * uncompressed file is not many gigabytes. - * - * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to - * encode your data. - * - LZMA_MEM_ERROR: Memory allocation failed. - * - LZMA_OPTIONS_ERROR: The given compression preset is not - * supported by this build of liblzma. - * - LZMA_UNSUPPORTED_CHECK: The given check type is not - * supported by this liblzma build. - * - LZMA_PROG_ERROR: One or more of the parameters have values - * that will never be valid. For example, strm == NULL. - * - * If initialization fails (return value is not LZMA_OK), all the memory - * allocated for *strm by liblzma is always freed. Thus, there is no need - * to call lzma_end() after failed initialization. - * - * If initialization succeeds, use lzma_code() to do the actual encoding. - * Valid values for `action' (the second argument of lzma_code()) are - * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, - * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. - */ -extern LZMA_API(lzma_ret) lzma_easy_encoder( - lzma_stream *strm, uint32_t preset, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream encoding using a preset number - * - * The maximum required output buffer size can be calculated with - * lzma_stream_buffer_bound(). - * - * \param preset Compression preset to use. See the description - * in lzma_easy_encoder(). - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( - uint32_t preset, lzma_check check, - const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Initialize .xz Stream encoder using a custom filter chain - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for - * more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm, - const lzma_filter *filters, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate approximate memory usage of multithreaded .xz encoder - * - * Since doing the encoding in threaded mode doesn't affect the memory - * requirements of single-threaded decompressor, you can use - * lzma_easy_decoder_memusage(options->preset) or - * lzma_raw_decoder_memusage(options->filters) to calculate - * the decompressor memory requirements. - * - * \param options Compression options - * - * \return Number of bytes of memory required for encoding with the - * given options. If an error occurs, for example due to - * unsupported preset or filter chain, UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage( - const lzma_mt *options) lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize multithreaded .xz Stream encoder - * - * This provides the functionality of lzma_easy_encoder() and - * lzma_stream_encoder() as a single function for multithreaded use. - * - * The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH, - * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be - * added in the future. - * - * \param strm Pointer to properly prepared lzma_stream - * \param options Pointer to multithreaded compression options - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_encoder_mt( - lzma_stream *strm, const lzma_mt *options) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma encoder (legacy file format) - * - * The .lzma format is sometimes called the LZMA_Alone format, which is the - * reason for the name of this function. The .lzma format supports only the - * LZMA1 filter. There is no support for integrity checks like CRC32. - * - * Use this function if and only if you need to create files readable by - * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format - * is strongly recommended. - * - * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * No kind of flushing is supported, because the file format doesn't make - * it possible. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_encoder( - lzma_stream *strm, const lzma_options_lzma *options) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate output buffer size for single-call Stream encoder - * - * When trying to compress uncompressible data, the encoded size will be - * slightly bigger than the input data. This function calculates how much - * output buffer space is required to be sure that lzma_stream_buffer_encode() - * doesn't return LZMA_BUF_ERROR. - * - * The calculated value is not exact, but it is guaranteed to be big enough. - * The actual maximum output space required may be slightly smaller (up to - * about 100 bytes). This should not be a problem in practice. - * - * If the calculated maximum size doesn't fit into size_t or would make the - * Stream grow past LZMA_VLI_MAX (which should never happen in practice), - * zero is returned to indicate the error. - * - * \note The limit calculated by this function applies only to - * single-call encoding. Multi-call encoding may (and probably - * will) have larger maximum expansion when encoding - * uncompressible data. Currently there is no function to - * calculate the maximum expansion of multi-call encoding. - */ -extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Stream encoder - * - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h - * for more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( - lzma_filter *filters, lzma_check check, - const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief MicroLZMA encoder - * - * The MicroLZMA format is a raw LZMA stream whose first byte (always 0x00) - * has been replaced with bitwise-negation of the LZMA properties (lc/lp/pb). - * This encoding ensures that the first byte of MicroLZMA stream is never - * 0x00. There is no end of payload marker and thus the uncompressed size - * must be stored separately. For the best error detection the dictionary - * size should be stored separately as well but alternatively one may use - * the uncompressed size as the dictionary size when decoding. - * - * With the MicroLZMA encoder, lzma_code() behaves slightly unusually. - * The action argument must be LZMA_FINISH and the return value will never be - * LZMA_OK. Thus the encoding is always done with a single lzma_code() after - * the initialization. The benefit of the combination of initialization - * function and lzma_code() is that memory allocations can be re-used for - * better performance. - * - * lzma_code() will try to encode as much input as is possible to fit into - * the given output buffer. If not all input can be encoded, the stream will - * be finished without encoding all the input. The caller must check both - * input and output buffer usage after lzma_code() (total_in and total_out - * in lzma_stream can be convenient). Often lzma_code() can fill the output - * buffer completely if there is a lot of input, but sometimes a few bytes - * may remain unused because the next LZMA symbol would require more space. - * - * lzma_stream.avail_out must be at least 6. Otherwise LZMA_PROG_ERROR - * will be returned. - * - * The LZMA dictionary should be reasonably low to speed up the encoder - * re-initialization. A good value is bigger than the resulting - * uncompressed size of most of the output chunks. For example, if output - * size is 4 KiB, dictionary size of 32 KiB or 64 KiB is good. If the - * data compresses extremely well, even 128 KiB may be useful. - * - * The MicroLZMA format and this encoder variant were made with the EROFS - * file system in mind. This format may be convenient in other embedded - * uses too where many small streams are needed. XZ Embedded includes a - * decoder for this format. - * - * \return - LZMA_STREAM_END: All good. Check the amounts of input used - * and output produced. Store the amount of input used - * (uncompressed size) as it needs to be known to decompress - * the data. - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR: In addition to the generic reasons for this - * error code, this may also be returned if there isn't enough - * output space (6 bytes) to create a valid MicroLZMA stream. - */ -extern LZMA_API( lzma_ret ) lzma_microlzma_encoder( lzma_stream * strm, const lzma_options_lzma * options ); - - -/************ - * Decoding * - ************/ - -/** - * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream - * being decoded has no integrity check. Note that when used with - * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK - * if LZMA_TELL_NO_CHECK is used. - */ -#define LZMA_TELL_NO_CHECK UINT32_C(0x01) - - -/** - * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input - * stream has an integrity check, but the type of the integrity check is not - * supported by this liblzma version or build. Such files can still be - * decoded, but the integrity check cannot be verified. - */ -#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02) - - -/** - * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type - * of the integrity check is known. The type can then be got with - * lzma_get_check(). - */ -#define LZMA_TELL_ANY_CHECK UINT32_C(0x04) - - -/** - * This flag makes lzma_code() not calculate and verify the integrity check - * of the compressed data in .xz files. This means that invalid integrity - * check values won't be detected and LZMA_DATA_ERROR won't be returned in - * such cases. - * - * This flag only affects the checks of the compressed data itself; the CRC32 - * values in the .xz headers will still be verified normally. - * - * Don't use this flag unless you know what you are doing. Possible reasons - * to use this flag: - * - * - Trying to recover data from a corrupt .xz file. - * - * - Speeding up decompression, which matters mostly with SHA-256 - * or with files that have compressed extremely well. It's recommended - * to not use this flag for this purpose unless the file integrity is - * verified externally in some other way. - * - * Support for this flag was added in liblzma 5.1.4beta. - */ -#define LZMA_IGNORE_CHECK UINT32_C(0x10) - - -/** - * This flag enables decoding of concatenated files with file formats that - * allow concatenating compressed files as is. From the formats currently - * supported by liblzma, only the .xz and .lz formats allow concatenated - * files. Concatenated files are not allowed with the legacy .lzma format. - * - * This flag also affects the usage of the `action' argument for lzma_code(). - * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END - * unless LZMA_FINISH is used as `action'. Thus, the application has to set - * LZMA_FINISH in the same way as it does when encoding. - * - * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH - * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required. - */ -#define LZMA_CONCATENATED UINT32_C(0x08) - - -/** - * This flag makes the threaded decoder report errors (like LZMA_DATA_ERROR) - * as soon as they are detected. This saves time when the application has no - * interest in a partially decompressed truncated or corrupt file. Note that - * due to timing randomness, if the same truncated or corrupt input is - * decompressed multiple times with this flag, a different amount of output - * may be produced by different runs, and even the error code might vary. - * - * When using LZMA_FAIL_FAST, it is recommended to use LZMA_FINISH to tell - * the decoder when no more input will be coming because it can help fast - * detection and reporting of truncated files. Note that in this situation - * truncated files might be diagnosed with LZMA_DATA_ERROR instead of - * LZMA_OK or LZMA_BUF_ERROR! - * - * Without this flag the threaded decoder will provide as much output as - * possible at first and then report the pending error. This default behavior - * matches the single-threaded decoder and provides repeatable behavior - * with truncated or corrupt input. There are a few special cases where the - * behavior can still differ like memory allocation failures (LZMA_MEM_ERROR). - * - * Single-threaded decoders currently ignore this flag. - * - * Support for this flag was added in liblzma 5.3.3alpha. Note that in older - * versions this flag isn't supported (LZMA_OPTIONS_ERROR) even by functions - * that ignore this flag in newer liblzma versions. - */ -#define LZMA_FAIL_FAST UINT32_C( 0x20 ) - - -/** - * \brief Initialize .xz Stream decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. liblzma - * 5.2.3 and earlier don't allow 0 here and return - * LZMA_PROG_ERROR; later versions treat 0 as if 1 - * had been specified. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, - * LZMA_CONCATENATED, LZMA_FAIL_FAST - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize multithreaded .xz Stream decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param options Pointer to multithreaded compression options - * - * The decoder can decode multiple Blocks in parallel. This requires that each - * Block Header contains the Compressed Size and Uncompressed size fields - * which are added by the multi-threaded encoder, see lzma_stream_encoder_mt(). - * - * A Stream with one Block will only utilize one thread. A Stream with multiple - * Blocks but without size information in Block Headers will be processed in - * single-threaded mode in the same way as done by lzma_stream_decoder(). - * Concatenated Streams are processed one Stream at a time; no inter-Stream - * parallelization is done. - * - * This function behaves like lzma_stream_decoder() when options->threads == 1 - * and options->memlimit_threading <= 1. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * - LZMA_OPTIONS_ERROR: Unsupported flags. - * - LZMA_PROG_ERROR - */ -extern LZMA_API( lzma_ret ) - lzma_stream_decoder_mt( lzma_stream * strm, const lzma_mt * options ) lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode .xz, .lzma, and .lz (lzip) files with autodetection - * - * This decoder autodetects between the .xz, .lzma, and .lz file formats, - * and calls lzma_stream_decoder(), lzma_alone_decoder(), or - * lzma_lzip_decoder() once the type of the input file has been detected. - * - * Support for .lz was added in 5.4.0. - * - * If the flag LZMA_CONCATENATED is used and the input is a .lzma file: - * For historical reasons concatenated .lzma files aren't supported. - * If there is trailing data after one .lzma stream, lzma_code() will - * return LZMA_DATA_ERROR. (lzma_alone_decoder() doesn't have such a check - * as it doesn't support any decoder flags. It will return LZMA_STREAM_END - * after one .lzma stream.) - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. liblzma - * 5.2.3 and earlier don't allow 0 here and return - * LZMA_PROG_ERROR; later versions treat 0 as if 1 - * had been specified. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, - * LZMA_CONCATENATED, LZMA_FAIL_FAST - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_auto_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma decoder (legacy file format) - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. liblzma - * 5.2.3 and earlier don't allow 0 here and return - * LZMA_PROG_ERROR; later versions treat 0 as if 1 - * had been specified. - * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * There is no need to use LZMA_FINISH, but it's allowed because it may - * simplify certain types of applications. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_decoder( - lzma_stream *strm, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lz (lzip) decoder (a foreign file format) - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of flags, or zero for no flags. - * All decoder flags listed above are supported - * although only LZMA_CONCATENATED and (in very rare - * cases) LZMA_IGNORE_CHECK are actually useful. - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK - * is supported for consistency only as CRC32 is - * always used in the .lz format. - * - * This decoder supports the .lz format version 0 and the unextended .lz - * format version 1: - * - * - Files in the format version 0 were produced by lzip 1.3 and older. - * Such files aren't common but may be found from file archives - * as a few source packages were released in this format. People - * might have old personal files in this format too. Decompression - * support for the format version 0 was removed in lzip 1.18. - * - * - lzip 1.3 added decompression support for .lz format version 1 files. - * Compression support was added in lzip 1.4. In lzip 1.6 the .lz format - * version 1 was extended to support the Sync Flush marker. This extension - * is not supported by liblzma. lzma_code() will return LZMA_DATA_ERROR - * at the location of the Sync Flush marker. In practice files with - * the Sync Flush marker are very rare and thus liblzma can decompress - * almost all .lz files. - * - * Just like with lzma_stream_decoder() for .xz files, LZMA_CONCATENATED - * should be used when decompressing normal standalone .lz files. - * - * The .lz format allows putting non-.lz data at the end of a file after at - * least one valid .lz member. That is, one can append custom data at the end - * of a .lz file and the decoder is required to ignore it. In liblzma this - * is relevant only when LZMA_CONCATENATED is used. In that case lzma_code() - * will return LZMA_STREAM_END and leave lzma_stream.next_in pointing to - * the first byte of the non-.lz data. An exception to this is if the first - * 1-3 bytes of the non-.lz data are identical to the .lz magic bytes - * (0x4C, 0x5A, 0x49, 0x50; "LZIP" in US-ASCII). In such a case the 1-3 bytes - * will have been ignored by lzma_code(). If one wishes to locate the non-.lz - * data reliably, one must ensure that the first byte isn't 0x4C. Actually - * one should ensure that none of the first four bytes of trailing data are - * equal to the magic bytes because lzip >= 1.20 requires it by default. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API( lzma_ret ) - lzma_lzip_decoder( lzma_stream * strm, uint64_t memlimit, uint32_t flags ) lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream decoder - * - * \param memlimit Pointer to how much memory the decoder is allowed - * to allocate. The value pointed by this pointer is - * modified if and only if LZMA_MEMLIMIT_ERROR is - * returned. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_IGNORE_CHECK, LZMA_CONCATENATED, - * LZMA_FAIL_FAST. Note that LZMA_TELL_ANY_CHECK - * is not allowed and will return LZMA_PROG_ERROR. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if decoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_NO_CHECK: This can be returned only if using - * the LZMA_TELL_NO_CHECK flag. - * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using - * the LZMA_TELL_UNSUPPORTED_CHECK flag. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( - uint64_t *memlimit, uint32_t flags, - const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief MicroLZMA decoder - * - * See lzma_microlzma_decoder() for more information. - * - * The lzma_code() usage with this decoder is completely normal. The - * special behavior of lzma_code() applies to lzma_microlzma_encoder() only. - * - * \param strm Pointer to properly prepared lzma_stream - * \param comp_size Compressed size of the MicroLZMA stream. - * The caller must somehow know this exactly. - * \param uncomp_size Uncompressed size of the MicroLZMA stream. - * If the exact uncompressed size isn't known, this - * can be set to a value that is at most as big as - * the exact uncompressed size would be, but then the - * next argument uncomp_size_is_exact must be false. - * \param uncomp_size_is_exact - * If true, uncomp_size must be exactly correct. - * This will improve error detection at the end of - * the stream. If the exact uncompressed size isn't - * known, this must be false. uncomp_size must still - * be at most as big as the exact uncompressed size - * is. Setting this to false when the exact size is - * known will work but error detection at the end of - * the stream will be weaker. - * \param dict_size LZMA dictionary size that was used when - * compressing the data. It is OK to use a bigger - * value too but liblzma will then allocate more - * memory than would actually be required and error - * detection will be slightly worse. (Note that with - * the implementation in XZ Embedded it doesn't - * affect the memory usage if one specifies bigger - * dictionary than actually required.) - */ -extern LZMA_API( lzma_ret ) lzma_microlzma_decoder( - lzma_stream * strm, uint64_t comp_size, uint64_t uncomp_size, lzma_bool uncomp_size_is_exact, uint32_t dict_size ); diff --git a/winlibs/include/lzma/delta.h b/winlibs/include/lzma/delta.h deleted file mode 100644 index 592fc4f84..000000000 --- a/winlibs/include/lzma/delta.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file lzma/delta.h - * \brief Delta filter - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Filter ID - * - * Filter ID of the Delta filter. This is used as lzma_filter.id. - */ -#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) - - -/** - * \brief Type of the delta calculation - * - * Currently only byte-wise delta is supported. Other possible types could - * be, for example, delta of 16/32/64-bit little/big endian integers, but - * these are not currently planned since byte-wise delta is almost as good. - */ -typedef enum { - LZMA_DELTA_TYPE_BYTE -} lzma_delta_type; - - -/** - * \brief Options for the Delta filter - * - * These options are needed by both encoder and decoder. - */ -typedef struct { - /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ - lzma_delta_type type; - - /** - * \brief Delta distance - * - * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, - * the distance is as bytes. - * - * Examples: - * - 16-bit stereo audio: distance = 4 bytes - * - 24-bit RGB image data: distance = 3 bytes - */ - uint32_t dist; -# define LZMA_DELTA_DIST_MIN 1 -# define LZMA_DELTA_DIST_MAX 256 - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_delta; diff --git a/winlibs/include/lzma/filter.h b/winlibs/include/lzma/filter.h deleted file mode 100644 index 68cebb014..000000000 --- a/winlibs/include/lzma/filter.h +++ /dev/null @@ -1,712 +0,0 @@ -/** - * \file lzma/filter.h - * \brief Common filter related types and functions - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum number of filters in a chain - * - * A filter chain can have 1-4 filters, of which three are allowed to change - * the size of the data. Usually only one or two filters are needed. - */ -#define LZMA_FILTERS_MAX 4 - - -/** - * \brief Filter options - * - * This structure is used to pass Filter ID and a pointer filter's - * options to liblzma. A few functions work with a single lzma_filter - * structure, while most functions expect a filter chain. - * - * A filter chain is indicated with an array of lzma_filter structures. - * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter - * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to - * be able to hold any arbitrary filter chain. This is important when - * using lzma_block_header_decode() from block.h, because too small - * array would make liblzma write past the end of the filters array. - */ -typedef struct { - /** - * \brief Filter ID - * - * Use constants whose name begin with `LZMA_FILTER_' to specify - * different filters. In an array of lzma_filter structures, use - * LZMA_VLI_UNKNOWN to indicate end of filters. - * - * \note This is not an enum, because on some systems enums - * cannot be 64-bit. - */ - lzma_vli id; - - /** - * \brief Pointer to filter-specific options structure - * - * If the filter doesn't need options, set this to NULL. If id is - * set to LZMA_VLI_UNKNOWN, options is ignored, and thus - * doesn't need be initialized. - */ - void *options; - -} lzma_filter; - - -/** - * \brief Test if the given Filter ID is supported for encoding - * - * Return true if the give Filter ID is supported for encoding by this - * liblzma build. Otherwise false is returned. - * - * There is no way to list which filters are available in this particular - * liblzma version and build. It would be useless, because the application - * couldn't know what kind of options the filter would need. - */ -extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Test if the given Filter ID is supported for decoding - * - * Return true if the give Filter ID is supported for decoding by this - * liblzma build. Otherwise false is returned. - */ -extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Copy the filters array - * - * Copy the Filter IDs and filter-specific options from src to dest. - * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating - * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least - * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that - * src is smaller than that. - * - * Unless the filter-specific options is NULL, the Filter ID has to be - * supported by liblzma, because liblzma needs to know the size of every - * filter-specific options structure. The filter-specific options are not - * validated. If options is NULL, any unsupported Filter IDs are copied - * without returning an error. - * - * Old filter-specific options in dest are not freed, so dest doesn't - * need to be initialized by the caller in any way. - * - * If an error occurs, memory possibly already allocated by this function - * is always freed. liblzma versions older than 5.2.7 may modify the dest - * array and leave its contents in an undefined state if an error occurs. - * liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options - * is not NULL. - * - LZMA_PROG_ERROR: src or dest is NULL. - */ -extern LZMA_API( lzma_ret ) - lzma_filters_copy( const lzma_filter * src, - lzma_filter * dest, - const lzma_allocator * allocator ) lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Free the options in the array of lzma_filter structures - * - * This frees the filter chain options. The filters array itself is not freed. - * - * The filters array must have at most LZMA_FILTERS_MAX + 1 elements - * including the terminating element which must have .id = LZMA_VLI_UNKNOWN. - * For all elements before the terminating element: - * - options will be freed using the given lzma_allocator or, - * if allocator is NULL, using free(). - * - options will be set to NULL. - * - id will be set to LZMA_VLI_UNKNOWN. - * - * If filters is NULL, this does nothing but remember that this never frees - * the filters array itself. - */ -extern LZMA_API( void ) lzma_filters_free( lzma_filter * filters, const lzma_allocator * allocator ) lzma_nothrow; - - -/** - * \brief Calculate approximate memory requirements for raw encoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream encoders too because Block and Stream encoders don't - * need significantly more memory than raw encoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when encoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate memory requirements for raw decoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream decoders too because Block and Stream decoders don't - * need significantly more memory than raw decoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when decoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize raw encoder - * - * This function may be useful when implementing custom file formats. - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * - * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the - * filter chain supports it), or LZMA_FINISH. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_encoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize raw decoder - * - * The initialization of raw decoder goes similarly to raw encoder. - * - * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using - * LZMA_FINISH is not required, it is supported just for convenience. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_decoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Update the filter chain in the encoder - * - * This function may be called after lzma_code() has returned LZMA_STREAM_END - * when LZMA_FULL_BARRIER, LZMA_FULL_FLUSH, or LZMA_SYNC_FLUSH was used: - * - * - After LZMA_FULL_BARRIER or LZMA_FULL_FLUSH: Single-threaded .xz Stream - * encoder (lzma_stream_encoder()) and (since liblzma 5.4.0) multi-threaded - * Stream encoder (lzma_stream_encoder_mt()) allow setting a new filter - * chain to be used for the next Block(s). - * - * - After LZMA_SYNC_FLUSH: Raw encoder (lzma_raw_encoder()), - * Block encocder (lzma_block_encoder()), and single-threaded .xz Stream - * encoder (lzma_stream_encoder()) allow changing certain filter-specific - * options in the middle of encoding. The actual filters in the chain - * (Filter IDs) must not be changed! Currently only the lc, lp, and pb - * options of LZMA2 (not LZMA1) can be changed this way. - * - * - In the future some filters might allow changing some of their options - * without any barrier or flushing but currently such filters don't exist. - * - * This function may also be called when no data has been compressed yet - * although this is rarely useful. In that case, this function will behave - * as if LZMA_FULL_FLUSH (Stream encoders) or LZMA_SYNC_FLUSH (Raw or Block - * encoder) had been used right before calling this function. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filters_update( - lzma_stream *strm, const lzma_filter *filters) lzma_nothrow; - - -/** - * \brief Single-call raw encoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - * - * \note There is no function to calculate how big output buffer - * would surely be big enough. (lzma_stream_buffer_bound() - * works only for lzma_stream_buffer_encode(); raw encoder - * won't necessarily meet that bound.) - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( - const lzma_filter *filters, const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, uint8_t *out, - size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call raw decoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( - const lzma_filter *filters, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Get the size of the Filter Properties field - * - * This function may be useful when implementing custom file formats - * using the raw encoder and decoder. - * - * \param size Pointer to uint32_t to hold the size of the properties - * \param filter Filter ID and options (the size of the properties may - * vary depending on the options) - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note This function validates the Filter ID, but does not - * necessarily validate the options. Thus, it is possible - * that this returns LZMA_OK while the following call to - * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. - */ -extern LZMA_API(lzma_ret) lzma_properties_size( - uint32_t *size, const lzma_filter *filter) lzma_nothrow; - - -/** - * \brief Encode the Filter Properties field - * - * \param filter Filter ID and options - * \param props Buffer to hold the encoded options. The size of - * buffer must have been already determined with - * lzma_properties_size(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note Even this function won't validate more options than actually - * necessary. Thus, it is possible that encoding the properties - * succeeds but using the same options to initialize the encoder - * will fail. - * - * \note If lzma_properties_size() indicated that the size - * of the Filter Properties field is zero, calling - * lzma_properties_encode() is not required, but it - * won't do any harm either. - */ -extern LZMA_API(lzma_ret) lzma_properties_encode( - const lzma_filter *filter, uint8_t *props) lzma_nothrow; - - -/** - * \brief Decode the Filter Properties field - * - * \param filter filter->id must have been set to the correct - * Filter ID. filter->options doesn't need to be - * initialized (it's not freed by this function). The - * decoded options will be stored in filter->options; - * it's application's responsibility to free it when - * appropriate. filter->options is set to NULL if - * there are no properties or if an error occurs. - * \param allocator Custom memory allocator used to allocate the - * options. Set to NULL to use the default malloc(), - * and in case of an error, also free(). - * \param props Input buffer containing the properties. - * \param props_size Size of the properties. This must be the exact - * size; giving too much or too little input will - * return LZMA_OPTIONS_ERROR. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_properties_decode( - lzma_filter *filter, const lzma_allocator *allocator, - const uint8_t *props, size_t props_size) lzma_nothrow; - - -/** - * \brief Calculate encoded size of a Filter Flags field - * - * Knowing the size of Filter Flags is useful to know when allocating - * memory to hold the encoded Filter Flags. - * - * \param size Pointer to integer to hold the calculated size - * \param filter Filter ID and associated options whose encoded - * size is to be calculated - * - * \return - LZMA_OK: *size set successfully. Note that this doesn't - * guarantee that filter->options is valid, thus - * lzma_filter_flags_encode() may still fail. - * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. - * - LZMA_PROG_ERROR: Invalid options - * - * \note If you need to calculate size of List of Filter Flags, - * you need to loop over every lzma_filter entry. - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_size( - uint32_t *size, const lzma_filter *filter) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Filter Flags into given buffer - * - * In contrast to some functions, this doesn't allocate the needed buffer. - * This is due to how this function is used internally by liblzma. - * - * \param filter Filter ID and options to be encoded - * \param out Beginning of the output buffer - * \param out_pos out[*out_pos] is the next write position. This - * is updated by the encoder. - * \param out_size out[out_size] is the first byte to not write. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid options or not enough output - * buffer space (you should have checked it with - * lzma_filter_flags_size()). - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Filter Flags from given buffer - * - * The decoded result is stored into *filter. The old value of - * filter->options is not free()d. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_decode( - lzma_filter *filter, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/*********** - * Strings * - ***********/ - -/** - * \brief Allow or show all filters - * - * By default only the filters supported in the .xz format are accept by - * lzma_str_to_filters() or shown by lzma_str_list_filters(). - */ -#define LZMA_STR_ALL_FILTERS UINT32_C( 0x01 ) - - -/** - * \brief Do not validate the filter chain in lzma_str_to_filters() - * - * By default lzma_str_to_filters() can return an error if the filter chain - * as a whole isn't usable in the .xz format or in the raw encoder or decoder. - * With this flag the validation is skipped (this doesn't affect the handling - * of the individual filter options). - */ -#define LZMA_STR_NO_VALIDATION UINT32_C( 0x02 ) - - -/** - * \brief Stringify encoder options - * - * Show the filter-specific options that the encoder will use. - * This may be useful for verbose diagnostic messages. - * - * Note that if options were decoded from .xz headers then the encoder options - * may be undefined. This flag shouldn't be used in such a situation. - */ -#define LZMA_STR_ENCODER UINT32_C( 0x10 ) - - -/** - * \brief Stringify decoder options - * - * Show the filter-specific options that the decoder will use. - * This may be useful for showing what filter options were decoded - * from file headers. - */ -#define LZMA_STR_DECODER UINT32_C( 0x20 ) - - -/** - * \brief Produce xz-compatible getopt_long() syntax - * - * That is, "delta:dist=2 lzma2:dict=4MiB,pb=1,lp=1" becomes - * "--delta=dist=2 --lzma2=dict=4MiB,pb=1,lp=1". - * - * This syntax is compatible with xz 5.0.0 as long as the filters and - * their options are supported too. - */ -#define LZMA_STR_GETOPT_LONG UINT32_C( 0x40 ) - - -/** - * \brief Use two dashes "--" instead of a space to separate filters - * - * That is, "delta:dist=2 lzma2:pb=1,lp=1" becomes - * "delta:dist=2--lzma2:pb=1,lp=1". This looks slightly odd but this - * kind of strings should be usable on the command line without quoting. - * However, it is possible that future versions with new filter options - * might produce strings that require shell quoting anyway as the exact - * set of possible characters isn't frozen for now. - * - * It is guaranteed that the single quote (') will never be used in - * filter chain strings (even if LZMA_STR_NO_SPACES isn't used). - */ -#define LZMA_STR_NO_SPACES UINT32_C( 0x80 ) - - -/** - * \brief Convert a string to a filter chain - * - * This tries to make it easier to write applications that allow users - * to set custom compression options. This only handles the filter - * configuration (including presets) but not the number of threads, - * block size, check type, or memory limits. - * - * The input string can be either a preset or a filter chain. Presets - * begin with a digit 0-9 and may be followed by zero or more flags - * which are lower-case letters. Currently only "e" is supported, matching - * LZMA_PRESET_EXTREME. For partial xz command line syntax compatibility, - * a preset string may start with a single dash "-". - * - * A filter chain consists of one or more "filtername:opt1=value1,opt2=value2" - * strings separated by one or more spaces. Leading and trailing spaces are - * ignored. All names and values must be lower-case. Extra commas in the - * option list are ignored. The order of filters is significant: when - * encoding, the uncompressed input data goes to the leftmost filter first. - * Normally "lzma2" is the last filter in the chain. - * - * If one wishes to avoid spaces, for example, to avoid shell quoting, - * it is possible to use two dashes "--" instead of spaces to separate - * the filters. - * - * For xz command line compatibility, each filter may be prefixed with - * two dashes "--" and the colon ":" separating the filter name from - * the options may be replaced with an equals sign "=". - * - * By default, only filters that can be used in the .xz format are accepted. - * To allow all filters (LZMA1) use the flag LZMA_STR_ALL_FILTERS. - * - * By default, very basic validation is done for the filter chain as a whole, - * for example, that LZMA2 is only used as the last filter in the chain. - * The validation isn't perfect though and it's possible that this function - * succeeds but using the filter chain for encoding or decoding will still - * result in LZMA_OPTIONS_ERROR. To disable this validation, use the flag - * LZMA_STR_NO_VALIDATION. - * - * The available filter names and their options are available via - * lzma_str_list_filters(). See the xz man page for the description - * of filter names and options. - * - * \param str User-supplied string describing a preset or - * a filter chain. If a default value is needed and - * you don't know what would be good, use "6" since - * that is the default preset in xz too. - * \param error_pos If this isn't NULL, this value will be set on - * both success and on all errors. This tells the - * location of the error in the string. This is - * an int to make it straightforward to use this - * as printf() field width. The value is guaranteed - * to be in the range [0, INT_MAX] even if strlen(str) - * somehow was greater than INT_MAX. - * \param filters An array of lzma_filter structures. There must - * be LZMA_FILTERS_MAX + 1 (that is, five) elements - * in the array. The old contents are ignored so it - * doesn't need to be initialized. This array is - * modified only if this function returns LZMA_OK. - * Once the allocated filter options are no longer - * needed, lzma_filters_free() can be used to free the - * options (it doesn't free the filters array itself). - * \param flags Bitwise-or of zero or more of the flags - * LZMA_STR_ALL_FILTERS and LZMA_STR_NO_VALIDATION. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * - * \return On success, NULL is returned. On error, a statically-allocated - * error message is returned which together with the error_pos - * should give some idea what is wrong. - * - * For command line applications, below is an example how an error message - * can be displayed. Note the use of an empty string for the field width. - * If "^" was used there it would create an off-by-one error except at - * the very beginning of the line. - * - * \code{.c} - * const char *str = ...; // From user - * lzma_filter filters[LZMA_FILTERS_MAX + 1]; - * int pos; - * const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL); - * if (msg != NULL) { - * printf("%s: Error in XZ compression options:\n", argv[0]); - * printf("%s: %s\n", argv[0], str); - * printf("%s: %*s^\n", argv[0], errpos, ""); - * printf("%s: %s\n", argv[0], msg); - * } - * \endcode - */ -extern LZMA_API( const char * ) - lzma_str_to_filters( const char * str, - int * error_pos, - lzma_filter * filters, - uint32_t flags, - const lzma_allocator * allocator ) lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Convert a filter chain to a string - * - * Use cases: - * - * - Verbose output showing the full encoder options to the user - * (use LZMA_STR_ENCODER in flags) - * - * - Showing the filters and options that are required to decode a file - * (use LZMA_STR_DECODER in flags) - * - * - Showing the filter names without any options in informational messages - * where the technical details aren't important (no flags). In this case - * the .options in the filters array are ignored and may be NULL even if - * a filter has a mandatory options structure. - * - * Note that even if the filter chain was specified using a preset, - * the resulting filter chain isn't reversed to a preset. So if you - * specify "6" to lzma_str_to_filters() then lzma_str_from_filters() - * will produce a string containing "lzma2". - * - * \param str On success *str will be set to point to an - * allocated string describing the given filter - * chain. Old value is ignored. On error *str is - * always set to NULL. - * \param filters Array of 1-4 filters and a terminating element - * with .id = LZMA_VLI_UNKNOWN. - * \param flags Bitwise-or of zero or more of the flags - * LZMA_STR_ENCODER, LZMA_STR_DECODER, - * LZMA_STR_GETOPT_LONG, and LZMA_STR_NO_SPACES. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR: Empty filter chain - * (filters[0].id == LZMA_VLI_UNKNOWN) or the filter chain - * includes a Filter ID that is not supported by this function. - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API( lzma_ret ) - lzma_str_from_filters( char ** str, const lzma_filter * filters, uint32_t flags, const lzma_allocator * allocator ) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief List available filters and/or their options (for help message) - * - * If a filter_id is given then only one line is created which contains the - * filter name. If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then the - * options required for encoding or decoding are listed on the same line too. - * - * If filter_id is LZMA_VLI_UNKNOWN then all supported .xz-compatible filters - * are listed: - * - * - If neither LZMA_STR_ENCODER nor LZMA_STR_DECODER is used then - * the supported filter names are listed on a single line separated - * by spaces. - * - * - If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then filters and - * the supported options are listed one filter per line. There won't - * be a '\n' after the last filter. - * - * - If LZMA_STR_ALL_FILTERS is used then the list will include also - * those filters that cannot be used in the .xz format (LZMA1). - * - * \param str On success *str will be set to point to an - * allocated string listing the filters and options. - * Old value is ignored. On error *str is always set - * to NULL. - * \param filter_id Filter ID or LZMA_VLI_UNKNOWN. - * \param flags Bitwise-or of zero or more of the flags - * LZMA_STR_ALL_FILTERS, LZMA_STR_ENCODER, - * LZMA_STR_DECODER, and LZMA_STR_GETOPT_LONG. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR: Unsupported filter_id or flags - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API( lzma_ret ) - lzma_str_list_filters( char ** str, lzma_vli filter_id, uint32_t flags, const lzma_allocator * allocator ) - lzma_nothrow lzma_attr_warn_unused_result; diff --git a/winlibs/include/lzma/hardware.h b/winlibs/include/lzma/hardware.h deleted file mode 100644 index 7040aae45..000000000 --- a/winlibs/include/lzma/hardware.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * \file lzma/hardware.h - * \brief Hardware information - * - * Since liblzma can consume a lot of system resources, it also provides - * ways to limit the resource usage. Applications linking against liblzma - * need to do the actual decisions how much resources to let liblzma to use. - * To ease making these decisions, liblzma provides functions to find out - * the relevant capabilities of the underlying hardware. Currently there - * is only a function to find out the amount of RAM, but in the future there - * will be also a function to detect how many concurrent threads the system - * can run. - * - * \note On some operating systems, these function may temporarily - * load a shared library or open file descriptor(s) to find out - * the requested hardware information. Unless the application - * assumes that specific file descriptors are not touched by - * other threads, this should have no effect on thread safety. - * Possible operations involving file descriptors will restart - * the syscalls if they return EINTR. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Get the total amount of physical memory (RAM) in bytes - * - * This function may be useful when determining a reasonable memory - * usage limit for decompressing or how much memory it is OK to use - * for compressing. - * - * \return On success, the total amount of physical memory in bytes - * is returned. If the amount of RAM cannot be determined, - * zero is returned. This can happen if an error occurs - * or if there is no code in liblzma to detect the amount - * of RAM on the specific operating system. - */ -extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; - - -/** - * \brief Get the number of processor cores or threads - * - * This function may be useful when determining how many threads to use. - * If the hardware supports more than one thread per CPU core, the number - * of hardware threads is returned if that information is available. - * - * \return On success, the number of available CPU threads or cores is - * returned. If this information isn't available or an error - * occurs, zero is returned. - */ -extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow; diff --git a/winlibs/include/lzma/index.h b/winlibs/include/lzma/index.h deleted file mode 100644 index bf68397de..000000000 --- a/winlibs/include/lzma/index.h +++ /dev/null @@ -1,752 +0,0 @@ -/** - * \file lzma/index.h - * \brief Handling of .xz Index and related information - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Opaque data type to hold the Index(es) and other information - * - * lzma_index often holds just one .xz Index and possibly the Stream Flags - * of the same Stream and size of the Stream Padding field. However, - * multiple lzma_indexes can be concatenated with lzma_index_cat() and then - * there may be information about multiple Streams in the same lzma_index. - * - * Notes about thread safety: Only one thread may modify lzma_index at - * a time. All functions that take non-const pointer to lzma_index - * modify it. As long as no thread is modifying the lzma_index, getting - * information from the same lzma_index can be done from multiple threads - * at the same time with functions that take a const pointer to - * lzma_index or use lzma_index_iter. The same iterator must be used - * only by one thread at a time, of course, but there can be as many - * iterators for the same lzma_index as needed. - */ -typedef struct lzma_index_s lzma_index; - - -/** - * \brief Iterator to get information about Blocks and Streams - */ -typedef struct { - struct { - /** - * \brief Pointer to Stream Flags - * - * This is NULL if Stream Flags have not been set for - * this Stream with lzma_index_stream_flags(). - */ - const lzma_stream_flags *flags; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - - /** - * \brief Stream number in the lzma_index - * - * The first Stream is 1. - */ - lzma_vli number; - - /** - * \brief Number of Blocks in the Stream - * - * If this is zero, the block structure below has - * undefined values. - */ - lzma_vli block_count; - - /** - * \brief Compressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli compressed_offset; - - /** - * \brief Uncompressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli uncompressed_offset; - - /** - * \brief Compressed size of this Stream - * - * This includes all headers except the possible - * Stream Padding after this Stream. - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed size of this Stream - */ - lzma_vli uncompressed_size; - - /** - * \brief Size of Stream Padding after this Stream - * - * If it hasn't been set with lzma_index_stream_padding(), - * this defaults to zero. Stream Padding is always - * a multiple of four bytes. - */ - lzma_vli padding; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - } stream; - - struct { - /** - * \brief Block number in the file - * - * The first Block is 1. - */ - lzma_vli number_in_file; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the - * lzma_index (i.e. usually the beginning of the .xz file). - * Normally this is where you should seek in the .xz file - * to start decompressing this Block. - */ - lzma_vli compressed_file_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - * - * When doing random-access reading, it is possible that - * the target offset is not exactly at Block boundary. One - * will need to compare the target offset against - * uncompressed_file_offset or uncompressed_stream_offset, - * and possibly decode and throw away some amount of data - * before reaching the target offset. - */ - lzma_vli uncompressed_file_offset; - - /** - * \brief Block number in this Stream - * - * The first Block is 1. - */ - lzma_vli number_in_stream; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli compressed_stream_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli uncompressed_stream_offset; - - /** - * \brief Uncompressed size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the uncompressed size. - */ - lzma_vli uncompressed_size; - - /** - * \brief Unpadded size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the unpadded size. - */ - lzma_vli unpadded_size; - - /** - * \brief Total compressed size - * - * This includes all headers and padding in this Block. - * This is useful if you need to know how many bytes - * the Block decoder will actually read. - */ - lzma_vli total_size; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - const void *reserved_ptr4; - } block; - - /* - * Internal data which is used to store the state of the iterator. - * The exact format may vary between liblzma versions, so don't - * touch these in any way. - */ - union { - const void *p; - size_t s; - lzma_vli v; - } internal[6]; -} lzma_index_iter; - - -/** - * \brief Operation mode for lzma_index_iter_next() - */ -typedef enum { - LZMA_INDEX_ITER_ANY = 0, - /**< - * \brief Get the next Block or Stream - * - * Go to the next Block if the current Stream has at least - * one Block left. Otherwise go to the next Stream even if - * it has no Blocks. If the Stream has no Blocks - * (lzma_index_iter.stream.block_count == 0), - * lzma_index_iter.block will have undefined values. - */ - - LZMA_INDEX_ITER_STREAM = 1, - /**< - * \brief Get the next Stream - * - * Go to the next Stream even if the current Stream has - * unread Blocks left. If the next Stream has at least one - * Block, the iterator will point to the first Block. - * If there are no Blocks, lzma_index_iter.block will have - * undefined values. - */ - - LZMA_INDEX_ITER_BLOCK = 2, - /**< - * \brief Get the next Block - * - * Go to the next Block if the current Stream has at least - * one Block left. If the current Stream has no Blocks left, - * the next Stream with at least one Block is located and - * the iterator will be made to point to the first Block of - * that Stream. - */ - - LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3 - /**< - * \brief Get the next non-empty Block - * - * This is like LZMA_INDEX_ITER_BLOCK except that it will - * skip Blocks whose Uncompressed Size is zero. - */ - -} lzma_index_iter_mode; - - -/** - * \brief Calculate memory usage of lzma_index - * - * On disk, the size of the Index field depends on both the number of Records - * stored and how big values the Records store (due to variable-length integer - * encoding). When the Index is kept in lzma_index structure, the memory usage - * depends only on the number of Records/Blocks stored in the Index(es), and - * in case of concatenated lzma_indexes, the number of Streams. The size in - * RAM is almost always significantly bigger than in the encoded form on disk. - * - * This function calculates an approximate amount of memory needed hold - * the given number of Streams and Blocks in lzma_index structure. This - * value may vary between CPU architectures and also between liblzma versions - * if the internal implementation is modified. - */ -extern LZMA_API(uint64_t) lzma_index_memusage( - lzma_vli streams, lzma_vli blocks) lzma_nothrow; - - -/** - * \brief Calculate the memory usage of an existing lzma_index - * - * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), - * lzma_index_block_count(i)). - */ -extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) - lzma_nothrow; - - -/** - * \brief Allocate and initialize a new lzma_index structure - * - * \return On success, a pointer to an empty initialized lzma_index is - * returned. If allocation fails, NULL is returned. - */ -extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Deallocate lzma_index - * - * If i is NULL, this does nothing. - */ -extern LZMA_API(void) lzma_index_end( - lzma_index *i, const lzma_allocator *allocator) lzma_nothrow; - - -/** - * \brief Add a new Block to lzma_index - * - * \param i Pointer to a lzma_index structure - * \param allocator Pointer to lzma_allocator, or NULL to - * use malloc() - * \param unpadded_size Unpadded Size of a Block. This can be - * calculated with lzma_block_unpadded_size() - * after encoding or decoding the Block. - * \param uncompressed_size Uncompressed Size of a Block. This can be - * taken directly from lzma_block structure - * after encoding or decoding the Block. - * - * Appending a new Block does not invalidate iterators. For example, - * if an iterator was pointing to the end of the lzma_index, after - * lzma_index_append() it is possible to read the next Block with - * an existing iterator. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_append( - lzma_index *i, const lzma_allocator *allocator, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Set the Stream Flags - * - * Set the Stream Flags of the last (and typically the only) Stream - * in lzma_index. This can be useful when reading information from the - * lzma_index, because to decode Blocks, knowing the integrity check type - * is needed. - * - * The given Stream Flags are copied into internal preallocated structure - * in the lzma_index, thus the caller doesn't need to keep the *stream_flags - * available after calling this function. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_flags( - lzma_index *i, const lzma_stream_flags *stream_flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the types of integrity Checks - * - * If lzma_index_stream_flags() is used to set the Stream Flags for - * every Stream, lzma_index_checks() can be used to get a bitmask to - * indicate which Check types have been used. It can be useful e.g. if - * showing the Check types to the user. - * - * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10. - */ -extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the amount of Stream Padding - * - * Set the amount of Stream Padding of the last (and typically the only) - * Stream in the lzma_index. This is needed when planning to do random-access - * reading within multiple concatenated Streams. - * - * By default, the amount of Stream Padding is assumed to be zero bytes. - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: The file size would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_padding( - lzma_index *i, lzma_vli stream_padding) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the number of Streams - */ -extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the number of Blocks - * - * This returns the total number of Blocks in lzma_index. To get number - * of Blocks in individual Streams, use lzma_index_iter. - */ -extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Stream - * - * If multiple lzma_indexes have been combined, this works as if the Blocks - * were in a single Stream. This is useful if you are going to combine - * Blocks from multiple Streams into a single new Stream. - */ -extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Blocks - * - * This doesn't include the Stream Header, Stream Footer, Stream Padding, - * or Index fields. - */ -extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the file - * - * When no lzma_indexes have been combined with lzma_index_cat() and there is - * no Stream Padding, this function is identical to lzma_index_stream_size(). - * If multiple lzma_indexes have been combined, this includes also the headers - * of each separate Stream and the possible Stream Padding fields. - */ -extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the uncompressed size of the file - */ -extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize an iterator - * - * \param iter Pointer to a lzma_index_iter structure - * \param i lzma_index to which the iterator will be associated - * - * This function associates the iterator with the given lzma_index, and calls - * lzma_index_iter_rewind() on the iterator. - * - * This function doesn't allocate any memory, thus there is no - * lzma_index_iter_end(). The iterator is valid as long as the - * associated lzma_index is valid, that is, until lzma_index_end() or - * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't - * become invalid if new Blocks are added to it with lzma_index_append() or - * if it is used as the destination in lzma_index_cat(). - * - * It is safe to make copies of an initialized lzma_index_iter, for example, - * to easily restart reading at some particular position. - */ -extern LZMA_API(void) lzma_index_iter_init( - lzma_index_iter *iter, const lzma_index *i) lzma_nothrow; - - -/** - * \brief Rewind the iterator - * - * Rewind the iterator so that next call to lzma_index_iter_next() will - * return the first Block or Stream. - */ -extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) - lzma_nothrow; - - -/** - * \brief Get the next Block or Stream - * - * \param iter Iterator initialized with lzma_index_iter_init() - * \param mode Specify what kind of information the caller wants - * to get. See lzma_index_iter_mode for details. - * - * \return If next Block or Stream matching the mode was found, *iter - * is updated and this function returns false. If no Block or - * Stream matching the mode is found, *iter is not modified - * and this function returns true. If mode is set to an unknown - * value, *iter is not modified and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_next( - lzma_index_iter *iter, lzma_index_iter_mode mode) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Locate a Block - * - * If it is possible to seek in the .xz file, it is possible to parse - * the Index field(s) and use lzma_index_iter_locate() to do random-access - * reading with granularity of Block size. - * - * \param iter Iterator that was earlier initialized with - * lzma_index_iter_init(). - * \param target Uncompressed target offset which the caller would - * like to locate from the Stream - * - * If the target is smaller than the uncompressed size of the Stream (can be - * checked with lzma_index_uncompressed_size()): - * - Information about the Stream and Block containing the requested - * uncompressed offset is stored into *iter. - * - Internal state of the iterator is adjusted so that - * lzma_index_iter_next() can be used to read subsequent Blocks or Streams. - * - This function returns false. - * - * If target is greater than the uncompressed size of the Stream, *iter - * is not modified, and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_locate( - lzma_index_iter *iter, lzma_vli target) lzma_nothrow; - - -/** - * \brief Concatenate lzma_indexes - * - * Concatenating lzma_indexes is useful when doing random-access reading in - * multi-Stream .xz file, or when combining multiple Streams into single - * Stream. - * - * \param dest lzma_index after which src is appended - * \param src lzma_index to be appended after dest. If this - * function succeeds, the memory allocated for src - * is freed or moved to be part of dest, and all - * iterators pointing to src will become invalid. - * \param allocator Custom memory allocator; can be NULL to use - * malloc() and free(). - * - * \return - LZMA_OK: lzma_indexes were concatenated successfully. - * src is now a dangling pointer. - * - LZMA_DATA_ERROR: *dest would grow too big. - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src, - const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Duplicate lzma_index - * - * \return A copy of the lzma_index, or NULL if memory allocation failed. - */ -extern LZMA_API(lzma_index *) lzma_index_dup( - const lzma_index *i, const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index encoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i Pointer to lzma_index which should be encoded. - * - * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * It is enough to use only one of them (you can choose freely). - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_encoder( - lzma_stream *strm, const lzma_index *i) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i The decoded Index will be made available via - * this pointer. Initially this function will - * set *i to NULL (the old value is ignored). If - * decoding succeeds (lzma_code() returns - * LZMA_STREAM_END), *i will be set to point - * to a new lzma_index, which the application - * has to later free with lzma_index_end(). - * \param memlimit How much memory the resulting lzma_index is - * allowed to require. liblzma 5.2.3 and earlier - * don't allow 0 here and return LZMA_PROG_ERROR; - * later versions treat 0 as if 1 had been specified. - * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * There is no need to use LZMA_FINISH, but it's allowed because it may - * simplify certain types of applications. - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - * - * liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here - * but that error code has never been possible from this - * initialization function. - */ -extern LZMA_API(lzma_ret) lzma_index_decoder( - lzma_stream *strm, lzma_index **i, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Index encoder - * - * \param i lzma_index to be encoded - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Output buffer is too small. Use - * lzma_index_size() to find out how much output - * space is needed. - * - LZMA_PROG_ERROR - * - * \note This function doesn't take allocator argument since all - * the internal data is allocated on stack. - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call .xz Index decoder - * - * \param i If decoding succeeds, *i will point to a new - * lzma_index, which the application has to - * later free with lzma_index_end(). If an error - * occurs, *i will be NULL. The old value of *i - * is always ignored and thus doesn't need to be - * initialized by the caller. - * \param memlimit Pointer to how much memory the resulting - * lzma_index is allowed to require. The value - * pointed by this pointer is modified if and only - * if LZMA_MEMLIMIT_ERROR is returned. - * \param allocator Pointer to lzma_allocator, or NULL to use malloc() - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, - uint64_t *memlimit, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; - - -/** - * \brief Initialize a .xz file information decoder - * - * \param strm Pointer to a properly prepared lzma_stream - * \param dest_index Pointer to a pointer where the decoder will put - * the decoded lzma_index. The old value - * of *dest_index is ignored (not freed). - * \param memlimit How much memory the resulting lzma_index is - * allowed to require. Use UINT64_MAX to - * effectively disable the limiter. - * \param file_size Size of the input .xz file - * - * This decoder decodes the Stream Header, Stream Footer, Index, and - * Stream Padding field(s) from the input .xz file and stores the resulting - * combined index in *dest_index. This information can be used to get the - * uncompressed file size with lzma_index_uncompressed_size(*dest_index) or, - * for example, to implement random access reading by locating the Blocks - * in the Streams. - * - * To get the required information from the .xz file, lzma_code() may ask - * the application to seek in the input file by returning LZMA_SEEK_NEEDED - * and having the target file position specified in lzma_stream.seek_pos. - * The number of seeks required depends on the input file and how big buffers - * the application provides. When possible, the decoder will seek backward - * and forward in the given buffer to avoid useless seek requests. Thus, if - * the application provides the whole file at once, no external seeking will - * be required (that is, lzma_code() won't return LZMA_SEEK_NEEDED). - * - * The value in lzma_stream.total_in can be used to estimate how much data - * liblzma had to read to get the file information. However, due to seeking - * and the way total_in is updated, the value of total_in will be somewhat - * inaccurate (a little too big). Thus, total_in is a good estimate but don't - * expect to see the same exact value for the same file if you change the - * input buffer size or switch to a different liblzma version. - * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * You only need to use LZMA_RUN; LZMA_FINISH is only supported because it - * might be convenient for some applications. If you use LZMA_FINISH and if - * lzma_code() asks the application to seek, remember to reset `action' back - * to LZMA_RUN unless you hit the end of the file again. - * - * Possible return values from lzma_code(): - * - LZMA_OK: All OK so far, more input needed - * - LZMA_SEEK_NEEDED: Provide more input starting from the absolute - * file position strm->seek_pos - * - LZMA_STREAM_END: Decoding was successful, *dest_index has been set - * - LZMA_FORMAT_ERROR: The input file is not in the .xz format (the - * expected magic bytes were not found from the beginning of the file) - * - LZMA_OPTIONS_ERROR: File looks valid but contains headers that aren't - * supported by this version of liblzma - * - LZMA_DATA_ERROR: File is corrupt - * - LZMA_BUF_ERROR - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_PROG_ERROR - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API( lzma_ret ) lzma_file_info_decoder( lzma_stream * strm, - lzma_index ** dest_index, - uint64_t memlimit, - uint64_t file_size ) lzma_nothrow; diff --git a/winlibs/include/lzma/index_hash.h b/winlibs/include/lzma/index_hash.h deleted file mode 100644 index 8ff416336..000000000 --- a/winlibs/include/lzma/index_hash.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \file lzma/index_hash.h - * \brief Validate Index by using a hash function - * - * Hashing makes it possible to use constant amount of memory to validate - * Index of arbitrary size. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - -/** - * \brief Opaque data type to hold the Index hash - */ -typedef struct lzma_index_hash_s lzma_index_hash; - - -/** - * \brief Allocate and initialize a new lzma_index_hash structure - * - * If index_hash is NULL, a new lzma_index_hash structure is allocated, - * initialized, and a pointer to it returned. If allocation fails, NULL - * is returned. - * - * If index_hash is non-NULL, it is reinitialized and the same pointer - * returned. In this case, return value cannot be NULL or a different - * pointer than the index_hash that was given as an argument. - */ -extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( - lzma_index_hash *index_hash, const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Deallocate lzma_index_hash structure - */ -extern LZMA_API(void) lzma_index_hash_end( - lzma_index_hash *index_hash, const lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Add a new Record to an Index hash - * - * \param index_hash Pointer to a lzma_index_hash structure - * \param unpadded_size Unpadded Size of a Block - * \param uncompressed_size Uncompressed Size of a Block - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR: Invalid arguments or this function is being - * used when lzma_index_hash_decode() has already been used. - */ -extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode and validate the Index field - * - * After telling the sizes of all Blocks with lzma_index_hash_append(), - * the actual Index field is decoded with this function. Specifically, - * once decoding of the Index field has been started, no more Records - * can be added using lzma_index_hash_append(). - * - * This function doesn't use lzma_stream structure to pass the input data. - * Instead, the input buffer is specified using three arguments. This is - * because it matches better the internal APIs of liblzma. - * - * \param index_hash Pointer to a lzma_index_hash structure - * \param in Pointer to the beginning of the input buffer - * \param in_pos in[*in_pos] is the next byte to process - * \param in_size in[in_size] is the first byte not to process - * - * \return - LZMA_OK: So far good, but more input is needed. - * - LZMA_STREAM_END: Index decoded successfully and it matches - * the Records given with lzma_index_hash_append(). - * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the - * information given with lzma_index_hash_append(). - * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_hash_size( - const lzma_index_hash *index_hash) - lzma_nothrow lzma_attr_pure; diff --git a/winlibs/include/lzma/lzma12.h b/winlibs/include/lzma/lzma12.h deleted file mode 100644 index 9045849ca..000000000 --- a/winlibs/include/lzma/lzma12.h +++ /dev/null @@ -1,529 +0,0 @@ -/** - * \file lzma/lzma12.h - * \brief LZMA1 and LZMA2 filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief LZMA1 Filter ID (for raw encoder/decoder only, not in .xz) - * - * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils, - * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from - * accidentally using LZMA when they actually want LZMA2. - */ -#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001) - -/** - * \brief LZMA1 Filter ID with extended options (for raw encoder/decoder) - * - * This is like LZMA_FILTER_LZMA1 but with this ID a few extra options - * are supported in the lzma_options_lzma structure: - * - * - A flag to tell the encoder if the end of payload marker (EOPM) alias - * end of stream (EOS) marker must be written at the end of the stream. - * In contrast, LZMA_FILTER_LZMA1 always writes the end marker. - * - * - Decoder needs to be told the uncompressed size of the stream - * or that it is unknown (using the special value UINT64_MAX). - * If the size is known, a flag can be set to allow the presence of - * the end marker anyway. In contrast, LZMA_FILTER_LZMA1 always - * behaves as if the uncompressed size was unknown. - * - * This allows handling file formats where LZMA1 streams are used but where - * the end marker isn't allowed or where it might not (always) be present. - * This extended LZMA1 functionality is provided as a Filter ID for raw - * encoder and decoder instead of adding new encoder and decoder initialization - * functions because this way it is possible to also use extra filters, - * for example, LZMA_FILTER_X86 in a filter chain with LZMA_FILTER_LZMA1EXT, - * which might be needed to handle some file formats. - */ -#define LZMA_FILTER_LZMA1EXT LZMA_VLI_C( 0x4000000000000002 ) - -/** - * \brief LZMA2 Filter ID - * - * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds - * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion - * when trying to compress uncompressible data), possibility to change - * lc/lp/pb in the middle of encoding, and some other internal improvements. - */ -#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) - - -/** - * \brief Match finders - * - * Match finder has major effect on both speed and compression ratio. - * Usually hash chains are faster than binary trees. - * - * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better - * choice, because binary trees get much higher compression ratio penalty - * with LZMA_SYNC_FLUSH. - * - * The memory usage formulas are only rough estimates, which are closest to - * reality when dict_size is a power of two. The formulas are more complex - * in reality, and can also change a little between liblzma versions. Use - * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. - */ -typedef enum { - LZMA_MF_HC3 = 0x03, - /**< - * \brief Hash Chain with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 7.5 - * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB - */ - - LZMA_MF_HC4 = 0x04, - /**< - * \brief Hash Chain with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 7.5 - * - dict_size > 32 MiB: dict_size * 6.5 - */ - - LZMA_MF_BT2 = 0x12, - /**< - * \brief Binary Tree with 2-byte hashing - * - * Minimum nice_len: 2 - * - * Memory usage: dict_size * 9.5 - */ - - LZMA_MF_BT3 = 0x13, - /**< - * \brief Binary Tree with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 11.5 - * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB - */ - - LZMA_MF_BT4 = 0x14 - /**< - * \brief Binary Tree with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 11.5 - * - dict_size > 32 MiB: dict_size * 10.5 - */ -} lzma_match_finder; - - -/** - * \brief Test if given match finder is supported - * - * Return true if the given match finder is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * isn't listed in lzma_match_finder enumeration; the return value will be - * false. - * - * There is no way to list which match finders are available in this - * particular liblzma version and build. It would be useless, because - * a new match finder, which the application developer wasn't aware, - * could require giving additional options to the encoder that the older - * match finders don't need. - */ -extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Compression modes - * - * This selects the function used to analyze the data produced by the match - * finder. - */ -typedef enum { - LZMA_MODE_FAST = 1, - /**< - * \brief Fast compression - * - * Fast mode is usually at its best when combined with - * a hash chain match finder. - */ - - LZMA_MODE_NORMAL = 2 - /**< - * \brief Normal compression - * - * This is usually notably slower than fast mode. Use this - * together with binary tree match finders to expose the - * full potential of the LZMA1 or LZMA2 encoder. - */ -} lzma_mode; - - -/** - * \brief Test if given compression mode is supported - * - * Return true if the given compression mode is supported by this liblzma - * build. Otherwise false is returned. It is safe to call this with a value - * that isn't listed in lzma_mode enumeration; the return value will be false. - * - * There is no way to list which modes are available in this particular - * liblzma version and build. It would be useless, because a new compression - * mode, which the application developer wasn't aware, could require giving - * additional options to the encoder that the older modes don't need. - */ -extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Options specific to the LZMA1 and LZMA2 filters - * - * Since LZMA1 and LZMA2 share most of the code, it's simplest to share - * the options structure too. For encoding, all but the reserved variables - * need to be initialized unless specifically mentioned otherwise. - * lzma_lzma_preset() can be used to get a good starting point. - * - * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and - * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb. - */ -typedef struct { - /** - * \brief Dictionary size in bytes - * - * Dictionary size indicates how many bytes of the recently processed - * uncompressed data is kept in memory. One method to reduce size of - * the uncompressed data is to store distance-length pairs, which - * indicate what data to repeat from the dictionary buffer. Thus, - * the bigger the dictionary, the better the compression ratio - * usually is. - * - * Maximum size of the dictionary depends on multiple things: - * - Memory usage limit - * - Available address space (not a problem on 64-bit systems) - * - Selected match finder (encoder only) - * - * Currently the maximum dictionary size for encoding is 1.5 GiB - * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit - * systems for certain match finder implementation reasons. In the - * future, there may be match finders that support bigger - * dictionaries. - * - * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. - * UINT32_MAX), so increasing the maximum dictionary size of the - * encoder won't cause problems for old decoders. - * - * Because extremely small dictionaries sizes would have unneeded - * overhead in the decoder, the minimum dictionary size is 4096 bytes. - * - * \note When decoding, too big dictionary does no other harm - * than wasting memory. - */ - uint32_t dict_size; -# define LZMA_DICT_SIZE_MIN UINT32_C(4096) -# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23) - - /** - * \brief Pointer to an initial dictionary - * - * It is possible to initialize the LZ77 history window using - * a preset dictionary. It is useful when compressing many - * similar, relatively small chunks of data independently from - * each other. The preset dictionary should contain typical - * strings that occur in the files being compressed. The most - * probable strings should be near the end of the preset dictionary. - * - * This feature should be used only in special situations. For - * now, it works correctly only with raw encoding and decoding. - * Currently none of the container formats supported by - * liblzma allow preset dictionary when decoding, thus if - * you create a .xz or .lzma file with preset dictionary, it - * cannot be decoded with the regular decoder functions. In the - * future, the .xz format will likely get support for preset - * dictionary though. - */ - const uint8_t *preset_dict; - - /** - * \brief Size of the preset dictionary - * - * Specifies the size of the preset dictionary. If the size is - * bigger than dict_size, only the last dict_size bytes are - * processed. - * - * This variable is read only when preset_dict is not NULL. - * If preset_dict is not NULL but preset_dict_size is zero, - * no preset dictionary is used (identical to only setting - * preset_dict to NULL). - */ - uint32_t preset_dict_size; - - /** - * \brief Number of literal context bits - * - * How many of the highest bits of the previous uncompressed - * eight-bit byte (also known as `literal') are taken into - * account when predicting the bits of the next literal. - * - * E.g. in typical English text, an upper-case letter is - * often followed by a lower-case letter, and a lower-case - * letter is usually followed by another lower-case letter. - * In the US-ASCII character set, the highest three bits are 010 - * for upper-case letters and 011 for lower-case letters. - * When lc is at least 3, the literal coding can take advantage of - * this property in the uncompressed data. - * - * There is a limit that applies to literal context bits and literal - * position bits together: lc + lp <= 4. Without this limit the - * decoding could become very slow, which could have security related - * results in some cases like email servers doing virus scanning. - * This limit also simplifies the internal implementation in liblzma. - * - * There may be LZMA1 streams that have lc + lp > 4 (maximum possible - * lc would be 8). It is not possible to decode such streams with - * liblzma. - */ - uint32_t lc; -# define LZMA_LCLP_MIN 0 -# define LZMA_LCLP_MAX 4 -# define LZMA_LC_DEFAULT 3 - - /** - * \brief Number of literal position bits - * - * lp affects what kind of alignment in the uncompressed data is - * assumed when encoding literals. A literal is a single 8-bit byte. - * See pb below for more information about alignment. - */ - uint32_t lp; -# define LZMA_LP_DEFAULT 0 - - /** - * \brief Number of position bits - * - * pb affects what kind of alignment in the uncompressed data is - * assumed in general. The default means four-byte alignment - * (2^ pb =2^2=4), which is often a good choice when there's - * no better guess. - * - * When the alignment is known, setting pb accordingly may reduce - * the file size a little. E.g. with text files having one-byte - * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can - * improve compression slightly. For UTF-16 text, pb=1 is a good - * choice. If the alignment is an odd number like 3 bytes, pb=0 - * might be the best choice. - * - * Even though the assumed alignment can be adjusted with pb and - * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. - * It might be worth taking into account when designing file formats - * that are likely to be often compressed with LZMA1 or LZMA2. - */ - uint32_t pb; -# define LZMA_PB_MIN 0 -# define LZMA_PB_MAX 4 -# define LZMA_PB_DEFAULT 2 - - /** Compression mode */ - lzma_mode mode; - - /** - * \brief Nice length of a match - * - * This determines how many bytes the encoder compares from the match - * candidates when looking for the best match. Once a match of at - * least nice_len bytes long is found, the encoder stops looking for - * better candidates and encodes the match. (Naturally, if the found - * match is actually longer than nice_len, the actual length is - * encoded; it's not truncated to nice_len.) - * - * Bigger values usually increase the compression ratio and - * compression time. For most files, 32 to 128 is a good value, - * which gives very good compression ratio at good speed. - * - * The exact minimum value depends on the match finder. The maximum - * is 273, which is the maximum length of a match that LZMA1 and - * LZMA2 can encode. - */ - uint32_t nice_len; - - /** Match finder ID */ - lzma_match_finder mf; - - /** - * \brief Maximum search depth in the match finder - * - * For every input byte, match finder searches through the hash chain - * or binary tree in a loop, each iteration going one step deeper in - * the chain or tree. The searching stops if - * - a match of at least nice_len bytes long is found; - * - all match candidates from the hash chain or binary tree have - * been checked; or - * - maximum search depth is reached. - * - * Maximum search depth is needed to prevent the match finder from - * wasting too much time in case there are lots of short match - * candidates. On the other hand, stopping the search before all - * candidates have been checked can reduce compression ratio. - * - * Setting depth to zero tells liblzma to use an automatic default - * value, that depends on the selected match finder and nice_len. - * The default is in the range [4, 200] or so (it may vary between - * liblzma versions). - * - * Using a bigger depth value than the default can increase - * compression ratio in some cases. There is no strict maximum value, - * but high values (thousands or millions) should be used with care: - * the encoder could remain fast enough with typical input, but - * malicious input could cause the match finder to slow down - * dramatically, possibly creating a denial of service attack. - */ - uint32_t depth; - - /** - * \brief For LZMA_FILTER_LZMA1EXT: Extended flags - * - * This is used only with LZMA_FILTER_LZMA1EXT. - * - * Currently only one flag is supported, LZMA_LZMA1EXT_ALLOW_EOPM: - * - * - Encoder: If the flag is set, then end marker is written just - * like it is with LZMA_FILTER_LZMA1. Without this flag the - * end marker isn't written and the application has to store - * the uncompressed size somewhere outside the compressed stream. - * To decompress streams without the end marker, the appliation - * has to set the correct uncompressed size in ext_size_low and - * ext_size_high. - * - * - Decoder: If the uncompressed size in ext_size_low and - * ext_size_high is set to the special value UINT64_MAX - * (indicating unknown uncompressed size) then this flag is - * ignored and the end marker must always be present, that is, - * the behavior is identical to LZMA_FILTER_LZMA1. - * - * Otherwise, if this flag isn't set, then the input stream - * must not have the end marker; if the end marker is detected - * then it will result in LZMA_DATA_ERROR. This is useful when - * it is known that the stream must not have the end marker and - * strict validation is wanted. - * - * If this flag is set, then it is autodetected if the end marker - * is present after the specified number of uncompressed bytes - * has been decompressed (ext_size_low and ext_size_high). The - * end marker isn't allowed in any other position. This behavior - * is useful when uncompressed size is known but the end marker - * may or may not be present. This is the case, for example, - * in .7z files (valid .7z files that have the end marker in - * LZMA1 streams are rare but they do exist). - */ - uint32_t ext_flags; -#define LZMA_LZMA1EXT_ALLOW_EOPM UINT32_C( 0x01 ) - - /** - * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (low bits) - * - * The 64-bit uncompressed size is needed for decompression with - * LZMA_FILTER_LZMA1EXT. The size is ignored by the encoder. - * - * The special value UINT64_MAX indicates that the uncompressed size - * is unknown and that the end of payload marker (also known as - * end of stream marker) must be present to indicate the end of - * the LZMA1 stream. Any other value indicates the expected - * uncompressed size of the LZMA1 stream. (If LZMA1 was used together - * with filters that change the size of the data then the uncompressed - * size of the LZMA1 stream could be different than the final - * uncompressed size of the filtered stream.) - * - * ext_size_low holds the least significant 32 bits of the - * uncompressed size. The most significant 32 bits must be set - * in ext_size_high. The macro lzma_ext_size_set(opt_lzma, u64size) - * can be used to set these members. - * - * The 64-bit uncompressed size is split into two uint32_t variables - * because there were no reserved uint64_t members and using the - * same options structure for LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA1EXT, - * and LZMA_FILTER_LZMA2 was otherwise more convenient than having - * a new options structure for LZMA_FILTER_LZMA1EXT. (Replacing two - * uint32_t members with one uint64_t changes the ABI on some systems - * as the alignment of this struct can increase from 4 bytes to 8.) - */ - uint32_t ext_size_low; - - /** - * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (high bits) - * - * This holds the most significant 32 bits of the uncompressed size. - */ - uint32_t ext_size_high; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int4; - uint32_t reserved_int5; - uint32_t reserved_int6; - uint32_t reserved_int7; - uint32_t reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_lzma; - - -/** - * \brief Macro to set the 64-bit uncompressed size in ext_size_* - * - * This might be convenient when decoding using LZMA_FILTER_LZMA1EXT. - * This isn't used with LZMA_FILTER_LZMA1 or LZMA_FILTER_LZMA2. - */ -#define lzma_set_ext_size( opt_lzma2, u64size ) \ - do { \ - ( opt_lzma2 ).ext_size_low = (uint32_t)( u64size ); \ - ( opt_lzma2 ).ext_size_high = (uint32_t)( (uint64_t)( u64size ) >> 32 ); \ - } while ( 0 ) - - -/** - * \brief Set a compression preset to lzma_options_lzma structure - * - * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 - * of the xz command line tool. In addition, it is possible to bitwise-or - * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. - * The flags are defined in container.h, because the flags are used also - * with lzma_easy_encoder(). - * - * The preset values are subject to changes between liblzma versions. - * - * This function is available only if LZMA1 or LZMA2 encoder has been enabled - * when building liblzma. - * - * \return On success, false is returned. If the preset is not - * supported, true is returned. - */ -extern LZMA_API(lzma_bool) lzma_lzma_preset( - lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/winlibs/include/lzma/stream_flags.h b/winlibs/include/lzma/stream_flags.h deleted file mode 100644 index bbdd40826..000000000 --- a/winlibs/include/lzma/stream_flags.h +++ /dev/null @@ -1,223 +0,0 @@ -/** - * \file lzma/stream_flags.h - * \brief .xz Stream Header and Stream Footer encoder and decoder - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Size of Stream Header and Stream Footer - * - * Stream Header and Stream Footer have the same size and they are not - * going to change even if a newer version of the .xz file format is - * developed in future. - */ -#define LZMA_STREAM_HEADER_SIZE 12 - - -/** - * \brief Options for encoding/decoding Stream Header and Stream Footer - */ -typedef struct { - /** - * \brief Stream Flags format version - * - * To prevent API and ABI breakages if new features are needed in - * Stream Header or Stream Footer, a version number is used to - * indicate which fields in this structure are in use. For now, - * version must always be zero. With non-zero version, the - * lzma_stream_header_encode() and lzma_stream_footer_encode() - * will return LZMA_OPTIONS_ERROR. - * - * lzma_stream_header_decode() and lzma_stream_footer_decode() - * will always set this to the lowest value that supports all the - * features indicated by the Stream Flags field. The application - * must check that the version number set by the decoding functions - * is supported by the application. Otherwise it is possible that - * the application will decode the Stream incorrectly. - */ - uint32_t version; - - /** - * \brief Backward Size - * - * Backward Size must be a multiple of four bytes. In this Stream - * format version, Backward Size is the size of the Index field. - * - * Backward Size isn't actually part of the Stream Flags field, but - * it is convenient to include in this structure anyway. Backward - * Size is present only in the Stream Footer. There is no need to - * initialize backward_size when encoding Stream Header. - * - * lzma_stream_header_decode() always sets backward_size to - * LZMA_VLI_UNKNOWN so that it is convenient to use - * lzma_stream_flags_compare() when both Stream Header and Stream - * Footer have been decoded. - */ - lzma_vli backward_size; -# define LZMA_BACKWARD_SIZE_MIN 4 -# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34) - - /** - * \brief Check ID - * - * This indicates the type of the integrity check calculated from - * uncompressed data. - */ - lzma_check check; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the - * names of these variables may change. - * - * (We will never be able to use all of these since Stream Flags - * is just two bytes plus Backward Size of four bytes. But it's - * nice to have the proper types when they are needed.) - */ - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - lzma_bool reserved_bool1; - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - uint32_t reserved_int1; - uint32_t reserved_int2; - -} lzma_stream_flags; - - -/** - * \brief Encode Stream Header - * - * \param options Stream Header options to be encoded. - * options->backward_size is ignored and doesn't - * need to be initialized. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Stream Footer - * - * \param options Stream Footer options to be encoded. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Header - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to - * help comparing Stream Flags from Stream Header and Stream Footer with - * lzma_stream_flags_compare(). - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Header. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in the header. - * - * \note When decoding .xz files that contain multiple Streams, it may - * make sense to print "file format not recognized" only if - * decoding of the Stream Header of the _first_ Stream gives - * LZMA_FORMAT_ERROR. If non-first Stream Header gives - * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is - * probably more appropriate. - * - * For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if - * LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode() - * when decoding non-first Stream. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Footer - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Footer. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in Stream Footer. - * - * \note If Stream Header was already decoded successfully, but - * decoding Stream Footer returns LZMA_FORMAT_ERROR, the - * application should probably report some other error message - * than "file format not recognized", since the file more likely - * is corrupt (possibly truncated). Stream decoder in liblzma - * uses LZMA_DATA_ERROR in this situation. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Compare two lzma_stream_flags structures - * - * backward_size values are compared only if both are not - * LZMA_VLI_UNKNOWN. - * - * \return - LZMA_OK: Both are equal. If either had backward_size set - * to LZMA_VLI_UNKNOWN, backward_size values were not - * compared or validated. - * - LZMA_DATA_ERROR: The structures differ. - * - LZMA_OPTIONS_ERROR: version in either structure is greater - * than the maximum supported version (currently zero). - * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or - * backward_size. - */ -extern LZMA_API(lzma_ret) lzma_stream_flags_compare( - const lzma_stream_flags *a, const lzma_stream_flags *b) - lzma_nothrow lzma_attr_pure; diff --git a/winlibs/include/lzma/version.h b/winlibs/include/lzma/version.h deleted file mode 100644 index 03feb5e0d..000000000 --- a/winlibs/include/lzma/version.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * \file lzma/version.h - * \brief Version number - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* - * Version number split into components - */ -#define LZMA_VERSION_MAJOR 5 -#define LZMA_VERSION_MINOR 4 -#define LZMA_VERSION_PATCH 1 -#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE - -#ifndef LZMA_VERSION_COMMIT -# define LZMA_VERSION_COMMIT "" -#endif - - -/* - * Map symbolic stability levels to integers. - */ -#define LZMA_VERSION_STABILITY_ALPHA 0 -#define LZMA_VERSION_STABILITY_BETA 1 -#define LZMA_VERSION_STABILITY_STABLE 2 - - -/** - * \brief Compile-time version number - * - * The version number is of format xyyyzzzs where - * - x = major - * - yyy = minor - * - zzz = revision - * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable - * - * The same xyyyzzz triplet is never reused with different stability levels. - * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta - * or 5.1.0 stable. - * - * \note The version number of liblzma has nothing to with - * the version number of Igor Pavlov's LZMA SDK. - */ -#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \ - + LZMA_VERSION_MINOR * UINT32_C(10000) \ - + LZMA_VERSION_PATCH * UINT32_C(10) \ - + LZMA_VERSION_STABILITY) - - -/* - * Macros to construct the compile-time version string - */ -#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA -# define LZMA_VERSION_STABILITY_STRING "alpha" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA -# define LZMA_VERSION_STABILITY_STRING "beta" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE -# define LZMA_VERSION_STABILITY_STRING "" -#else -# error Incorrect LZMA_VERSION_STABILITY -#endif - -#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \ - #major "." #minor "." #patch stability commit - -#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \ - LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) - - -/** - * \brief Compile-time version as a string - * - * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable - * versions don't have any "stable" suffix). In future, a snapshot built - * from source code repository may include an additional suffix, for example - * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form - * in LZMA_VERSION macro. - */ -#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \ - LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \ - LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \ - LZMA_VERSION_COMMIT) - - -/* #ifndef is needed for use with windres (MinGW or Cygwin). */ -#ifndef LZMA_H_INTERNAL_RC - -/** - * \brief Run-time version number as an integer - * - * Return the value of LZMA_VERSION macro at the compile time of liblzma. - * This allows the application to compare if it was built against the same, - * older, or newer version of liblzma that is currently running. - */ -extern LZMA_API(uint32_t) lzma_version_number(void) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Run-time version as a string - * - * This function may be useful if you want to display which version of - * liblzma your application is currently using. - */ -extern LZMA_API(const char *) lzma_version_string(void) - lzma_nothrow lzma_attr_const; - -#endif diff --git a/winlibs/include/lzma/vli.h b/winlibs/include/lzma/vli.h deleted file mode 100644 index 7a0a803df..000000000 --- a/winlibs/include/lzma/vli.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * \file lzma/vli.h - * \brief Variable-length integer handling - * - * In the .xz format, most integers are encoded in a variable-length - * representation, which is sometimes called little endian base-128 encoding. - * This saves space when smaller values are more likely than bigger values. - * - * The encoding scheme encodes seven bits to every byte, using minimum - * number of bytes required to represent the given value. Encodings that use - * non-minimum number of bytes are invalid, thus every integer has exactly - * one encoded representation. The maximum number of bits in a VLI is 63, - * thus the vli argument must be less than or equal to UINT64_MAX / 2. You - * should use LZMA_VLI_MAX for clarity. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum supported value of a variable-length integer - */ -#define LZMA_VLI_MAX (UINT64_MAX / 2) - -/** - * \brief VLI value to denote that the value is unknown - */ -#define LZMA_VLI_UNKNOWN UINT64_MAX - -/** - * \brief Maximum supported encoded length of variable length integers - */ -#define LZMA_VLI_BYTES_MAX 9 - -/** - * \brief VLI constant suffix - */ -#define LZMA_VLI_C(n) UINT64_C(n) - - -/** - * \brief Variable-length integer type - * - * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is - * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the - * underlying integer type. - * - * lzma_vli will be uint64_t for the foreseeable future. If a bigger size - * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will - * not overflow lzma_vli. This simplifies integer overflow detection. - */ -typedef uint64_t lzma_vli; - - -/** - * \brief Validate a variable-length integer - * - * This is useful to test that application has given acceptable values - * for example in the uncompressed_size and compressed_size variables. - * - * \return True if the integer is representable as VLI or if it - * indicates unknown value. - */ -#define lzma_vli_is_valid(vli) \ - ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN) - - -/** - * \brief Encode a variable-length integer - * - * This function has two modes: single-call and multi-call. Single-call mode - * encodes the whole integer at once; it is an error if the output buffer is - * too small. Multi-call mode saves the position in *vli_pos, and thus it is - * possible to continue encoding if the buffer becomes full before the whole - * integer has been encoded. - * - * \param vli Integer to be encoded - * \param vli_pos How many VLI-encoded bytes have already been written - * out. When starting to encode a new integer in - * multi-call mode, *vli_pos must be set to zero. - * To use single-call encoding, set vli_pos to NULL. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully encoded. - * - LZMA_PROG_ERROR: Arguments are not sane. This can be due - * to too little output space; single-call mode doesn't use - * LZMA_BUF_ERROR, since the application should have checked - * the encoded size with lzma_vli_size(). - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely written out yet. - * - LZMA_STREAM_END: Integer successfully encoded. - * - LZMA_BUF_ERROR: No output space was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Decode a variable-length integer - * - * Like lzma_vli_encode(), this function has single-call and multi-call modes. - * - * \param vli Pointer to decoded integer. The decoder will - * initialize it to zero when *vli_pos == 0, so - * application isn't required to initialize *vli. - * \param vli_pos How many bytes have already been decoded. When - * starting to decode a new integer in multi-call - * mode, *vli_pos must be initialized to zero. To - * use single-call decoding, set vli_pos to NULL. - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting - * the end of the input buffer before the whole integer was - * decoded; providing no input at all will use LZMA_DATA_ERROR. - * - LZMA_PROG_ERROR: Arguments are not sane. - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely decoded yet. - * - LZMA_STREAM_END: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. - * - LZMA_BUF_ERROR: No input was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; - - -/** - * \brief Get the number of bytes required to encode a VLI - * - * \param vli Integer whose encoded size is to be determined - * - * \return Number of bytes on success (1-9). If vli isn't valid, - * zero is returned. - */ -extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli) - lzma_nothrow lzma_attr_pure; diff --git a/winlibs/include/lzo/lzo1.h b/winlibs/include/lzo/lzo1.h deleted file mode 100644 index de0fba579..000000000 --- a/winlibs/include/lzo/lzo1.h +++ /dev/null @@ -1,99 +0,0 @@ -/* lzo1.h -- public interface of the LZO1 compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1_H_INCLUDED -#define __LZO1_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1_MEM_COMPRESS ((lzo_uint32) (8192L * lzo_sizeof_dict_t)) -#define LZO1_MEM_DECOMPRESS (0) - - -LZO_EXTERN(int) -lzo1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -LZO_EXTERN(int) -lzo1_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1a.h b/winlibs/include/lzo/lzo1a.h deleted file mode 100644 index 0969c67db..000000000 --- a/winlibs/include/lzo/lzo1a.h +++ /dev/null @@ -1,99 +0,0 @@ -/* lzo1a.h -- public interface of the LZO1A compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1A_H_INCLUDED -#define __LZO1A_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1A_MEM_COMPRESS ((lzo_uint32) (8192L * lzo_sizeof_dict_t)) -#define LZO1A_MEM_DECOMPRESS (0) - - -LZO_EXTERN(int) -lzo1a_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -LZO_EXTERN(int) -lzo1a_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1A_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1a_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1b.h b/winlibs/include/lzo/lzo1b.h deleted file mode 100644 index da3b597c6..000000000 --- a/winlibs/include/lzo/lzo1b.h +++ /dev/null @@ -1,163 +0,0 @@ -/* lzo1b.h -- public interface of the LZO1B compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1B_H_INCLUDED -#define __LZO1B_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1B_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1B_MEM_DECOMPRESS (0) - - -/* compression levels */ -#define LZO1B_BEST_SPEED 1 -#define LZO1B_BEST_COMPRESSION 9 -#define LZO1B_DEFAULT_COMPRESSION (-1) /* fastest by default */ - - -LZO_EXTERN(int) -lzo1b_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - int compression_level ); - -/* decompression */ -LZO_EXTERN(int) -lzo1b_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1b_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1b_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_2_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_3_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_4_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_5_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_6_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_7_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_8_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_9_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1B_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1b_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -#define LZO1B_999_MEM_COMPRESS ((lzo_uint32) (3 * 65536L * sizeof(lzo_xint))) - -LZO_EXTERN(int) -lzo1b_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1c.h b/winlibs/include/lzo/lzo1c.h deleted file mode 100644 index d5b1b8c5b..000000000 --- a/winlibs/include/lzo/lzo1c.h +++ /dev/null @@ -1,163 +0,0 @@ -/* lzo1c.h -- public interface of the LZO1C compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1C_H_INCLUDED -#define __LZO1C_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1C_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1C_MEM_DECOMPRESS (0) - - -/* compression levels */ -#define LZO1C_BEST_SPEED 1 -#define LZO1C_BEST_COMPRESSION 9 -#define LZO1C_DEFAULT_COMPRESSION (-1) /* fastest by default */ - - -LZO_EXTERN(int) -lzo1c_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - int compression_level ); - -/* decompression */ -LZO_EXTERN(int) -lzo1c_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1c_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1c_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_2_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_3_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_4_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_5_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_6_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_7_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_8_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_9_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1C_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1c_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -#define LZO1C_999_MEM_COMPRESS ((lzo_uint32) (5 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1c_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1f.h b/winlibs/include/lzo/lzo1f.h deleted file mode 100644 index 771307031..000000000 --- a/winlibs/include/lzo/lzo1f.h +++ /dev/null @@ -1,111 +0,0 @@ -/* lzo1f.h -- public interface of the LZO1F compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1F_H_INCLUDED -#define __LZO1F_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1F_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1F_MEM_DECOMPRESS (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1f_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1f_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1f_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1F_999_MEM_COMPRESS ((lzo_uint32) (5 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1f_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1x.h b/winlibs/include/lzo/lzo1x.h deleted file mode 100644 index 9bb993cc0..000000000 --- a/winlibs/include/lzo/lzo1x.h +++ /dev/null @@ -1,180 +0,0 @@ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1X_H_INCLUDED -#define __LZO1X_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 KiB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 KiB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1y.h b/winlibs/include/lzo/lzo1y.h deleted file mode 100644 index 359e35807..000000000 --- a/winlibs/include/lzo/lzo1y.h +++ /dev/null @@ -1,148 +0,0 @@ -/* lzo1y.h -- public interface of the LZO1Y compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1Y_H_INCLUDED -#define __LZO1Y_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1Y_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1Y_MEM_DECOMPRESS (0) -#define LZO1Y_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1y_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1y_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1Y_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1y_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1y_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1y_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo1z.h b/winlibs/include/lzo/lzo1z.h deleted file mode 100644 index f385ca395..000000000 --- a/winlibs/include/lzo/lzo1z.h +++ /dev/null @@ -1,153 +0,0 @@ -/* lzo1z.h -- public interface of the LZO1Z compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1Z_H_INCLUDED -#define __LZO1Z_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1Z_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1Z_MEM_DECOMPRESS (0) -#define LZO1Z_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1z_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1z_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#if 0 -/* not yet implemented */ -LZO_EXTERN(int) -lzo1z_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1Z_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1z_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1z_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1z_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1z_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -#if 0 -/* not yet implemented */ -LZO_EXTERN(int) -lzo1z_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); -#endif - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo2a.h b/winlibs/include/lzo/lzo2a.h deleted file mode 100644 index ef65155ed..000000000 --- a/winlibs/include/lzo/lzo2a.h +++ /dev/null @@ -1,95 +0,0 @@ -/* lzo2a.h -- public interface of the LZO2A compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO2A_H_INCLUDED -#define __LZO2A_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO2A_MEM_DECOMPRESS (0) - -/* decompression */ -LZO_EXTERN(int) -lzo2a_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo2a_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO2A_999_MEM_COMPRESS ((lzo_uint32) (8 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo2a_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzo_asm.h b/winlibs/include/lzo/lzo_asm.h deleted file mode 100644 index 51bea6573..000000000 --- a/winlibs/include/lzo/lzo_asm.h +++ /dev/null @@ -1,155 +0,0 @@ -/* lzo_asm.h -- assembler prototypes for the LZO data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO_ASM_H_INCLUDED -#define __LZO_ASM_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// i386 assembly decompressors -// -// NOTE: -// ==== -// -// - For reasons of speed all fast assembler decompressors (having '_fast' -// in their name) can access (write to) up to 3 bytes past the end of -// the decompressed ("dst") block. Data past the end of the compressed -// ("src") block is never accessed (read from). -// [ technical note: because data is transferred in 32-bit units ] -// -// - Please also see asm/i386/00README.TXT and doc/LZO.FAQ for more -// important details about the assembler versions. -// -************************************************************************/ - -LZO_EXTERN(int) lzo1c_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1c_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1f_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1x_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1y_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - - -/*********************************************************************** -// checksum and misc functions -************************************************************************/ - -#if 0 - -LZO_EXTERN(lzo_uint32) -lzo_crc32_asm(lzo_uint32 c, const lzo_bytep buf, lzo_uint len, - const lzo_uint32p tab); - -LZO_EXTERN(lzo_uint32) -lzo_crc32_asm_small(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); - -LZO_EXTERN(int) -lzo_cpuid_asm(lzo_uint32p /* lzo_uint32 info[16] */ ); - -LZO_EXTERN(lzo_uint32) -lzo_rdtsc_asm(lzo_uint32p /* lzo_uint32 ticks[2] */ ); - -#endif - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzoconf.h b/winlibs/include/lzo/lzoconf.h deleted file mode 100644 index 23c6ca93f..000000000 --- a/winlibs/include/lzo/lzoconf.h +++ /dev/null @@ -1,446 +0,0 @@ -/* lzoconf.h -- configuration of the LZO data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZOCONF_H_INCLUDED -#define __LZOCONF_H_INCLUDED 1 - -#define LZO_VERSION 0x2060 -#define LZO_VERSION_STRING "2.06" -#define LZO_VERSION_DATE "Aug 12 2011" - -/* internal Autoconf configuration file - only used when building LZO */ -#if defined(LZO_HAVE_CONFIG_H) -# include -#endif -#include -#include - - -/*********************************************************************** -// LZO requires a conforming -************************************************************************/ - -#if !defined(CHAR_BIT) || (CHAR_BIT != 8) -# error "invalid CHAR_BIT" -#endif -#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -# error "check your compiler installation" -#endif -#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) -# error "your limits.h macros are broken" -#endif - -/* get OS and architecture defines */ -#ifndef __LZODEFS_H_INCLUDED -#include "lzodefs.h" -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// some core defines -************************************************************************/ - -#if !defined(LZO_UINT32_C) -# if (UINT_MAX < LZO_0xffffffffL) -# define LZO_UINT32_C(c) c ## UL -# else -# define LZO_UINT32_C(c) ((c) + 0U) -# endif -#endif - -/* memory checkers */ -#if !defined(__LZO_CHECKER) -# if defined(__BOUNDS_CHECKING_ON) -# define __LZO_CHECKER 1 -# elif defined(__CHECKER__) -# define __LZO_CHECKER 1 -# elif defined(__INSURE__) -# define __LZO_CHECKER 1 -# elif defined(__PURIFY__) -# define __LZO_CHECKER 1 -# endif -#endif - - -/*********************************************************************** -// integral and pointer types -************************************************************************/ - -/* lzo_uint should match size_t */ -#if !defined(LZO_UINT_MAX) -# if defined(LZO_ABI_LLP64) /* WIN64 */ -# if defined(LZO_OS_WIN64) - typedef unsigned __int64 lzo_uint; - typedef __int64 lzo_int; -# else - typedef unsigned long long lzo_uint; - typedef long long lzo_int; -# endif -# define LZO_UINT_MAX 0xffffffffffffffffull -# define LZO_INT_MAX 9223372036854775807LL -# define LZO_INT_MIN (-1LL - LZO_INT_MAX) -# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ - typedef unsigned int lzo_uint; - typedef int lzo_int; -# define LZO_UINT_MAX UINT_MAX -# define LZO_INT_MAX INT_MAX -# define LZO_INT_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -# define LZO_UINT_MAX ULONG_MAX -# define LZO_INT_MAX LONG_MAX -# define LZO_INT_MIN LONG_MIN -# else -# error "lzo_uint" -# endif -#endif - -/* Integral types with 32 bits or more. */ -#if !defined(LZO_UINT32_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint32; - typedef int lzo_int32; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint32; - typedef long lzo_int32; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif -#endif - -/* Integral types with exactly 64 bits. */ -#if !defined(LZO_UINT64_MAX) -# if (LZO_UINT_MAX >= LZO_0xffffffffL) -# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) -# define lzo_uint64 lzo_uint -# define lzo_int64 lzo_int -# define LZO_UINT64_MAX LZO_UINT_MAX -# define LZO_INT64_MAX LZO_INT_MAX -# define LZO_INT64_MIN LZO_INT_MIN -# endif -# elif (ULONG_MAX >= LZO_0xffffffffL) -# if ((((ULONG_MAX) >> 31) >> 31) == 3) - typedef unsigned long lzo_uint64; - typedef long lzo_int64; -# define LZO_UINT64_MAX ULONG_MAX -# define LZO_INT64_MAX LONG_MAX -# define LZO_INT64_MIN LONG_MIN -# endif -# endif -#endif - -/* The larger type of lzo_uint and lzo_uint32. */ -#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -# define lzo_xint lzo_uint -#else -# define lzo_xint lzo_uint32 -#endif - -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL /*empty*/ -# elif defined(LZO_HAVE_MM_HUGE_PTR) -# define __LZO_MMODEL_HUGE 1 -# define __LZO_MMODEL __huge -# else -# define __LZO_MMODEL /*empty*/ -# endif -#endif - -/* no typedef here because of const-pointer issues */ -#define lzo_bytep unsigned char __LZO_MMODEL * -#define lzo_charp char __LZO_MMODEL * -#define lzo_voidp void __LZO_MMODEL * -#define lzo_shortp short __LZO_MMODEL * -#define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#if defined(LZO_UINT64_MAX) -#define lzo_uint64p lzo_uint64 __LZO_MMODEL * -#define lzo_int64p lzo_int64 __LZO_MMODEL * -#endif -#define lzo_uintp lzo_uint __LZO_MMODEL * -#define lzo_intp lzo_int __LZO_MMODEL * -#define lzo_xintp lzo_xint __LZO_MMODEL * -#define lzo_voidpp lzo_voidp __LZO_MMODEL * -#define lzo_bytepp lzo_bytep __LZO_MMODEL * -/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -#define lzo_byte unsigned char __LZO_MMODEL - -typedef int lzo_bool; - - -/*********************************************************************** -// function types -************************************************************************/ - -/* name mangling */ -#if !defined(__LZO_EXTERN_C) -# ifdef __cplusplus -# define __LZO_EXTERN_C extern "C" -# else -# define __LZO_EXTERN_C extern -# endif -#endif - -/* calling convention */ -#if !defined(__LZO_CDECL) -# define __LZO_CDECL __lzo_cdecl -#endif - -/* DLL export information */ -#if !defined(__LZO_EXPORT1) -# define __LZO_EXPORT1 /*empty*/ -#endif -#if !defined(__LZO_EXPORT2) -# define __LZO_EXPORT2 /*empty*/ -#endif - -/* __cdecl calling convention for public C and assembly functions */ -#if !defined(LZO_PUBLIC) -# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL -#endif -#if !defined(LZO_EXTERN) -# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE) -# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL -#endif - -/* function types */ -typedef int -(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -typedef int -(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - - -/* Callback interface. Currently only the progress indicator ("nprogress") - * is used, but this may change in a future release. */ - -struct lzo_callback_t; -typedef struct lzo_callback_t lzo_callback_t; -#define lzo_callback_p lzo_callback_t __LZO_MMODEL * - -/* malloc & free function types */ -typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) - (lzo_callback_p self, lzo_uint items, lzo_uint size); -typedef void (__LZO_CDECL *lzo_free_func_t) - (lzo_callback_p self, lzo_voidp ptr); - -/* a progress indicator callback function */ -typedef void (__LZO_CDECL *lzo_progress_func_t) - (lzo_callback_p, lzo_uint, lzo_uint, int); - -struct lzo_callback_t -{ - /* custom allocators (set to 0 to disable) */ - lzo_alloc_func_t nalloc; /* [not used right now] */ - lzo_free_func_t nfree; /* [not used right now] */ - - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - - /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; - lzo_xint user2; - lzo_xint user3; -}; - - -/*********************************************************************** -// error codes and prototypes -************************************************************************/ - -/* Error codes for the compression/decompression functions. Negative - * values are errors, positive values will be used for special but - * normal events. - */ -#define LZO_E_OK 0 -#define LZO_E_ERROR (-1) -#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ -#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ -#define LZO_E_INPUT_OVERRUN (-4) -#define LZO_E_OUTPUT_OVERRUN (-5) -#define LZO_E_LOOKBEHIND_OVERRUN (-6) -#define LZO_E_EOF_NOT_FOUND (-7) -#define LZO_E_INPUT_NOT_CONSUMED (-8) -#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ -#define LZO_E_INVALID_ARGUMENT (-10) - - -#ifndef lzo_sizeof_dict_t -# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) -#endif - -/* lzo_init() should be the first function you call. - * Check the return code ! - * - * lzo_init() is a macro to allow checking that the library and the - * compiler's view of various types are consistent. - */ -#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ - (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) -LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); - -/* version functions (useful for shared libraries) */ -LZO_EXTERN(unsigned) lzo_version(void); -LZO_EXTERN(const char *) lzo_version_string(void); -LZO_EXTERN(const char *) lzo_version_date(void); -LZO_EXTERN(const lzo_charp) _lzo_version_string(void); -LZO_EXTERN(const lzo_charp) _lzo_version_date(void); - -/* string functions */ -LZO_EXTERN(int) - lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memset(lzo_voidp buf, int c, lzo_uint len); - -/* checksum functions */ -LZO_EXTERN(lzo_uint32) - lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(lzo_uint32) - lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(const lzo_uint32p) - lzo_get_crc32_table(void); - -/* misc. */ -LZO_EXTERN(int) _lzo_config_check(void); -typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; -typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; -typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; - -/* align a char pointer on a boundary that is a multiple of 'size' */ -LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); -#define LZO_PTR_ALIGN_UP(p,size) \ - ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size))) - - -/*********************************************************************** -// deprecated macros - only for backward compatibility with LZO v1.xx -************************************************************************/ - -#if defined(LZO_CFG_COMPAT) - -#define __LZOCONF_H 1 - -#if defined(LZO_ARCH_I086) -# define __LZO_i386 1 -#elif defined(LZO_ARCH_I386) -# define __LZO_i386 1 -#endif - -#if defined(LZO_OS_DOS16) -# define __LZO_DOS 1 -# define __LZO_DOS16 1 -#elif defined(LZO_OS_DOS32) -# define __LZO_DOS 1 -#elif defined(LZO_OS_WIN16) -# define __LZO_WIN 1 -# define __LZO_WIN16 1 -#elif defined(LZO_OS_WIN32) -# define __LZO_WIN 1 -#endif - -#define __LZO_CMODEL /*empty*/ -#define __LZO_DMODEL /*empty*/ -#define __LZO_ENTRY __LZO_CDECL -#define LZO_EXTERN_CDECL LZO_EXTERN -#define LZO_ALIGN LZO_PTR_ALIGN_UP - -#define lzo_compress_asm_t lzo_compress_t -#define lzo_decompress_asm_t lzo_decompress_t - -#endif /* LZO_CFG_COMPAT */ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzodefs.h b/winlibs/include/lzo/lzodefs.h deleted file mode 100644 index 0e40e332a..000000000 --- a/winlibs/include/lzo/lzodefs.h +++ /dev/null @@ -1,1852 +0,0 @@ -/* lzodefs.h -- architecture, OS and compiler specific defines - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZODEFS_H_INCLUDED -#define __LZODEFS_H_INCLUDED 1 - -#if defined(__CYGWIN32__) && !defined(__CYGWIN__) -# define __CYGWIN__ __CYGWIN32__ -#endif -#if defined(__IBMCPP__) && !defined(__IBMC__) -# define __IBMC__ __IBMCPP__ -#endif -#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) -# define __INTEL_COMPILER __ICL -#endif -#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) -# define _ALL_SOURCE 1 -#endif -#if defined(__mips__) && defined(__R5900__) -# if !defined(__LONG_MAX__) -# define __LONG_MAX__ 9223372036854775807L -# endif -#endif -#if defined(__INTEL_COMPILER) && defined(__linux__) -# pragma warning(disable: 193) -#endif -#if defined(__KEIL__) && defined(__C166__) -# pragma warning disable = 322 -#elif 0 && defined(__C251__) -# pragma warning disable = 322 -#endif -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -# if (_MSC_VER >= 1300) -# pragma warning(disable: 4668) -# endif -#endif -#if 0 && defined(__WATCOMC__) -# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) -# pragma warning 203 9 -# endif -#endif -#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) -# pragma option -h -#endif -#if 0 -#define LZO_0xffffL 0xfffful -#define LZO_0xffffffffL 0xfffffffful -#else -#define LZO_0xffffL 65535ul -#define LZO_0xffffffffL 4294967295ul -#endif -#if (LZO_0xffffL == LZO_0xffffffffL) -# error "your preprocessor is broken 1" -#endif -#if (16ul * 16384ul != 262144ul) -# error "your preprocessor is broken 2" -#endif -#if 0 -#if (32767 >= 4294967295ul) -# error "your preprocessor is broken 3" -#endif -#if (65535u >= 4294967295ul) -# error "your preprocessor is broken 4" -#endif -#endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) -# if !defined(MSDOS) -# define MSDOS 1 -# endif -# if !defined(_MSDOS) -# define _MSDOS 1 -# endif -#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) -# if (__VERSION == 520) && (MB_LEN_MAX == 1) -# if !defined(__AZTEC_C__) -# define __AZTEC_C__ __VERSION -# endif -# if !defined(__DOS__) -# define __DOS__ 1 -# endif -# endif -#endif -#endif -#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) -# define ptrdiff_t long -# define _PTRDIFF_T_DEFINED 1 -#endif -#if (UINT_MAX == LZO_0xffffL) -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -# if defined(__AZTEC_C__) && defined(__DOS__) -# define __LZO_RENAME_A 1 -# elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define __LZO_RENAME_A 1 -# elif (_MSC_VER < 700) -# define __LZO_RENAME_B 1 -# endif -# elif defined(__TSC__) && defined(__OS2__) -# define __LZO_RENAME_A 1 -# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) -# define __LZO_RENAME_A 1 -# elif defined(__PACIFIC__) && defined(DOS) -# if !defined(__far) -# define __far far -# endif -# if !defined(__near) -# define __near near -# endif -# endif -# if defined(__LZO_RENAME_A) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__far) -# define __far far -# endif -# if !defined(__huge) -# define __huge huge -# endif -# if !defined(__near) -# define __near near -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# if !defined(__huge) -# define __huge huge -# endif -# elif defined(__LZO_RENAME_B) -# if !defined(__cdecl) -# define __cdecl _cdecl -# endif -# if !defined(__far) -# define __far _far -# endif -# if !defined(__huge) -# define __huge _huge -# endif -# if !defined(__near) -# define __near _near -# endif -# if !defined(__pascal) -# define __pascal _pascal -# endif -# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# endif -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -#endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__AZTEC_C__) && defined(__DOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -#elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# endif -# if (_MSC_VER < 700) -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# define LZO_BROKEN_SIZEOF 1 -# endif -#elif defined(__PACIFIC__) && defined(DOS) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -#elif defined(__TURBOC__) && defined(__MSDOS__) -# if (__TURBOC__ < 0x0150) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# endif -# if (__TURBOC__ < 0x0200) -# define LZO_BROKEN_SIZEOF 1 -# endif -# if (__TURBOC__ < 0x0400) && defined(__cplusplus) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# endif -#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_SIZEOF 1 -#endif -#endif -#if defined(__WATCOMC__) && (__WATCOMC__ < 900) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -#endif -#if defined(_CRAY) && defined(_CRAY1) -# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 -#endif -#define LZO_PP_STRINGIZE(x) #x -#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -#define LZO_PP_CONCAT2(a,b) a ## b -#define LZO_PP_CONCAT3(a,b,c) a ## b ## c -#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d -#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) -#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) -#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) -#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -#if 1 -#define LZO_CPP_STRINGIZE(x) #x -#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -#define LZO_CPP_CONCAT2(a,b) a ## b -#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c -#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d -#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) -#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) -#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) -#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -#endif -#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -#if 1 && defined(__cplusplus) -# if !defined(__STDC_CONSTANT_MACROS) -# define __STDC_CONSTANT_MACROS 1 -# endif -# if !defined(__STDC_LIMIT_MACROS) -# define __STDC_LIMIT_MACROS 1 -# endif -#endif -#if defined(__cplusplus) -# define LZO_EXTERN_C extern "C" -#else -# define LZO_EXTERN_C extern -#endif -#if !defined(__LZO_OS_OVERRIDE) -#if (LZO_OS_FREESTANDING) -# define LZO_INFO_OS "freestanding" -#elif (LZO_OS_EMBEDDED) -# define LZO_INFO_OS "embedded" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_OS_EMBEDDED 1 -# define LZO_INFO_OS "embedded" -#elif defined(__CYGWIN__) && defined(__GNUC__) -# define LZO_OS_CYGWIN 1 -# define LZO_INFO_OS "cygwin" -#elif defined(__EMX__) && defined(__GNUC__) -# define LZO_OS_EMX 1 -# define LZO_INFO_OS "emx" -#elif defined(__BEOS__) -# define LZO_OS_BEOS 1 -# define LZO_INFO_OS "beos" -#elif defined(__Lynx__) -# define LZO_OS_LYNXOS 1 -# define LZO_INFO_OS "lynxos" -#elif defined(__OS400__) -# define LZO_OS_OS400 1 -# define LZO_INFO_OS "os400" -#elif defined(__QNX__) -# define LZO_OS_QNX 1 -# define LZO_INFO_OS "qnx" -#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -#elif defined(__BORLANDC__) && defined(__DPMI16__) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -#elif defined(__ZTC__) && defined(DOS386) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -#elif defined(__OS2__) || defined(__OS2V2__) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_OS216 1 -# define LZO_INFO_OS "os216" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_OS2 1 -# define LZO_INFO_OS "os2" -# else -# error "check your limits.h header" -# endif -#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) -# define LZO_OS_WIN64 1 -# define LZO_INFO_OS "win64" -#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -#elif defined(__MWERKS__) && defined(__INTEL__) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_WIN16 1 -# define LZO_INFO_OS "win16" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -# else -# error "check your limits.h header" -# endif -#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -# else -# error "check your limits.h header" -# endif -#elif defined(__WATCOMC__) -# if defined(__NT__) && (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif defined(__NT__) && (__WATCOMC__ < 1100) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -# elif defined(__linux__) || defined(__LINUX__) -# define LZO_OS_POSIX 1 -# define LZO_INFO_OS "posix" -# else -# error "please specify a target using the -bt compiler option" -# endif -#elif defined(__palmos__) -# define LZO_OS_PALMOS 1 -# define LZO_INFO_OS "palmos" -#elif defined(__TOS__) || defined(__atarist__) -# define LZO_OS_TOS 1 -# define LZO_INFO_OS "tos" -#elif defined(macintosh) && !defined(__ppc__) -# define LZO_OS_MACCLASSIC 1 -# define LZO_INFO_OS "macclassic" -#elif defined(__VMS) -# define LZO_OS_VMS 1 -# define LZO_INFO_OS "vms" -#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define LZO_OS_CONSOLE 1 -# define LZO_OS_CONSOLE_PS2 1 -# define LZO_INFO_OS "console" -# define LZO_INFO_OS_CONSOLE "ps2" -#elif (defined(__mips__) && defined(__psp__)) -# define LZO_OS_CONSOLE 1 -# define LZO_OS_CONSOLE_PSP 1 -# define LZO_INFO_OS "console" -# define LZO_INFO_OS_CONSOLE "psp" -#else -# define LZO_OS_POSIX 1 -# define LZO_INFO_OS "posix" -#endif -#if (LZO_OS_POSIX) -# if defined(_AIX) || defined(__AIX__) || defined(__aix__) -# define LZO_OS_POSIX_AIX 1 -# define LZO_INFO_OS_POSIX "aix" -# elif defined(__FreeBSD__) -# define LZO_OS_POSIX_FREEBSD 1 -# define LZO_INFO_OS_POSIX "freebsd" -# elif defined(__hpux__) || defined(__hpux) -# define LZO_OS_POSIX_HPUX 1 -# define LZO_INFO_OS_POSIX "hpux" -# elif defined(__INTERIX) -# define LZO_OS_POSIX_INTERIX 1 -# define LZO_INFO_OS_POSIX "interix" -# elif defined(__IRIX__) || defined(__irix__) -# define LZO_OS_POSIX_IRIX 1 -# define LZO_INFO_OS_POSIX "irix" -# elif defined(__linux__) || defined(__linux) || defined(__LINUX__) -# define LZO_OS_POSIX_LINUX 1 -# define LZO_INFO_OS_POSIX "linux" -# elif defined(__APPLE__) || defined(__MACOS__) -# define LZO_OS_POSIX_MACOSX 1 -# define LZO_INFO_OS_POSIX "macosx" -# elif defined(__minix__) || defined(__minix) -# define LZO_OS_POSIX_MINIX 1 -# define LZO_INFO_OS_POSIX "minix" -# elif defined(__NetBSD__) -# define LZO_OS_POSIX_NETBSD 1 -# define LZO_INFO_OS_POSIX "netbsd" -# elif defined(__OpenBSD__) -# define LZO_OS_POSIX_OPENBSD 1 -# define LZO_INFO_OS_POSIX "openbsd" -# elif defined(__osf__) -# define LZO_OS_POSIX_OSF 1 -# define LZO_INFO_OS_POSIX "osf" -# elif defined(__solaris__) || defined(__sun) -# if defined(__SVR4) || defined(__svr4__) -# define LZO_OS_POSIX_SOLARIS 1 -# define LZO_INFO_OS_POSIX "solaris" -# else -# define LZO_OS_POSIX_SUNOS 1 -# define LZO_INFO_OS_POSIX "sunos" -# endif -# elif defined(__ultrix__) || defined(__ultrix) -# define LZO_OS_POSIX_ULTRIX 1 -# define LZO_INFO_OS_POSIX "ultrix" -# elif defined(_UNICOS) -# define LZO_OS_POSIX_UNICOS 1 -# define LZO_INFO_OS_POSIX "unicos" -# else -# define LZO_OS_POSIX_UNKNOWN 1 -# define LZO_INFO_OS_POSIX "unknown" -# endif -#endif -#endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (UINT_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -# define LZO_CC_CILLY 1 -# define LZO_INFO_CC "Cilly" -# if defined(__CILLY__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) -# define LZO_CC_SDCC 1 -# define LZO_INFO_CC "sdcc" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) -#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) -# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -# define LZO_INFO_CC "Pathscale C" -# define LZO_INFO_CCVER __PATHSCALE__ -#elif defined(__INTEL_COMPILER) -# define LZO_CC_INTELC 1 -# define LZO_INFO_CC "Intel C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) -# if defined(_WIN32) || defined(_WIN64) -# define LZO_CC_SYNTAX_MSC 1 -# else -# define LZO_CC_SYNTAX_GNUC 1 -# endif -#elif defined(__POCC__) && defined(_WIN32) -# define LZO_CC_PELLESC 1 -# define LZO_INFO_CC "Pelles C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) -#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -# if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# else -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# endif -# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) -# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -# else -# define LZO_CC_CLANG_CLANG 0x010000L -# endif -# define LZO_CC_CLANG LZO_CC_CLANG_GNUC -# define LZO_INFO_CC "clang" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -# if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# else -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# endif -# define LZO_CC_LLVM LZO_CC_LLVM_GNUC -# define LZO_INFO_CC "llvm-gcc" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__GNUC__) && defined(__VERSION__) -# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# elif defined(__GNUC_MINOR__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# else -# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -# endif -# define LZO_INFO_CC "gcc" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__ACK__) && defined(_ACK) -# define LZO_CC_ACK 1 -# define LZO_INFO_CC "Amsterdam Compiler Kit C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__AZTEC_C__) -# define LZO_CC_AZTECC 1 -# define LZO_INFO_CC "Aztec C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) -#elif defined(__CODEGEARC__) -# define LZO_CC_CODEGEARC 1 -# define LZO_INFO_CC "CodeGear C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__) -#elif defined(__BORLANDC__) -# define LZO_CC_BORLANDC 1 -# define LZO_INFO_CC "Borland C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) -#elif defined(_CRAYC) && defined(_RELEASE) -# define LZO_CC_CRAYC 1 -# define LZO_INFO_CC "Cray C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) -#elif defined(__DMC__) && defined(__SC__) -# define LZO_CC_DMC 1 -# define LZO_INFO_CC "Digital Mars C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) -#elif defined(__DECC) -# define LZO_CC_DECC 1 -# define LZO_INFO_CC "DEC C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -#elif defined(__HIGHC__) -# define LZO_CC_HIGHC 1 -# define LZO_INFO_CC "MetaWare High C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__IAR_SYSTEMS_ICC__) -# define LZO_CC_IARC 1 -# define LZO_INFO_CC "IAR C" -# if defined(__VER__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__IBMC__) -# define LZO_CC_IBMC 1 -# define LZO_INFO_CC "IBM C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -#elif defined(__KEIL__) && defined(__C166__) -# define LZO_CC_KEILC 1 -# define LZO_INFO_CC "Keil C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) -#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) -# define LZO_CC_LCCWIN32 1 -# define LZO_INFO_CC "lcc-win32" -# define LZO_INFO_CCVER "unknown" -#elif defined(__LCC__) -# define LZO_CC_LCC 1 -# define LZO_INFO_CC "lcc" -# if defined(__LCC_VERSION__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(_MSC_VER) -# define LZO_CC_MSC 1 -# define LZO_INFO_CC "Microsoft C" -# if defined(_MSC_FULL_VER) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -# endif -#elif defined(__MWERKS__) -# define LZO_CC_MWERKS 1 -# define LZO_INFO_CC "Metrowerks C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) -#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -# define LZO_CC_NDPC 1 -# define LZO_INFO_CC "Microway NDP C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__PACIFIC__) -# define LZO_CC_PACIFICC 1 -# define LZO_INFO_CC "Pacific C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) -# define LZO_CC_PGI 1 -# define LZO_INFO_CC "Portland Group PGI C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__PUREC__) && defined(__TOS__) -# define LZO_CC_PUREC 1 -# define LZO_INFO_CC "Pure C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) -#elif defined(__SC__) && defined(__ZTC__) -# define LZO_CC_SYMANTECC 1 -# define LZO_INFO_CC "Symantec C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) -#elif defined(__SUNPRO_C) -# define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_C)+0 > 0) -# define LZO_CC_SUNPROC __SUNPRO_C -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) -# else -# define LZO_CC_SUNPROC 1 -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__SUNPRO_CC) -# define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_CC)+0 > 0) -# define LZO_CC_SUNPROC __SUNPRO_CC -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) -# else -# define LZO_CC_SUNPROC 1 -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__TINYC__) -# define LZO_CC_TINYC 1 -# define LZO_INFO_CC "Tiny C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) -#elif defined(__TSC__) -# define LZO_CC_TOPSPEEDC 1 -# define LZO_INFO_CC "TopSpeed C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) -#elif defined(__WATCOMC__) -# define LZO_CC_WATCOMC 1 -# define LZO_INFO_CC "Watcom C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) -#elif defined(__TURBOC__) -# define LZO_CC_TURBOC 1 -# define LZO_INFO_CC "Turbo C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) -#elif defined(__ZTC__) -# define LZO_CC_ZORTECHC 1 -# define LZO_INFO_CC "Zortech C" -# if (__ZTC__ == 0x310) -# define LZO_INFO_CCVER "0x310" -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) -# endif -#else -# define LZO_CC_UNKNOWN 1 -# define LZO_INFO_CC "unknown" -# define LZO_INFO_CCVER "unknown" -#endif -#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) -# error "LZO_CC_MSC: _MSC_FULL_VER is not defined" -#endif -#if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY) -# if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) -# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) -# define LZO_ARCH_CRAY_MPP 1 -# elif defined(_CRAY1) -# define LZO_ARCH_CRAY_PVP 1 -# endif -# endif -#endif -#if !defined(__LZO_ARCH_OVERRIDE) -#if (LZO_ARCH_GENERIC) -# define LZO_INFO_ARCH "generic" -#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086 1 -# define LZO_ARCH_IA16 1 -# define LZO_INFO_ARCH "i086" -#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) -# define LZO_ARCH_ALPHA 1 -# define LZO_INFO_ARCH "alpha" -#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) -# define LZO_ARCH_ALPHA 1 -# define LZO_INFO_ARCH "alpha" -#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) -# define LZO_ARCH_AMD64 1 -# define LZO_INFO_ARCH "amd64" -#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) -# define LZO_ARCH_ARM 1 -# define LZO_ARCH_ARM_THUMB 1 -# define LZO_INFO_ARCH "arm_thumb" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) -# define LZO_ARCH_ARM 1 -# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -# define LZO_ARCH_ARM_THUMB 1 -# define LZO_INFO_ARCH "arm_thumb" -# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -# define LZO_INFO_ARCH "arm" -# else -# define LZO_INFO_ARCH "arm" -# endif -#elif defined(__arm__) || defined(_M_ARM) -# define LZO_ARCH_ARM 1 -# define LZO_INFO_ARCH "arm" -#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) -# define LZO_ARCH_AVR 1 -# define LZO_INFO_ARCH "avr" -#elif defined(__avr32__) || defined(__AVR32__) -# define LZO_ARCH_AVR32 1 -# define LZO_INFO_ARCH "avr32" -#elif defined(__bfin__) -# define LZO_ARCH_BLACKFIN 1 -# define LZO_INFO_ARCH "blackfin" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) -# define LZO_ARCH_C166 1 -# define LZO_INFO_ARCH "c166" -#elif defined(__cris__) -# define LZO_ARCH_CRIS 1 -# define LZO_INFO_ARCH "cris" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) -# define LZO_ARCH_EZ80 1 -# define LZO_INFO_ARCH "ez80" -#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define LZO_ARCH_H8300 1 -# define LZO_INFO_ARCH "h8300" -#elif defined(__hppa__) || defined(__hppa) -# define LZO_ARCH_HPPA 1 -# define LZO_INFO_ARCH "hppa" -#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif (LZO_CC_ZORTECHC && defined(__I86__)) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) -# define LZO_ARCH_IA64 1 -# define LZO_INFO_ARCH "ia64" -#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" -#elif defined(__m32r__) -# define LZO_ARCH_M32R 1 -# define LZO_INFO_ARCH "m32r" -#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) -# define LZO_ARCH_M68K 1 -# define LZO_INFO_ARCH "m68k" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) -# define LZO_ARCH_MCS251 1 -# define LZO_INFO_ARCH "mcs251" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" -#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) -# define LZO_ARCH_MIPS 1 -# define LZO_INFO_ARCH "mips" -#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" -#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) -# define LZO_ARCH_POWERPC 1 -# define LZO_INFO_ARCH "powerpc" -#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) -# define LZO_ARCH_S390 1 -# define LZO_INFO_ARCH "s390" -#elif defined(__sh__) || defined(_M_SH) -# define LZO_ARCH_SH 1 -# define LZO_INFO_ARCH "sh" -#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) -# define LZO_ARCH_SPARC 1 -# define LZO_INFO_ARCH "sparc" -#elif defined(__SPU__) -# define LZO_ARCH_SPU 1 -# define LZO_INFO_ARCH "spu" -#elif (UINT_MAX == LZO_0xffffL) && defined(__z80) -# define LZO_ARCH_Z80 1 -# define LZO_INFO_ARCH "z80" -#elif (LZO_ARCH_CRAY_PVP) -# if defined(_CRAYSV1) -# define LZO_ARCH_CRAY_SV1 1 -# define LZO_INFO_ARCH "cray_sv1" -# elif (_ADDR64) -# define LZO_ARCH_CRAY_T90 1 -# define LZO_INFO_ARCH "cray_t90" -# elif (_ADDR32) -# define LZO_ARCH_CRAY_YMP 1 -# define LZO_INFO_ARCH "cray_ymp" -# else -# define LZO_ARCH_CRAY_XMP 1 -# define LZO_INFO_ARCH "cray_xmp" -# endif -#else -# define LZO_ARCH_UNKNOWN 1 -# define LZO_INFO_ARCH "unknown" -#endif -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) -# error "FIXME - missing define for CPU architecture" -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) -# error "FIXME - missing WIN32 define for CPU architecture" -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) -# error "FIXME - missing WIN64 define for CPU architecture" -#endif -#if (LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(BLX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#endif -#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) -# error "this should not happen" -#endif -#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) -# error "this should not happen" -#endif -#if (LZO_ARCH_I086) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if (LZO_ARCH_I386) -# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) -# error "this should not happen" -# endif -# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if !defined(__LZO_MM_OVERRIDE) -#if (LZO_ARCH_I086) -#if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -#endif -#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) -# define LZO_MM_TINY 1 -#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) -# define LZO_MM_HUGE 1 -#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) -# define LZO_MM_SMALL 1 -#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) -# define LZO_MM_MEDIUM 1 -#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) -# define LZO_MM_COMPACT 1 -#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) -# define LZO_MM_LARGE 1 -#elif (LZO_CC_AZTECC) -# if defined(_LARGE_CODE) && defined(_LARGE_DATA) -# define LZO_MM_LARGE 1 -# elif defined(_LARGE_CODE) -# define LZO_MM_MEDIUM 1 -# elif defined(_LARGE_DATA) -# define LZO_MM_COMPACT 1 -# else -# define LZO_MM_SMALL 1 -# endif -#elif (LZO_CC_ZORTECHC && defined(__VCM__)) -# define LZO_MM_LARGE 1 -#else -# error "unknown memory model" -#endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -#define LZO_HAVE_MM_HUGE_PTR 1 -#define LZO_HAVE_MM_HUGE_ARRAY 1 -#if (LZO_MM_TINY) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) -# undef LZO_HAVE_MM_HUGE_PTR -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_MSC && defined(_QC)) -# undef LZO_HAVE_MM_HUGE_ARRAY -# if (_MSC_VER < 600) -# undef LZO_HAVE_MM_HUGE_PTR -# endif -#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) -# if (LZO_OS_DOS16) -# error "this should not happen" -# elif (LZO_CC_ZORTECHC) -# else -# error "this should not happen" -# endif -#endif -#ifdef __cplusplus -extern "C" { -#endif -#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) -# define LZO_MM_AHSHIFT 12 -#elif (LZO_CC_WATCOMC) - extern unsigned char _HShift; -# define LZO_MM_AHSHIFT ((unsigned) _HShift) -#else -# error "FIXME - implement LZO_MM_AHSHIFT" -#endif -#ifdef __cplusplus -} -#endif -#endif -#elif (LZO_ARCH_C166) -#if !defined(__MODEL__) -# error "FIXME - C166 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - C166 __MODEL__" -#endif -#elif (LZO_ARCH_MCS251) -#if !defined(__MODEL__) -# error "FIXME - MCS251 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS251 __MODEL__" -#endif -#elif (LZO_ARCH_MCS51) -#if !defined(__MODEL__) -# error "FIXME - MCS51 __MODEL__" -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS51 __MODEL__" -#endif -#elif (LZO_ARCH_CRAY_PVP) -# define LZO_MM_PVP 1 -#else -# define LZO_MM_FLAT 1 -#endif -#if (LZO_MM_COMPACT) -# define LZO_INFO_MM "compact" -#elif (LZO_MM_FLAT) -# define LZO_INFO_MM "flat" -#elif (LZO_MM_HUGE) -# define LZO_INFO_MM "huge" -#elif (LZO_MM_LARGE) -# define LZO_INFO_MM "large" -#elif (LZO_MM_MEDIUM) -# define LZO_INFO_MM "medium" -#elif (LZO_MM_PVP) -# define LZO_INFO_MM "pvp" -#elif (LZO_MM_SMALL) -# define LZO_INFO_MM "small" -#elif (LZO_MM_TINY) -# define LZO_INFO_MM "tiny" -#else -# error "unknown memory model" -#endif -#endif -#if defined(SIZEOF_SHORT) -# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -#endif -#if defined(SIZEOF_INT) -# define LZO_SIZEOF_INT (SIZEOF_INT) -#endif -#if defined(SIZEOF_LONG) -# define LZO_SIZEOF_LONG (SIZEOF_LONG) -#endif -#if defined(SIZEOF_LONG_LONG) -# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -#endif -#if defined(SIZEOF___INT16) -# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -#endif -#if defined(SIZEOF___INT32) -# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -#endif -#if defined(SIZEOF___INT64) -# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -#endif -#if defined(SIZEOF_VOID_P) -# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -#endif -#if defined(SIZEOF_SIZE_T) -# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -#endif -#if defined(SIZEOF_PTRDIFF_T) -# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -#endif -#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -#if !defined(LZO_SIZEOF_SHORT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_SHORT 8 -# elif (USHRT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,7) == 1) -# define LZO_SIZEOF_SHORT 1 -# elif (__LZO_LSR(USHRT_MAX,15) == 1) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,31) == 1) -# define LZO_SIZEOF_SHORT 4 -# elif (__LZO_LSR(USHRT_MAX,63) == 1) -# define LZO_SIZEOF_SHORT 8 -# elif (__LZO_LSR(USHRT_MAX,127) == 1) -# define LZO_SIZEOF_SHORT 16 -# else -# error "LZO_SIZEOF_SHORT" -# endif -#endif -#if !defined(LZO_SIZEOF_INT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_INT 8 -# elif (UINT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_INT 2 -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,7) == 1) -# define LZO_SIZEOF_INT 1 -# elif (__LZO_LSR(UINT_MAX,15) == 1) -# define LZO_SIZEOF_INT 2 -# elif (__LZO_LSR(UINT_MAX,31) == 1) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,63) == 1) -# define LZO_SIZEOF_INT 8 -# elif (__LZO_LSR(UINT_MAX,127) == 1) -# define LZO_SIZEOF_INT 16 -# else -# error "LZO_SIZEOF_INT" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG) -# if (ULONG_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,7) == 1) -# define LZO_SIZEOF_LONG 1 -# elif (__LZO_LSR(ULONG_MAX,15) == 1) -# define LZO_SIZEOF_LONG 2 -# elif (__LZO_LSR(ULONG_MAX,31) == 1) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,63) == 1) -# define LZO_SIZEOF_LONG 8 -# elif (__LZO_LSR(ULONG_MAX,127) == 1) -# define LZO_SIZEOF_LONG 16 -# else -# error "LZO_SIZEOF_LONG" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -# if (LZO_CC_GNUC >= 0x030300ul) -# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -# define LZO_SIZEOF_LONG_LONG 4 -# endif -# endif -# endif -#endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -#if (LZO_ARCH_I086 && LZO_CC_DMC) -#elif (LZO_CC_CILLY) && defined(__GNUC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_SIZEOF_LONG_LONG 8 -#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_OS_WIN64 || defined(_WIN64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define LZO_SIZEOF_LONG_LONG 8 -#endif -#endif -#endif -#if defined(__cplusplus) && (LZO_CC_GNUC) -# if (LZO_CC_GNUC < 0x020800ul) -# undef LZO_SIZEOF_LONG_LONG -# endif -#endif -#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -# undef LZO_SIZEOF_LONG_LONG -#endif -#if !defined(LZO_SIZEOF_VOID_P) -#if (LZO_ARCH_I086) -# define __LZO_WORDSIZE 2 -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -# define LZO_SIZEOF_VOID_P 2 -# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -# define LZO_SIZEOF_VOID_P 4 -# else -# error "LZO_MM" -# endif -#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) -# define __LZO_WORDSIZE 1 -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_H8300) -# if defined(__NORMAL_MODE__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 2 -# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 4 -# else -# define __LZO_WORDSIZE 2 -# define LZO_SIZEOF_VOID_P 2 -# endif -# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -# endif -#elif (LZO_ARCH_M16C) -# define __LZO_WORDSIZE 2 -# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -# define LZO_SIZEOF_VOID_P 4 -# else -# define LZO_SIZEOF_VOID_P 2 -# endif -#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 4 -#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_OS_OS400 || defined(__OS400__)) -# define __LZO_WORDSIZE LZO_SIZEOF_LONG -# define LZO_SIZEOF_VOID_P 16 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_VOID_P 8 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_ARCH_SPU) -# if 0 -# define __LZO_WORDSIZE 16 -# endif -# define LZO_SIZEOF_VOID_P 4 -#else -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -#endif -#endif -#if !defined(LZO_WORDSIZE) -# if defined(__LZO_WORDSIZE) -# define LZO_WORDSIZE __LZO_WORDSIZE -# else -# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -# endif -#endif -#if !defined(LZO_SIZEOF_SIZE_T) -#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -# define LZO_SIZEOF_SIZE_T 2 -#else -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -#endif -#endif -#if !defined(LZO_SIZEOF_PTRDIFF_T) -#if (LZO_ARCH_I086) -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -# define LZO_SIZEOF_PTRDIFF_T 4 -# else -# define LZO_SIZEOF_PTRDIFF_T 2 -# endif -# else -# error "LZO_MM" -# endif -#else -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -#endif -#endif -#if (LZO_ABI_NEUTRAL_ENDIAN) -# undef LZO_ABI_BIG_ENDIAN -# undef LZO_ABI_LITTLE_ENDIAN -#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -# define LZO_ABI_BIG_ENDIAN 1 -#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -# if (__LITTLE_ENDIAN__ == 1) -# define LZO_ABI_LITTLE_ENDIAN 1 -# else -# define LZO_ABI_BIG_ENDIAN 1 -# endif -#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#endif -#endif -#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -# error "this should not happen" -#endif -#if (LZO_ABI_BIG_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "be" -#elif (LZO_ABI_LITTLE_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "le" -#elif (LZO_ABI_NEUTRAL_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "neutral" -#endif -#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_I8LP16 1 -# define LZO_INFO_ABI_PM "i8lp16" -#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_ILP16 1 -# define LZO_INFO_ABI_PM "ilp16" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_ILP32 1 -# define LZO_INFO_ABI_PM "ilp32" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -# define LZO_ABI_LLP64 1 -# define LZO_INFO_ABI_PM "llp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_LP64 1 -# define LZO_INFO_ABI_PM "lp64" -#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_ILP64 1 -# define LZO_INFO_ABI_PM "ilp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_IP32L64 1 -# define LZO_INFO_ABI_PM "ip32l64" -#endif -#if !defined(__LZO_LIBC_OVERRIDE) -#if (LZO_LIBC_NAKED) -# define LZO_INFO_LIBC "naked" -#elif (LZO_LIBC_FREESTANDING) -# define LZO_INFO_LIBC "freestanding" -#elif (LZO_LIBC_MOSTLY_FREESTANDING) -# define LZO_INFO_LIBC "mfreestanding" -#elif (LZO_LIBC_ISOC90) -# define LZO_INFO_LIBC "isoc90" -#elif (LZO_LIBC_ISOC99) -# define LZO_INFO_LIBC "isoc99" -#elif defined(__dietlibc__) -# define LZO_LIBC_DIETLIBC 1 -# define LZO_INFO_LIBC "dietlibc" -#elif defined(_NEWLIB_VERSION) -# define LZO_LIBC_NEWLIB 1 -# define LZO_INFO_LIBC "newlib" -#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -# if defined(__UCLIBC_SUBLEVEL__) -# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -# else -# define LZO_LIBC_UCLIBC 0x00090bL -# endif -# define LZO_INFO_LIBC "uclibc" -#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -# define LZO_INFO_LIBC "glibc" -#elif (LZO_CC_MWERKS) && defined(__MSL__) -# define LZO_LIBC_MSL __MSL__ -# define LZO_INFO_LIBC "msl" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_LIBC_ISOC90 1 -# define LZO_INFO_LIBC "isoc90" -#else -# define LZO_LIBC_DEFAULT 1 -# define LZO_INFO_LIBC "default" -#endif -#endif -#if !defined(__lzo_gnuc_extension__) -#if (LZO_CC_GNUC >= 0x020800ul) -# define __lzo_gnuc_extension__ __extension__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_gnuc_extension__ __extension__ -#else -# define __lzo_gnuc_extension__ /*empty*/ -#endif -#endif -#if !defined(__lzo_ua_volatile) -# define __lzo_ua_volatile volatile -#endif -#if !defined(__lzo_alignof) -#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_alignof(e) __alignof(e) -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_alignof(e) __alignof__(e) -#endif -#endif -#if defined(__lzo_alignof) -# define __lzo_HAVE_alignof 1 -#endif -#if !defined(__lzo_constructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_constructor __attribute__((__constructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_constructor __attribute__((__constructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_constructor __attribute__((__constructor__)) -#endif -#endif -#if defined(__lzo_constructor) -# define __lzo_HAVE_constructor 1 -#endif -#if !defined(__lzo_destructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_destructor __attribute__((__destructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_destructor __attribute__((__destructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_destructor __attribute__((__destructor__)) -#endif -#endif -#if defined(__lzo_destructor) -# define __lzo_HAVE_destructor 1 -#endif -#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -# error "this should not happen" -#endif -#if !defined(__lzo_inline) -#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -#elif defined(__cplusplus) -# define __lzo_inline inline -#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -# define __lzo_inline __inline -#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_inline __inline__ -#elif (LZO_CC_DMC) -# define __lzo_inline __inline -#elif (LZO_CC_INTELC) -# define __lzo_inline __inline -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -# define __lzo_inline __inline -#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -# define __lzo_inline __inline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_inline __inline__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define __lzo_inline inline -#endif -#endif -#if defined(__lzo_inline) -# define __lzo_HAVE_inline 1 -#else -# define __lzo_inline /*empty*/ -#endif -#if !defined(__lzo_forceinline) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#endif -#endif -#if defined(__lzo_forceinline) -# define __lzo_HAVE_forceinline 1 -#else -# define __lzo_forceinline /*empty*/ -#endif -#if !defined(__lzo_noinline) -#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -# define __lzo_noinline __attribute__((__noinline__,__used__)) -#elif (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -# if defined(__cplusplus) -# else -# define __lzo_noinline __declspec(noinline) -# endif -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_noinline __attribute__((__noinline__)) -#endif -#endif -#if defined(__lzo_noinline) -# define __lzo_HAVE_noinline 1 -#else -# define __lzo_noinline /*empty*/ -#endif -#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -# error "this should not happen" -#endif -#if !defined(__lzo_noreturn) -#if (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_noreturn __declspec(noreturn) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_noreturn __declspec(noreturn) -#endif -#endif -#if defined(__lzo_noreturn) -# define __lzo_HAVE_noreturn 1 -#else -# define __lzo_noreturn /*empty*/ -#endif -#if !defined(__lzo_nothrow) -#if (LZO_CC_GNUC >= 0x030300ul) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#endif -#endif -#if defined(__lzo_nothrow) -# define __lzo_HAVE_nothrow 1 -#else -# define __lzo_nothrow /*empty*/ -#endif -#if !defined(__lzo_restrict) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -# define __lzo_restrict __restrict -#endif -#endif -#if defined(__lzo_restrict) -# define __lzo_HAVE_restrict 1 -#else -# define __lzo_restrict /*empty*/ -#endif -#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#endif -#endif -#if defined(__lzo_likely) -# define __lzo_HAVE_likely 1 -#else -# define __lzo_likely(e) (e) -#endif -#if defined(__lzo_unlikely) -# define __lzo_HAVE_unlikely 1 -#else -# define __lzo_unlikely(e) (e) -#endif -#if !defined(LZO_UNUSED) -# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -# define LZO_UNUSED(var) ((void) &var) -# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -# define LZO_UNUSED(var) if (&var) ; else -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNUSED(var) ((void) var) -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_UNUSED(var) if (&var) ; else -# elif (LZO_CC_KEILC) -# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} -# elif (LZO_CC_PACIFICC) -# define LZO_UNUSED(var) ((void) sizeof(var)) -# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED(var) ((void) var) -# else -# define LZO_UNUSED(var) ((void) &var) -# endif -#endif -#if !defined(LZO_UNUSED_FUNC) -# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -# define LZO_UNUSED_FUNC(func) ((void) func) -# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -# define LZO_UNUSED_FUNC(func) if (func) ; else -# elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define LZO_UNUSED_FUNC(func) ((void) &func) -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_UNUSED_FUNC(func) if (func) ; else -# elif (LZO_CC_MSC) -# define LZO_UNUSED_FUNC(func) ((void) &func) -# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} -# else -# define LZO_UNUSED_FUNC(func) ((void) func) -# endif -#endif -#if !defined(LZO_UNUSED_LABEL) -# if (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -# define LZO_UNUSED_LABEL(l) if (0) goto l -# else -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# endif -#endif -#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -# if 0 -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -# elif 0 && (LZO_CC_GNUC) -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -# else -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -# endif -#endif -#if !defined(LZO_UNCONST_CAST) -# if 0 && defined(__cplusplus) -# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) -# else -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) -# endif -#endif -#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; -# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -# else -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; -# endif -#endif -#if !defined(LZO_COMPILE_TIME_ASSERT) -# if (LZO_CC_AZTECC) -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} -# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# else -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} -# endif -#endif -#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -# define __lzo_cdecl __cdecl -# define __lzo_cdecl_atexit /*empty*/ -# define __lzo_cdecl_main __cdecl -# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -# define __lzo_cdecl_qsort __pascal -# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -# define __lzo_cdecl_qsort _stdcall -# else -# define __lzo_cdecl_qsort __cdecl -# endif -# elif (LZO_CC_WATCOMC) -# define __lzo_cdecl __cdecl -# else -# define __lzo_cdecl __cdecl -# define __lzo_cdecl_atexit __cdecl -# define __lzo_cdecl_main __cdecl -# define __lzo_cdecl_qsort __cdecl -# endif -# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -# define __lzo_cdecl_sighandler __pascal -# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -# define __lzo_cdecl_sighandler _stdcall -# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -# define __lzo_cdecl_sighandler __clrcall -# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -# if defined(_DLL) -# define __lzo_cdecl_sighandler _far _cdecl _loadds -# elif defined(_MT) -# define __lzo_cdecl_sighandler _far _cdecl -# else -# define __lzo_cdecl_sighandler _cdecl -# endif -# else -# define __lzo_cdecl_sighandler __cdecl -# endif -#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -# define __lzo_cdecl __cdecl -#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -# define __lzo_cdecl cdecl -#endif -#if !defined(__lzo_cdecl) -# define __lzo_cdecl /*empty*/ -#endif -#if !defined(__lzo_cdecl_atexit) -# define __lzo_cdecl_atexit /*empty*/ -#endif -#if !defined(__lzo_cdecl_main) -# define __lzo_cdecl_main /*empty*/ -#endif -#if !defined(__lzo_cdecl_qsort) -# define __lzo_cdecl_qsort /*empty*/ -#endif -#if !defined(__lzo_cdecl_sighandler) -# define __lzo_cdecl_sighandler /*empty*/ -#endif -#if !defined(__lzo_cdecl_va) -# define __lzo_cdecl_va __lzo_cdecl -#endif -#if !(LZO_CFG_NO_WINDOWS_H) -#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -# else -# define LZO_HAVE_WINDOWS_H 1 -# endif -#endif -#endif -#if (LZO_ARCH_ALPHA) -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_AMD64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# define LZO_OPT_UNALIGNED64 1 -#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -#elif (LZO_ARCH_ARM) -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_CRIS) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_I386) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_IA64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_PREFER_POSTINC 1 -#elif (LZO_ARCH_M68K) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -# if defined(__mc68020__) && !defined(__mcoldfire__) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# endif -#elif (LZO_ARCH_MIPS) -# define LZO_OPT_AVOID_UINT_INDEX 1 -#elif (LZO_ARCH_POWERPC) -# define LZO_OPT_PREFER_PREINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -# if (LZO_ABI_BIG_ENDIAN) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# endif -#elif (LZO_ARCH_S390) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# if (LZO_SIZEOF_SIZE_T == 8) -# define LZO_OPT_UNALIGNED64 1 -# endif -#elif (LZO_ARCH_SH) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -#endif -#ifndef LZO_CFG_NO_INLINE_ASM -#if (LZO_CC_LLVM) -# define LZO_CFG_NO_INLINE_ASM 1 -#endif -#endif -#ifndef LZO_CFG_NO_UNALIGNED -#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -# define LZO_CFG_NO_UNALIGNED 1 -#endif -#endif -#if (LZO_CFG_NO_UNALIGNED) -# undef LZO_OPT_UNALIGNED16 -# undef LZO_OPT_UNALIGNED32 -# undef LZO_OPT_UNALIGNED64 -#endif -#if (LZO_CFG_NO_INLINE_ASM) -#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -# define LZO_ASM_SYNTAX_MSC 1 -#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#endif -#if (LZO_ASM_SYNTAX_GNUC) -#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -# define __LZO_ASM_CLOBBER "ax" -#elif (LZO_CC_INTELC) -# define __LZO_ASM_CLOBBER "memory" -#else -# define __LZO_ASM_CLOBBER "cc", "memory" -#endif -#endif -#if defined(__LZO_INFOSTR_MM) -#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) -# define __LZO_INFOSTR_MM "" -#elif defined(LZO_INFO_MM) -# define __LZO_INFOSTR_MM "." LZO_INFO_MM -#else -# define __LZO_INFOSTR_MM "" -#endif -#if defined(__LZO_INFOSTR_PM) -#elif defined(LZO_INFO_ABI_PM) -# define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM -#else -# define __LZO_INFOSTR_PM "" -#endif -#if defined(__LZO_INFOSTR_ENDIAN) -#elif defined(LZO_INFO_ABI_ENDIAN) -# define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN -#else -# define __LZO_INFOSTR_ENDIAN "" -#endif -#if defined(__LZO_INFOSTR_OSNAME) -#elif defined(LZO_INFO_OS_CONSOLE) -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE -#elif defined(LZO_INFO_OS_POSIX) -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX -#else -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS -#endif -#if defined(__LZO_INFOSTR_LIBC) -#elif defined(LZO_INFO_LIBC) -# define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC -#else -# define __LZO_INFOSTR_LIBC "" -#endif -#if defined(__LZO_INFOSTR_CCVER) -#elif defined(LZO_INFO_CCVER) -# define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER -#else -# define __LZO_INFOSTR_CCVER "" -#endif -#define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER - -#endif /* already included */ - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/lzo/lzoutil.h b/winlibs/include/lzo/lzoutil.h deleted file mode 100644 index eb741ce2d..000000000 --- a/winlibs/include/lzo/lzoutil.h +++ /dev/null @@ -1,76 +0,0 @@ -/* lzoutil.h -- utilitiy functions for use by applications [DEPRECATED] - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZOUTIL_H_INCLUDED -#define __LZOUTIL_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// LZO-v1 deprecated macros (which were used in the old example programs) -// DO NOT USE -************************************************************************/ - -#define lzo_alloc(a,b) (malloc((a)*(b))) -#define lzo_malloc(a) (malloc(a)) -#define lzo_free(a) (free(a)) - -#define lzo_fread(f,b,s) (fread(b,1,s,f)) -#define lzo_fwrite(f,b,s) (fwrite(b,1,s,f)) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/winlibs/include/ogg/config_types.h b/winlibs/include/ogg/config_types.h deleted file mode 100644 index 1a87df642..000000000 --- a/winlibs/include/ogg/config_types.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __CONFIG_TYPES_H__ -#define __CONFIG_TYPES_H__ - -/* these are filled in by configure or cmake*/ -#define INCLUDE_INTTYPES_H 1 -#define INCLUDE_STDINT_H 1 -#define INCLUDE_SYS_TYPES_H 1 - -#if INCLUDE_INTTYPES_H -# include -#endif -#if INCLUDE_STDINT_H -# include -#endif -#if INCLUDE_SYS_TYPES_H -# include -#endif - -typedef int16_t ogg_int16_t; -typedef uint16_t ogg_uint16_t; -typedef int32_t ogg_int32_t; -typedef uint32_t ogg_uint32_t; -typedef int64_t ogg_int64_t; -typedef uint64_t ogg_uint64_t; - -#endif diff --git a/winlibs/include/ogg/ogg.h b/winlibs/include/ogg/ogg.h deleted file mode 100644 index c4325aa76..000000000 --- a/winlibs/include/ogg/ogg.h +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: toplevel libogg include - - ********************************************************************/ -#ifndef _OGG_H -#define _OGG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct { - void *iov_base; - size_t iov_len; -} ogg_iovec_t; - -typedef struct { - long endbyte; - int endbit; - - unsigned char *buffer; - unsigned char *ptr; - long storage; -} oggpack_buffer; - -/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ - -typedef struct { - unsigned char *header; - long header_len; - unsigned char *body; - long body_len; -} ogg_page; - -/* ogg_stream_state contains the current encode/decode state of a logical - Ogg bitstream **********************************************************/ - -typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - long body_storage; /* storage elements allocated */ - long body_fill; /* elements stored; fill mark */ - long body_returned; /* elements of fill returned */ - - - int *lacing_vals; /* The values that will go to the segment table */ - ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact - this way, but it is simple coupled to the - lacing fifo */ - long lacing_storage; - long lacing_fill; - long lacing_packet; - long lacing_returned; - - unsigned char header[282]; /* working space for header encode */ - int header_fill; - - int e_o_s; /* set when we have buffered the last packet in the - logical bitstream */ - int b_o_s; /* set after we've written the initial page - of a logical bitstream */ - long serialno; - long pageno; - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ - ogg_int64_t granulepos; - -} ogg_stream_state; - -/* ogg_packet is used to encapsulate the data and metadata belonging - to a single raw Ogg/Vorbis packet *************************************/ - -typedef struct { - unsigned char *packet; - long bytes; - long b_o_s; - long e_o_s; - - ogg_int64_t granulepos; - - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ -} ogg_packet; - -typedef struct { - unsigned char *data; - int storage; - int fill; - int returned; - - int unsynced; - int headerbytes; - int bodybytes; -} ogg_sync_state; - -/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ - -extern void oggpack_writeinit(oggpack_buffer *b); -extern int oggpack_writecheck(oggpack_buffer *b); -extern void oggpack_writetrunc(oggpack_buffer *b,long bits); -extern void oggpack_writealign(oggpack_buffer *b); -extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpack_reset(oggpack_buffer *b); -extern void oggpack_writeclear(oggpack_buffer *b); -extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpack_look(oggpack_buffer *b,int bits); -extern long oggpack_look1(oggpack_buffer *b); -extern void oggpack_adv(oggpack_buffer *b,int bits); -extern void oggpack_adv1(oggpack_buffer *b); -extern long oggpack_read(oggpack_buffer *b,int bits); -extern long oggpack_read1(oggpack_buffer *b); -extern long oggpack_bytes(oggpack_buffer *b); -extern long oggpack_bits(oggpack_buffer *b); -extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); - -extern void oggpackB_writeinit(oggpack_buffer *b); -extern int oggpackB_writecheck(oggpack_buffer *b); -extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); -extern void oggpackB_writealign(oggpack_buffer *b); -extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpackB_reset(oggpack_buffer *b); -extern void oggpackB_writeclear(oggpack_buffer *b); -extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpackB_look(oggpack_buffer *b,int bits); -extern long oggpackB_look1(oggpack_buffer *b); -extern void oggpackB_adv(oggpack_buffer *b,int bits); -extern void oggpackB_adv1(oggpack_buffer *b); -extern long oggpackB_read(oggpack_buffer *b,int bits); -extern long oggpackB_read1(oggpack_buffer *b); -extern long oggpackB_bytes(oggpack_buffer *b); -extern long oggpackB_bits(oggpack_buffer *b); -extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); - -/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ - -extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, - int count, long e_o_s, ogg_int64_t granulepos); -extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); -extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill); - -/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ - -extern int ogg_sync_init(ogg_sync_state *oy); -extern int ogg_sync_clear(ogg_sync_state *oy); -extern int ogg_sync_reset(ogg_sync_state *oy); -extern int ogg_sync_destroy(ogg_sync_state *oy); -extern int ogg_sync_check(ogg_sync_state *oy); - -extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); -extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); -extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); -extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); -extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); -extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); - -/* Ogg BITSTREAM PRIMITIVES: general ***************************/ - -extern int ogg_stream_init(ogg_stream_state *os,int serialno); -extern int ogg_stream_clear(ogg_stream_state *os); -extern int ogg_stream_reset(ogg_stream_state *os); -extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); -extern int ogg_stream_destroy(ogg_stream_state *os); -extern int ogg_stream_check(ogg_stream_state *os); -extern int ogg_stream_eos(ogg_stream_state *os); - -extern void ogg_page_checksum_set(ogg_page *og); - -extern int ogg_page_version(const ogg_page *og); -extern int ogg_page_continued(const ogg_page *og); -extern int ogg_page_bos(const ogg_page *og); -extern int ogg_page_eos(const ogg_page *og); -extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); -extern int ogg_page_serialno(const ogg_page *og); -extern long ogg_page_pageno(const ogg_page *og); -extern int ogg_page_packets(const ogg_page *og); - -extern void ogg_packet_clear(ogg_packet *op); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OGG_H */ diff --git a/winlibs/include/ogg/os_types.h b/winlibs/include/ogg/os_types.h deleted file mode 100644 index e655a1d62..000000000 --- a/winlibs/include/ogg/os_types.h +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: Define a consistent set of types on each platform. - - ********************************************************************/ -#ifndef _OS_TYPES_H -#define _OS_TYPES_H - -/* make it easy on the folks that want to compile the libs with a - different malloc than stdlib */ -#define _ogg_malloc malloc -#define _ogg_calloc calloc -#define _ogg_realloc realloc -#define _ogg_free free - -#if defined(_WIN32) - -# if defined(__CYGWIN__) -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; -# elif defined(__MINGW32__) -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; -# elif defined(__MWERKS__) - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; -# else -# if defined(_MSC_VER) && (_MSC_VER >= 1800) /* MSVC 2013 and newer */ -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; -# else - /* MSVC/Borland */ - typedef __int64 ogg_int64_t; - typedef __int32 ogg_int32_t; - typedef unsigned __int32 ogg_uint32_t; - typedef unsigned __int64 ogg_uint64_t; - typedef __int16 ogg_int16_t; - typedef unsigned __int16 ogg_uint16_t; -# endif -# endif - -#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ - -# include - typedef int16_t ogg_int16_t; - typedef u_int16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef u_int32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef u_int64_t ogg_uint64_t; - -#elif defined(__HAIKU__) - - /* Haiku */ -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - -#elif defined(__BEOS__) - - /* Be */ -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; - -#elif defined (__EMX__) - - /* OS/2 GCC */ - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - - -#elif defined (DJGPP) - - /* DJGPP */ - typedef short ogg_int16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - -#elif defined(R5900) - - /* PS2 EE */ - typedef long ogg_int64_t; - typedef unsigned long ogg_uint64_t; - typedef int ogg_int32_t; - typedef unsigned ogg_uint32_t; - typedef short ogg_int16_t; - -#elif defined(__SYMBIAN32__) - - /* Symbian GCC */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - typedef unsigned long long int ogg_uint64_t; - -#elif defined(__TMS320C6X__) - - /* TI C64x compiler */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - typedef unsigned long long int ogg_uint64_t; - -#else - -# include - -#endif - -#endif /* _OS_TYPES_H */ diff --git a/winlibs/include/opencc/BinaryDict.hpp b/winlibs/include/opencc/BinaryDict.hpp deleted file mode 100644 index 7c23268fe..000000000 --- a/winlibs/include/opencc/BinaryDict.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Binary dictionary for faster deserialization - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT BinaryDict : public SerializableDict { -public: - BinaryDict(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} - - virtual ~BinaryDict() {} - - virtual void SerializeToFile(FILE* fp) const; - - static BinaryDictPtr NewFromFile(FILE* fp); - - const LexiconPtr& GetLexicon() const { return lexicon; } - - size_t KeyMaxLength() const; - -private: - LexiconPtr lexicon; - std::string keyBuffer; - std::string valueBuffer; - - void ConstructBuffer(std::string& keyBuffer, std::vector& keyOffset, - size_t& keyTotalLength, std::string& valueBuffer, - std::vector& valueOffset, - size_t& valueTotalLength) const; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Common.hpp b/winlibs/include/opencc/Common.hpp deleted file mode 100644 index 067966b55..000000000 --- a/winlibs/include/opencc/Common.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -// Microsoft Visual C++ specific -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma warning(disable : 4251 4266 4350 4503 4512 4514 4710 4820) -#endif - -#include -#include -#include -#include - -#include "Export.hpp" -#include "Optional.hpp" -#include "opencc_config.h" - -// Forward decalarations and alias -namespace opencc { -class Config; -class Conversion; -class ConversionChain; -class Converter; -class Dict; -class DictEntry; -class DictGroup; -class Lexicon; -class MarisaDict; -class MultiValueDictEntry; -class NoValueDictEntry; -class Segmentation; -class Segments; -class SerializableDict; -class SingleValueDictEntry; -class TextDict; -typedef std::shared_ptr ConversionPtr; -typedef std::shared_ptr ConversionChainPtr; -typedef std::shared_ptr ConverterPtr; -typedef std::shared_ptr DictPtr; -typedef std::shared_ptr DictGroupPtr; -typedef std::shared_ptr LexiconPtr; -typedef std::shared_ptr MarisaDictPtr; -typedef std::shared_ptr SegmentationPtr; -typedef std::shared_ptr SegmentsPtr; -typedef std::shared_ptr SerializableDictPtr; -typedef std::shared_ptr TextDictPtr; - -#ifdef OPENCC_ENABLE_DARTS -class BinaryDict; -class DartsDict; -typedef std::shared_ptr BinaryDictPtr; -typedef std::shared_ptr DartsDictPtr; -#endif - -} // namespace opencc - -#ifndef PKGDATADIR -const std::string PACKAGE_DATA_DIRECTORY = ""; -#else // ifndef PKGDATADIR -const std::string PACKAGE_DATA_DIRECTORY = PKGDATADIR "/"; -#endif // ifndef PKGDATADIR - -#ifndef VERSION -#define VERSION "1.0.*" -#endif // ifndef VERSION diff --git a/winlibs/include/opencc/Config.hpp b/winlibs/include/opencc/Config.hpp deleted file mode 100644 index 7a904cee6..000000000 --- a/winlibs/include/opencc/Config.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Configuration loader - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Config { -public: - Config(); - - virtual ~Config(); - - ConverterPtr NewFromString(const std::string& json, - const std::string& configDirectory); - - ConverterPtr NewFromFile(const std::string& fileName); - -private: - void* internal; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Conversion.hpp b/winlibs/include/opencc/Conversion.hpp deleted file mode 100644 index cf73a254a..000000000 --- a/winlibs/include/opencc/Conversion.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Conversion interface - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Conversion { -public: - Conversion(DictPtr _dict) : dict(_dict) {} - - // Convert single phrase - std::string Convert(const std::string& phrase) const; - - // Convert single phrase - std::string Convert(const char* phrase) const; - - // Convert segmented text - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/ConversionChain.hpp b/winlibs/include/opencc/ConversionChain.hpp deleted file mode 100644 index 28853c67c..000000000 --- a/winlibs/include/opencc/ConversionChain.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include - -#include "Common.hpp" -#include "Conversion.hpp" - -namespace opencc { -/** - * Chain of conversions - * Consists of a list of conversions. Converts input in sequence. - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT ConversionChain { -public: - ConversionChain(const std::list _conversions); - - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const std::list GetConversions() const { return conversions; } - -private: - const std::list conversions; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Converter.hpp b/winlibs/include/opencc/Converter.hpp deleted file mode 100644 index 9f1f3f942..000000000 --- a/winlibs/include/opencc/Converter.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Controller of segmentation and conversion - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Converter { -public: - Converter(const std::string& _name, SegmentationPtr _segmentation, - ConversionChainPtr _conversionChain) - : name(_name), segmentation(_segmentation), - conversionChain(_conversionChain) {} - - std::string Convert(const std::string& text) const; - - size_t Convert(const char* input, char* output) const; - - const SegmentationPtr GetSegmentation() const { return segmentation; } - - const ConversionChainPtr GetConversionChain() const { - return conversionChain; - } - -private: - const std::string name; - const SegmentationPtr segmentation; - const ConversionChainPtr conversionChain; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/DartsDict.hpp b/winlibs/include/opencc/DartsDict.hpp deleted file mode 100644 index eacc1a8c6..000000000 --- a/winlibs/include/opencc/DartsDict.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Darts dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DartsDict : public Dict, public SerializableDict { -public: - virtual ~DartsDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a DartsDict from another dictionary. - */ - static DartsDictPtr NewFromDict(const Dict& thatDict); - - static DartsDictPtr NewFromFile(FILE* fp); - -private: - DartsDict(); - - size_t maxLength; - LexiconPtr lexicon; - - class DartsInternal; - DartsInternal* internal; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Dict.hpp b/winlibs/include/opencc/Dict.hpp deleted file mode 100644 index 1c810346c..000000000 --- a/winlibs/include/opencc/Dict.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** - * Abstract class of dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Dict { -public: - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - virtual Optional Match(const char* word, - size_t len) const = 0; - - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - Optional Match(const std::string& word) const { - return Match(word.c_str(), word.length()); - } - - /** - * Matches the longest matched prefix of a word. - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * the longest prefix of "banana" matched is "bana". - */ - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - /** - * Matches the longest matched prefix of a word. - */ - Optional MatchPrefix(const char* word) const { - return MatchPrefix(word, KeyMaxLength()); - } - - /** - * Matches the longest matched prefix of a word. - */ - Optional MatchPrefix(const std::string& word) const { - return MatchPrefix(word.c_str(), word.length()); - } - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * all the matched prefixes of "banana" are "bana", "ban", "ba", "b". - */ - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - */ - std::vector - MatchAllPrefixes(const std::string& word) const { - return MatchAllPrefixes(word.c_str(), word.length()); - } - - /** - * Returns the length of the longest key in the dictionary. - */ - virtual size_t KeyMaxLength() const = 0; - - /** - * Returns all entries in the dictionary. - */ - virtual LexiconPtr GetLexicon() const = 0; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/DictConverter.hpp b/winlibs/include/opencc/DictConverter.hpp deleted file mode 100644 index f911c4feb..000000000 --- a/winlibs/include/opencc/DictConverter.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2017 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Converts a dictionary from a format to another. - * @ingroup opencc_cpp_api - */ -OPENCC_EXPORT void ConvertDictionary(const std::string& inputFileName, - const std::string& outputFileName, - const std::string& formatFrom, - const std::string& formatTo); -} // namespace opencc diff --git a/winlibs/include/opencc/DictEntry.hpp b/winlibs/include/opencc/DictEntry.hpp deleted file mode 100644 index 7b2babda5..000000000 --- a/winlibs/include/opencc/DictEntry.hpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "Segments.hpp" -#include "UTF8Util.hpp" - -namespace opencc { -/** - * Key-values pair entry - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DictEntry { -public: - virtual ~DictEntry() {} - - virtual std::string Key() const = 0; - - virtual std::vector Values() const = 0; - - virtual std::string GetDefault() const = 0; - - virtual size_t NumValues() const = 0; - - virtual std::string ToString() const = 0; - - size_t KeyLength() const { return Key().length(); } - - bool operator<(const DictEntry& that) const { return Key() < that.Key(); } - - bool operator==(const DictEntry& that) const { return Key() == that.Key(); } - - static bool UPtrLessThan(const std::unique_ptr& a, - const std::unique_ptr& b) { - return *a < *b; - } -}; - -class OPENCC_EXPORT NoValueDictEntry : public DictEntry { -public: - NoValueDictEntry(const std::string& _key) : key(_key) {} - - virtual ~NoValueDictEntry() {} - - virtual std::string Key() const { return key; } - - virtual std::vector Values() const { - return std::vector(); - } - - virtual std::string GetDefault() const { return key; } - - virtual size_t NumValues() const { return 0; } - - virtual std::string ToString() const { return key; } - -private: - std::string key; -}; - -class OPENCC_EXPORT SingleValueDictEntry : public DictEntry { -public: - virtual std::string Value() const = 0; - - virtual std::vector Values() const { - return std::vector{Value()}; - } - - virtual std::string GetDefault() const { return Value(); } - - virtual size_t NumValues() const { return 1; } - - virtual std::string ToString() const { - return std::string(Key()) + "\t" + Value(); - } -}; - -class OPENCC_EXPORT StrSingleValueDictEntry : public SingleValueDictEntry { -public: - StrSingleValueDictEntry(const std::string& _key, const std::string& _value) - : key(_key), value(_value) {} - - virtual ~StrSingleValueDictEntry() {} - - virtual std::string Key() const { return key; } - - virtual std::string Value() const { return value; } - -private: - std::string key; - std::string value; -}; - -class OPENCC_EXPORT MultiValueDictEntry : public DictEntry { -public: - virtual std::string GetDefault() const { - if (NumValues() > 0) { - return Values().at(0); - } else { - return Key(); - } - } - - virtual std::string ToString() const; -}; - -class OPENCC_EXPORT StrMultiValueDictEntry : public MultiValueDictEntry { -public: - StrMultiValueDictEntry(const std::string& _key, - const std::vector& _values) - : key(_key), values(_values) {} - - virtual ~StrMultiValueDictEntry() {} - - virtual std::string Key() const { return key; } - - size_t NumValues() const { return values.size(); } - - std::vector Values() const { return values; } - -private: - std::string key; - std::vector values; -}; - -class OPENCC_EXPORT DictEntryFactory { -public: - static DictEntry* New(const std::string& key) { - return new NoValueDictEntry(key); - } - - static DictEntry* New(const std::string& key, const std::string& value) { - return new StrSingleValueDictEntry(key, value); - } - - static DictEntry* New(const std::string& key, - const std::vector& values) { - if (values.size() == 0) { - return New(key); - } else if (values.size() == 1) { - return New(key, values.front()); - } - return new StrMultiValueDictEntry(key, values); - } - - static DictEntry* New(const DictEntry* entry) { - if (entry->NumValues() == 0) { - return new NoValueDictEntry(entry->Key()); - } else if (entry->NumValues() == 1) { - return new StrSingleValueDictEntry(entry->Key(), entry->Values().front()); - } else { - return new StrMultiValueDictEntry(entry->Key(), entry->Values()); - } - } -}; -} // namespace opencc diff --git a/winlibs/include/opencc/DictGroup.hpp b/winlibs/include/opencc/DictGroup.hpp deleted file mode 100644 index fd51d9133..000000000 --- a/winlibs/include/opencc/DictGroup.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include - -#include "Common.hpp" -#include "Dict.hpp" - -namespace opencc { -/** - * Group of dictionaries - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DictGroup : public Dict { -public: - DictGroup(const std::list& dicts); - - static DictGroupPtr NewFromDict(const Dict& dict); - - virtual ~DictGroup(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - const std::list GetDicts() const { return dicts; } - -private: - const size_t keyMaxLength; - const std::list dicts; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Exception.hpp b/winlibs/include/opencc/Exception.hpp deleted file mode 100644 index 7875537f6..000000000 --- a/winlibs/include/opencc/Exception.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include -#include -#include - -#include "Export.hpp" - -#if defined(_MSC_VER) && _MSC_VER < 1900 -// Before Visual Studio 2015 (14.0), C++ 11 "noexcept" qualifier is not -// supported -#define noexcept -#endif // ifdef _MSC_VER - -namespace opencc { - -class OPENCC_EXPORT Exception { -public: - Exception() {} - - virtual ~Exception() throw() {} - - Exception(const std::string& _message) : message(_message) {} - - virtual const char* what() const noexcept { return message.c_str(); } - -protected: - std::string message; -}; - -class OPENCC_EXPORT FileNotFound : public Exception { -public: - FileNotFound(const std::string& fileName) - : Exception(fileName + " not found or not accessible.") {} -}; - -class OPENCC_EXPORT FileNotWritable : public Exception { -public: - FileNotWritable(const std::string& fileName) - : Exception(fileName + " not writable.") {} -}; - -class OPENCC_EXPORT InvalidFormat : public Exception { -public: - InvalidFormat(const std::string& message) - : Exception("Invalid format: " + message) {} -}; - -class OPENCC_EXPORT InvalidTextDictionary : public InvalidFormat { -public: - InvalidTextDictionary(const std::string& _message, size_t lineNum) - : InvalidFormat("") { - std::ostringstream buffer; - buffer << "Invalid text dictionary at line " << lineNum << ": " << _message; - message = buffer.str(); - } -}; - -class OPENCC_EXPORT InvalidUTF8 : public Exception { -public: - InvalidUTF8(const std::string& _message) - : Exception("Invalid UTF8: " + _message) {} -}; - -class OPENCC_EXPORT ShouldNotBeHere : public Exception { -public: - ShouldNotBeHere() : Exception("ShouldNotBeHere! This must be a bug.") {} -}; - -} // namespace opencc diff --git a/winlibs/include/opencc/Export.hpp b/winlibs/include/opencc/Export.hpp deleted file mode 100644 index 0015e880f..000000000 --- a/winlibs/include/opencc/Export.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#define OPENCC_EXPORT -#define OPENCC_NO_EXPORT -#else // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#ifndef OPENCC_EXPORT -#ifdef libopencc_EXPORTS - -/* We are building this library */ -#define OPENCC_EXPORT __declspec(dllexport) -#else // ifdef libopencc_EXPORTS - -/* We are using this library */ -#define OPENCC_EXPORT __declspec(dllimport) -#endif // ifdef libopencc_EXPORTS -#endif // ifndef OPENCC_EXPORT - -#ifndef OPENCC_NO_EXPORT -#define OPENCC_NO_EXPORT -#endif // ifndef OPENCC_NO_EXPORT -#endif // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) diff --git a/winlibs/include/opencc/Lexicon.hpp b/winlibs/include/opencc/Lexicon.hpp deleted file mode 100644 index 688912875..000000000 --- a/winlibs/include/opencc/Lexicon.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** - * Storage of all entries - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Lexicon { -public: - Lexicon() {} - Lexicon(std::vector> entries_) - : entries(std::move(entries_)) {} - Lexicon(const Lexicon&) = delete; - Lexicon& operator=(const Lexicon&) = delete; - - // Lexicon will take the ownership of the entry. - void Add(DictEntry* entry) { entries.emplace_back(entry); } - - void Add(std::unique_ptr entry) { - entries.push_back(std::move(entry)); - } - - void Sort(); - - // Returns true if the lexicon is sorted by key. - bool IsSorted(); - - // Returns true if every key unique (after sorted). - // When dupkey is set, it is set to the duplicate key. - bool IsUnique(std::string* dupkey = nullptr); - - const DictEntry* At(size_t index) const { return entries.at(index).get(); } - - size_t Length() const { return entries.size(); } - - std::vector>::const_iterator begin() const { - return entries.begin(); - } - - std::vector>::const_iterator end() const { - return entries.end(); - } - -private: - std::vector> entries; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/MarisaDict.hpp b/winlibs/include/opencc/MarisaDict.hpp deleted file mode 100644 index 6917c23aa..000000000 --- a/winlibs/include/opencc/MarisaDict.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2020 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Darts dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT MarisaDict : public Dict, public SerializableDict { -public: - virtual ~MarisaDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a MarisaDict from another dictionary. - */ - static MarisaDictPtr NewFromDict(const Dict& thatDict); - - static MarisaDictPtr NewFromFile(FILE* fp); - -private: - MarisaDict(); - - size_t maxLength; - LexiconPtr lexicon; - - class MarisaInternal; - std::unique_ptr internal; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/MaxMatchSegmentation.hpp b/winlibs/include/opencc/MaxMatchSegmentation.hpp deleted file mode 100644 index 1ecc227e2..000000000 --- a/winlibs/include/opencc/MaxMatchSegmentation.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "DictGroup.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Implementation of maximal match segmentation - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT MaxMatchSegmentation : public Segmentation { -public: - MaxMatchSegmentation(const DictPtr _dict) : dict(_dict) {} - - virtual ~MaxMatchSegmentation() {} - - virtual SegmentsPtr Segment(const std::string& text) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Optional.hpp b/winlibs/include/opencc/Optional.hpp deleted file mode 100644 index 8a510f43b..000000000 --- a/winlibs/include/opencc/Optional.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -namespace opencc { -/** - * A class that wraps type T into a nullable type. - * @ingroup opencc_cpp_api - */ -template class Optional { -public: - /** - * The constructor of Optional. - */ - Optional(T actual) : isNull(false), data(actual) {} - - /** - * Returns true if the instance is null. - */ - bool IsNull() const { return isNull; } - - /** - * Returns the containing data of the instance. - */ - const T& Get() const { return data; } - - /** - * Constructs a null instance. - */ - static Optional Null() { return Optional(); } - -private: - Optional() : isNull(true) {} - - bool isNull; - T data; -}; - -/** - * Specialization of Optional for pointers. - * - * Reduce a bool. - */ -template class Optional { -private: - Optional() : data(nullptr) {} - - typedef T* TPtr; - TPtr data; - -public: - Optional(TPtr actual) : data(actual) {} - - bool IsNull() const { return data == nullptr; } - - const TPtr& Get() const { return data; } - - static Optional Null() { return Optional(); } -}; -} // namespace opencc \ No newline at end of file diff --git a/winlibs/include/opencc/PhraseExtract.hpp b/winlibs/include/opencc/PhraseExtract.hpp deleted file mode 100644 index 75a165deb..000000000 --- a/winlibs/include/opencc/PhraseExtract.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2015 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include -#include - -#include "Common.hpp" -#include "UTF8StringSlice.hpp" - -namespace opencc { - -class OPENCC_EXPORT PhraseExtract { -public: - typedef UTF8StringSlice::LengthType LengthType; - - typedef UTF8StringSliceBase UTF8StringSlice8Bit; - - PhraseExtract(); - - virtual ~PhraseExtract(); - - void Extract(const std::string& text) { - SetFullText(text); - ExtractSuffixes(); - CalculateFrequency(); - CalculateSuffixEntropy(); - ReleaseSuffixes(); - ExtractPrefixes(); - CalculatePrefixEntropy(); - ReleasePrefixes(); - ExtractWordCandidates(); - CalculateCohesions(); - SelectWords(); - } - - void SetFullText(const std::string& fullText) { - utf8FullText = UTF8StringSlice(fullText.c_str()); - } - - void SetFullText(const char* fullText) { - utf8FullText = UTF8StringSlice(fullText); - } - - void SetFullText(const UTF8StringSlice& fullText) { utf8FullText = fullText; } - - void SetWordMinLength(const LengthType _wordMinLength) { - wordMinLength = _wordMinLength; - } - - void SetWordMaxLength(const LengthType _wordMaxLength) { - wordMaxLength = _wordMaxLength; - } - - void SetPrefixSetLength(const LengthType _prefixSetLength) { - prefixSetLength = _prefixSetLength; - } - - void SetSuffixSetLength(const LengthType _suffixSetLength) { - suffixSetLength = _suffixSetLength; - } - - // PreCalculationFilter is called after frequencies statistics. - void SetPreCalculationFilter( - const std::function& filter) { - preCalculationFilter = filter; - } - - void SetPostCalculationFilter( - const std::function& filter) { - postCalculationFilter = filter; - } - - void ReleaseSuffixes() { std::vector().swap(suffixes); } - - void ReleasePrefixes() { std::vector().swap(prefixes); } - - const std::vector& Words() const { return words; } - - const std::vector& WordCandidates() const { - return wordCandidates; - } - - struct Signals { - size_t frequency; - double cohesion; - double suffixEntropy; - double prefixEntropy; - }; - - const Signals& Signal(const UTF8StringSlice8Bit& wordCandidate) const; - - double Cohesion(const UTF8StringSlice8Bit& wordCandidate) const; - - double Entropy(const UTF8StringSlice8Bit& wordCandidate) const; - - double SuffixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; - - double PrefixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; - - size_t Frequency(const UTF8StringSlice8Bit& word) const; - - double Probability(const UTF8StringSlice8Bit& word) const; - - double LogProbability(const UTF8StringSlice8Bit& word) const; - - void Reset(); - - void ExtractSuffixes(); - - void ExtractPrefixes(); - - void ExtractWordCandidates(); - - void CalculateFrequency(); - - void CalculateCohesions(); - - void CalculateSuffixEntropy(); - - void CalculatePrefixEntropy(); - - void SelectWords(); - - static bool - DefaultPreCalculationFilter(const PhraseExtract&, - const PhraseExtract::UTF8StringSlice8Bit&); - - static bool - DefaultPostCalculationFilter(const PhraseExtract&, - const PhraseExtract::UTF8StringSlice8Bit&); - -private: - class DictType; - - // Pointwise Mutual Information - double PMI(const UTF8StringSlice8Bit& wordCandidate, - const UTF8StringSlice8Bit& part1, - const UTF8StringSlice8Bit& part2) const; - - double CalculateCohesion(const UTF8StringSlice8Bit& wordCandidate) const; - - double CalculateEntropy( - const std::unordered_map& choices) const; - - LengthType wordMinLength; - LengthType wordMaxLength; - LengthType prefixSetLength; - LengthType suffixSetLength; - std::function - preCalculationFilter; - std::function - postCalculationFilter; - - bool prefixesExtracted; - bool suffixesExtracted; - bool frequenciesCalculated; - bool wordCandidatesExtracted; - bool cohesionsCalculated; - bool prefixEntropiesCalculated; - bool suffixEntropiesCalculated; - bool wordsSelected; - - UTF8StringSlice utf8FullText; - size_t totalOccurrence; - double logTotalOccurrence; - std::vector prefixes; - std::vector suffixes; - std::vector wordCandidates; - std::vector words; - DictType* signals; - - friend class PhraseExtractTest; -}; - -} // namespace opencc diff --git a/winlibs/include/opencc/Segmentation.hpp b/winlibs/include/opencc/Segmentation.hpp deleted file mode 100644 index c260ea6de..000000000 --- a/winlibs/include/opencc/Segmentation.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Abstract segmentation - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Segmentation { -public: - virtual SegmentsPtr Segment(const std::string& text) const = 0; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/Segments.hpp b/winlibs/include/opencc/Segments.hpp deleted file mode 100644 index 21c39813c..000000000 --- a/winlibs/include/opencc/Segments.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include - -#include "Common.hpp" - -namespace opencc { -/** - * Segmented text - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Segments { -public: - Segments() {} - - Segments(std::initializer_list initList) { - for (const std::string& item : initList) { - AddSegment(item); - } - } - - Segments(std::initializer_list initList) { - for (const std::string& item : initList) { - AddSegment(item); - } - } - - void AddSegment(const char* unmanagedString) { - indexes.push_back(std::make_pair(unmanaged.size(), false)); - unmanaged.push_back(unmanagedString); - } - - void AddSegment(const std::string& str) { - indexes.push_back(std::make_pair(managed.size(), true)); - managed.push_back(str); - } - - class iterator : public std::iterator { - public: - iterator(const Segments* const _segments, size_t _cursor) - : segments(_segments), cursor(_cursor) {} - - iterator& operator++() { - cursor++; - return *this; - } - - bool operator==(const iterator& that) const { - return cursor == that.cursor && segments == that.segments; - } - - bool operator!=(const iterator& that) const { - return !this->operator==(that); - } - - const char* operator*() const { return segments->At(cursor); } - - private: - const Segments* const segments; - size_t cursor; - }; - - const char* At(size_t cursor) const { - const auto& index = indexes[cursor]; - if (index.second) { - return managed[index.first].c_str(); - } else { - return unmanaged[index.first]; - } - } - - size_t Length() const { return indexes.size(); } - - iterator begin() const { return iterator(this, 0); } - - iterator end() const { return iterator(this, indexes.size()); } - - std::string ToString() const { - // TODO implement a nested structure to reduce concatenation, - // like a purely functional differential list - std::ostringstream buffer; - for (const char* segment : *this) { - buffer << segment; - } - return buffer.str(); - } - -private: - Segments(const Segments&) {} - - std::vector unmanaged; - std::vector managed; - // index, managed - std::vector> indexes; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/SerializableDict.hpp b/winlibs/include/opencc/SerializableDict.hpp deleted file mode 100644 index 17cea8903..000000000 --- a/winlibs/include/opencc/SerializableDict.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Dict.hpp" - -namespace opencc { -/** - * Serializable dictionary interface - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT SerializableDict { -public: - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(FILE* fp) const = 0; - - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(const std::string& fileName) const { - FILE* fp = fopen(fileName.c_str(), "wb"); - if (fp == NULL) { - throw FileNotWritable(fileName); - } - SerializeToFile(fp); - fclose(fp); - } - - template - static bool TryLoadFromFile(const std::string& fileName, - std::shared_ptr* dict) { - FILE* fp = -#ifdef _MSC_VER - // well, the 'GetPlatformString' shall return a 'wstring' - _wfopen(UTF8Util::GetPlatformString(fileName).c_str(), L"rb") -#else - fopen(UTF8Util::GetPlatformString(fileName).c_str(), "rb") -#endif // _MSC_VER - ; - - if (fp == NULL) { - return false; - } - std::shared_ptr loadedDict = DICT::NewFromFile(fp); - fclose(fp); - *dict = loadedDict; - return true; - } - - template - static std::shared_ptr NewFromFile(const std::string& fileName) { - std::shared_ptr dict; - if (!TryLoadFromFile(fileName, &dict)) { - throw FileNotFound(fileName); - } - return dict; - } -}; -} // namespace opencc diff --git a/winlibs/include/opencc/SerializedValues.hpp b/winlibs/include/opencc/SerializedValues.hpp deleted file mode 100644 index c17210ba7..000000000 --- a/winlibs/include/opencc/SerializedValues.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2020 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Binary format for dictionary values serialization. - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT SerializedValues : public SerializableDict { -public: - SerializedValues(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} - - virtual ~SerializedValues() {} - - virtual void SerializeToFile(FILE* fp) const; - - static std::shared_ptr NewFromFile(FILE* fp); - - const LexiconPtr& GetLexicon() const { return lexicon; } - - size_t KeyMaxLength() const; - -private: - LexiconPtr lexicon; - - void ConstructBuffer(std::string* valueBuffer, - std::vector* valueBytes, - uint32_t* valueTotalLength) const; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/SimpleConverter.hpp b/winlibs/include/opencc/SimpleConverter.hpp deleted file mode 100644 index 56932b76c..000000000 --- a/winlibs/include/opencc/SimpleConverter.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#include "Export.hpp" -#include - -#ifndef __OPENCC_SIMPLECONVERTER_HPP_ -#define __OPENCC_SIMPLECONVERTER_HPP_ - -/** - * @defgroup opencc_simple_api OpenCC C++ Simple API - * - * Simple API in C++ language - */ - -namespace opencc { -/** - * A high level converter - * This interface does not require C++11 to compile. - * @ingroup opencc_simple_api - */ -class OPENCC_EXPORT SimpleConverter { -public: - /** - * Constructor of SimpleConverter - * @param configFileName File name of configuration. - */ - SimpleConverter(const std::string& configFileName); - - ~SimpleConverter(); - - /** - * Converts a text - * @param input Text to be converted. - */ - std::string Convert(const std::string& input) const; - - /** - * Converts a text - * @param input A C-Style std::string (terminated by '\0') to be converted. - */ - std::string Convert(const char* input) const; - - /** - * Converts a text - * @param input A C-Style std::string limited by a given length to be - * converted. - * @param length Maximal length in byte of the input std::string. - */ - std::string Convert(const char* input, size_t length) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficient space. - * @param input A C-Style std::string (terminated by '\0') to be converted. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, char* output) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficient space. - * @param input A C-Style std::string limited by a given length to be - * converted. - * @param length Maximal length in byte of the input std::string. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, size_t length, char* output) const; - -private: - const void* internalData; -}; - -} // namespace opencc - -#endif diff --git a/winlibs/include/opencc/TextDict.hpp b/winlibs/include/opencc/TextDict.hpp deleted file mode 100644 index f1cb67d92..000000000 --- a/winlibs/include/opencc/TextDict.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * 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. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Text dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT TextDict : public Dict, public SerializableDict { -public: - /** - * Constructor of TextDict. - * _lexicon must be sorted. - */ - TextDict(const LexiconPtr& _lexicon); - - virtual ~TextDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a TextDict from another dictionary. - */ - static TextDictPtr NewFromDict(const Dict& dict); - - static TextDictPtr NewFromFile(FILE* fp); - - static TextDictPtr NewFromSortedFile(FILE* fp); - -private: - const size_t maxLength; - const LexiconPtr lexicon; -}; -} // namespace opencc diff --git a/winlibs/include/opencc/UTF8StringSlice.hpp b/winlibs/include/opencc/UTF8StringSlice.hpp deleted file mode 100644 index 0c9dfdc6e..000000000 --- a/winlibs/include/opencc/UTF8StringSlice.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2015 Carbo Kuo - * - * 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. - */ - -#include - -#include "Common.hpp" -#include "UTF8Util.hpp" - -namespace opencc { - -namespace internal { - -inline size_t FNVHash(const char* text, const size_t byteLength, - const size_t FNV_prime, const size_t FNV_offset_basis) { - size_t hash = FNV_offset_basis; - for (const char* pstr = text; pstr < text + byteLength; pstr++) { - hash ^= *pstr; - hash *= FNV_prime; - } - return hash; -} - -template size_t FNVHash(const char* text, const size_t byteLength); - -template <> -inline size_t FNVHash<4>(const char* text, const size_t byteLength) { - return FNVHash(text, byteLength, 16777619UL, 2166136261UL); -} - -#if SIZE_MAX == 0xffffffffffffffff -template <> -inline size_t FNVHash<8>(const char* text, const size_t byteLength) { - return FNVHash(text, byteLength, 1099511628211UL, 14695981039346656037UL); -} -#endif - -} // namespace internal - -template class UTF8StringSliceBase { -public: - typedef LENGTH_TYPE LengthType; - - UTF8StringSliceBase(const char* _str) - : str(_str), utf8Length(static_cast(UTF8Util::Length(_str))), - byteLength(static_cast(strlen(_str))) {} - - UTF8StringSliceBase(const char* _str, const LengthType _utf8Length) - : str(_str), utf8Length(_utf8Length) { - CalculateByteLength(); - } - - UTF8StringSliceBase(const char* _str, const LengthType _utf8Length, - const LengthType _byteLength) - : str(_str), utf8Length(_utf8Length), byteLength(_byteLength) { - CalculateByteLength(); - } - - LengthType UTF8Length() const { return utf8Length; } - - LengthType ByteLength() const { return byteLength; } - - UTF8StringSliceBase Left(const LengthType numberOfCharacters) const { - if (numberOfCharacters == UTF8Length()) { - return *this; - } else { - return UTF8StringSliceBase(str, numberOfCharacters); - } - } - - UTF8StringSliceBase Right(const LengthType numberOfCharacters) const { - if (numberOfCharacters == UTF8Length()) { - return *this; - } else { - const char* pstr = str + byteLength; - for (size_t i = 0; i < numberOfCharacters; i++) { - pstr = UTF8Util::PrevChar(pstr); - } - return UTF8StringSliceBase(pstr, numberOfCharacters); - } - } - - UTF8StringSliceBase SubString(const LengthType offset, - const LengthType numberOfCharacters) const { - if (offset == 0) { - return Left(numberOfCharacters); - } else { - const char* pstr = str; - for (size_t i = 0; i < offset; i++) { - pstr = UTF8Util::NextChar(pstr); - } - return UTF8StringSliceBase(pstr, numberOfCharacters); - } - } - - std::string ToString() const { return std::string(str, str + byteLength); } - - const char* CString() const { return str; } - - LengthType CommonPrefixLength(const UTF8StringSliceBase& that) const { - if (str == that.str) { - return (std::min)(utf8Length, that.utf8Length); - } else { - const char* pstr1 = str; - const char* pstr2 = that.str; - for (size_t length = 0; length < utf8Length && length < that.utf8Length; - length++) { - size_t charLen1 = UTF8Util::NextCharLength(pstr1); - size_t charLen2 = UTF8Util::NextCharLength(pstr2); - if (charLen1 != charLen2 || strncmp(pstr1, pstr2, charLen1) != 0) { - return length; - } - pstr1 += charLen1; - pstr2 += charLen2; - } - return 0; - } - } - - void MoveRight() { - if (utf8Length > 0) { - const size_t charLen = UTF8Util::NextCharLength(str); - str += charLen; - utf8Length--; - byteLength -= charLen; - } - } - - void MoveLeft() { - if (utf8Length > 0) { - const size_t charLen = UTF8Util::PrevCharLength(str + byteLength); - utf8Length--; - byteLength -= charLen; - } - } - - int ReverseCompare(const UTF8StringSliceBase& that) const { - const char* pstr1 = str + byteLength; - const char* pstr2 = that.str + that.byteLength; - const size_t length = (std::min)(utf8Length, that.utf8Length); - for (size_t i = 0; i < length; i++) { - const size_t charLen1 = UTF8Util::PrevCharLength(pstr1); - const size_t charLen2 = UTF8Util::PrevCharLength(pstr2); - pstr1 -= charLen1; - pstr2 -= charLen2; - const int cmp = strncmp(pstr1, pstr2, (std::min)(charLen1, charLen2)); - if (cmp < 0) { - return -1; - } else if (cmp > 0) { - return 1; - } else if (charLen1 < charLen2) { - return -1; - } else if (charLen1 > charLen2) { - return 1; - } - } - if (utf8Length < that.utf8Length) { - return -1; - } else if (utf8Length > that.utf8Length) { - return 1; - } else { - return 0; - } - } - - LengthType FindBytePosition(const UTF8StringSliceBase& pattern) const { - return static_cast( - ToString().find(pattern.str, 0, pattern.byteLength)); - } - - bool operator<(const UTF8StringSliceBase& that) const { - return Compare(that) < 0; - } - - bool operator>(const UTF8StringSliceBase& that) const { - return Compare(that) > 0; - } - - bool operator==(const UTF8StringSliceBase& that) const { - return (str == that.str && utf8Length == that.utf8Length) || - Compare(that) == 0; - } - - bool operator!=(const UTF8StringSliceBase& that) const { - return !this->operator==(that); - } - - class Hasher { - public: - size_t operator()(const UTF8StringSliceBase& text) const { - return internal::FNVHash(text.CString(), - text.ByteLength()); - } - }; - -private: - inline int Compare(const UTF8StringSliceBase& that) const { - int cmp = strncmp(str, that.str, (std::min)(byteLength, that.byteLength)); - if (cmp == 0) { - if (utf8Length < that.utf8Length) { - cmp = -1; - } else if (utf8Length > that.utf8Length) { - cmp = 1; - } else { - cmp = 0; - } - } - return cmp; - } - - void CalculateByteLength() { - const char* pstr = str; - for (size_t i = 0; i < utf8Length; i++) { - pstr = UTF8Util::NextChar(pstr); - } - byteLength = static_cast(pstr - str); - } - - const char* str; - LengthType utf8Length; - LengthType byteLength; -}; - -typedef UTF8StringSliceBase UTF8StringSlice; - -template -std::ostream& operator<<(::std::ostream& os, - const UTF8StringSliceBase& str) { - return os << str.ToString(); -} - -} // namespace opencc diff --git a/winlibs/include/opencc/UTF8Util.hpp b/winlibs/include/opencc/UTF8Util.hpp deleted file mode 100644 index 9d3e39b8d..000000000 --- a/winlibs/include/opencc/UTF8Util.hpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2013 Carbo Kuo - * - * 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. - */ - -#pragma once - -#ifdef _MSC_VER -#define NOMINMAX -#include -#undef NOMINMAX -#endif // _MSC_VER - -#include - -#include "Common.hpp" -#include "Exception.hpp" - -namespace opencc { -/** - * UTF8 std::string utilities - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT UTF8Util { -public: - /** - * Detect UTF8 BOM and skip it. - */ - static void SkipUtf8Bom(FILE* fp); - - /** - * Returns the length in byte for the next UTF8 character. - * On error returns 0. - */ - static size_t NextCharLengthNoException(const char* str) { - char ch = *str; - if ((ch & 0xF0) == 0xE0) { - return 3; - } else if ((ch & 0x80) == 0x00) { - return 1; - } else if ((ch & 0xE0) == 0xC0) { - return 2; - } else if ((ch & 0xF8) == 0xF0) { - return 4; - } else if ((ch & 0xFC) == 0xF8) { - return 5; - } else if ((ch & 0xFE) == 0xFC) { - return 6; - } - return 0; - } - - /** - * Returns the length in byte for the next UTF8 character. - */ - static size_t NextCharLength(const char* str) { - size_t length = NextCharLengthNoException(str); - if (length == 0) { - throw InvalidUTF8(str); - } - return length; - } - - /** - * Returns the length in byte for the previous UTF8 character. - */ - static size_t PrevCharLength(const char* str) { - { - const size_t length = NextCharLengthNoException(str - 3); - if (length == 3) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 1); - if (length == 1) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 2); - if (length == 2) { - return length; - } - } - for (size_t i = 4; i <= 6; i++) { - const size_t length = NextCharLengthNoException(str - i); - if (length == i) { - return length; - } - } - throw InvalidUTF8(str); - } - - /** - * Returns the char* pointer over the next UTF8 character. - */ - static const char* NextChar(const char* str) { - return str + NextCharLength(str); - } - - /** - * Move the char* pointer before the previous UTF8 character. - */ - static const char* PrevChar(const char* str) { - return str - PrevCharLength(str); - } - - /** - * Returns the UTF8 length of a valid UTF8 std::string. - */ - static size_t Length(const char* str) { - size_t length = 0; - while (*str != '\0') { - str = NextChar(str); - length++; - } - return length; - } - - /** - * Finds a character in the same line. - * @param str The text to be searched in. - * @param ch The character to find. - * @return The pointer that points to the found chacter in str or EOL/EOF. - */ - static const char* FindNextInline(const char* str, const char ch) { - while (!IsLineEndingOrFileEnding(*str) && *str != ch) { - str = NextChar(str); - } - return str; - } - - /** - * Returns true if the character is a line ending or end of file. - */ - static bool IsLineEndingOrFileEnding(const char ch) { - return ch == '\0' || ch == '\n' || ch == '\r'; - } - - /** - * Copies a substring with given length to a new string. - */ - static std::string FromSubstr(const char* str, size_t length) { - std::string newStr; - newStr.resize(length); - strncpy(const_cast(newStr.c_str()), str, length); - return newStr; - } - - /** - * Returns true if the given std::string is longer or as long as the given - * length. - */ - static bool NotShorterThan(const char* str, size_t byteLength) { - while (byteLength > 0) { - if (*str == '\0') { - return false; - } - byteLength--; - str++; - } - return true; - } - - /** - * Truncates a std::string with a maximal length in byte. - * No UTF8 character will be broken. - */ - static std::string TruncateUTF8(const char* str, size_t maxByteLength) { - std::string wordTrunc; - if (NotShorterThan(str, maxByteLength)) { - size_t len = 0; - const char* pStr = str; - for (;;) { - const size_t charLength = NextCharLength(pStr); - if (len + charLength > maxByteLength) { - break; - } - pStr += charLength; - len += charLength; - } - wordTrunc = FromSubstr(str, len); - } else { - wordTrunc = str; - } - return wordTrunc; - } - - /** - * Replaces all patterns in a std::string in place. - */ - static void ReplaceAll(std::string& str, const char* from, const char* to) { - std::string::size_type pos = 0; - std::string::size_type fromLen = strlen(from); - std::string::size_type toLen = strlen(to); - while ((pos = str.find(from, pos)) != std::string::npos) { - str.replace(pos, fromLen, to); - pos += toLen; - } - } - - /** - * Joins a std::string vector in to a std::string with a separator. - */ - static std::string Join(const std::vector& strings, - const std::string& separator) { - std::ostringstream buffer; - bool first = true; - for (const auto& str : strings) { - if (!first) { - buffer << separator; - } - buffer << str; - first = false; - } - return buffer.str(); - } - - /** - * Joins a std::string vector in to a std::string. - */ - static std::string Join(const std::vector& strings) { - std::ostringstream buffer; - for (const auto& str : strings) { - buffer << str; - } - return buffer.str(); - } - - static void GetByteMap(const char* str, const size_t utf8Length, - std::vector* byteMap) { - if (byteMap->size() < utf8Length) { - byteMap->resize(utf8Length); - } - const char* pstr = str; - for (size_t i = 0; i < utf8Length; i++) { - (*byteMap)[i] = pstr - str; - pstr = NextChar(pstr); - } - } - -#ifdef _MSC_VER - static std::wstring GetPlatformString(const std::string& str) { - return U8ToU16(str); - } -#else - static std::string GetPlatformString(const std::string& str) { return str; } -#endif // _MSC_VER - -#ifdef _MSC_VER - static std::string U16ToU8(const std::wstring& wstr) { - std::string ret; - int length = static_cast(wstr.length()); - int convcnt = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, NULL, 0, - NULL, NULL); - if (convcnt > 0) { - ret.resize(convcnt); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, &ret[0], convcnt, - NULL, NULL); - } - return ret; - } - - static std::wstring U8ToU16(const std::string& str) { - std::wstring ret; - int length = static_cast(str.length()); - int convcnt = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, NULL, 0); - if (convcnt > 0) { - ret.resize(convcnt); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &ret[0], convcnt); - } - return ret; - } -#endif // _MSC_VER -}; -} // namespace opencc diff --git a/winlibs/include/opencc/opencc.h b/winlibs/include/opencc/opencc.h deleted file mode 100644 index bc3a9e97b..000000000 --- a/winlibs/include/opencc/opencc.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * 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. - */ - -#ifndef __OPENCC_H_ -#define __OPENCC_H_ - -#ifdef __cplusplus - -#include "Export.hpp" -#include "SimpleConverter.hpp" -#include - -extern "C" { -#else -#include -#endif - -#ifndef OPENCC_EXPORT -#define OPENCC_EXPORT -#endif - -/** - * @defgroup opencc_c_api OpenCC C API - * - * API in C language - */ - -/** - * Filename of default Simplified to Traditional configuration - * - * @ingroup opencc_c_api - */ -#define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json" - -/** - * Filename of default Traditional to Simplified configuration - * - * @ingroup opencc_c_api - */ -#define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json" - -/** - * Type of opencc descriptor - * - * @ingroup opencc_c_api - */ -typedef void* opencc_t; - -/** - * Makes an instance of opencc - * - * @param configFileName Location of configuration file. If this is set to NULL, - * OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. - * @return A description pointer of the newly allocated instance of - * opencc. On error the return value will be (opencc_t) -1. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT opencc_t opencc_open(const char* configFileName); -#ifdef _MSC_VER -/** - * Makes an instance of opencc (wide char / Unicode) - * - * @param configFileName Location of configuration file. If this is set to NULL, - * OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. - * @return A description pointer of the newly allocated instance of - * opencc. On error the return value will be (opencc_t) -1. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT opencc_t opencc_open_w(const wchar_t* configFileName); -#endif /* _MSC_VER */ - -/** - * Destroys an instance of opencc - * - * @param opencc The description pointer. - * @return 0 on success or non-zero number on failure. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT int opencc_close(opencc_t opencc); - -/** - * Converts UTF-8 std::string - * - * @param opencc The opencc description pointer. - * @param input The UTF-8 encoded std::string. - * @param length The maximum length in byte to convert. If length is (size_t)-1, - * the whole std::string (terminated by '\0') will be converted. - * @param output The buffer to store converted text. You MUST make sure this - * buffer has sufficient space. - * - * @return The length of converted std::string or (size_t)-1 on error. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc, - const char* input, - size_t length, char* output); - -/** - * Converts UTF-8 std::string - * This function returns an allocated C-Style std::string, which stores - * the converted std::string. - * You MUST call opencc_convert_utf8_free() to release allocated memory. - * - * @param opencc The opencc description pointer. - * @param input The UTF-8 encoded std::string. - * @param length The maximum length in byte to convert. If length is (size_t)-1, - * the whole std::string (terminated by '\0') will be converted. - * - * @return The newly allocated UTF-8 std::string that stores text - * converted, or NULL on error. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc, const char* input, - size_t length); - -/** - * Releases allocated buffer by opencc_convert_utf8 - * - * @param str Pointer to the allocated std::string buffer by - * opencc_convert_utf8. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT void opencc_convert_utf8_free(char* str); - -/** - * Returns the last error message - * - * Note that this function is the only one which is NOT thread-safe. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT const char* opencc_error(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -/** - * @defgroup opencc_cpp_api OpenCC C++ Comprehensive API - * - * Comprehensive API in C++ language - */ - -#endif diff --git a/winlibs/include/opencc/opencc_config.h b/winlibs/include/opencc/opencc_config.h deleted file mode 100644 index 711f432c6..000000000 --- a/winlibs/include/opencc/opencc_config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2021 Carbo Kuo - * - * 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. - */ - -#pragma once - -#define OPENCC_ENABLE_DARTS diff --git a/winlibs/include/vorbis/codec.h b/winlibs/include/vorbis/codec.h deleted file mode 100644 index f8a912bc2..000000000 --- a/winlibs/include/vorbis/codec.h +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - - ******************************************************************** - - function: libvorbis codec headers - - ********************************************************************/ - -#ifndef _vorbis_codec_h_ -#define _vorbis_codec_h_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include - -typedef struct vorbis_info{ - int version; - int channels; - long rate; - - /* The below bitrate declarations are *hints*. - Combinations of the three values carry the following implications: - - all three set to the same value: - implies a fixed rate bitstream - only nominal set: - implies a VBR stream that averages the nominal bitrate. No hard - upper/lower limit - upper and or lower set: - implies a VBR bitstream that obeys the bitrate limits. nominal - may also be set to give a nominal rate. - none set: - the coder does not care to speculate. - */ - - long bitrate_upper; - long bitrate_nominal; - long bitrate_lower; - long bitrate_window; - - void *codec_setup; -} vorbis_info; - -/* vorbis_dsp_state buffers the current vorbis audio - analysis/synthesis state. The DSP state belongs to a specific - logical bitstream ****************************************************/ -typedef struct vorbis_dsp_state{ - int analysisp; - vorbis_info *vi; - - float **pcm; - float **pcmret; - int pcm_storage; - int pcm_current; - int pcm_returned; - - int preextrapolate; - int eofflag; - - long lW; - long W; - long nW; - long centerW; - - ogg_int64_t granulepos; - ogg_int64_t sequence; - - ogg_int64_t glue_bits; - ogg_int64_t time_bits; - ogg_int64_t floor_bits; - ogg_int64_t res_bits; - - void *backend_state; -} vorbis_dsp_state; - -typedef struct vorbis_block{ - /* necessary stream state for linking to the framing abstraction */ - float **pcm; /* this is a pointer into local storage */ - oggpack_buffer opb; - - long lW; - long W; - long nW; - int pcmend; - int mode; - - int eofflag; - ogg_int64_t granulepos; - ogg_int64_t sequence; - vorbis_dsp_state *vd; /* For read-only access of configuration */ - - /* local storage to avoid remallocing; it's up to the mapping to - structure it */ - void *localstore; - long localtop; - long localalloc; - long totaluse; - struct alloc_chain *reap; - - /* bitmetrics for the frame */ - long glue_bits; - long time_bits; - long floor_bits; - long res_bits; - - void *internal; - -} vorbis_block; - -/* vorbis_block is a single block of data to be processed as part of -the analysis/synthesis stream; it belongs to a specific logical -bitstream, but is independent from other vorbis_blocks belonging to -that logical bitstream. *************************************************/ - -struct alloc_chain{ - void *ptr; - struct alloc_chain *next; -}; - -/* vorbis_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). vorbis_info and substructures are in backends.h. -*********************************************************************/ - -/* the comments are not part of vorbis_info so that vorbis_info can be - static storage */ -typedef struct vorbis_comment{ - /* unlimited user comment fields. libvorbis writes 'libvorbis' - whatever vendor is set to in encode */ - char **user_comments; - int *comment_lengths; - int comments; - char *vendor; - -} vorbis_comment; - - -/* libvorbis encodes in two abstraction layers; first we perform DSP - and produce a packet (see docs/analysis.txt). The packet is then - coded into a framed OggSquish bitstream by the second layer (see - docs/framing.txt). Decode is the reverse process; we sync/frame - the bitstream and extract individual packets, then decode the - packet back into PCM audio. - - The extra framing/packetizing is used in streaming formats, such as - files. Over the net (such as with UDP), the framing and - packetization aren't necessary as they're provided by the transport - and the streaming layer is not used */ - -/* Vorbis PRIMITIVES: general ***************************************/ - -extern void vorbis_info_init(vorbis_info *vi); -extern void vorbis_info_clear(vorbis_info *vi); -extern int vorbis_info_blocksize(vorbis_info *vi,int zo); -extern void vorbis_comment_init(vorbis_comment *vc); -extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); -extern void vorbis_comment_add_tag(vorbis_comment *vc, - const char *tag, const char *contents); -extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); -extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); -extern void vorbis_comment_clear(vorbis_comment *vc); - -extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); -extern int vorbis_block_clear(vorbis_block *vb); -extern void vorbis_dsp_clear(vorbis_dsp_state *v); -extern double vorbis_granule_time(vorbis_dsp_state *v, - ogg_int64_t granulepos); - -extern const char *vorbis_version_string(void); - -/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ - -extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); -extern int vorbis_analysis_headerout(vorbis_dsp_state *v, - vorbis_comment *vc, - ogg_packet *op, - ogg_packet *op_comm, - ogg_packet *op_code); -extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); - -extern int vorbis_bitrate_addblock(vorbis_block *vb); -extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, - ogg_packet *op); - -/* Vorbis PRIMITIVES: synthesis layer *******************************/ -extern int vorbis_synthesis_idheader(ogg_packet *op); -extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, - ogg_packet *op); - -extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_synthesis_restart(vorbis_dsp_state *v); -extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); -extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); - -extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); -extern int vorbis_synthesis_halfrate_p(vorbis_info *v); - -/* Vorbis ERRORS and return codes ***********************************/ - -#define OV_FALSE -1 -#define OV_EOF -2 -#define OV_HOLE -3 - -#define OV_EREAD -128 -#define OV_EFAULT -129 -#define OV_EIMPL -130 -#define OV_EINVAL -131 -#define OV_ENOTVORBIS -132 -#define OV_EBADHEADER -133 -#define OV_EVERSION -134 -#define OV_ENOTAUDIO -135 -#define OV_EBADPACKET -136 -#define OV_EBADLINK -137 -#define OV_ENOSEEK -138 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/winlibs/include/vorbis/vorbisenc.h b/winlibs/include/vorbis/vorbisenc.h deleted file mode 100644 index 085b15e66..000000000 --- a/winlibs/include/vorbis/vorbisenc.h +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: vorbis encode-engine setup - - ********************************************************************/ - -/** \file - * Libvorbisenc is a convenient API for setting up an encoding - * environment using libvorbis. Libvorbisenc encapsulates the - * actions needed to set up the encoder properly. - */ - -#ifndef _OV_ENC_H_ -#define _OV_ENC_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "codec.h" - -/** - * This is the primary function within libvorbisenc for setting up managed - * bitrate modes. - * - * Before this function is called, the \ref vorbis_info - * struct should be initialized by using vorbis_info_init() from the libvorbis - * API. After encoding, vorbis_info_clear() should be called. - * - * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set - * constraints for the encoded file. This function uses these settings to - * select the appropriate encoding mode and set it up. - * - * \param vi Pointer to an initialized \ref vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. - * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. - * \param min_bitrate Desired minimum bitrate. -1 indicates unset. - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success. - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. - */ -extern int vorbis_encode_init(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate); - -/** - * This function performs step-one of a three-step bitrate-managed encode - * setup. It functions similarly to the one-step setup performed by \ref - * vorbis_encode_init but allows an application to make further encode setup - * tweaks using \ref vorbis_encode_ctl before finally calling \ref - * vorbis_encode_setup_init to complete the setup process. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set - * constraints for the encoded file. This function uses these settings to - * select the appropriate encoding mode and set it up. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. - * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. - * \param min_bitrate Desired minimum bitrate. -1 indicates unset. - * - * \return Zero for success, and negative for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. - */ -extern int vorbis_encode_setup_managed(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate); - -/** - * This function performs step-one of a three-step variable bitrate - * (quality-based) encode setup. It functions similarly to the one-step setup - * performed by \ref vorbis_encode_init_vbr() but allows an application to - * make further encode setup tweaks using \ref vorbis_encode_ctl() before - * finally calling \ref vorbis_encode_setup_init to complete the setup - * process. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using \ref vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. - */ -extern int vorbis_encode_setup_vbr(vorbis_info *vi, - long channels, - long rate, - - float quality - ); - -/** - * This is the primary function within libvorbisenc for setting up variable - * bitrate ("quality" based) modes. - * - * - * Before this function is called, the vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). - * - * - * \return Zero for success, or a negative number for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. - */ -extern int vorbis_encode_init_vbr(vorbis_info *vi, - long channels, - long rate, - - float base_quality - ); - -/** - * This function performs the last stage of three-step encoding setup, as - * described in the API overview under managed bitrate modes. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API, one of - * \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to - * initialize the high-level encoding setup, and \ref vorbis_encode_ctl() - * called if necessary to make encoding setup changes. - * vorbis_encode_setup_init() finalizes the highlevel encoding structure into - * a complete encoding setup after which the application may make no further - * setup changes. - * - * After encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized \ref vorbis_info struct. - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success. - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * - * \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first - * calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to - * initialize the high-level encoding setup - * - */ -extern int vorbis_encode_setup_init(vorbis_info *vi); - -/** - * This function implements a generic interface to miscellaneous encoder - * settings similar to the classic UNIX 'ioctl()' system call. Applications - * may use vorbis_encode_ctl() to query or set bitrate management or quality - * mode details by using one of several \e request arguments detailed below. - * vorbis_encode_ctl() must be called after one of - * vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used - * to modify settings, \ref vorbis_encode_ctl() must be called before \ref - * vorbis_encode_setup_init(). - * - * \param vi Pointer to an initialized vorbis_info struct. - * - * \param number Specifies the desired action; See \ref encctlcodes "the list - * of available requests". - * - * \param arg void * pointing to a data structure matching the request - * argument. - * - * \retval 0 Success. Any further return information (such as the result of a - * query) is placed into the storage pointed to by *arg. - * - * \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after - * calling vorbis_encode_setup_init(). - * - * \retval OV_EIMPL Unimplemented or unknown request - */ -extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); - -/** - * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl() - * with the \ref ovectl_ratemanage2_arg struct and \ref - * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code. - * - * The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() - * and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref - * OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to - * query and modify specifics of the encoder's bitrate management - * configuration. -*/ -struct ovectl_ratemanage_arg { - int management_active; /**< nonzero if bitrate management is active*/ -/** hard lower limit (in kilobits per second) below which the stream bitrate - will never be allowed for any given bitrate_hard_window seconds of time.*/ - long bitrate_hard_min; -/** hard upper limit (in kilobits per second) above which the stream bitrate - will never be allowed for any given bitrate_hard_window seconds of time.*/ - long bitrate_hard_max; -/** the window period (in seconds) used to regulate the hard bitrate minimum - and maximum*/ - double bitrate_hard_window; -/** soft lower limit (in kilobits per second) below which the average bitrate - tracker will start nudging the bitrate higher.*/ - long bitrate_av_lo; -/** soft upper limit (in kilobits per second) above which the average bitrate - tracker will start nudging the bitrate lower.*/ - long bitrate_av_hi; -/** the window period (in seconds) used to regulate the average bitrate - minimum and maximum.*/ - double bitrate_av_window; -/** Regulates the relative centering of the average and hard windows; in - libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but - followed the average window regulation. In libvorbis 1.1 a bit-reservoir - interface replaces the old windowing interface; the older windowing - interface is simulated and this field has no effect.*/ - double bitrate_av_window_center; -}; - -/** - * \name struct ovectl_ratemanage2_arg - * - * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and - * the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to - * query and modify specifics of the encoder's bitrate management - * configuration. - * -*/ -struct ovectl_ratemanage2_arg { - int management_active; /**< nonzero if bitrate management is active */ -/** Lower allowed bitrate limit in kilobits per second */ - long bitrate_limit_min_kbps; -/** Upper allowed bitrate limit in kilobits per second */ - long bitrate_limit_max_kbps; - long bitrate_limit_reservoir_bits; /**struct ovectl_ratemanage2_arg * - * - * Used to query the current encoder bitrate management setting. Also used to - * initialize fields of an ovectl_ratemanage2_arg structure for use with - * \ref OV_ECTL_RATEMANAGE2_SET. - */ -#define OV_ECTL_RATEMANAGE2_GET 0x14 - -/** - * Set the current encoder bitrate management settings. - * - * Argument: struct ovectl_ratemanage2_arg * - * - * Used to set the current encoder bitrate management settings to the values - * listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable - * bitrate management. -*/ -#define OV_ECTL_RATEMANAGE2_SET 0x15 - -/** - * Returns the current encoder hard-lowpass setting (kHz) in the double - * pointed to by arg. - * - * Argument: double * -*/ -#define OV_ECTL_LOWPASS_GET 0x20 - -/** - * Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid - * lowpass settings range from 2 to 99. - * - * Argument: double * -*/ -#define OV_ECTL_LOWPASS_SET 0x21 - -/** - * Returns the current encoder impulse block setting in the double pointed - * to by arg. - * - * Argument: double * -*/ -#define OV_ECTL_IBLOCK_GET 0x30 - -/** - * Sets the impulse block bias to the the value pointed to by arg. - * - * Argument: double * - * - * Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will - * direct to encoder to use more bits when incoding short blocks that contain - * strong impulses, thus improving the accuracy of impulse encoding. - */ -#define OV_ECTL_IBLOCK_SET 0x31 - -/** - * Returns the current encoder coupling setting in the int pointed - * to by arg. - * - * Argument: int * -*/ -#define OV_ECTL_COUPLING_GET 0x40 - -/** - * Enables/disables channel coupling in multichannel encoding according to arg. - * - * Argument: int * - * - * Zero disables channel coupling for multichannel inputs, nonzer enables - * channel coupling. Setting has no effect on monophonic encoding or - * multichannel counts that do not offer coupling. At present, coupling is - * available for stereo and 5.1 encoding. - */ -#define OV_ECTL_COUPLING_SET 0x41 - - /* deprecated rate management supported only for compatibility */ - -/** - * Old interface to querying bitrate management settings. - * - * Deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_GET 0x10 -/** - * Old interface to modifying bitrate management settings. - * - * deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_SET 0x11 -/** - * Old interface to setting average-bitrate encoding mode. - * - * Deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_AVG 0x12 -/** - * Old interface to setting bounded-bitrate encoding modes. - * - * deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_HARD 0x13 - -/*@}*/ - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/winlibs/include/vorbis/vorbisfile.h b/winlibs/include/vorbis/vorbisfile.h deleted file mode 100644 index 3d65393f5..000000000 --- a/winlibs/include/vorbis/vorbisfile.h +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - - ********************************************************************/ - -#ifndef _OV_FILE_H_ -#define _OV_FILE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include "codec.h" - -/* The function prototypes for the callbacks are basically the same as for - * the stdio functions fread, fseek, fclose, ftell. - * The one difference is that the FILE * arguments have been replaced with - * a void * - this is to be used as a pointer to whatever internal data these - * functions might need. In the stdio case, it's just a FILE * cast to a void * - * - * If you use other functions, check the docs for these functions and return - * the right values. For seek_func(), you *MUST* return -1 if the stream is - * unseekable - */ -typedef struct { - size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); - int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); - int (*close_func) (void *datasource); - long (*tell_func) (void *datasource); -} ov_callbacks; - -#ifndef OV_EXCLUDE_STATIC_CALLBACKS - -/* a few sets of convenient callbacks, especially for use under - * Windows where ov_open_callbacks() should always be used instead of - * ov_open() to avoid problems with incompatible crt.o version linking - * issues. */ - -static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ - if(f==NULL)return(-1); - -#ifdef __MINGW32__ - return fseeko64(f,off,whence); -#elif defined (_WIN32) - return _fseeki64(f,off,whence); -#else - return fseek(f,off,whence); -#endif -} - -/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as - * static data. That means that every file which includes this header - * will get its own copy of these structs whether it uses them or - * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS. - * These static symbols are essential on platforms such as Windows on - * which several different versions of stdio support may be linked to - * by different DLLs, and we need to be certain we know which one - * we're using (the same one as the main application). - */ - -static ov_callbacks OV_CALLBACKS_DEFAULT = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) fclose, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) NULL, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) fclose, - (long (*)(void *)) NULL -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) NULL, - (long (*)(void *)) NULL -}; - -#endif - -#define NOTOPEN 0 -#define PARTOPEN 1 -#define OPENED 2 -#define STREAMSET 3 -#define INITSET 4 - -typedef struct OggVorbis_File { - void *datasource; /* Pointer to a FILE *, etc. */ - int seekable; - ogg_int64_t offset; - ogg_int64_t end; - ogg_sync_state oy; - - /* If the FILE handle isn't seekable (eg, a pipe), only the current - stream appears */ - int links; - ogg_int64_t *offsets; - ogg_int64_t *dataoffsets; - long *serialnos; - ogg_int64_t *pcmlengths; /* overloaded to maintain binary - compatibility; x2 size, stores both - beginning and end values */ - vorbis_info *vi; - vorbis_comment *vc; - - /* Decoding working state local storage */ - ogg_int64_t pcm_offset; - int ready_state; - long current_serialno; - int current_link; - - double bittrack; - double samptrack; - - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - ov_callbacks callbacks; - -} OggVorbis_File; - - -extern int ov_clear(OggVorbis_File *vf); -extern int ov_fopen(const char *path,OggVorbis_File *vf); -extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); - -extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); -extern int ov_test_open(OggVorbis_File *vf); - -extern long ov_bitrate(OggVorbis_File *vf,int i); -extern long ov_bitrate_instant(OggVorbis_File *vf); -extern long ov_streams(OggVorbis_File *vf); -extern long ov_seekable(OggVorbis_File *vf); -extern long ov_serialnumber(OggVorbis_File *vf,int i); - -extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); -extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); -extern double ov_time_total(OggVorbis_File *vf,int i); - -extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page(OggVorbis_File *vf,double pos); - -extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); - -extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); -extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); -extern double ov_time_tell(OggVorbis_File *vf); - -extern vorbis_info *ov_info(OggVorbis_File *vf,int link); -extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); - -extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, - int *bitstream); -extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream, - void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); -extern long ov_read(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream); -extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); - -extern int ov_halfrate(OggVorbis_File *vf,int flag); -extern int ov_halfrate_p(OggVorbis_File *vf); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/winlibs/include/xapian.h b/winlibs/include/xapian.h deleted file mode 100644 index ae2f92e41..000000000 --- a/winlibs/include/xapian.h +++ /dev/null @@ -1,150 +0,0 @@ -/** @file - * @brief Public interfaces for the Xapian library. - */ -// Copyright (C) 2003,2004,2005,2007,2008,2009,2010,2012,2013,2015,2016,2019 Olly Betts -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_XAPIAN_H -#define XAPIAN_INCLUDED_XAPIAN_H - -#ifdef slots -# ifdef Q_OBJECT -// Qt headers '#define slots' by default, which clashes with us using it as a -// class member name. Including first is a simple workaround, or -// you can use 'no_keywords' to stop Qt polluting the global macro namespace, -// as described here: -// -// https://doc.qt.io/qt-5/signalsandslots.html#using-qt-with-3rd-party-signals-and-slots -# error Include before Qt headers, or put 'CONFIG += no_keywords' in your .pro file and use Q_SLOTS instead of slots, etc -# endif -# ifdef WT_API -// Argh, copycat polluters! -# error Include before Wt headers, or define WT_NO_SLOT_MACROS to stop Wt from defining the macros 'slots' and 'SLOT()' -# endif -#endif - -// Define so that deprecation warnings are given to API users, but not -// while building the library. -#define XAPIAN_IN_XAPIAN_H - -// Set defines for library version and check C++ ABI versions match. -#include - -// Types -#include - -// Function attributes -#include - -// Constants -#include - -// Exceptions -#include -#include - -// Access to databases, documents, etc. -#include -#include -#include -#include -#include -#include -#include - -// Indexing -#include - -// Searching -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Stemming -#include - -// Subclass registry -#include - -// Unicode support -#include - -// Geospatial -#include - -// Database compaction and merging -#include - -// ELF visibility annotations for GCC. -#include - -// Mechanism for accessing a struct of constant information -#include - -/// The Xapian namespace contains public interfaces for the Xapian library. -namespace Xapian { - -// Functions returning library version: - -/** Report the version string of the library which the program is linked with. - * - * This may be different to the version compiled against (given by - * XAPIAN_VERSION) if shared libraries are being used. - */ -inline const char* version_string() { - return Internal::get_constinfo_()->str; -} - -/** Report the major version of the library which the program is linked with. - * - * This may be different to the version compiled against (given by - * XAPIAN_MAJOR_VERSION) if shared libraries are being used. - */ -inline int major_version() { - return Internal::get_constinfo_()->major; -} - -/** Report the minor version of the library which the program is linked with. - * - * This may be different to the version compiled against (given by - * XAPIAN_MINOR_VERSION) if shared libraries are being used. - */ -inline int minor_version() { - return Internal::get_constinfo_()->minor; -} - -/** Report the revision of the library which the program is linked with. - * - * This may be different to the version compiled against (given by - * XAPIAN_REVISION) if shared libraries are being used. - */ -inline int revision() { - return Internal::get_constinfo_()->revision; -} - -} - -#undef XAPIAN_IN_XAPIAN_H - -#endif /* XAPIAN_INCLUDED_XAPIAN_H */ diff --git a/winlibs/include/xapian/attributes.h b/winlibs/include/xapian/attributes.h deleted file mode 100644 index d3948390f..000000000 --- a/winlibs/include/xapian/attributes.h +++ /dev/null @@ -1,76 +0,0 @@ -/** @file - * @brief Compiler attribute macros - */ -// Copyright (C) 2012,2013,2014,2015 Olly Betts -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_ATTRIBUTES_H -#define XAPIAN_INCLUDED_ATTRIBUTES_H - -#if __cplusplus >= 201103L || (defined _MSC_VER && _MSC_VER >= 1900) -// C++11 has noexcept for marking a function which shouldn't throw. -// -// You need a C++11 compiler to build Xapian, but we still support using a -// non-C++11 compiler to build code which uses Xapian (one reason is that -// currently you need an option to enable C++11 support for most -// compilers). Once we require C++11 for using Xapian, XAPIAN_NOTHROW can go -// away. -// -// We can't simply just add noexcept via XAPIAN_NOTHROW as noexcept has -// to be added to all declarations, whereas the GCC attribute can't be used on -// a function definition. So for now, XAPIAN_NOTHROW() goes around -// declarations, and XAPIAN_NOEXCEPT needs to be explicitly added to -// definitions. -# define XAPIAN_NOEXCEPT noexcept -#else -# define XAPIAN_NOEXCEPT -#endif - -#ifdef __GNUC__ - -// __attribute__((__const__)) is available at least as far back as GCC 2.95. -# define XAPIAN_CONST_FUNCTION __attribute__((__const__)) -// __attribute__((__pure__)) is available from GCC 2.96 onwards. -# define XAPIAN_PURE_FUNCTION __attribute__((__pure__)) -// __attribute__((__nothrow__)) is available from GCC 3.3 onwards. -# if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) -# define XAPIAN_NOTHROW(D) D XAPIAN_NOEXCEPT __attribute__((__nothrow__)) -# endif - -#else - -/** A function which does not examine any values except its arguments and has - * no effects except its return value. - * - * This means the compiler can perform CSE (common subexpression elimination) - * on calls to such a function with the same arguments, and also completely - * eliminate calls to this function when the return value isn't used. - */ -# define XAPIAN_CONST_FUNCTION - -/** Like XAPIAN_CONST_FUNCTION, but such a function can also examine global - * memory, perhaps via pointer or reference parameters. - */ -# define XAPIAN_PURE_FUNCTION - -#endif - -#ifndef XAPIAN_NOTHROW -/** A function or method which will never throw an exception. */ -# define XAPIAN_NOTHROW(D) D XAPIAN_NOEXCEPT -#endif - -#endif // XAPIAN_INCLUDED_ATTRIBUTES_H diff --git a/winlibs/include/xapian/compactor.h b/winlibs/include/xapian/compactor.h deleted file mode 100644 index 3c9c9cd39..000000000 --- a/winlibs/include/xapian/compactor.h +++ /dev/null @@ -1,189 +0,0 @@ -/** @file - * @brief Compact a database, or merge and compact several. - */ -/* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010,2011,2013,2014,2015,2018 Olly Betts - * Copyright (C) 2008 Lemur Consulting Ltd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_COMPACTOR_H -#define XAPIAN_INCLUDED_COMPACTOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include -#include -#include - -namespace Xapian { - -class Database; - -/** Compact a database, or merge and compact several. - */ -class XAPIAN_VISIBILITY_DEFAULT Compactor { - public: - /// Class containing the implementation. - class Internal; - - /** Compaction level. */ - typedef enum { - /** Don't split items unnecessarily. */ - STANDARD = 0, - /** Split items whenever it saves space (the default). */ - FULL = 1, - /** Allow oversize items to save more space (not recommended if you - * ever plan to update the compacted database). */ - FULLER = 2 - } compaction_level; - - private: - /// @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - void set_flags_(unsigned flags, unsigned mask = 0); - - public: - Compactor(); - - virtual ~Compactor(); - - /** Set the block size to use for tables in the output database. - * - * @param block_size The block size to use. Valid block sizes are - * currently powers of two between 2048 and 65536, - * with the default being 8192, but the valid - * sizes and default may change in the future. - */ - XAPIAN_DEPRECATED(void set_block_size(size_t block_size)); - - /** Set whether to preserve existing document id values. - * - * @param renumber The default is true, which means that document ids will - * be renumbered - currently by applying the same offset - * to all the document ids in a particular source - * database. - * - * If false, then the document ids must be unique over all - * source databases. Currently the ranges of document ids - * in each source must not overlap either, though this - * restriction may be removed in the future. - */ - XAPIAN_DEPRECATED(void set_renumber(bool renumber)) { - set_flags_(renumber ? 0 : DBCOMPACT_NO_RENUMBER, - ~unsigned(DBCOMPACT_NO_RENUMBER)); - } - - /** Set whether to merge postlists in multiple passes. - * - * @param multipass If true and merging more than 3 databases, - * merge the postlists in multiple passes, which is generally faster but - * requires more disk space for temporary files. By default we don't do - * this. - */ - XAPIAN_DEPRECATED(void set_multipass(bool multipass)) { - set_flags_(multipass ? DBCOMPACT_MULTIPASS : 0, - ~unsigned(DBCOMPACT_MULTIPASS)); - } - - /** Set the compaction level. - * - * @param compaction Available values are: - * - Xapian::Compactor::STANDARD - Don't split items unnecessarily. - * - Xapian::Compactor::FULL - Split items whenever it saves space - * (the default). - * - Xapian::Compactor::FULLER - Allow oversize items to save more space - * (not recommended if you ever plan to update the compacted database). - */ - XAPIAN_DEPRECATED(void set_compaction_level(compaction_level compaction)) { - set_flags_(compaction, ~unsigned(STANDARD|FULL|FULLER)); - } - - /** Set where to write the output. - * - * @deprecated Use Database::compact(destdir[, compactor]) instead. - * - * @param destdir Output path. This can be the same as an input if that - * input is a stub database (in which case the database(s) - * listed in the stub will be compacted to a new database - * and then the stub will be atomically updated to point - * to this new database). - */ - XAPIAN_DEPRECATED(void set_destdir(const std::string & destdir)); - - /** Add a source database. - * - * @deprecated Use Database::compact(destdir[, compactor]) instead. - * - * @param srcdir The path to the source database to add. - */ - XAPIAN_DEPRECATED(void add_source(const std::string & srcdir)); - - /** Perform the actual compaction/merging operation. - * - * @deprecated Use Database::compact(destdir[, compactor]) instead. - */ - XAPIAN_DEPRECATED(void compact()); - - /** Update progress. - * - * Subclass this method if you want to get progress updates during - * compaction. This is called for each table first with empty status, - * And then one or more times with non-empty status. - * - * The default implementation does nothing. - * - * @param table The table currently being compacted. - * @param status A status message. - */ - virtual void - set_status(const std::string & table, const std::string & status); - - /** Resolve multiple user metadata entries with the same key. - * - * When merging, if the same user metadata key is set in more than one - * input, then this method is called to allow this to be resolving in - * an appropriate way. - * - * The default implementation just returns tags[0]. - * - * For multipass this will currently get called multiple times for the - * same key if there are duplicates to resolve in each pass, but this - * may change in the future. - * - * Since 1.4.6, an implementation of this method can return an empty - * string to indicate that the appropriate result is to not set a value - * for this user metadata key in the output database. In older versions, - * you should not return an empty string. - * - * @param key The metadata key with duplicate entries. - * @param num_tags How many tags there are. - * @param tags An array of num_tags strings containing the tags to - * merge. - */ - virtual std::string - resolve_duplicate_metadata(const std::string & key, - size_t num_tags, const std::string tags[]); -}; - -} - -#endif /* XAPIAN_INCLUDED_COMPACTOR_H */ diff --git a/winlibs/include/xapian/constants.h b/winlibs/include/xapian/constants.h deleted file mode 100644 index c4d692d50..000000000 --- a/winlibs/include/xapian/constants.h +++ /dev/null @@ -1,284 +0,0 @@ -/** @file - * @brief Constants in the Xapian namespace - */ -/* Copyright (C) 2012,2013,2014,2015,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_CONSTANTS_H -#define XAPIAN_INCLUDED_CONSTANTS_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -namespace Xapian { - -/** Create database if it doesn't already exist. - * - * If no opening mode is specified, this is the default. - */ -const int DB_CREATE_OR_OPEN = 0x00; - -/** Create database if it doesn't already exist, or overwrite if it does. */ -const int DB_CREATE_OR_OVERWRITE = 0x01; - -/** Create a new database. - * - * If the database already exists, an exception will be thrown. - */ -const int DB_CREATE = 0x02; - -/** Open an existing database. - * - * If the database doesn't exist, an exception will be thrown. - */ -const int DB_OPEN = 0x03; - -#ifdef XAPIAN_LIB_BUILD -/** @internal Bit mask for action codes. */ -const int DB_ACTION_MASK_ = 0x03; -#endif - -/** Don't attempt to ensure changes have hit disk. - * - * By default, Xapian ask the OS to ensure changes have hit disk (by calling - * fdatasync(), fsync() or similar functions). If these calls do their job, - * this should mean that when WritableDatabase::commit() returns, the changes - * are durable, but this comes at a performance cost, and if you don't mind - * losing changes in the case of a crash, power failure, etc, then this option - * can speed up indexing significantly. - */ -const int DB_NO_SYNC = 0x04; - -/** Try to ensure changes are really written to disk. - * - * Generally fsync() and similar functions only ensure that data has been sent - * to the drive. Modern drives have large write-back caches for performance, - * and a power failure could still lose data which is in the write-back cache - * waiting to be written. - * - * Some platforms provide a way to ensure data has actually been written and - * setting DB_FULL_SYNC will attempt to do so where possible. The downside is - * that committing changes takes longer, and other I/O to the same disk may be - * delayed too. - * - * Currently only macOS is supported, and only on some filing system types - * - if not supported, Xapian will use fsync() or similar instead. - */ -const int DB_FULL_SYNC = 0x08; - -/** Update the database in-place. - * - * Xapian's disk-based backends use block-based storage, with copy-on-write - * to allow the previous revision to be searched while a new revision forms. - * - * This option means changed blocks get written back over the top of the - * old version. The benefits of this are that less I/O is required during - * indexing, and the result of indexing is more compact. The downsides are - * that you can't concurrently search while indexing, transactions can't be - * cancelled, and if indexing ends uncleanly (i.e. without commit() or - * WritableDatabase's destructor being called) then the database won't be - * usable. - * - * Currently all the base files will be removed upon the first modification, - * and new base files will be written upon commit. This prevents new - * readers from opening the database while it unsafe to do so, but there's - * not currently a mechanism in Xapian to handle notifying existing readers. - */ -const int DB_DANGEROUS = 0x10; - -/** When creating a database, don't create a termlist table. - * - * For backends which support it (currently glass), this will prevent creation - * of a termlist table. This saves on the disk space that would be needed to - * store it, and the CPU and I/O needed to update it, but some features either - * inherently need the termlist table, or the current implementation of them - * requires it. - * - * The following probably can't be sensibly implemented without it: - * - * - Database::termlist_begin() - * - Document::termlist_begin() - * - Document::termlist_count() - * - Enquire::get_eset() - * - * And the following currently require it: - * - * - Enquire::matching_terms_begin() - we could record this information - * during the match, though it might be hard to do without a speed penalty. - * - WritableDatabase::delete_document() - we could allow this with inexact - * statistics (like how Lucene does). - * - WritableDatabase::replace_document() if the document exists already - * (again, possible with inexact statistics). - * - Currently the list of which values are used in each document is stored - * in the termlist table, so things like iterating the values in a document - * require it (which is probably reasonable since iterating the terms in - * a document requires it). - * - * You can also convert an existing database to not have a termlist table - * by simply deleting termlist.*. - */ -const int DB_NO_TERMLIST = 0x20; - -/** If the database is already locked, retry the lock. - * - * By default, if the database is already locked by a writer, trying to - * open it again for writing will fail by throwing Xapian::DatabaseLockError. - * If this flag is specified, then Xapian will instead wait for the lock - * (indefinitely, unless it gets an error trying to do so). - */ -const int DB_RETRY_LOCK = 0x40; - -/** Use the glass backend. - * - * When opening a WritableDatabase, this means create a glass database if a - * new database is created. If there's an existing database (of any type) - * at the specified path, this flag has no effect. - * - * When opening a Database, this flag means to only open it if it's a glass - * database. There's rarely a good reason to do this - it's mostly provided - * as equivalent functionality to that provided by the namespaced open() - * functions in Xapian 1.2. - */ -const int DB_BACKEND_GLASS = 0x100; - -/** Use the chert backend. - * - * When opening a WritableDatabase, this means create a chert database if a - * new database is created. If there's an existing database (of any type) - * at the specified path, this flag has no effect. - * - * When opening a Database, this flag means to only open it if it's a chert - * database. There's rarely a good reason to do this - it's mostly provided - * as equivalent functionality to Xapian::Chert::open() in Xapian 1.2. - */ -const int DB_BACKEND_CHERT = 0x200; - -/** Open a stub database file. - * - * When opening a Database, this flag means to only open it if it's a stub - * database file. There's rarely a good reason to do this - it's mostly - * provided as equivalent functionality to Xapian::Auto::open_stub() in - * Xapian 1.2. - */ -const int DB_BACKEND_STUB = 0x300; - -/** Use the "in memory" backend. - * - * The filename is currently ignored when this flag is used, but an empty - * string should be passed to allow for future expansion. - * - * A new empty database is created, so when creating a Database object this - * creates an empty read-only database - sometimes useful to avoid special - * casing this situation, but otherwise of limited use. It's more useful - * when creating a WritableDatabase object, though beware that the current - * inmemory backend implementation was not built for performance and - * scalability. - * - * This provides an equivalent to Xapian::InMemory::open() in Xapian 1.2. - */ -const int DB_BACKEND_INMEMORY = 0x400; - -#ifdef XAPIAN_LIB_BUILD -/** @internal Bit mask for backend codes. */ -const int DB_BACKEND_MASK_ = 0x700; - -/** @internal Used internally to signify opening read-only. */ -const int DB_READONLY_ = -1; -#endif - - -/** Show a short-format display of the B-tree contents. - * - * For use with Xapian::Database::check(). - */ -const int DBCHECK_SHORT_TREE = 1; - -/** Show a full display of the B-tree contents. - * - * For use with Xapian::Database::check(). - */ -const int DBCHECK_FULL_TREE = 2; - -/** Show the bitmap for the B-tree. - * - * For use with Xapian::Database::check(). - */ -const int DBCHECK_SHOW_FREELIST = 4; - -/** Show statistics for the B-tree. - * - * For use with Xapian::Database::check(). - */ -const int DBCHECK_SHOW_STATS = 8; - -/** Fix problems. - * - * For use with Xapian::Database::check(). - * - * Currently this is supported for chert, and will: - * - * @li regenerate the "iamchert" file if it isn't valid (so if it is lost, you - * can just create it empty and then "fix problems"). - * - * @li regenerate base files (currently the algorithm for finding the root - * block may not work if there was a change partly written but not - * committed). - */ -const int DBCHECK_FIX = 16; - - -/** Use the same document ids in the output as in the input(s). - * - * By default compaction renumbers the document ids in the output database, - * currently by applying the same offset to all the document ids in a - * particular source database. If this flag is specified, then this - * renumbering doesn't happen, but all the document ids must be unique over - * all source databases. Currently the ranges of document ids in each source - * must not overlap either, though this restriction may be removed in the - * future. - */ -const int DBCOMPACT_NO_RENUMBER = 4; - -/** If merging more than 3 databases, merge the postlists in multiple passes. - * - * This is generally faster but requires more disk space for temporary files. - */ -const int DBCOMPACT_MULTIPASS = 8; - -/** Produce a single-file database. - * - * Only supported by the glass backend currently. - */ -const int DBCOMPACT_SINGLE_FILE = 16; - -/** Assume document id is valid. - * - * By default, Database::get_document() checks that the document id passed is - * actually in use and throws DocNotFoundError if not. This flag can be used - * to disable this check - useful to save a bit of work when you know for sure - * that the document id is valid. - * - * Some database backends may check anyway - the remote backend currently - * does. - */ -const int DOC_ASSUME_VALID = 1; - -} - -#endif /* XAPIAN_INCLUDED_CONSTANTS_H */ diff --git a/winlibs/include/xapian/constinfo.h b/winlibs/include/xapian/constinfo.h deleted file mode 100644 index 9becc1787..000000000 --- a/winlibs/include/xapian/constinfo.h +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - * @brief Mechanism for accessing a struct of constant information - */ -// Copyright (C) 2003,2004,2005,2007,2008,2009,2010,2012,2013,2015 Olly Betts -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_XAPIAN_CONSTINFO_H -#define XAPIAN_INCLUDED_XAPIAN_CONSTINFO_H - -#include -#include - -namespace Xapian { -namespace Internal { - -/** @private @internal */ -struct constinfo { - unsigned char C_tab[256]; - int major, minor, revision; - char str[8]; - unsigned stemmer_name_len; - // FIXME: We don't want to fix the size of this in the API headers. - char stemmer_data[256]; -}; - -/** @private @internal - * - * Rather than having a separate function to access each piece of information, - * we put it all into a structure and have a single function which returns a - * pointer to this (and we mark that function with attribute const, so the - * compiler should be able to CSE calls to it. This means that when Xapian is - * loaded as a shared library we save N-1 relocations (where N is the - * number of pieces of information), which reduces the library load time. - */ -XAPIAN_VISIBILITY_DEFAULT -const struct constinfo * XAPIAN_NOTHROW(get_constinfo_()) XAPIAN_CONST_FUNCTION; - -} -} - -#endif /* XAPIAN_INCLUDED_XAPIAN_CONSTINFO_H */ diff --git a/winlibs/include/xapian/database.h b/winlibs/include/xapian/database.h deleted file mode 100644 index 4760e8014..000000000 --- a/winlibs/include/xapian/database.h +++ /dev/null @@ -1,1282 +0,0 @@ -/** @file - * @brief API for working with Xapian databases - */ -/* Copyright 1999,2000,2001 BrightStation PLC - * Copyright 2002 Ananova Ltd - * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2019 Olly Betts - * Copyright 2006,2008 Lemur Consulting Ltd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_DATABASE_H -#define XAPIAN_INCLUDED_DATABASE_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#ifdef XAPIAN_MOVE_SEMANTICS -# include -#endif -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Xapian { - -class Compactor; -class Document; - -/** This class is used to access a database, or a group of databases. - * - * For searching, this class is used in conjunction with an Enquire object. - * - * @exception InvalidArgumentError will be thrown if an invalid - * argument is supplied, for example, an unknown database type. - * - * @exception DatabaseOpeningError may be thrown if the database cannot - * be opened (for example, a required file cannot be found). - * - * @exception DatabaseVersionError may be thrown if the database is in an - * unsupported format (for example, created by a newer version of Xapian - * which uses an incompatible format). - */ -class XAPIAN_VISIBILITY_DEFAULT Database { - /// @internal Implementation behind check() static methods. - static size_t check_(const std::string * path_ptr, int fd, int opts, - std::ostream *out); - - /// Internal helper behind public compact() methods. - void compact_(const std::string * output_ptr, - int fd, - unsigned flags, - int block_size, - Xapian::Compactor * compactor) const; - - public: - class Internal; - /// @private @internal Reference counted internals. - std::vector > internal; - - /** Add an existing database (or group of databases) to those - * accessed by this object. - * - * @param database the database(s) to add. - */ - void add_database(const Database & database); - - /** Return number of shards in this Database object. */ - size_t size() const { - return internal.size(); - } - - /** Create a Database with no databases in. - */ - Database(); - - /** Open a Database, automatically determining the database - * backend to use. - * - * @param path directory that the database is stored in. - * @param flags Bitwise-or of Xapian::DB_* constants. - */ - explicit Database(const std::string &path, int flags = 0); - - /** Open a single-file Database. - * - * This method opens a single-file Database given a file descriptor - * open on it. Xapian looks starting at the current file offset, - * allowing a single file database to be easily embedded within - * another file. - * - * @param fd file descriptor for the file. Xapian takes ownership of - * this and will close it when the database is closed. - * @param flags Bitwise-or of Xapian::DB_* constants. - */ - explicit Database(int fd, int flags = 0); - - /** @private @internal Create a Database from its internals. - */ - explicit Database(Internal *internal); - - /** Destroy this handle on the database. - * - * If there are no copies of this object remaining, the database(s) - * will be closed. - */ - virtual ~Database(); - - /** Copying is allowed. The internals are reference counted, so - * copying is cheap. - * - * @param other The object to copy. - */ - Database(const Database &other); - - /** Assignment is allowed. The internals are reference counted, - * so assignment is cheap. - * - * @param other The object to copy. - */ - void operator=(const Database &other); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - Database(Database&& o); - - /// Move assignment operator. - Database& operator=(Database&& o); -#endif - - /** Re-open the database. - * - * This re-opens the database(s) to the latest available version(s). - * It can be used either to make sure the latest results are returned, - * or to recover from a Xapian::DatabaseModifiedError. - * - * Calling reopen() on a database which has been closed (with @a - * close()) will always raise a Xapian::DatabaseError. - * - * @return true if the database might have been reopened (if false - * is returned, the database definitely hasn't been - * reopened, which applications may find useful when - * caching results, etc). In Xapian < 1.3.0, this method - * did not return a value. - */ - bool reopen(); - - /** Close the database. - * - * This closes the database and closes all its file handles. - * - * For a WritableDatabase, if a transaction is active it will be - * aborted, while if no transaction is active commit() will be - * implicitly called. Also the write lock is released. - * - * Closing a database cannot be undone - in particular, calling - * reopen() after close() will not reopen it, but will instead throw a - * Xapian::DatabaseError exception. - * - * Calling close() again on a database which has already been closed - * has no effect (and doesn't raise an exception). - * - * After close() has been called, calls to other methods of the - * database, and to methods of other objects associated with the - * database, will either: - * - * - behave exactly as they would have done if the database had not - * been closed (this can only happen if all the required data is - * cached) - * - * - raise a Xapian::DatabaseError exception indicating that the - * database is closed. - * - * The reason for this behaviour is that otherwise we'd have to check - * that the database is still open on every method call on every - * object associated with a Database, when in many cases they are - * working on data which has already been loaded and so they are able - * to just behave correctly. - * - * This method was added in Xapian 1.1.0. - */ - virtual void close(); - - /// Return a string describing this object. - virtual std::string get_description() const; - - /** An iterator pointing to the start of the postlist - * for a given term. - * - * @param tname The termname to iterate postings for. If the - * term name is the empty string, the iterator - * returned will list all the documents in the - * database. Such an iterator will always return - * a WDF value of 1, since there is no obvious - * meaning for this quantity in this case. - */ - PostingIterator postlist_begin(const std::string &tname) const; - - /** Corresponding end iterator to postlist_begin(). - */ - PostingIterator XAPIAN_NOTHROW(postlist_end(const std::string &) const) { - return PostingIterator(); - } - - /** An iterator pointing to the start of the termlist - * for a given document. - * - * @param did The document id of the document to iterate terms for. - */ - TermIterator termlist_begin(Xapian::docid did) const; - - /** Corresponding end iterator to termlist_begin(). - */ - TermIterator XAPIAN_NOTHROW(termlist_end(Xapian::docid) const) { - return TermIterator(); - } - - /** Does this database have any positional information? */ - bool has_positions() const; - - /** An iterator pointing to the start of the position list - * for a given term in a given document. - */ - PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const; - - /** Corresponding end iterator to positionlist_begin(). - */ - PositionIterator XAPIAN_NOTHROW(positionlist_end(Xapian::docid, const std::string &) const) { - return PositionIterator(); - } - - /** An iterator which runs across all terms with a given prefix. - * - * @param prefix The prefix to restrict the returned terms to (default: - * iterate all terms) - */ - TermIterator allterms_begin(const std::string & prefix = std::string()) const; - - /** Corresponding end iterator to allterms_begin(prefix). - */ - TermIterator XAPIAN_NOTHROW(allterms_end(const std::string & = std::string()) const) { - return TermIterator(); - } - - /// Get the number of documents in the database. - Xapian::doccount get_doccount() const; - - /// Get the highest document id which has been used in the database. - Xapian::docid get_lastdocid() const; - - /// Get the average length of the documents in the database. - Xapian::doclength get_avlength() const; - - /** New name for get_avlength(). - * - * Added for forward compatibility with the next release series. - * - * @since 1.4.17. - */ - double get_average_length() const { return get_avlength(); } - - /** Get the total length of all the documents in the database. - * - * Added in Xapian 1.4.5. - */ - Xapian::totallength get_total_length() const; - - /// Get the number of documents in the database indexed by a given term. - Xapian::doccount get_termfreq(const std::string & tname) const; - - /** Check if a given term exists in the database. - * - * @param tname The term to test the existence of. - * - * @return true if and only if the term exists in the database. - * This is the same as (get_termfreq(tname) != 0), but - * will often be more efficient. - */ - bool term_exists(const std::string & tname) const; - - /** Return the total number of occurrences of the given term. - * - * This is the sum of the number of occurrences of the term in each - * document it indexes: i.e., the sum of the within document - * frequencies of the term. - * - * @param tname The term whose collection frequency is being - * requested. - */ - Xapian::termcount get_collection_freq(const std::string & tname) const; - - /** Return the frequency of a given value slot. - * - * This is the number of documents which have a (non-empty) value - * stored in the slot. - * - * @param slot The value slot to examine. - */ - Xapian::doccount get_value_freq(Xapian::valueno slot) const; - - /** Get a lower bound on the values stored in the given value slot. - * - * If there are no values stored in the given value slot, this will - * return an empty string. - * - * @param slot The value slot to examine. - */ - std::string get_value_lower_bound(Xapian::valueno slot) const; - - /** Get an upper bound on the values stored in the given value slot. - * - * If there are no values stored in the given value slot, this will - * return an empty string. - * - * @param slot The value slot to examine. - */ - std::string get_value_upper_bound(Xapian::valueno slot) const; - - /** Get a lower bound on the length of a document in this DB. - * - * This bound does not include any zero-length documents. - */ - Xapian::termcount get_doclength_lower_bound() const; - - /// Get an upper bound on the length of a document in this DB. - Xapian::termcount get_doclength_upper_bound() const; - - /// Get an upper bound on the wdf of term @a term. - Xapian::termcount get_wdf_upper_bound(const std::string & term) const; - - /// Return an iterator over the value in slot @a slot for each document. - ValueIterator valuestream_begin(Xapian::valueno slot) const; - - /// Return end iterator corresponding to valuestream_begin(). - ValueIterator XAPIAN_NOTHROW(valuestream_end(Xapian::valueno) const) { - return ValueIterator(); - } - - /// Get the length of a document. - Xapian::termcount get_doclength(Xapian::docid did) const; - - /// Get the number of unique terms in document. - Xapian::termcount get_unique_terms(Xapian::docid did) const; - - /** Send a "keep-alive" to remote databases to stop them timing out. - * - * Has no effect on non-remote databases. - */ - void keep_alive(); - - /** Get a document from the database, given its document id. - * - * This method returns a Xapian::Document object which provides the - * information about a document. - * - * @param did The document id of the document to retrieve. - * - * @return A Xapian::Document object containing the document data - * - * @exception Xapian::DocNotFoundError The document specified - * could not be found in the database. - * - * @exception Xapian::InvalidArgumentError did was 0, which is not - * a valid document id. - */ - Xapian::Document get_document(Xapian::docid did) const; - - /** Get a document from the database, given its document id. - * - * This method returns a Xapian::Document object which provides the - * information about a document. - * - * @param did The document id of the document to retrieve. - * @param flags Zero or more flags bitwise-or-ed together (currently - * only Xapian::DOC_ASSUME_VALID is supported). - * - * @return A Xapian::Document object containing the document data - * - * @exception Xapian::DocNotFoundError The document specified - * could not be found in the database. - * - * @exception Xapian::InvalidArgumentError did was 0, which is not - * a valid document id. - */ - Xapian::Document get_document(Xapian::docid did, unsigned flags) const; - - /** Suggest a spelling correction. - * - * @param word The potentially misspelled word. - * @param max_edit_distance Only consider words which are at most - * @a max_edit_distance edits from @a word. An edit is a - * character insertion, deletion, or the transposition of two - * adjacent characters (default is 2). - */ - std::string get_spelling_suggestion(const std::string &word, - unsigned max_edit_distance = 2) const; - - /** An iterator which returns all the spelling correction targets. - * - * This returns all the words which are considered as targets for the - * spelling correction algorithm. The frequency of each word is - * available as the term frequency of each entry in the returned - * iterator. - */ - Xapian::TermIterator spellings_begin() const; - - /// Corresponding end iterator to spellings_begin(). - Xapian::TermIterator XAPIAN_NOTHROW(spellings_end() const) { - return Xapian::TermIterator(); - } - - /** An iterator which returns all the synonyms for a given term. - * - * @param term The term to return synonyms for. - */ - Xapian::TermIterator synonyms_begin(const std::string &term) const; - - /// Corresponding end iterator to synonyms_begin(term). - Xapian::TermIterator XAPIAN_NOTHROW(synonyms_end(const std::string &) const) { - return Xapian::TermIterator(); - } - - /** An iterator which returns all terms which have synonyms. - * - * @param prefix If non-empty, only terms with this prefix are - * returned. - */ - Xapian::TermIterator synonym_keys_begin(const std::string &prefix = std::string()) const; - - /// Corresponding end iterator to synonym_keys_begin(prefix). - Xapian::TermIterator XAPIAN_NOTHROW(synonym_keys_end(const std::string & = std::string()) const) { - return Xapian::TermIterator(); - } - - /** Get the user-specified metadata associated with a given key. - * - * User-specified metadata allows you to store arbitrary information - * in the form of (key, value) pairs. See @a - * WritableDatabase::set_metadata() for more information. - * - * When invoked on a Xapian::Database object representing multiple - * databases, currently only the metadata for the first is considered - * but this behaviour may change in the future. - * - * If there is no piece of metadata associated with the specified - * key, an empty string is returned (this applies even for backends - * which don't support metadata). - * - * Empty keys are not valid, and specifying one will cause an - * exception. - * - * @param key The key of the metadata item to access. - * - * @return The retrieved metadata item's value. - * - * @exception Xapian::InvalidArgumentError will be thrown if the - * key supplied is empty. - */ - std::string get_metadata(const std::string & key) const; - - /** An iterator which returns all user-specified metadata keys. - * - * When invoked on a Xapian::Database object representing multiple - * databases, currently only the metadata for the first is considered - * but this behaviour may change in the future. - * - * If the backend doesn't support metadata, then this method returns - * an iterator which compares equal to that returned by - * metadata_keys_end(). - * - * @param prefix If non-empty, only keys with this prefix are - * returned. - * - * @exception Xapian::UnimplementedError will be thrown if the - * backend implements user-specified metadata, but - * doesn't implement iterating its keys (currently - * this happens for the InMemory backend). - */ - Xapian::TermIterator metadata_keys_begin(const std::string &prefix = std::string()) const; - - /// Corresponding end iterator to metadata_keys_begin(). - Xapian::TermIterator XAPIAN_NOTHROW(metadata_keys_end(const std::string & = std::string()) const) { - return Xapian::TermIterator(); - } - - /** Get a UUID for the database. - * - * The UUID will persist for the lifetime of the database. - * - * Replicas (eg, made with the replication protocol, or by copying all - * the database files) will have the same UUID. However, copies (made - * with copydatabase, or xapian-compact) will have different UUIDs. - * - * If the backend does not support UUIDs or this database has no - * subdatabases, the UUID will be empty. - * - * If this database has multiple sub-databases, the UUID string will - * contain the UUIDs of all the sub-databases. - */ - std::string get_uuid() const; - - /** Test if this database is currently locked for writing. - * - * If the underlying object is actually a WritableDatabase, always - * returns true. - * - * Otherwise tests if there's a writer holding the lock (or if - * we can't test for a lock without taking it on the current platform, - * throw Xapian::UnimplementedError). If there's an error while - * trying to test the lock, throws Xapian::DatabaseLockError. - * - * For multi-databases, this tests each sub-database and returns - * true if any of them are locked. - */ - bool locked() const; - - /** Get the revision of the database. - * - * The revision is an unsigned integer which increases with each - * commit. - * - * The database must have exactly one sub-database, which must be of - * type chert or glass. Otherwise an exception will be thrown. - * - * Experimental - see - * https://xapian.org/docs/deprecation#experimental-features - */ - Xapian::rev get_revision() const; - - /** Check the integrity of a database or database table. - * - * @param path Path to database or table - * @param opts Options to use for check - * @param out std::ostream to write output to (NULL for no output) - */ - static size_t check(const std::string & path, int opts = 0, - std::ostream *out = NULL) { - return check_(&path, 0, opts, out); - } - - /** Check the integrity of a single file database. - * - * @param fd file descriptor for the database. The current file - * offset is used, allowing checking a single file - * database which is embedded within another file. Xapian - * takes ownership of the file descriptor and will close - * it before returning. - * @param opts Options to use for check - * @param out std::ostream to write output to (NULL for no output) - */ - static size_t check(int fd, int opts = 0, std::ostream *out = NULL) { - return check_(NULL, fd, opts, out); - } - - /** Produce a compact version of this database. - * - * New 1.3.4. Various methods of the Compactor class were deprecated - * in 1.3.4. - * - * @param output Path to write the compact version to. - * This can be the same as an input if that input is a - * stub database (in which case the database(s) listed - * in the stub will be compacted to a new database and - * then the stub will be atomically updated to point to - * this new database). - * - * @param flags Any of the following combined using bitwise-or (| in - * C++): - * - Xapian::DBCOMPACT_NO_RENUMBER By default the document ids will - * be renumbered the output - currently by applying the - * same offset to all the document ids in a particular - * source database. If this flag is specified, then this - * renumbering doesn't happen, but all the document ids - * must be unique over all source databases. Currently - * the ranges of document ids in each source must not - * overlap either, though this restriction may be removed - * in the future. - * - Xapian::DBCOMPACT_MULTIPASS - * If merging more than 3 databases, merge the postlists - * in multiple passes, which is generally faster but - * requires more disk space for temporary files. - * - Xapian::DBCOMPACT_SINGLE_FILE - * Produce a single-file database (only supported for - * glass currently). - * - At most one of: - * - Xapian::Compactor::STANDARD - Don't split items unnecessarily. - * - Xapian::Compactor::FULL - Split items whenever it saves - * space (the default). - * - Xapian::Compactor::FULLER - Allow oversize items to save - * more space (not recommended if you ever plan to update the - * compacted database). - * - * @param block_size This specifies the block size (in bytes) for - * to use for the output. For glass, the block size must - * be a power of 2 between 2048 and 65536 (inclusive), and - * the default (also used if an invalid value is passed) - * is 8192 bytes. - */ - void compact(const std::string & output, - unsigned flags = 0, - int block_size = 0) { - compact_(&output, 0, flags, block_size, NULL); - } - - /** Produce a compact version of this database. - * - * New 1.3.4. Various methods of the Compactor class were deprecated - * in 1.3.4. - * - * This variant writes a single-file database to the specified file - * descriptor. Only the glass backend supports such databases, so - * this form is only supported for this backend. - * - * @param fd File descriptor to write the compact version to. The - * descriptor needs to be readable and writable (open with - * O_RDWR) and seekable. The current file offset is used, - * allowing compacting to a single file database embedded - * within another file. Xapian takes ownership of the - * file descriptor and will close it before returning. - * - * @param flags Any of the following combined using bitwise-or (| in - * C++): - * - Xapian::DBCOMPACT_NO_RENUMBER By default the document ids will - * be renumbered the output - currently by applying the - * same offset to all the document ids in a particular - * source database. If this flag is specified, then this - * renumbering doesn't happen, but all the document ids - * must be unique over all source databases. Currently - * the ranges of document ids in each source must not - * overlap either, though this restriction may be removed - * in the future. - * - Xapian::DBCOMPACT_MULTIPASS - * If merging more than 3 databases, merge the postlists - * in multiple passes, which is generally faster but - * requires more disk space for temporary files. - * - Xapian::DBCOMPACT_SINGLE_FILE - * Produce a single-file database (only supported for - * glass currently) - this flag is implied in this form - * and need not be specified explicitly. - * - * @param block_size This specifies the block size (in bytes) for - * to use for the output. For glass, the block size must - * be a power of 2 between 2048 and 65536 (inclusive), and - * the default (also used if an invalid value is passed) - * is 8192 bytes. - */ - void compact(int fd, - unsigned flags = 0, - int block_size = 0) { - compact_(NULL, fd, flags, block_size, NULL); - } - - /** Produce a compact version of this database. - * - * New 1.3.4. Various methods of the Compactor class were deprecated - * in 1.3.4. - * - * The @a compactor functor allows handling progress output and - * specifying how user metadata is merged. - * - * @param output Path to write the compact version to. - * This can be the same as an input if that input is a - * stub database (in which case the database(s) listed - * in the stub will be compacted to a new database and - * then the stub will be atomically updated to point to - * this new database). - * - * @param flags Any of the following combined using bitwise-or (| in - * C++): - * - Xapian::DBCOMPACT_NO_RENUMBER By default the document ids will - * be renumbered the output - currently by applying the - * same offset to all the document ids in a particular - * source database. If this flag is specified, then this - * renumbering doesn't happen, but all the document ids - * must be unique over all source databases. Currently - * the ranges of document ids in each source must not - * overlap either, though this restriction may be removed - * in the future. - * - Xapian::DBCOMPACT_MULTIPASS - * If merging more than 3 databases, merge the postlists - * in multiple passes, which is generally faster but - * requires more disk space for temporary files. - * - Xapian::DBCOMPACT_SINGLE_FILE - * Produce a single-file database (only supported for - * glass currently). - * - * @param block_size This specifies the block size (in bytes) for - * to use for the output. For glass, the block size must - * be a power of 2 between 2048 and 65536 (inclusive), and - * the default (also used if an invalid value is passed) - * is 8192 bytes. - * - * @param compactor Functor - */ - void compact(const std::string & output, - unsigned flags, - int block_size, - Xapian::Compactor & compactor) - { - compact_(&output, 0, flags, block_size, &compactor); - } - - /** Produce a compact version of this database. - * - * New 1.3.4. Various methods of the Compactor class were deprecated - * in 1.3.4. - * - * The @a compactor functor allows handling progress output and - * specifying how user metadata is merged. - * - * This variant writes a single-file database to the specified file - * descriptor. Only the glass backend supports such databases, so - * this form is only supported for this backend. - * - * @param fd File descriptor to write the compact version to. The - * descriptor needs to be readable and writable (open with - * O_RDWR) and seekable. The current file offset is used, - * allowing compacting to a single file database embedded - * within another file. Xapian takes ownership of the - * file descriptor and will close it before returning. - * - * @param flags Any of the following combined using bitwise-or (| in - * C++): - * - Xapian::DBCOMPACT_NO_RENUMBER By default the document ids will - * be renumbered the output - currently by applying the - * same offset to all the document ids in a particular - * source database. If this flag is specified, then this - * renumbering doesn't happen, but all the document ids - * must be unique over all source databases. Currently - * the ranges of document ids in each source must not - * overlap either, though this restriction may be removed - * in the future. - * - Xapian::DBCOMPACT_MULTIPASS - * If merging more than 3 databases, merge the postlists - * in multiple passes, which is generally faster but - * requires more disk space for temporary files. - * - Xapian::DBCOMPACT_SINGLE_FILE - * Produce a single-file database (only supported for - * glass currently) - this flag is implied in this form - * and need not be specified explicitly. - * - * @param block_size This specifies the block size (in bytes) for - * to use for the output. For glass, the block size must - * be a power of 2 between 2048 and 65536 (inclusive), and - * the default (also used if an invalid value is passed) - * is 8192 bytes. - * - * @param compactor Functor - */ - void compact(int fd, - unsigned flags, - int block_size, - Xapian::Compactor & compactor) - { - compact_(NULL, fd, flags, block_size, &compactor); - } -}; - -/** This class provides read/write access to a database. - */ -class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database { - public: - /** Destroy this handle on the database. - * - * If no other handles to this database remain, the database will be - * closed. - * - * If a transaction is active cancel_transaction() will be implicitly - * called; if no transaction is active commit() will be implicitly - * called, but any exception will be swallowed (because throwing - * exceptions in C++ destructors is problematic). If you aren't using - * transactions and want to know about any failure to commit changes, - * call commit() explicitly before the destructor gets called. - */ - virtual ~WritableDatabase(); - - /** Create a WritableDatabase with no subdatabases. - * - * The created object isn't very useful in this state - it's intended - * as a placeholder value. - */ - WritableDatabase(); - - /** Open a database for update, automatically determining the database - * backend to use. - * - * If the database is to be created, Xapian will try - * to create the directory indicated by path if it doesn't already - * exist (but only the leaf directory, not recursively). - * - * @param path directory that the database is stored in. - * @param flags one of: - * - Xapian::DB_CREATE_OR_OPEN open for read/write; create if no db - * exists (the default if flags isn't specified) - * - Xapian::DB_CREATE create new database; fail if db exists - * - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing db; create if - * none exists - * - Xapian::DB_OPEN open for read/write; fail if no db exists - * - * Additionally, the following flags can be combined with action - * using bitwise-or (| in C++): - * - * - Xapian::DB_NO_SYNC don't call fsync() or similar - * - Xapian::DB_FULL_SYNC try harder to ensure data is safe - * - Xapian::DB_DANGEROUS don't be crash-safe, no concurrent readers - * - Xapian::DB_NO_TERMLIST don't use a termlist table - * - Xapian::DB_RETRY_LOCK to wait to get a write lock - * - * @param block_size If a new database is created, this specifies - * the block size (in bytes) for backends which - * have such a concept. For chert and glass, the - * block size must be a power of 2 between 2048 and - * 65536 (inclusive), and the default (also used if - * an invalid value is passed) is 8192 bytes. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - * - * @exception Xapian::DatabaseLockError will be thrown if a lock - * couldn't be acquired on the database. - */ - explicit WritableDatabase(const std::string &path, - int flags = 0, - int block_size = 0); - - /** @private @internal Create an WritableDatabase given its internals. - */ - explicit WritableDatabase(Database::Internal *internal); - - /** Copying is allowed. The internals are reference counted, so - * copying is cheap. - * - * @param other The object to copy. - */ - WritableDatabase(const WritableDatabase &other); - - /** Assignment is allowed. The internals are reference counted, - * so assignment is cheap. - * - * Note that only an WritableDatabase may be assigned to an - * WritableDatabase: an attempt to assign a Database is caught - * at compile-time. - * - * @param other The object to copy. - */ - void operator=(const WritableDatabase &other); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - WritableDatabase(WritableDatabase&& o) : Database(std::move(o)) {} - - /// Move assignment operator. - WritableDatabase& operator=(WritableDatabase&& o) { - Database::operator=(std::move(o)); - return *this; - } -#endif - - /** Add shards from another WritableDatabase. - * - * Any shards in @a other are added to the list of shards in this - * object. The shards are reference counted and also remain in - * @a other. - * - * @param other Another WritableDatabase object to add shards from - */ - void add_database(const WritableDatabase& other) { - // This method is provided mainly so that adding a Database to a - // WritableDatabase is a compile-time error - prior to 1.4.19, it - // would essentially act as a "black-hole" shard which discarded - // any changes made to it. - Database::add_database(other); - } - - /** Commit any pending modifications made to the database. - * - * For efficiency reasons, when performing multiple updates to a - * database it is best (indeed, almost essential) to make as many - * modifications as memory will permit in a single pass through - * the database. To ensure this, Xapian batches up modifications. - * - * This method may be called at any time to commit any pending - * modifications to the database. - * - * If any of the modifications fail, an exception will be thrown and - * the database will be left in a state in which each separate - * addition, replacement or deletion operation has either been fully - * performed or not performed at all: it is then up to the - * application to work out which operations need to be repeated. - * - * It's not valid to call commit() within a transaction. - * - * Beware of calling commit() too frequently: this will make indexing - * take much longer. - * - * Note that commit() need not be called explicitly: it will be called - * automatically when the database is closed, or when a sufficient - * number of modifications have been made. By default, this is every - * 10000 documents added, deleted, or modified. This value is rather - * conservative, and if you have a machine with plenty of memory, - * you can improve indexing throughput dramatically by setting - * XAPIAN_FLUSH_THRESHOLD in the environment to a larger value. - * - * This method was new in Xapian 1.1.0 - in earlier versions it was - * called flush(). - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while modifying the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - void commit(); - - /** Pre-1.1.0 name for commit(). - * - * Use commit() instead. - */ - XAPIAN_DEPRECATED(void flush()) { commit(); } - - /** Begin a transaction. - * - * In Xapian a transaction is a group of modifications to the database - * which are linked such that either all will be applied - * simultaneously or none will be applied at all. Even in the case of - * a power failure, this characteristic should be preserved (as long - * as the filesystem isn't corrupted, etc). - * - * A transaction is started with begin_transaction() and can - * either be committed by calling commit_transaction() or aborted - * by calling cancel_transaction(). - * - * By default, a transaction implicitly calls commit() before and - * after so that the modifications stand and fall without affecting - * modifications before or after. - * - * The downside of these implicit calls to commit() is that small - * transactions can harm indexing performance in the same way that - * explicitly calling commit() frequently can. - * - * If you're applying atomic groups of changes and only wish to - * ensure that each group is either applied or not applied, then - * you can prevent the automatic commit() before and after the - * transaction by starting the transaction with - * begin_transaction(false). However, if cancel_transaction is - * called (or if commit_transaction isn't called before the - * WritableDatabase object is destroyed) then any changes which - * were pending before the transaction began will also be discarded. - * - * Transactions aren't currently supported by the InMemory backend. - * - * @param flushed Is this a flushed transaction? By default - * transactions are "flushed", which means that - * committing a transaction will ensure those - * changes are permanently written to the - * database. By contrast, unflushed transactions - * only ensure that changes within the transaction - * are either all applied or all aren't. - * - * @exception Xapian::UnimplementedError will be thrown if transactions - * are not available for this database type. - * - * @exception Xapian::InvalidOperationError will be thrown if this is - * called at an invalid time, such as when a transaction - * is already in progress. - */ - void begin_transaction(bool flushed = true); - - /** Complete the transaction currently in progress. - * - * If this method completes successfully and this is a flushed - * transaction, all the database modifications - * made during the transaction will have been committed to the - * database. - * - * If an error occurs, an exception will be thrown, and none of - * the modifications made to the database during the transaction - * will have been applied to the database. - * - * In all cases the transaction will no longer be in progress. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while modifying the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - * - * @exception Xapian::InvalidOperationError will be thrown if a - * transaction is not currently in progress. - * - * @exception Xapian::UnimplementedError will be thrown if transactions - * are not available for this database type. - */ - void commit_transaction(); - - /** Abort the transaction currently in progress, discarding the - * pending modifications made to the database. - * - * If an error occurs in this method, an exception will be thrown, - * but the transaction will be cancelled anyway. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while modifying the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - * - * @exception Xapian::InvalidOperationError will be thrown if a - * transaction is not currently in progress. - * - * @exception Xapian::UnimplementedError will be thrown if transactions - * are not available for this database type. - */ - void cancel_transaction(); - - /** Add a new document to the database. - * - * This method adds the specified document to the database, - * returning a newly allocated document ID. Automatically allocated - * document IDs come from a per-database monotonically increasing - * counter, so IDs from deleted documents won't be reused. - * - * If you want to specify the document ID to be used, you should - * call replace_document() instead. - * - * Note that changes to the database won't be immediately committed to - * disk; see commit() for more details. - * - * As with all database modification operations, the effect is - * atomic: the document will either be fully added, or the document - * fails to be added and an exception is thrown (possibly at a - * later time when commit() is called or the database is closed). - * - * @param document The new document to be added. - * - * @return The document ID of the newly added document. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - Xapian::docid add_document(const Xapian::Document & document); - - /** Delete a document from the database. - * - * This method removes the document with the specified document ID - * from the database. - * - * Note that changes to the database won't be immediately committed to - * disk; see commit() for more details. - * - * As with all database modification operations, the effect is - * atomic: the document will either be fully removed, or the document - * fails to be removed and an exception is thrown (possibly at a - * later time when commit() is called or the database is closed). - * - * @param did The document ID of the document to be removed. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - void delete_document(Xapian::docid did); - - /** Delete any documents indexed by a term from the database. - * - * This method removes any documents indexed by the specified term - * from the database. - * - * A major use is for convenience when UIDs from another system are - * mapped to terms in Xapian, although this method has other uses - * (for example, you could add a "deletion date" term to documents at - * index time and use this method to delete all documents due for - * deletion on a particular date). - * - * @param unique_term The term to remove references to. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - void delete_document(const std::string & unique_term); - - /** Replace a given document in the database. - * - * This method replaces the document with the specified document ID. - * If document ID @a did isn't currently used, the document will be - * added with document ID @a did. - * - * The monotonic counter used for automatically allocating document - * IDs is increased so that the next automatically allocated document - * ID will be did + 1. Be aware that if you use this method to - * specify a high document ID for a new document, and also use - * WritableDatabase::add_document(), Xapian may get to a state where - * this counter wraps around and will be unable to automatically - * allocate document IDs! - * - * Note that changes to the database won't be immediately committed to - * disk; see commit() for more details. - * - * As with all database modification operations, the effect is - * atomic: the document will either be fully replaced, or the document - * fails to be replaced and an exception is thrown (possibly at a - * later time when commit() is called or the database is closed). - * - * @param did The document ID of the document to be replaced. - * @param document The new document. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - void replace_document(Xapian::docid did, - const Xapian::Document & document); - - /** Replace any documents matching a term. - * - * This method replaces any documents indexed by the specified term - * with the specified document. If any documents are indexed by the - * term, the lowest document ID will be used for the document, - * otherwise a new document ID will be generated as for add_document. - * - * One common use is to allow UIDs from another system to easily be - * mapped to terms in Xapian. Note that this method doesn't - * automatically add unique_term as a term, so you'll need to call - * document.add_term(unique_term) first when using replace_document() - * in this way. - * - * Note that changes to the database won't be immediately committed to - * disk; see commit() for more details. - * - * As with all database modification operations, the effect is - * atomic: the document(s) will either be fully replaced, or the - * document(s) fail to be replaced and an exception is thrown - * (possibly at a - * later time when commit() is called or the database is closed). - * - * @param unique_term The "unique" term. - * @param document The new document. - * - * @return The document ID that document was given. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - */ - Xapian::docid replace_document(const std::string & unique_term, - const Xapian::Document & document); - - /** Add a word to the spelling dictionary. - * - * If the word is already present, its frequency is increased. - * - * @param word The word to add. - * @param freqinc How much to increase its frequency by (default 1). - */ - void add_spelling(const std::string & word, - Xapian::termcount freqinc = 1) const; - - /** Remove a word from the spelling dictionary. - * - * The word's frequency is decreased, and if would become zero or less - * then the word is removed completely. - * - * @param word The word to remove. - * @param freqdec How much to decrease its frequency by (default 1). - */ - void remove_spelling(const std::string & word, - Xapian::termcount freqdec = 1) const; - - /** Add a synonym for a term. - * - * @param term The term to add a synonym for. - * @param synonym The synonym to add. If this is already a - * synonym for @a term, then no action is taken. - */ - void add_synonym(const std::string & term, - const std::string & synonym) const; - - /** Remove a synonym for a term. - * - * @param term The term to remove a synonym for. - * @param synonym The synonym to remove. If this isn't currently - * a synonym for @a term, then no action is taken. - */ - void remove_synonym(const std::string & term, - const std::string & synonym) const; - - /** Remove all synonyms for a term. - * - * @param term The term to remove all synonyms for. If the - * term has no synonyms, no action is taken. - */ - void clear_synonyms(const std::string & term) const; - - /** Set the user-specified metadata associated with a given key. - * - * This method sets the metadata value associated with a given key. - * If there is already a metadata value stored in the database with - * the same key, the old value is replaced. If you want to delete an - * existing item of metadata, just set its value to the empty string. - * - * User-specified metadata allows you to store arbitrary information - * in the form of (key, value) pairs. - * - * There's no hard limit on the number of metadata items, or the size - * of the metadata values. Metadata keys have a limited length, which - * depend on the backend. We recommend limiting them to 200 bytes. - * Empty keys are not valid, and specifying one will cause an - * exception. - * - * Metadata modifications are committed to disk in the same way as - * modifications to the documents in the database are: i.e., - * modifications are atomic, and won't be committed to disk - * immediately (see commit() for more details). This allows metadata - * to be used to link databases with versioned external resources - * by storing the appropriate version number in a metadata item. - * - * You can also use the metadata to store arbitrary extra information - * associated with terms, documents, or postings by encoding the - * termname and/or document id into the metadata key. - * - * @param key The key of the metadata item to set. - * - * @param metadata The value of the metadata item to set. - * - * @exception Xapian::DatabaseError will be thrown if a problem occurs - * while writing to the database. - * - * @exception Xapian::DatabaseCorruptError will be thrown if the - * database is in a corrupt state. - * - * @exception Xapian::InvalidArgumentError will be thrown if the - * key supplied is empty. - * - * @exception Xapian::UnimplementedError will be thrown if the - * database backend in use doesn't support user-specified - * metadata. - */ - void set_metadata(const std::string & key, const std::string & metadata); - - /// Return a string describing this object. - std::string get_description() const; -}; - -} - -#endif /* XAPIAN_INCLUDED_DATABASE_H */ diff --git a/winlibs/include/xapian/dbfactory.h b/winlibs/include/xapian/dbfactory.h deleted file mode 100644 index 2d8067d67..000000000 --- a/winlibs/include/xapian/dbfactory.h +++ /dev/null @@ -1,254 +0,0 @@ -/** @file - * @brief Factory functions for constructing Database and WritableDatabase objects - */ -/* Copyright (C) 2005,2006,2007,2008,2009,2011,2013,2014,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_DBFACTORY_H -#define XAPIAN_INCLUDED_DBFACTORY_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#ifndef _MSC_VER -# include -#endif - -#include - -#include -#include -#include -#include -#include -#include - -namespace Xapian { - -#ifdef _MSC_VER -typedef unsigned useconds_t; -#endif - -/// Database factory functions which determine the database type automatically. -namespace Auto { - -/** Construct a Database object for a stub database file. - * - * The stub database file contains serialised parameters for one - * or more databases. - * - * @param file pathname of the stub database file. - */ -XAPIAN_DEPRECATED(Database open_stub(const std::string &file)); - -inline Database -open_stub(const std::string &file) -{ - return Database(file, DB_BACKEND_STUB); -} - -/** Construct a WritableDatabase object for a stub database file. - * - * The stub database file must contain serialised parameters for exactly one - * database. - * - * @param file pathname of the stub database file. - * @param action determines handling of existing/non-existing database: - * - Xapian::DB_CREATE fail if database already exist, - * otherwise create new database. - * - Xapian::DB_CREATE_OR_OPEN open existing database, or create new - * database if none exists. - * - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create - * new database if none exists. - * - Xapian::DB_OPEN open existing database, failing if none - * exists. - */ -XAPIAN_DEPRECATED(WritableDatabase open_stub(const std::string &file, int action)); - -inline WritableDatabase -open_stub(const std::string &file, int action) -{ - return WritableDatabase(file, action|DB_BACKEND_STUB); -} - -} - -#ifdef XAPIAN_HAS_INMEMORY_BACKEND -/// Database factory functions for the inmemory backend. -namespace InMemory { - -/** Construct a WritableDatabase object for a new, empty InMemory database. - * - * Only a writable InMemory database can be created, since a read-only one - * would always remain empty. - */ -XAPIAN_DEPRECATED(WritableDatabase open()); - -inline WritableDatabase -open() -{ - return WritableDatabase(std::string(), DB_BACKEND_INMEMORY); -} - -} -#endif - -#ifdef XAPIAN_HAS_CHERT_BACKEND -/// Database factory functions for the chert backend. -namespace Chert { - -/** Construct a Database object for read-only access to a Chert database. - * - * @param dir pathname of the directory containing the database. - */ -XAPIAN_DEPRECATED(Database open(const std::string &dir)); - -inline Database -open(const std::string &dir) -{ - return Database(dir, DB_BACKEND_CHERT); -} - -/** Construct a Database object for update access to a Chert database. - * - * @param dir pathname of the directory containing the database. - * @param action determines handling of existing/non-existing database: - * - Xapian::DB_CREATE fail if database already exist, - * otherwise create new database. - * - Xapian::DB_CREATE_OR_OPEN open existing database, or create new - * database if none exists. - * - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create - * new database if none exists. - * - Xapian::DB_OPEN open existing database, failing if none - * exists. - * @param block_size the Btree blocksize to use (in bytes), which must be a - * power of two between 2048 and 65536 (inclusive). The - * default (also used if an invalid value if passed) is - * 8192 bytes. This parameter is ignored when opening an - * existing database. - */ -XAPIAN_DEPRECATED(WritableDatabase open(const std::string &dir, int action, int block_size = 0)); - -inline WritableDatabase -open(const std::string &dir, int action, int block_size) -{ - return WritableDatabase(dir, action|DB_BACKEND_CHERT, block_size); -} - -} -#endif - -#ifdef XAPIAN_HAS_REMOTE_BACKEND -/// Database factory functions for the remote backend. -namespace Remote { - -#if defined __GNUC__ && defined __MINGW32__ -// Avoid deprecation warnings about useconds_t on mingw. -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - -/** Construct a Database object for read-only access to a remote database - * accessed via a TCP connection. - * - * Access to the remote database is via a TCP connection to the specified - * host and port. - * - * @param host hostname to connect to. - * @param port port number to connect to. - * @param timeout timeout in milliseconds. If this timeout is exceeded - * for any individual operation on the remote database - * then Xapian::NetworkTimeoutError is thrown. A timeout - * of 0 means don't timeout. (Default is 10000ms, which - * is 10 seconds). - * @param connect_timeout timeout to use when connecting to the server. - * If this timeout is exceeded then - * Xapian::NetworkTimeoutError is thrown. A - * timeout of 0 means don't timeout. (Default is - * 10000ms, which is 10 seconds). - */ -XAPIAN_VISIBILITY_DEFAULT -Database open(const std::string &host, unsigned int port, useconds_t timeout = 10000, useconds_t connect_timeout = 10000); - -/** Construct a WritableDatabase object for update access to a remote database - * accessed via a TCP connection. - * - * Access to the remote database is via a TCP connection to the specified - * host and port. - * - * @param host hostname to connect to. - * @param port port number to connect to. - * @param timeout timeout in milliseconds. If this timeout is exceeded - * for any individual operation on the remote database - * then Xapian::NetworkTimeoutError is thrown. (Default - * is 0, which means don't timeout). - * @param connect_timeout timeout to use when connecting to the server. - * If this timeout is exceeded then - * Xapian::NetworkTimeoutError is thrown. A - * timeout of 0 means don't timeout. (Default is - * 10000ms, which is 10 seconds). - * @param flags Xapian::DB_RETRY_LOCK or 0. - */ -XAPIAN_VISIBILITY_DEFAULT -WritableDatabase open_writable(const std::string &host, unsigned int port, useconds_t timeout = 0, useconds_t connect_timeout = 10000, int flags = 0); - -/** Construct a Database object for read-only access to a remote database - * accessed via a program. - * - * Access to the remote database is done by running an external program and - * communicating with it on stdin/stdout. - * - * @param program the external program to run. - * @param args space-separated list of arguments to pass to program. - * @param timeout timeout in milliseconds. If this timeout is exceeded - * for any individual operation on the remote database - * then Xapian::NetworkTimeoutError is thrown. A timeout - * of 0 means don't timeout. (Default is 10000ms, which - * is 10 seconds). - */ -XAPIAN_VISIBILITY_DEFAULT -Database open(const std::string &program, const std::string &args, useconds_t timeout = 10000); - -/** Construct a WritableDatabase object for update access to a remote database - * accessed via a program. - * - * Access to the remote database is done by running an external program and - * communicating with it on stdin/stdout. - * - * @param program the external program to run. - * @param args space-separated list of arguments to pass to program. - * @param timeout timeout in milliseconds. If this timeout is exceeded - * for any individual operation on the remote database - * then Xapian::NetworkTimeoutError is thrown. (Default - * is 0, which means don't timeout). - * @param flags Xapian::DB_RETRY_LOCK or 0. - */ -XAPIAN_VISIBILITY_DEFAULT -WritableDatabase open_writable(const std::string &program, const std::string &args, useconds_t timeout = 0, int flags = 0); - -#if defined __GNUC__ && defined __MINGW32__ -# pragma GCC diagnostic pop -#endif - -} -#endif - -} - -#endif /* XAPIAN_INCLUDED_DBFACTORY_H */ diff --git a/winlibs/include/xapian/deprecated.h b/winlibs/include/xapian/deprecated.h deleted file mode 100644 index 6af296c73..000000000 --- a/winlibs/include/xapian/deprecated.h +++ /dev/null @@ -1,65 +0,0 @@ -/** @file - * @brief Define XAPIAN_DEPRECATED() and related macros. - */ -// Copyright (C) 2006,2007,2009,2011,2012,2013,2014 Olly Betts -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_DEPRECATED_H -#define XAPIAN_INCLUDED_DEPRECATED_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -// How to make use of XAPIAN_DEPRECATED, etc is documented in HACKING - see -// the section "Marking Features as Deprecated". Don't forget to update the -// documentation of deprecated methods for end users in docs/deprecation.rst -// too! - -// Don't give deprecation warnings for features marked as externally deprecated -// when building the library. -#ifdef XAPIAN_IN_XAPIAN_H -# define XAPIAN_DEPRECATED_EX(D) XAPIAN_DEPRECATED(D) -# define XAPIAN_DEPRECATED_CLASS_EX XAPIAN_DEPRECATED_CLASS -#else -# define XAPIAN_DEPRECATED_EX(D) D -# define XAPIAN_DEPRECATED_CLASS_EX -#endif - -// xapian-bindings needs to wrap deprecated functions without warnings, -// so check if XAPIAN_DEPRECATED is defined so xapian-bindings can override -// it. -#ifndef XAPIAN_DEPRECATED -# ifdef __GNUC__ -// __attribute__((__deprecated__)) is supported by GCC 3.1 and later, which -// is now our minimum requirement, so there's no need to check the GCC version -// in use. -# define XAPIAN_DEPRECATED(D) D __attribute__((__deprecated__)) -# define XAPIAN_DEPRECATED_CLASS __attribute__((__deprecated__)) -# elif defined _MSC_VER && _MSC_VER >= 1300 -// __declspec(deprecated) is supported by MSVC 7.0 and later. -# define XAPIAN_DEPRECATED(D) __declspec(deprecated) D -# define XAPIAN_DEPRECATED_CLASS __declspec(deprecated) -# else -# define XAPIAN_DEPRECATED(D) D -# endif -#endif - -#ifndef XAPIAN_DEPRECATED_CLASS -# define XAPIAN_DEPRECATED_CLASS -#endif - -#endif diff --git a/winlibs/include/xapian/derefwrapper.h b/winlibs/include/xapian/derefwrapper.h deleted file mode 100644 index 38f23bc09..000000000 --- a/winlibs/include/xapian/derefwrapper.h +++ /dev/null @@ -1,62 +0,0 @@ -/** @file - * @brief Class for wrapping type returned by an input_iterator. - */ -/* Copyright (C) 2004,2008,2009,2013,2014 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_DEREFWRAPPER_H -#define XAPIAN_INCLUDED_DEREFWRAPPER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -namespace Xapian { - -/** @private @internal Class which returns a value when dereferenced with - * operator*. - * - * We need this wrapper class to implement input_iterator semantics for the - * postfix operator++ methods of some of our iterator classes. - */ -template -class DerefWrapper_ { - /// Don't allow assignment. -#if __cplusplus >= 201103L - // Avoid warnings with newer clang. - void operator=(const DerefWrapper_&) = delete; -#else - void operator=(const DerefWrapper_&); -#endif - - /// The value. - T res; - - public: -#if __cplusplus >= 201103L - /// Default copy constructor. - DerefWrapper_(const DerefWrapper_&) = default; -#endif - - explicit DerefWrapper_(const T &res_) : res(res_) { } - const T & operator*() const { return res; } -}; - -} - -#endif // XAPIAN_INCLUDED_DEREFWRAPPER_H diff --git a/winlibs/include/xapian/document.h b/winlibs/include/xapian/document.h deleted file mode 100644 index 1fd1b19e6..000000000 --- a/winlibs/include/xapian/document.h +++ /dev/null @@ -1,307 +0,0 @@ -/** @file - * @brief API for working with documents - */ -/* Copyright 1999,2000,2001 BrightStation PLC - * Copyright 2002 Ananova Ltd - * Copyright 2002,2003,2004,2006,2007,2009,2010,2011,2012,2013,2014,2018 Olly Betts - * Copyright 2009 Lemur Consulting Ltd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_DOCUMENT_H -#define XAPIAN_INCLUDED_DOCUMENT_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include - -#include -#include -#include -#include -#include -#include - -namespace Xapian { - -/** A handle representing a document in a Xapian database. - * - * The Document class fetches information from the database lazily. Usually - * this behaviour isn't visible to users (except for the speed benefits), but - * if the document in the database is modified or deleted, then preexisting - * Document objects may return the old or new versions of data (or throw - * Xapian::DocNotFoundError in the case of deletion). - * - * Since Database objects work on a snapshot of the database's state, the - * situation above can only happen with a WritableDatabase object, or if - * you call Database::reopen() on a Database object. - * - * We recommend you avoid designs where this behaviour is an issue, but if - * you need a way to make a non-lazy version of a Document object, you can do - * this like so: - * - * doc = Xapian::Document::unserialise(doc.serialise()); - */ -class XAPIAN_VISIBILITY_DEFAULT Document { - public: - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /** @private @internal Constructor is only used by internal classes. - * - * @param internal_ pointer to internal opaque class - */ - explicit Document(Internal *internal_); - - /** Copying is allowed. The internals are reference counted, so - * copying is cheap. - * - * @param other The object to copy. - */ - Document(const Document &other); - - /** Assignment is allowed. The internals are reference counted, - * so assignment is cheap. - * - * @param other The object to copy. - */ - void operator=(const Document &other); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - Document(Document&& o); - - /// Move assignment operator. - Document& operator=(Document&& o); -#endif - - /// Make a new empty Document - Document(); - - /// Destructor - ~Document(); - - /** Get value by number. - * - * Returns an empty string if no value with the given number is present - * in the document. - * - * @param slot The number of the value. - */ - std::string get_value(Xapian::valueno slot) const; - - /** Add a new value. - * - * The new value will replace any existing value with the same number - * (or if the new value is empty, it will remove any existing value - * with the same number). - * - * @param slot The value slot to add the value in. - * @param value The value to set. - */ - void add_value(Xapian::valueno slot, const std::string &value); - - /// Remove any value with the given number. - void remove_value(Xapian::valueno slot); - - /// Remove all values associated with the document. - void clear_values(); - - /** Get data stored in the document. - * - * This is potentially a relatively expensive operation, and shouldn't - * normally be used during the match (e.g. in a PostingSource or match - * decider functor. Put data for use by match deciders in a value - * instead. - */ - std::string get_data() const; - - /** Set data stored in the document. - * - * Xapian treats the data as an opaque blob. It may try to compress - * it, but other than that it will just store it and return it when - * requested. - * - * @param data The data to store. - */ - void set_data(const std::string &data); - - /** Add an occurrence of a term at a particular position. - * - * Multiple occurrences of the term at the same position are - * represented only once in the positional information, but do - * increase the wdf. - * - * If the term is not already in the document, it will be added to - * it. - * - * @param tname The name of the term. - * @param tpos The position of the term. - * @param wdfinc The increment that will be applied to the wdf - * for this term. - */ - void add_posting(const std::string & tname, - Xapian::termpos tpos, - Xapian::termcount wdfinc = 1); - - /** Add a term to the document, without positional information. - * - * Any existing positional information for the term will be left - * unmodified. - * - * @param tname The name of the term. - * @param wdfinc The increment that will be applied to the wdf - * for this term (default: 1). - */ - void add_term(const std::string & tname, Xapian::termcount wdfinc = 1); - - /** Add a boolean filter term to the document. - * - * This method adds @a term to the document with wdf of 0 - - * this is generally what you want for a term used for boolean - * filtering as the wdf of such terms is ignored, and it doesn't - * make sense for them to contribute to the document's length. - * - * If the specified term already indexes this document, this method - * has no effect. - * - * It is exactly the same as add_term(term, 0). - * - * This method was added in Xapian 1.0.18. - * - * @param term The term to add. - */ - void add_boolean_term(const std::string & term) { add_term(term, 0); } - - /** Remove a posting of a term from the document. - * - * Note that the term will still index the document even if all - * occurrences are removed. To remove a term from a document - * completely, use remove_term(). - * - * @param tname The name of the term. - * @param tpos The position of the term. - * @param wdfdec The decrement that will be applied to the wdf - * when removing this posting. The wdf will not go - * below the value of 0. - * - * @exception Xapian::InvalidArgumentError will be thrown if the term - * is not at the position specified in the position list for this term - * in this document. - * - * @exception Xapian::InvalidArgumentError will be thrown if the term - * is not in the document - */ - void remove_posting(const std::string & tname, - Xapian::termpos tpos, - Xapian::termcount wdfdec = 1); - - /** Remove a range of postings for a term. - * - * Any instances of the term at positions >= @a term_pos_first and - * <= @a term_pos_last will be removed, and the wdf reduced by - * @a wdf_dec for each instance removed (the wdf will not ever go - * below zero though). - * - * It's OK if the term doesn't occur in the range of positions - * specified (unlike @a remove_posting()). And if - * term_pos_first > term_pos_last, this method does nothing. - * - * @return The number of postings removed. - * - * @exception Xapian::InvalidArgumentError will be thrown if the term - * is not in the document - * - * @since Added in Xapian 1.4.8. - */ - Xapian::termpos remove_postings(const std::string& term, - Xapian::termpos term_pos_first, - Xapian::termpos term_pos_last, - Xapian::termcount wdf_dec = 1); - - /** Remove a term and all postings associated with it. - * - * @param tname The name of the term. - * - * @exception Xapian::InvalidArgumentError will be thrown if the term - * is not in the document - */ - void remove_term(const std::string & tname); - - /// Remove all terms (and postings) from the document. - void clear_terms(); - - /** The length of the termlist - i.e. the number of different terms - * which index this document. - */ - Xapian::termcount termlist_count() const; - - /// Iterator for the terms in this document. - TermIterator termlist_begin() const; - - /// Equivalent end iterator for termlist_begin(). - TermIterator XAPIAN_NOTHROW(termlist_end() const) { - return TermIterator(); - } - - /// Count the values in this document. - Xapian::termcount values_count() const; - - /// Iterator for the values in this document. - ValueIterator values_begin() const; - - /// Equivalent end iterator for values_begin(). - ValueIterator XAPIAN_NOTHROW(values_end() const) { - return ValueIterator(); - } - - /** Get the document id which is associated with this document (if any). - * - * NB If multiple databases are being searched together, then this - * will be the document id in the individual database, not the merged - * database! - * - * @return If this document came from a database, return the document - * id in that database. Otherwise, return 0 (in Xapian - * 1.0.22/1.2.4 or later; prior to this the returned value was - * uninitialised). - */ - docid get_docid() const; - - /** Serialise document into a string. - * - * The document representation may change between Xapian releases: - * even between minor versions. However, it is guaranteed not to - * change if the remote database protocol has not changed between - * releases. - */ - std::string serialise() const; - - /** Unserialise a document from a string produced by serialise(). - */ - static Document unserialise(const std::string &serialised); - - /// Return a string describing this object. - std::string get_description() const; -}; - -} - -#endif // XAPIAN_INCLUDED_DOCUMENT_H diff --git a/winlibs/include/xapian/enquire.h b/winlibs/include/xapian/enquire.h deleted file mode 100644 index abcdb5197..000000000 --- a/winlibs/include/xapian/enquire.h +++ /dev/null @@ -1,752 +0,0 @@ -/** @file - * @brief API for running queries - */ -/* Copyright 1999,2000,2001 BrightStation PLC - * Copyright 2001,2002 Ananova Ltd - * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016 Olly Betts - * Copyright 2009 Lemur Consulting Ltd - * Copyright 2011 Action Without Borders - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_ENQUIRE_H -#define XAPIAN_INCLUDED_ENQUIRE_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include "xapian/deprecated.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Xapian { - -class Database; -class Document; -class ErrorHandler; -class ExpandDecider; -class KeyMaker; -class MatchSpy; -class Query; -class Weight; - -/** A relevance set (R-Set). - * This is the set of documents which are marked as relevant, for use - * in modifying the term weights, and in performing query expansion. - */ -class XAPIAN_VISIBILITY_DEFAULT RSet { - public: - /// Class holding details of RSet - class Internal; - - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /// Copy constructor - RSet(const RSet &rset); - - /// Assignment operator - void operator=(const RSet &rset); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - RSet(RSet && o); - - /// Move assignment operator. - RSet & operator=(RSet && o); -#endif - - /// Default constructor - RSet(); - - /// Destructor - ~RSet(); - - /** The number of documents in this R-Set */ - Xapian::doccount size() const; - - /** Test if this R-Set is empty */ - bool empty() const; - - /// Add a document to the relevance set. - void add_document(Xapian::docid did); - - /// Add a document to the relevance set. - void add_document(const Xapian::MSetIterator & i) { add_document(*i); } - - /// Remove a document from the relevance set. - void remove_document(Xapian::docid did); - - /// Remove a document from the relevance set. - void remove_document(const Xapian::MSetIterator & i) { remove_document(*i); } - - /// Test if a given document in the relevance set. - bool contains(Xapian::docid did) const; - - /// Test if a given document in the relevance set. - bool contains(const Xapian::MSetIterator & i) const { return contains(*i); } - - /// Return a string describing this object. - std::string get_description() const; -}; - -/** Base class for matcher decision functor. - */ -class XAPIAN_VISIBILITY_DEFAULT MatchDecider { - /// Don't allow assignment. - void operator=(const MatchDecider &); - - /// Don't allow copying. - MatchDecider(const MatchDecider &); - - public: - /// Default constructor - MatchDecider() { } - - /** Decide whether we want this document to be in the MSet. - * - * @param doc The document to test. - * - * @return true if the document is acceptable, or false if the document - * should be excluded from the MSet. - */ - virtual bool operator()(const Xapian::Document &doc) const = 0; - - /// Destructor. - virtual ~MatchDecider(); -}; - -/** This class provides an interface to the information retrieval - * system for the purpose of searching. - * - * Databases are usually opened lazily, so exceptions may not be - * thrown where you would expect them to be. You should catch - * Xapian::Error exceptions when calling any method in Xapian::Enquire. - * - * @exception Xapian::InvalidArgumentError will be thrown if an invalid - * argument is supplied, for example, an unknown database type. - */ -class XAPIAN_VISIBILITY_DEFAULT Enquire { - public: - /// Copying is allowed (and is cheap). - Enquire(const Enquire & other); - - /// Assignment is allowed (and is cheap). - void operator=(const Enquire & other); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - Enquire(Enquire&& o); - - /// Move assignment operator. - Enquire& operator=(Enquire&& o); -#endif - - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /** Create a Xapian::Enquire object. - * - * This specification cannot be changed once the Xapian::Enquire is - * opened: you must create a new Xapian::Enquire object to access a - * different database, or set of databases. - * - * The database supplied must have been initialised (ie, must not be - * the result of calling the Database::Database() constructor). If - * you need to handle a situation where you have no databases - * gracefully, a database created with DB_BACKEND_INMEMORY can be - * passed here to provide a completely empty database. - * - * @param database Specification of the database or databases to - * use. - * - * @exception Xapian::InvalidArgumentError will be thrown if an - * empty Database object is supplied. - */ - explicit Enquire(const Database &database); - - /** Create a Xapian::Enquire object. - * - * This specification cannot be changed once the Xapian::Enquire is - * opened: you must create a new Xapian::Enquire object to access a - * different database, or set of databases. - * - * The database supplied must have been initialised (ie, must not be - * the result of calling the Database::Database() constructor). If - * you need to handle a situation where you have no databases - * gracefully, a database created with DB_BACKEND_INMEMORY can be - * passed here to provide a completely empty database. - * - * @param database Specification of the database or databases to - * use. - * @param errorhandler_ This parameter is deprecated (since Xapian - * 1.3.1), and as of 1.3.5 it's ignored completely. - * - * @exception Xapian::InvalidArgumentError will be thrown if an - * empty Database object is supplied. - */ - XAPIAN_DEPRECATED_EX(Enquire(const Database &database, ErrorHandler * errorhandler_)); - - /** Close the Xapian::Enquire object. - */ - ~Enquire(); - - /** Set the query to run. - * - * @param query the new query to run. - * @param qlen the query length to use in weight calculations - - * by default the sum of the wqf of all terms is used. - */ - void set_query(const Xapian::Query & query, Xapian::termcount qlen = 0); - - /** Get the current query. - * - * If called before set_query(), this will return a default - * initialised Query object. - */ - const Xapian::Query & get_query() const; - - /** Add a matchspy. - * - * This matchspy will be called with some of the documents which match - * the query, during the match process. Exactly which of the matching - * documents are passed to it depends on exactly when certain - * optimisations occur during the match process, but it can be - * controlled to some extent by setting the @a checkatleast parameter - * to @a get_mset(). - * - * In particular, if there are enough matching documents, at least the - * number specified by @a checkatleast will be passed to the matchspy. - * This means that you can force the matchspy to be shown all matching - * documents by setting @a checkatleast to the number of documents in - * the database. - * - * @param spy The MatchSpy subclass to add. The caller must - * ensure that this remains valid while the Enquire - * object remains active, or until @a - * clear_matchspies() is called. - */ - void add_matchspy(MatchSpy * spy); - - /** Remove all the matchspies. - */ - void clear_matchspies(); - - /** Set the weighting scheme to use for queries. - * - * @param weight_ the new weighting scheme. If no weighting scheme - * is specified, the default is BM25 with the - * default parameters. - */ - void set_weighting_scheme(const Weight &weight_); - - /** Set the weighting scheme to use for expansion. - * - * If you don't call this method, the default is as if you'd used: - * - * get_expansion_scheme("trad"); - * - * @param eweightname_ A string in lowercase specifying the name of - * the scheme to be used. The following schemes - * are currently available: - * "bo1" : The Bo1 scheme for query expansion. - * "trad" : The TradWeight scheme for query expansion. - * @param expand_k_ The parameter required for TradWeight query expansion. - * A default value of 1.0 is used if none is specified. - */ - void set_expansion_scheme(const std::string &eweightname_, - double expand_k_ = 1.0) const; - - /** Set the collapse key to use for queries. - * - * @param collapse_key value number to collapse on - at most one MSet - * entry with each particular value will be returned - * (default is Xapian::BAD_VALUENO which means no collapsing). - * - * @param collapse_max Max number of items with the same key to leave - * after collapsing (default 1). - * - * The MSet returned by get_mset() will have only the "best" - * (at most) @a collapse_max entries with each particular - * value of @a collapse_key ("best" being highest ranked - i.e. - * highest weight or highest sorting key). - * - * An example use might be to create a value for each document - * containing an MD5 hash of the document contents. Then - * duplicate documents from different sources can be eliminated at - * search time by collapsing with @a collapse_max = 1 (it's better - * to eliminate duplicates at index time, but this may not be - * always be possible - for example the search may be over more - * than one Xapian database). - * - * Another use is to group matches in a particular category (e.g. - * you might collapse a mailing list search on the Subject: so - * that there's only one result per discussion thread). In this - * case you can use get_collapse_count() to give the user some - * idea how many other results there are. And if you index the - * Subject: as a boolean term as well as putting it in a value, - * you can offer a link to a non-collapsed search restricted to - * that thread using a boolean filter. - */ - void set_collapse_key(Xapian::valueno collapse_key, - Xapian::doccount collapse_max = 1); - - /** Ordering of docids. - * - * Parameter to Enquire::set_docid_order(). - */ - typedef enum { - /** docids sort in ascending order (default) */ - ASCENDING = 1, - /** docids sort in descending order. */ - DESCENDING = 0, - /** docids sort in whatever order is most efficient for the - * backend. */ - DONT_CARE = 2 - } docid_order; - - /** Set sort order for document IDs. - * - * This order only has an effect on documents which would otherwise - * have equal rank. When ordering by relevance without a sort key, - * this means documents with equal weight. For a boolean match - * with no sort key, this means all documents. And if a sort key - * is used, this means documents with the same sort key (and also equal - * weight if ordering on relevance before or after the sort key). - * - * @param order This can be: - * - Xapian::Enquire::ASCENDING - * docids sort in ascending order (default) - * - Xapian::Enquire::DESCENDING - * docids sort in descending order - * - Xapian::Enquire::DONT_CARE - * docids sort in whatever order is most efficient for the backend - * - * Note: If you add documents in strict date order, then a boolean - * search - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with - * set_docid_order(Xapian::Enquire::DESCENDING) is an efficient - * way to perform "sort by date, newest first", and with - * set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way - * to perform "sort by date, oldest first". - */ - void set_docid_order(docid_order order); - - /** Set the percentage and/or weight cutoffs. - * - * @param percent_cutoff Minimum percentage score for returned - * documents. If a document has a lower percentage score than this, - * it will not appear in the MSet. If your intention is to return - * only matches which contain all the terms in the query, then - * it's more efficient to use Xapian::Query::OP_AND instead of - * Xapian::Query::OP_OR in the query than to use set_cutoff(100). - * (default 0 => no percentage cut-off). - * @param weight_cutoff Minimum weight for a document to be returned. - * If a document has a lower score that this, it will not appear - * in the MSet. It is usually only possible to choose an - * appropriate weight for cutoff based on the results of a - * previous run of the same query; this is thus mainly useful for - * alerting operations. The other potential use is with a user - * specified weighting scheme. - * (default 0 => no weight cut-off). - */ - void set_cutoff(int percent_cutoff, double weight_cutoff = 0); - - /** Set the sorting to be by relevance only. - * - * This is the default. - */ - void set_sort_by_relevance(); - - /** Set the sorting to be by value only. - * - * Note that sorting by values uses a string comparison, so to use - * this to sort by a numeric value you'll need to store the numeric - * values in a manner which sorts appropriately. For example, you - * could use Xapian::sortable_serialise() (which works for floating - * point numbers as well as integers), or store numbers padded with - * leading zeros or spaces, or with the number of digits prepended. - * - * @param sort_key value number to sort on. - * - * @param reverse If true, reverses the sort order. - */ - void set_sort_by_value(Xapian::valueno sort_key, bool reverse); - - /** Set the sorting to be by key generated from values only. - * - * @param sorter The functor to use for generating keys. - * - * @param reverse If true, reverses the sort order. - */ - void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse); - - /** Set the sorting to be by value, then by relevance for documents - * with the same value. - * - * Note that sorting by values uses a string comparison, so to use - * this to sort by a numeric value you'll need to store the numeric - * values in a manner which sorts appropriately. For example, you - * could use Xapian::sortable_serialise() (which works for floating - * point numbers as well as integers), or store numbers padded with - * leading zeros or spaces, or with the number of digits prepended. - * - * @param sort_key value number to sort on. - * - * @param reverse If true, reverses the sort order. - */ - void set_sort_by_value_then_relevance(Xapian::valueno sort_key, - bool reverse); - - /** Set the sorting to be by keys generated from values, then by - * relevance for documents with identical keys. - * - * @param sorter The functor to use for generating keys. - * - * @param reverse If true, reverses the sort order. - */ - void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter, - bool reverse); - - /** Set the sorting to be by relevance then value. - * - * Note that sorting by values uses a string comparison, so to use - * this to sort by a numeric value you'll need to store the numeric - * values in a manner which sorts appropriately. For example, you - * could use Xapian::sortable_serialise() (which works for floating - * point numbers as well as integers), or store numbers padded with - * leading zeros or spaces, or with the number of digits prepended. - * - * Note that with the default BM25 weighting scheme parameters, - * non-identical documents will rarely have the same weight, so - * this setting will give very similar results to - * set_sort_by_relevance(). It becomes more useful with particular - * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom - * weighting schemes. - * - * @param sort_key value number to sort on. - * - * @param reverse If true, reverses the sort order of sort_key. - * Beware that in 1.2.16 and earlier, the sense - * of this parameter was incorrectly inverted - * and inconsistent with the other set_sort_by_... - * methods. This was fixed in 1.2.17, so make that - * version a minimum requirement if this detail - * matters to your application. - */ - void set_sort_by_relevance_then_value(Xapian::valueno sort_key, - bool reverse); - - /** Set the sorting to be by relevance, then by keys generated from - * values. - * - * Note that with the default BM25 weighting scheme parameters, - * non-identical documents will rarely have the same weight, so - * this setting will give very similar results to - * set_sort_by_relevance(). It becomes more useful with particular - * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom - * weighting schemes. - * - * @param sorter The functor to use for generating keys. - * - * @param reverse If true, reverses the sort order of the generated - * keys. Beware that in 1.2.16 and earlier, the sense - * of this parameter was incorrectly inverted - * and inconsistent with the other set_sort_by_... - * methods. This was fixed in 1.2.17, so make that - * version a minimum requirement if this detail - * matters to your application. - */ - void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter, - bool reverse); - - /** Set a time limit for the match. - * - * Matches with check_at_least set high can take a long time in some - * cases. You can set a time limit on this, after which check_at_least - * will be turned off. - * - * @param time_limit time in seconds after which to disable - * check_at_least (default: 0.0 which means no - * time limit) - * - * Limitations: - * - * This feature is currently supported on platforms which support POSIX - * interval timers. Interaction with the remote backend when using - * multiple databases may have bugs. There's not currently a way to - * force the match to end after a certain time. - */ - void set_time_limit(double time_limit); - - /** Get (a portion of) the match set for the current query. - * - * @param first the first item in the result set to return. - * A value of zero corresponds to the first item - * returned being that with the highest score. - * A value of 10 corresponds to the first 10 items - * being ignored, and the returned items starting - * at the eleventh. - * @param maxitems the maximum number of items to return. If you - * want all matches, then you can pass the result - * of calling get_doccount() on the Database object - * (though if you are doing this so you can filter - * results, you are likely to get much better - * performance by using Xapian's match-time filtering - * features instead). You can pass 0 for maxitems - * which will give you an empty MSet with valid - * statistics (such as get_matches_estimated()) - * calculated without looking at any postings, which - * is very quick, but means the estimates may be - * more approximate and the bounds may be much - * looser. - * @param checkatleast the minimum number of items to check. Because - * the matcher optimises, it won't consider every - * document which might match, so the total number - * of matches is estimated. Setting checkatleast - * forces it to consider at least this many matches - * and so allows for reliable paging links. - * @param omrset the relevance set to use when performing the query. - * @param mdecider a decision functor to use to decide whether a - * given document should be put in the MSet. - * - * @return A Xapian::MSet object containing the results of the - * query. - * - * @exception Xapian::InvalidArgumentError See class documentation. - */ - MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, - Xapian::doccount checkatleast = 0, - const RSet * omrset = 0, - const MatchDecider * mdecider = 0) const; - - /** Get (a portion of) the match set for the current query. - * - * @param first the first item in the result set to return. - * A value of zero corresponds to the first item - * returned being that with the highest score. - * A value of 10 corresponds to the first 10 items - * being ignored, and the returned items starting - * at the eleventh. - * @param maxitems the maximum number of items to return. If you - * want all matches, then you can pass the result - * of calling get_doccount() on the Database object - * (though if you are doing this so you can filter - * results, you are likely to get much better - * performance by using Xapian's match-time filtering - * features instead). You can pass 0 for maxitems - * which will give you an empty MSet with valid - * statistics (such as get_matches_estimated()) - * calculated without looking at any postings, which - * is very quick, but means the estimates may be - * more approximate and the bounds may be much - * looser. - * @param omrset the relevance set to use when performing the query. - * @param mdecider a decision functor to use to decide whether a - * given document should be put in the MSet. - * - * @return A Xapian::MSet object containing the results of the - * query. - * - * @exception Xapian::InvalidArgumentError See class documentation. - */ - MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, - const RSet * omrset, - const MatchDecider * mdecider = 0) const { - return get_mset(first, maxitems, 0, omrset, mdecider); - } - - /** Terms in the query may be returned by get_eset(). - * - * The original intended use for Enquire::get_eset() is for query - * expansion - suggesting terms to add to the query, generally with - * the aim of improving recall (i.e. finding more of the relevant - * documents), so by default terms already in the query won't be - * returned in the ESet. For some uses you might want to consider - * all terms, and this flag allows you to specify that. - */ - static const int INCLUDE_QUERY_TERMS = 1; - - /** Calculate exact term frequencies in get_eset(). - * - * By default, when working over multiple databases, - * Enquire::get_eset() uses an approximation to the termfreq to - * improve efficiency. This should still return good results, but - * if you want to calculate the exact combined termfreq then you - * can use this flag. - */ - static const int USE_EXACT_TERMFREQ = 2; - - /** Get the expand set for the given rset. - * - * @param maxitems the maximum number of items to return. - * @param omrset the relevance set to use when performing - * the expand operation. - * @param flags zero or more of these values |-ed together: - * - Xapian::Enquire::INCLUDE_QUERY_TERMS query - * terms may be returned from expand - * - Xapian::Enquire::USE_EXACT_TERMFREQ for multi - * dbs, calculate the exact termfreq; otherwise an - * approximation is used which can greatly improve - * efficiency, but still returns good results. - * @param edecider a decision functor to use to decide whether a - * given term should be put in the ESet - * @param min_wt the minimum weight for included terms - * - * @return An ESet object containing the results of the - * expand. - * - * @exception Xapian::InvalidArgumentError See class documentation. - */ - ESet get_eset(Xapian::termcount maxitems, - const RSet & omrset, - int flags = 0, - const Xapian::ExpandDecider * edecider = 0, - double min_wt = 0.0) const; - - /** Get the expand set for the given rset. - * - * @param maxitems the maximum number of items to return. - * @param omrset the relevance set to use when performing - * the expand operation. - * @param edecider a decision functor to use to decide whether a - * given term should be put in the ESet - * - * @return An ESet object containing the results of the - * expand. - * - * @exception Xapian::InvalidArgumentError See class documentation. - */ - ESet get_eset(Xapian::termcount maxitems, const RSet & omrset, - const Xapian::ExpandDecider * edecider) const { - return get_eset(maxitems, omrset, 0, edecider); - } - - /** Get the expand set for the given rset. - * - * @param maxitems the maximum number of items to return. - * @param rset the relevance set to use when performing - * the expand operation. - * @param flags zero or more of these values |-ed together: - * - Xapian::Enquire::INCLUDE_QUERY_TERMS query - * terms may be returned from expand - * - Xapian::Enquire::USE_EXACT_TERMFREQ for multi - * dbs, calculate the exact termfreq; otherwise an - * approximation is used which can greatly improve - * efficiency, but still returns good results. - * @param k the parameter k in the query expansion algorithm - * (default is 1.0) - * @param edecider a decision functor to use to decide whether a - * given term should be put in the ESet - * - * @param min_wt the minimum weight for included terms - * - * @return An ESet object containing the results of the - * expand. - * - * @exception Xapian::InvalidArgumentError See class documentation. - */ - XAPIAN_DEPRECATED(ESet get_eset(Xapian::termcount maxitems, - const RSet & rset, - int flags, - double k, - const Xapian::ExpandDecider * edecider = NULL, - double min_wt = 0.0) const) { - set_expansion_scheme("trad", k); - return get_eset(maxitems, rset, flags, edecider, min_wt); - } - - /** Get terms which match a given document, by document id. - * - * This method returns the terms in the current query which match - * the given document. - * - * It is possible for the document to have been removed from the - * database between the time it is returned in an MSet, and the - * time that this call is made. If possible, you should specify - * an MSetIterator instead of a Xapian::docid, since this will enable - * database backends with suitable support to prevent this - * occurring. - * - * Note that a query does not need to have been run in order to - * make this call. - * - * @param did The document id for which to retrieve the matching - * terms. - * - * @return An iterator returning the terms which match the - * document. The terms will be returned (as far as this - * makes any sense) in the same order as the terms - * in the query. Terms will not occur more than once, - * even if they do in the query. - * - * @exception Xapian::InvalidArgumentError See class documentation. - * @exception Xapian::DocNotFoundError The document specified - * could not be found in the database. - */ - TermIterator get_matching_terms_begin(Xapian::docid did) const; - - /** End iterator corresponding to get_matching_terms_begin() */ - TermIterator XAPIAN_NOTHROW(get_matching_terms_end(Xapian::docid /*did*/) const) { - return TermIterator(); - } - - /** Get terms which match a given document, by match set item. - * - * This method returns the terms in the current query which match - * the given document. - * - * If the underlying database has suitable support, using this call - * (rather than passing a Xapian::docid) will enable the system to - * ensure that the correct data is returned, and that the document - * has not been deleted or changed since the query was performed. - * - * @param it The iterator for which to retrieve the matching terms. - * - * @return An iterator returning the terms which match the - * document. The terms will be returned (as far as this - * makes any sense) in the same order as the terms - * in the query. Terms will not occur more than once, - * even if they do in the query. - * - * @exception Xapian::InvalidArgumentError See class documentation. - * @exception Xapian::DocNotFoundError The document specified - * could not be found in the database. - */ - TermIterator get_matching_terms_begin(const MSetIterator &it) const; - - /** End iterator corresponding to get_matching_terms_begin() */ - TermIterator XAPIAN_NOTHROW(get_matching_terms_end(const MSetIterator &/*it*/) const) { - return TermIterator(); - } - - /// Return a string describing this object. - std::string get_description() const; -}; - -} - -#endif /* XAPIAN_INCLUDED_ENQUIRE_H */ diff --git a/winlibs/include/xapian/error.h b/winlibs/include/xapian/error.h deleted file mode 100644 index e73278334..000000000 --- a/winlibs/include/xapian/error.h +++ /dev/null @@ -1,1139 +0,0 @@ -/** @file - * @brief Hierarchy of classes which Xapian can throw as exceptions. - */ -/* Warning: This file is generated by ./generate-exceptions - do not modify directly! */ -/* Copyright (C) 2003,2004,2006,2007,2008,2009,2011,2015,2019 Olly Betts - * Copyright (C) 2007 Richard Boulton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_ERROR_H -#define XAPIAN_INCLUDED_ERROR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include - -namespace Xapian { - -class ErrorHandler; - -/** All exceptions thrown by Xapian are subclasses of Xapian::Error. - * - * This class can not be instantiated directly - instead a subclass should - * be used. - */ -class XAPIAN_VISIBILITY_DEFAULT Error { - // ErrorHandler needs to be able to access Error::already_handled. - friend class ErrorHandler; - - /// Message giving details of the error, intended for human consumption. - std::string msg; - - /** Optional context information. - * - * This context is intended for use by Xapian::ErrorHandler (for example - * so it can know which remote server is unreliable and report the problem - * and remove that server from those being searched). But it's typically - * a plain-text string, and so also fit for human consumption. - */ - std::string context; - - /** The error string derived from my_errno. - * - * This string is generated from my_errno lazily. - */ - mutable std::string error_string; - - /// The type of this error (e.g. DocNotFoundError.) - const char * type; - - /** Optional value of 'errno' associated with this error. - * - * If no value is associated, this member variable will be 0. - * - * On UNIX, if this value is < 0, it's an error code returned from - * getaddrinfo() (negated if such error codes are positive). - * - * On Windows, if this value is < 0, it's a negated Windows error code - * (as given by GetLastError()), while if it is >= WSABASEERR then it is a - * WinSock error code (as given by WSAGetLastError()). Prior to Xapian - * 1.2.20 and 1.3.3, WSAGetLastError() codes were also negated. - * - * NB We don't just call this member "errno" to avoid problems on - * platforms where errno is a preprocessor macro. - */ - int my_errno; - - /// True if this error has already been passed to an ErrorHandler. - bool already_handled; - - /// Don't allow assignment of the base class. - void operator=(const Error &o); - - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - Error(const std::string &msg_, const std::string &context_, - const char * type_, const char * error_string_); - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - Error(const std::string &msg_, const std::string &context_, - const char * type_, int errno_) - : msg(msg_), context(context_), error_string(), type(type_), - my_errno(errno_), already_handled(false) { } - - public: -#if __cplusplus >= 201103L - /** Default copy constructor. - * - * We explicitly specify this to avoid warnings from GCC 9 (from - * -Wdeprecated-copy which is enabled by -Wextra). - */ - Error(const Error&) = default; -#endif - - /// The type of this error (e.g. "DocNotFoundError".) - const char * XAPIAN_NOTHROW(get_type() const) { - return type + 1; - } - - /// Message giving details of the error, intended for human consumption. - const std::string & XAPIAN_NOTHROW(get_msg() const) { - return msg; - } - - /** Optional context information. - * - * This context is intended for use by Xapian::ErrorHandler (for example - * so it can know which remote server is unreliable and report the problem - * and remove that server from those being searched). But it's typically - * a plain-text string, and so also fit for human consumption. - */ - const std::string & XAPIAN_NOTHROW(get_context() const) { - return context; - } - - /** Returns any system error string associated with this exception. - * - * The system error string may come from errno, h_errno (on UNIX), or - * GetLastError() (on MS Windows). If there is no associated system - * error string, NULL is returned. - */ - const char * get_error_string() const; - - /// Return a string describing this object. - std::string get_description() const; -}; - -/** The base class for exceptions indicating errors in the program logic. - * - * A subclass of LogicError will be thrown if Xapian detects a violation - * of a class invariant or a logical precondition or postcondition, etc. - */ -class XAPIAN_VISIBILITY_DEFAULT LogicError : public Error { - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - LogicError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : Error(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - LogicError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : Error(msg_, context_, type_, errno_) {} -}; - -/** The base class for exceptions indicating errors only detectable at runtime. - * - * A subclass of RuntimeError will be thrown if Xapian detects an error - * which is exception derived from RuntimeError is thrown when an - * error is caused by problems with the data or environment rather - * than a programming mistake. - */ -class XAPIAN_VISIBILITY_DEFAULT RuntimeError : public Error { - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : Error(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : Error(msg_, context_, type_, errno_) {} -}; - -/** AssertionError is thrown if a logical assertion inside Xapian fails. - * - * In a debug build of Xapian, a failed assertion in the core library code - * will cause AssertionError to be thrown. - * - * This represents a bug in Xapian (either an invariant, precondition, etc - * has been violated, or the assertion is incorrect!) - */ -class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - AssertionError(const std::string &msg_, const std::string &context_, const char * error_string_) - : LogicError(msg_, context_, "\000AssertionError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit AssertionError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : LogicError(msg_, context_, "\000AssertionError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - AssertionError(const std::string &msg_, int errno_) - : LogicError(msg_, std::string(), "\000AssertionError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - AssertionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : LogicError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - AssertionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : LogicError(msg_, context_, type_, errno_) {} -}; - -/** InvalidArgumentError indicates an invalid parameter value was passed to the API. - */ -class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * error_string_) - : LogicError(msg_, context_, "\001InvalidArgumentError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit InvalidArgumentError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : LogicError(msg_, context_, "\001InvalidArgumentError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - InvalidArgumentError(const std::string &msg_, int errno_) - : LogicError(msg_, std::string(), "\001InvalidArgumentError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : LogicError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : LogicError(msg_, context_, type_, errno_) {} -}; - -/** InvalidOperationError indicates the API was used in an invalid way. - */ -class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - InvalidOperationError(const std::string &msg_, const std::string &context_, const char * error_string_) - : LogicError(msg_, context_, "\002InvalidOperationError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit InvalidOperationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : LogicError(msg_, context_, "\002InvalidOperationError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - InvalidOperationError(const std::string &msg_, int errno_) - : LogicError(msg_, std::string(), "\002InvalidOperationError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : LogicError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : LogicError(msg_, context_, type_, errno_) {} -}; - -/** UnimplementedError indicates an attempt to use an unimplemented feature. - */ -class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - UnimplementedError(const std::string &msg_, const std::string &context_, const char * error_string_) - : LogicError(msg_, context_, "\003UnimplementedError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit UnimplementedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : LogicError(msg_, context_, "\003UnimplementedError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - UnimplementedError(const std::string &msg_, int errno_) - : LogicError(msg_, std::string(), "\003UnimplementedError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : LogicError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : LogicError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseError indicates some sort of database related error. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\004DatabaseError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\004DatabaseError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\004DatabaseError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseCorruptError indicates database corruption was detected. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\005DatabaseCorruptError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseCorruptError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\005DatabaseCorruptError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseCorruptError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\005DatabaseCorruptError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseCreateError indicates a failure to create a database. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\006DatabaseCreateError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseCreateError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\006DatabaseCreateError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseCreateError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\006DatabaseCreateError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseLockError indicates failure to lock a database. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseLockError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\007DatabaseLockError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseLockError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\007DatabaseLockError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseLockError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\007DatabaseLockError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseModifiedError indicates a database was modified. - * - * To recover after catching this error, you need to call - * Xapian::Database::reopen() on the Database and repeat the operation - * which failed. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\010DatabaseModifiedError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseModifiedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\010DatabaseModifiedError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseModifiedError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\010DatabaseModifiedError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseOpeningError indicates failure to open a database. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\011DatabaseOpeningError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseOpeningError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\011DatabaseOpeningError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseOpeningError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\011DatabaseOpeningError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -/** DatabaseVersionError indicates that a database is in an unsupported format. - * - * From time to time, new versions of Xapian will require the database format - * to be changed, to allow new information to be stored or new optimisations - * to be performed. Backwards compatibility will sometimes be maintained, so - * that new versions of Xapian can open old databases, but in some cases - * Xapian will be unable to open a database because it is in too old (or new) - * a format. This can be resolved either be upgrading or downgrading the - * version of Xapian in use, or by rebuilding the database from scratch with - * the current version of Xapian. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeningError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseVersionError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseVersionError(const std::string &msg_, int errno_) - : DatabaseOpeningError(msg_, std::string(), "\012DatabaseVersionError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseOpeningError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseOpeningError(msg_, context_, type_, errno_) {} -}; - -/** Indicates an attempt to access a document not present in the database. - */ -class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DocNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\013DocNotFoundError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DocNotFoundError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\013DocNotFoundError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DocNotFoundError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\013DocNotFoundError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** Indicates an attempt to use a feature which is unavailable. - * - * Typically a feature is unavailable because it wasn't compiled in, or - * because it requires other software or facilities which aren't available. - */ -class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\014FeatureUnavailableError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit FeatureUnavailableError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\014FeatureUnavailableError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - FeatureUnavailableError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\014FeatureUnavailableError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** InternalError indicates a runtime problem of some sort. - */ -class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - InternalError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\015InternalError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit InternalError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\015InternalError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - InternalError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\015InternalError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InternalError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - InternalError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** Indicates a problem communicating with a remote database. - */ -class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - NetworkError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\016NetworkError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit NetworkError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\016NetworkError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - NetworkError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\016NetworkError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - NetworkError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - NetworkError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** Indicates a timeout expired while communicating with a remote database. - */ -class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * error_string_) - : NetworkError(msg_, context_, "\017NetworkTimeoutError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit NetworkTimeoutError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : NetworkError(msg_, context_, "\017NetworkTimeoutError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - NetworkTimeoutError(const std::string &msg_, int errno_) - : NetworkError(msg_, std::string(), "\017NetworkTimeoutError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : NetworkError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : NetworkError(msg_, context_, type_, errno_) {} -}; - -/** Indicates a query string can't be parsed. - */ -class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - QueryParserError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\020QueryParserError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit QueryParserError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\020QueryParserError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - QueryParserError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\020QueryParserError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** Indicates an error in the std::string serialisation of an object. - */ -class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - SerialisationError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\021SerialisationError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit SerialisationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\021SerialisationError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - SerialisationError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\021SerialisationError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - SerialisationError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - SerialisationError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** RangeError indicates an attempt to access outside the bounds of a container. - */ -class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - RangeError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\022RangeError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit RangeError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\022RangeError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - RangeError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\022RangeError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - RangeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - RangeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** WildcardError indicates an error expanding a wildcarded query. - */ -class XAPIAN_VISIBILITY_DEFAULT WildcardError : public RuntimeError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - WildcardError(const std::string &msg_, const std::string &context_, const char * error_string_) - : RuntimeError(msg_, context_, "\023WildcardError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit WildcardError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : RuntimeError(msg_, context_, "\023WildcardError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - WildcardError(const std::string &msg_, int errno_) - : RuntimeError(msg_, std::string(), "\023WildcardError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - WildcardError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : RuntimeError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - WildcardError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : RuntimeError(msg_, context_, type_, errno_) {} -}; - -/** Indicates an attempt to access a database not present. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseNotFoundError : public DatabaseOpeningError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseOpeningError(msg_, context_, "\024DatabaseNotFoundError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseNotFoundError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseOpeningError(msg_, context_, "\024DatabaseNotFoundError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseNotFoundError(const std::string &msg_, int errno_) - : DatabaseOpeningError(msg_, std::string(), "\024DatabaseNotFoundError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseOpeningError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseOpeningError(msg_, context_, type_, errno_) {} -}; - -/** Indicates an attempt to access a closed database. - */ -class XAPIAN_VISIBILITY_DEFAULT DatabaseClosedError : public DatabaseError { - public: - /** @private @internal - * @brief Private constructor for use by remote backend. - * - * @param error_string_ Optional string describing error. May be NULL. - */ - DatabaseClosedError(const std::string &msg_, const std::string &context_, const char * error_string_) - : DatabaseError(msg_, context_, "\025DatabaseClosedError", error_string_) {} - /** General purpose constructor. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param context_ Optional context information for this error. - * @param errno_ Optional errno value associated with this error. - */ - explicit DatabaseClosedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) - : DatabaseError(msg_, context_, "\025DatabaseClosedError", errno_) {} - /** Construct from message and errno value. - * - * @param msg_ Message giving details of the error, intended - * for human consumption. - * @param errno_ Optional errno value associated with this error. - */ - DatabaseClosedError(const std::string &msg_, int errno_) - : DatabaseError(msg_, std::string(), "\025DatabaseClosedError", errno_) {} - protected: - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseClosedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) - : DatabaseError(msg_, context_, type_, error_string_) {} - - /** @private @internal - * @brief Constructor for use by constructors of derived classes. - */ - DatabaseClosedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_) - : DatabaseError(msg_, context_, type_, errno_) {} -}; - -} - -#endif /* XAPIAN_INCLUDED_ERROR_H */ diff --git a/winlibs/include/xapian/errorhandler.h b/winlibs/include/xapian/errorhandler.h deleted file mode 100644 index bc3162f04..000000000 --- a/winlibs/include/xapian/errorhandler.h +++ /dev/null @@ -1,125 +0,0 @@ -/** @file errorhandler.h - * @brief Decide if a Xapian::Error exception should be ignored. - */ -/* Copyright (C) 2003,2006,2007,2012,2013,2014,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_ERRORHANDLER_H -#define XAPIAN_INCLUDED_ERRORHANDLER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error "Never use directly; include instead." -#endif - -#include -#include -#include -#include - -namespace Xapian { - -class Error; - -/** Decide if a Xapian::Error exception should be ignored. - * - * You can create your own subclass of this class and pass in an instance - * of it when you construct a Xapian::Enquire object. Xapian::Error - * exceptions which happen during the match process are passed to this - * object and it can decide whether they should propagate or whether - * Enquire should attempt to continue. - * - * The motivation is to allow searching over remote databases to handle a - * remote server which has died (both to allow results to be returned, and - * also so that such errors can be logged and dead servers temporarily removed - * from use). - */ -class XAPIAN_VISIBILITY_DEFAULT ErrorHandler - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const ErrorHandler &); - - /// Don't allow copying. - ErrorHandler(const Xapian::ErrorHandler &); - - /** Perform user-specified error handling. - * - * This virtual method must be defined by the API user to specify - * how a Xapian::Error is to be handled. - * - * If you want execution to continue (where possible), then return - * true. If you want the Error to be rethrown and propagate out - * of the library, then return false. - * - * Note that it's not always possible to continue execution, so - * the error may be rethrown even if you return true. The ErrorHandler - * is still called in this situation as you may want to log that a - * particular remote backend server isn't responding, and perhaps - * remove it from those being searched temporarily. - * - * @param error The Xapian::Error object under consideration. - * - * @return true to attempt to continue; false to rethrow the error. - */ - XAPIAN_DEPRECATED_EX(virtual bool handle_error(Xapian::Error &error)) = 0; - - public: - /// Default constructor. - XAPIAN_NOTHROW(ErrorHandler()) {} - - /// We require a virtual destructor because we have virtual methods. - virtual ~ErrorHandler(); - - /** Handle a Xapian::Error object. - * - * This method is called when a Xapian::Error object is thrown and - * caught inside Enquire. If this is the first ErrorHandler that - * the Error has been passed to, then the handle_error() virtual - * method is called, which allows the API user to decide how to - * handle the error. - * - * @param error The Xapian::Error object under consideration. - */ - void operator()(Xapian::Error &error); - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ErrorHandler - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - ErrorHandler * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ErrorHandler - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const ErrorHandler * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -} - -#endif /* XAPIAN_INCLUDED_ERRORHANDLER_H */ diff --git a/winlibs/include/xapian/eset.h b/winlibs/include/xapian/eset.h deleted file mode 100644 index 7d1ad6580..000000000 --- a/winlibs/include/xapian/eset.h +++ /dev/null @@ -1,368 +0,0 @@ -/** @file - * @brief Class representing a list of query expansion terms - */ -/* Copyright (C) 2015,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_ESET_H -#define XAPIAN_INCLUDED_ESET_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include -#include - -namespace Xapian { - -class ESetIterator; - -/// Class representing a list of search results. -class XAPIAN_VISIBILITY_DEFAULT ESet { - friend class ESetIterator; - - public: - /// Class representing the ESet internals. - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /** Copying is allowed. - * - * The internals are reference counted, so copying is cheap. - */ - ESet(const ESet & o); - - /** Copying is allowed. - * - * The internals are reference counted, so assignment is cheap. - */ - ESet & operator=(const ESet & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - ESet(ESet && o); - - /// Move assignment operator. - ESet & operator=(ESet && o); -#endif - - /** Default constructor. - * - * Creates an empty ESet, mostly useful as a placeholder. - */ - ESet(); - - /// Destructor. - ~ESet(); - - /** Return number of items in this ESet object. */ - Xapian::doccount size() const; - - /** Return true if this ESet object is empty. */ - bool empty() const { return size() == 0; } - - /** Return a bound on the full size of this ESet object. - * - * This is a bound on size() if get_eset() had been called with - * maxitems set high enough that all results were returned. - */ - Xapian::termcount get_ebound() const; - - /** Efficiently swap this ESet object with another. */ - void swap(ESet & o) { internal.swap(o.internal); } - - /** Return iterator pointing to the first item in this ESet. */ - ESetIterator begin() const; - - /** Return iterator pointing to just after the last item in this ESet. */ - ESetIterator end() const; - - /** Return iterator pointing to the i-th object in this ESet. */ - ESetIterator operator[](Xapian::doccount i) const; - - /** Return iterator pointing to the last object in this ESet. */ - ESetIterator back() const; - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal ESet is what the C++ STL calls a container. - * - * The following typedefs allow the class to be used in templates in the - * same way the standard containers can be. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian container classes are compatible with the STL. - * - * See "The C++ Programming Language", 3rd ed. section 16.3.1: - */ - // @{ - /// @private - typedef Xapian::ESetIterator value_type; - /// @private - typedef Xapian::termcount size_type; - /// @private - typedef Xapian::termcount_diff difference_type; - /// @private - typedef Xapian::ESetIterator iterator; - /// @private - typedef Xapian::ESetIterator const_iterator; - /// @private - typedef value_type * pointer; - /// @private - typedef const value_type * const_pointer; - /// @private - typedef value_type & reference; - /// @private - typedef const value_type & const_reference; - // @} - // - /** @private @internal ESet is what the C++ STL calls a container. - * - * The following methods allow the class to be used in templates in the - * same way the standard containers can be. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian container classes are compatible with the STL. - */ - // @{ - // The size is fixed once created. - Xapian::doccount max_size() const { return size(); } - // @} -}; - -/// Iterator over a Xapian::ESet. -class XAPIAN_VISIBILITY_DEFAULT ESetIterator { - friend class ESet; - - ESetIterator(const Xapian::ESet & eset_, Xapian::doccount off_from_end_) - : eset(eset_), off_from_end(off_from_end_) { } - - public: - /** @private @internal The ESet we are iterating over. */ - Xapian::ESet eset; - - /** @private @internal The current position of the iterator. - * - * We store the offset from the end of @a eset, since that means - * ESet::end() just needs to set this member to 0. - */ - Xapian::ESet::size_type off_from_end; - - /** Create an unpositioned ESetIterator. */ - ESetIterator() : off_from_end(0) { } - - /** Get the term at the current position. */ - std::string operator*() const; - - /// Advance the iterator to the next position. - ESetIterator & operator++() { - --off_from_end; - return *this; - } - - /// Advance the iterator to the next position (postfix version). - ESetIterator operator++(int) { - ESetIterator retval = *this; - --off_from_end; - return retval; - } - - /// Move the iterator to the previous position. - ESetIterator & operator--() { - ++off_from_end; - return *this; - } - - /// Move the iterator to the previous position (postfix version). - ESetIterator operator--(int) { - ESetIterator retval = *this; - ++off_from_end; - return retval; - } - - /** @private @internal ESetIterator is what the C++ STL calls an - * random_access_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::random_access_iterator_tag iterator_category; - /// @private - typedef std::string value_type; - /// @private - typedef Xapian::termcount_diff difference_type; - /// @private - typedef std::string * pointer; - /// @private - typedef std::string & reference; - // @} - - /// Move the iterator forwards by n positions. - ESetIterator & operator+=(difference_type n) { - off_from_end -= n; - return *this; - } - - /// Move the iterator back by n positions. - ESetIterator & operator-=(difference_type n) { - off_from_end += n; - return *this; - } - - /** Return the iterator incremented by @a n positions. - * - * If @a n is negative, decrements by (-n) positions. - */ - ESetIterator operator+(difference_type n) const { - return ESetIterator(eset, off_from_end - n); - } - - /** Return the iterator decremented by @a n positions. - * - * If @a n is negative, increments by (-n) positions. - */ - ESetIterator operator-(difference_type n) const { - return ESetIterator(eset, off_from_end + n); - } - - /** Return the number of positions between @a o and this iterator. */ - difference_type operator-(const ESetIterator& o) const { - return difference_type(o.off_from_end) - difference_type(off_from_end); - } - - /** Get the weight for the current position. */ - double get_weight() const; - - /// Return a string describing this object. - std::string get_description() const; -}; - -bool -XAPIAN_NOTHROW(operator==(const ESetIterator &a, const ESetIterator &b)); - -/// Equality test for ESetIterator objects. -inline bool -operator==(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return a.off_from_end == b.off_from_end; -} - -inline bool -XAPIAN_NOTHROW(operator!=(const ESetIterator &a, const ESetIterator &b)); - -/// Inequality test for ESetIterator objects. -inline bool -operator!=(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -bool -XAPIAN_NOTHROW(operator<(const ESetIterator &a, const ESetIterator &b)); - -/// Inequality test for ESetIterator objects. -inline bool -operator<(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return a.off_from_end > b.off_from_end; -} - -inline bool -XAPIAN_NOTHROW(operator>(const ESetIterator &a, const ESetIterator &b)); - -/// Inequality test for ESetIterator objects. -inline bool -operator>(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return b < a; -} - -inline bool -XAPIAN_NOTHROW(operator>=(const ESetIterator &a, const ESetIterator &b)); - -/// Inequality test for ESetIterator objects. -inline bool -operator>=(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return !(a < b); -} - -inline bool -XAPIAN_NOTHROW(operator<=(const ESetIterator &a, const ESetIterator &b)); - -/// Inequality test for ESetIterator objects. -inline bool -operator<=(const ESetIterator &a, const ESetIterator &b) XAPIAN_NOEXCEPT -{ - return !(b < a); -} - -/** Return ESetIterator @a it incremented by @a n positions. - * - * If @a n is negative, decrements by (-n) positions. - */ -inline ESetIterator -operator+(ESetIterator::difference_type n, const ESetIterator& it) -{ - return it + n; -} - -// Inlined methods of ESet which need ESetIterator to have been defined: - -inline ESetIterator -ESet::begin() const { - return ESetIterator(*this, size()); -} - -inline ESetIterator -ESet::end() const { - // Decrementing the result of end() needs to work, so we must pass in - // *this here. - return ESetIterator(*this, 0); -} - -inline ESetIterator -ESet::operator[](Xapian::doccount i) const { - return ESetIterator(*this, size() - i); -} - -inline ESetIterator -ESet::back() const { - return ESetIterator(*this, 1); -} - -} - -#endif // XAPIAN_INCLUDED_ESET_H diff --git a/winlibs/include/xapian/expanddecider.h b/winlibs/include/xapian/expanddecider.h deleted file mode 100644 index 12c71a71c..000000000 --- a/winlibs/include/xapian/expanddecider.h +++ /dev/null @@ -1,158 +0,0 @@ -/** @file - * @brief Allow rejection of terms during ESet generation. - */ -/* Copyright (C) 2007,2011,2013,2014,2015,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_EXPANDDECIDER_H -#define XAPIAN_INCLUDED_EXPANDDECIDER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include - -namespace Xapian { - -/** Virtual base class for expand decider functor. */ -class XAPIAN_VISIBILITY_DEFAULT ExpandDecider - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const ExpandDecider &); - - /// Don't allow copying. - ExpandDecider(const ExpandDecider &); - - public: - /// Default constructor. - ExpandDecider() { } - - /** Do we want this term in the ESet? - * - * @param term The term to test. - */ - virtual bool operator()(const std::string &term) const = 0; - - /** Virtual destructor, because we have virtual methods. */ - virtual ~ExpandDecider(); - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ExpandDecider - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - ExpandDecider * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ExpandDecider - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const ExpandDecider * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/** ExpandDecider subclass which rejects terms using two ExpandDeciders. - * - * Terms are only accepted if they are accepted by both of the specified - * ExpandDecider objects. - */ -class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderAnd : public ExpandDecider { - Internal::opt_intrusive_ptr first, second; - - public: - /** Terms will be checked with @a first, and if accepted, then checked - * with @a second. - * - * @param first_ First ExpandDecider object to test with. - * @param second_ ExpandDecider object to test with if first_ accepts. - */ - ExpandDeciderAnd(const ExpandDecider &first_, - const ExpandDecider &second_) - : first(&first_), second(&second_) { } - - /** Compatibility method. - * - * @param first_ First ExpandDecider object to test with. - * @param second_ ExpandDecider object to test with if first_ accepts. - */ - ExpandDeciderAnd(const ExpandDecider *first_, - const ExpandDecider *second_) - : first(first_), second(second_) { } - - virtual bool operator()(const std::string &term) const; -}; - -/** ExpandDecider subclass which rejects terms in a specified list. - * - * ExpandDeciderFilterTerms provides an easy way to filter out terms from - * a fixed list when generating an ESet. - */ -class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderFilterTerms : public ExpandDecider { - std::set rejects; - - public: - /** The two iterators specify a list of terms to be rejected. - * - * @param reject_begin Begin iterator for the list of terms to - * reject. It can be any input_iterator type - * which returns std::string or char * (e.g. - * TermIterator or char **). - * @param reject_end End iterator for the list of terms to reject. - */ - template - ExpandDeciderFilterTerms(Iterator reject_begin, Iterator reject_end) - : rejects(reject_begin, reject_end) { } - - virtual bool operator()(const std::string &term) const; -}; - -/** ExpandDecider subclass which restrict terms to a particular prefix - * - * ExpandDeciderFilterPrefix provides an easy way to choose terms with a - * particular prefix when generating an ESet. - */ -class XAPIAN_VISIBILITY_DEFAULT ExpandDeciderFilterPrefix : public ExpandDecider { - std::string prefix; - - public: - /** The parameter specify the prefix of terms to be retained - * @param prefix_ restrict terms to the particular prefix_ - */ - explicit ExpandDeciderFilterPrefix(const std::string &prefix_) - : prefix(prefix_) { } - - virtual bool operator() (const std::string &term) const; -}; - -} - -#endif // XAPIAN_INCLUDED_EXPANDDECIDER_H diff --git a/winlibs/include/xapian/geospatial.h b/winlibs/include/xapian/geospatial.h deleted file mode 100644 index ea7ea8cea..000000000 --- a/winlibs/include/xapian/geospatial.h +++ /dev/null @@ -1,688 +0,0 @@ -/** @file - * @brief Geospatial search support routines. - */ -/* Copyright 2008,2009 Lemur Consulting Ltd - * Copyright 2010,2011 Richard Boulton - * Copyright 2012,2013,2014,2015,2016 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_GEOSPATIAL_H -#define XAPIAN_INCLUDED_GEOSPATIAL_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include // For sortable_serialise -#include - -namespace Xapian { - -class Registry; - -double -XAPIAN_NOTHROW(miles_to_metres(double miles)) XAPIAN_CONST_FUNCTION; - -/** Convert from miles to metres. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -inline double -miles_to_metres(double miles) XAPIAN_NOEXCEPT -{ - return 1609.344 * miles; -} - -double -XAPIAN_NOTHROW(metres_to_miles(double metres)) XAPIAN_CONST_FUNCTION; - -/** Convert from metres to miles. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -inline double -metres_to_miles(double metres) XAPIAN_NOEXCEPT -{ - return metres * (1.0 / 1609.344); -} - -/** A latitude-longitude coordinate. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - * - * Note that latitude-longitude coordinates are only precisely meaningful if - * the datum used to define them is specified. This class ignores this - * issue - it is up to the caller to ensure that the datum used for each - * coordinate in a system is consistent. - */ -struct XAPIAN_VISIBILITY_DEFAULT LatLongCoord { - /** A latitude, as decimal degrees. - * - * Should be in the range -90 <= latitude <= 90 - * - * Positive latitudes represent the northern hemisphere. - */ - double latitude; - - /** A longitude, as decimal degrees. - * - * Will be wrapped around, so for example, -150 is equal to 210. When - * obtained from a serialised form, will be in the range 0 <= longitude < - * 360. - * - * Longitudes increase as coordinates move eastwards. - */ - double longitude; - - /** Construct an uninitialised coordinate. - */ - XAPIAN_NOTHROW(LatLongCoord()) {} - - /** Construct a coordinate. - * - * If the supplied longitude is out of the standard range, it will be - * normalised to the range 0 <= longitude < 360. - * - * If you want to avoid the checks (for example, you know that your values - * are already in range), you can use the alternate constructor to - * construct an uninitialised coordinate, and then set the latitude and - * longitude directly. - * - * @exception InvalidArgumentError the supplied latitude is out of range. - */ - LatLongCoord(double latitude_, double longitude_); - - /** Unserialise a string and set this object to its coordinate. - * - * @param serialised the string to unserialise the coordinate from. - * - * @exception Xapian::SerialisationError if the string does not contain - * a valid serialised latitude-longitude pair, or contains extra data at - * the end of it. - */ - void unserialise(const std::string & serialised); - - /** Unserialise a buffer and set this object to its coordinate. - * - * The buffer may contain further data after that for the coordinate. - * - * @param ptr A pointer to the start of the string. This will be updated - * to point to the end of the data representing the coordinate. - * @param end A pointer to the end of the string. - * - * @exception Xapian::SerialisationError if the string does not start with - * a valid serialised latitude-longitude pair. - */ - void unserialise(const char ** ptr, const char * end); - - /** Return a serialised representation of the coordinate. - */ - std::string serialise() const; - - /** Compare with another LatLongCoord. - * - * This is mostly provided so that things like std::map work - * - the ordering isn't particularly meaningful. - */ - bool XAPIAN_NOTHROW(operator<(const LatLongCoord & other) const) - { - if (latitude < other.latitude) return true; - if (latitude > other.latitude) return false; - return (longitude < other.longitude); - } - - /// Return a string describing this object. - std::string get_description() const; -}; - -/** An iterator across the values in a LatLongCoords object. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -class XAPIAN_VISIBILITY_DEFAULT LatLongCoordsIterator { - /// Friend class which needs to be able to construct us. - friend class LatLongCoords; - - /// The current position of the iterator. - std::vector::const_iterator iter; - - /// Constructor used by LatLongCoords. - LatLongCoordsIterator(std::vector::const_iterator iter_) - : iter(iter_) {} - - public: - /// Default constructor. Produces an uninitialised iterator. - LatLongCoordsIterator() {} - - /** Get the LatLongCoord for the current position. */ - const LatLongCoord & operator*() const { - return *iter; - } - - /// Advance the iterator to the next position. - LatLongCoordsIterator & operator++() { - ++iter; - return *this; - } - - /// Advance the iterator to the next position (postfix version). - DerefWrapper_ operator++(int) { - const LatLongCoord & tmp = **this; - ++iter; - return DerefWrapper_(tmp); - } - - /// Equality test for LatLongCoordsIterator objects. - bool operator==(const LatLongCoordsIterator &other) const - { - return iter == other.iter; - } - - /** @private @internal LatLongCoordsIterator is what the C++ STL calls an - * input_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::input_iterator_tag iterator_category; - /// @private - typedef LatLongCoord value_type; - /// @private - typedef size_t difference_type; - /// @private - typedef LatLongCoord * pointer; - /// @private - typedef LatLongCoord & reference; - // @} -}; - -/** A sequence of latitude-longitude coordinates. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -class XAPIAN_VISIBILITY_DEFAULT LatLongCoords { - /// The coordinates. - std::vector coords; - - public: - /// Get a begin iterator for the coordinates. - LatLongCoordsIterator begin() const { - return LatLongCoordsIterator(coords.begin()); - } - - /// Get an end iterator for the coordinates. - LatLongCoordsIterator end() const { - return LatLongCoordsIterator(coords.end()); - } - - /// Get the number of coordinates in the container. - size_t size() const - { - return coords.size(); - } - - /// Return true if and only if there are no coordinates in the container. - bool empty() const - { - return coords.empty(); - } - - /// Append a coordinate to the end of the sequence. - void append(const LatLongCoord & coord) - { - coords.push_back(coord); - } - - /// Construct an empty container. - LatLongCoords() : coords() {} - - /// Construct a container holding one coordinate. - LatLongCoords(const LatLongCoord & coord) : coords() - { - coords.push_back(coord); - } - - /** Unserialise a string and set this object to the coordinates in it. - * - * @param serialised the string to unserialise the coordinates from. - * - * @exception Xapian::SerialisationError if the string does not contain - * a valid serialised latitude-longitude pair, or contains junk at the end - * of it. - */ - void unserialise(const std::string & serialised); - - /** Return a serialised form of the coordinate list. - */ - std::string serialise() const; - - /// Return a string describing this object. - std::string get_description() const; -}; - -/// Inequality test for LatLongCoordsIterator objects. -inline bool -operator!=(const LatLongCoordsIterator &a, const LatLongCoordsIterator &b) -{ - return !(a == b); -} - -/** Base class for calculating distances between two lat/long coordinates. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -class XAPIAN_VISIBILITY_DEFAULT LatLongMetric { - public: - /// Destructor. - virtual ~LatLongMetric(); - - /** Return the distance between two coordinates, in metres. - */ - virtual double pointwise_distance(const LatLongCoord & a, - const LatLongCoord & b) const = 0; - - /** Return the distance between two coordinate lists, in metres. - * - * The distance between the coordinate lists is defined to be the minimum - * pairwise distance between coordinates in the lists. - * - * @exception InvalidArgumentError either of the lists is empty. - * - * @param a The first coordinate list. - * @param b The second coordinate list. - */ - double operator()(const LatLongCoords & a, const LatLongCoords & b) const; - - /** Return the distance between two coordinate lists, in metres. - * - * One of the coordinate lists is supplied in serialised form. - * - * The distance between the coordinate lists is defined to be the minimum - * pairwise distance between coordinates in the lists. - * - * @exception InvalidArgumentError either of the lists is empty. - * - * @param a The first coordinate list. - * @param b The second coordinate list, in serialised form. - */ - double operator()(const LatLongCoords & a, const std::string & b) const - { - return (*this)(a, b.data(), b.size()); - } - - /** Return the distance between two coordinate lists, in metres. - * - * One of the coordinate lists is supplied in serialised form. - * - * The distance between the coordinate lists is defined to be the minimum - * pairwise distance between coordinates in the lists. - * - * @exception InvalidArgumentError either of the lists is empty. - * - * @param a The first coordinate list. - * @param b_ptr The start of the serialised form of the second coordinate - * list. - * @param b_len The length of the serialised form of the second coordinate - * list. - */ - double operator()(const LatLongCoords & a, - const char * b_ptr, size_t b_len) const; - - /** Clone the metric. */ - virtual LatLongMetric * clone() const = 0; - - /** Return the full name of the metric. - * - * This is used when serialising and unserialising metrics; for example, - * for performing remote searches. - * - * If the subclass is in a C++ namespace, the namespace should be included - * in the name, using "::" as a separator. For example, for a - * LatLongMetric subclass called "FooLatLongMetric" in the "Xapian" - * namespace the result of this call should be "Xapian::FooLatLongMetric". - */ - virtual std::string name() const = 0; - - /** Serialise object parameters into a string. - * - * The serialised parameters should represent the configuration of the - * metric. - */ - virtual std::string serialise() const = 0; - - /** Create object given string serialisation returned by serialise(). - * - * @param serialised A serialised instance of this LatLongMetric subclass. - */ - virtual LatLongMetric * unserialise(const std::string & serialised) const = 0; -}; - -/** Calculate the great-circle distance between two coordinates on a sphere. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - * - * This uses the haversine formula to calculate the distance. Note that this - * formula is subject to inaccuracy due to numerical errors for coordinates on - * the opposite side of the sphere. - * - * See https://en.wikipedia.org/wiki/Haversine_formula - */ -class XAPIAN_VISIBILITY_DEFAULT GreatCircleMetric : public LatLongMetric { - /** The radius of the sphere in metres. - */ - double radius; - - public: - /** Construct a GreatCircleMetric. - * - * The (quadratic mean) radius of the Earth will be used by this - * calculator. - */ - GreatCircleMetric(); - - /** Construct a GreatCircleMetric using a specified radius. - * - * This is useful for data sets in which the points are not on Earth (eg, - * a database of features on Mars). - * - * @param radius_ The radius of the sphere to use, in metres. - */ - explicit GreatCircleMetric(double radius_); - - /** Return the great-circle distance between points on the sphere. - */ - double pointwise_distance(const LatLongCoord & a, - const LatLongCoord &b) const; - - LatLongMetric * clone() const; - std::string name() const; - std::string serialise() const; - LatLongMetric * unserialise(const std::string & serialised) const; -}; - -/** Posting source which returns a weight based on geospatial distance. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - * - * Results are weighted by the distance from a fixed point, or list of points, - * calculated according to the metric supplied. If multiple points are - * supplied (either in the constructor, or in the coordinates stored in a - * document), the closest pointwise distance is used. - * - * Documents further away than a specified maximum range (or with no location - * stored in the specified slot) will not be returned. - * - * The weight returned is computed from the distance using the formula: - * - * k1 * pow(distance + k1, -k2) - * - * (Where k1 and k2 are (strictly) positive, floating point constants, which - * default to 1000 and 1, respectively. Distance is measured in metres, so - * this means that something at the centre gets a weight of 1.0, something 1km - * away gets a weight of 0.5, and something 3km away gets a weight of 0.25, - * etc) - */ -class XAPIAN_VISIBILITY_DEFAULT LatLongDistancePostingSource : public ValuePostingSource -{ - /// Current distance from centre. - double dist; - - /// Centre, to compute distance from. - LatLongCoords centre; - - /// Metric to compute the distance with. - const LatLongMetric * metric; - - /// Maximum range to allow. If set to 0, there is no maximum range. - double max_range; - - /// Constant used in weighting function. - double k1; - - /// Constant used in weighting function. - double k2; - - /// Calculate the distance for the current document. - void calc_distance(); - - /// Internal constructor; used by clone() and serialise(). - LatLongDistancePostingSource(Xapian::valueno slot_, - const LatLongCoords & centre_, - const LatLongMetric * metric_, - double max_range_, - double k1_, - double k2_); - - public: - /** Construct a new posting source which returns only documents within - * range of one of the central coordinates. - * - * @param slot_ The value slot to read values from. - * @param centre_ The centre point to use for distance calculations. - * @param metric_ The metric to use for distance calculations. - * @param max_range_ The maximum distance for documents which are returned. - * @param k1_ The k1 constant to use in the weighting function. - * @param k2_ The k2 constant to use in the weighting function. - */ - LatLongDistancePostingSource(Xapian::valueno slot_, - const LatLongCoords & centre_, - const LatLongMetric & metric_, - double max_range_ = 0.0, - double k1_ = 1000.0, - double k2_ = 1.0); - - /** Construct a new posting source which returns only documents within - * range of one of the central coordinates. - * - * @param slot_ The value slot to read values from. - * @param centre_ The centre point to use for distance calculations. - * @param max_range_ The maximum distance for documents which are returned. - * @param k1_ The k1 constant to use in the weighting function. - * @param k2_ The k2 constant to use in the weighting function. - * - * Xapian::GreatCircleMetric is used as the metric. - */ - LatLongDistancePostingSource(Xapian::valueno slot_, - const LatLongCoords & centre_, - double max_range_ = 0.0, - double k1_ = 1000.0, - double k2_ = 1.0); - ~LatLongDistancePostingSource(); - - void next(double min_wt); - void skip_to(Xapian::docid min_docid, double min_wt); - bool check(Xapian::docid min_docid, double min_wt); - - double get_weight() const; - LatLongDistancePostingSource * clone() const; - std::string name() const; - std::string serialise() const; - LatLongDistancePostingSource * - unserialise_with_registry(const std::string &serialised, - const Registry & registry) const; - void init(const Database & db_); - - std::string get_description() const; -}; - -/** KeyMaker subclass which sorts by distance from a latitude/longitude. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - * - * Results are ordered by the distance from a fixed point, or list of points, - * calculated according to the metric supplied. If multiple points are - * supplied (either in the constructor, or in the coordinates stored in a - * document), the closest pointwise distance is used. - * - * If a document contains no coordinate stored in the specified slot, a - * special value for the distance will be used. This defaults to a large - * number, so that such results get a low rank, but may be specified by a - * constructor parameter. - */ -class XAPIAN_VISIBILITY_DEFAULT LatLongDistanceKeyMaker : public KeyMaker { - - /// The value slot to read. - Xapian::valueno slot; - - /// The centre point (or points) for distance calculation. - LatLongCoords centre; - - /// The metric to use when calculating distances. - const LatLongMetric * metric; - - /// The default key to return, for documents with no value stored. - std::string defkey; - - public: - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ List of points to calculate distance from - * (closest distance is used). - * @param metric_ LatLongMetric to use. - * @param defdistance Distance to use for docs with no value set. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoords & centre_, - const LatLongMetric & metric_, - double defdistance) - : slot(slot_), - centre(centre_), - metric(metric_.clone()), - defkey(sortable_serialise(defdistance)) - {} - - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ List of points to calculate distance from - * (closest distance is used). - * @param metric_ LatLongMetric to use. - * - * Documents where no value is set are assumed to be a large distance - * away. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoords & centre_, - const LatLongMetric & metric_) - : slot(slot_), - centre(centre_), - metric(metric_.clone()), - defkey(9, '\xff') - {} - - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ List of points to calculate distance from - * (closest distance is used). - * - * Xapian::GreatCircleMetric is used as the metric. - * - * Documents where no value is set are assumed to be a large distance - * away. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoords & centre_) - : slot(slot_), - centre(centre_), - metric(new Xapian::GreatCircleMetric()), - defkey(9, '\xff') - {} - - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ Point to calculate distance from. - * @param metric_ LatLongMetric to use. - * @param defdistance Distance to use for docs with no value set. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoord & centre_, - const LatLongMetric & metric_, - double defdistance) - : slot(slot_), - centre(), - metric(metric_.clone()), - defkey(sortable_serialise(defdistance)) - { - centre.append(centre_); - } - - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ Point to calculate distance from. - * @param metric_ LatLongMetric to use. - * - * Documents where no value is set are assumed to be a large distance - * away. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoord & centre_, - const LatLongMetric & metric_) - : slot(slot_), - centre(), - metric(metric_.clone()), - defkey(9, '\xff') - { - centre.append(centre_); - } - - /** Construct a LatLongDistanceKeyMaker. - * - * @param slot_ Value slot to use. - * @param centre_ Point to calculate distance from. - * - * Xapian::GreatCircleMetric is used as the metric. - * - * Documents where no value is set are assumed to be a large distance - * away. - */ - LatLongDistanceKeyMaker(Xapian::valueno slot_, - const LatLongCoord & centre_) - : slot(slot_), - centre(), - metric(new Xapian::GreatCircleMetric()), - defkey(9, '\xff') - { - centre.append(centre_); - } - - ~LatLongDistanceKeyMaker(); - - std::string operator()(const Xapian::Document & doc) const; -}; - -} - -#endif /* XAPIAN_INCLUDED_GEOSPATIAL_H */ diff --git a/winlibs/include/xapian/intrusive_ptr.h b/winlibs/include/xapian/intrusive_ptr.h deleted file mode 100644 index d55fa03ee..000000000 --- a/winlibs/include/xapian/intrusive_ptr.h +++ /dev/null @@ -1,417 +0,0 @@ -#ifndef XAPIAN_INCLUDED_INTRUSIVE_PTR_H -#define XAPIAN_INCLUDED_INTRUSIVE_PTR_H - -// -// Based on Boost's intrusive_ptr.hpp -// -// Copyright (c) 2001, 2002 Peter Dimov -// Copyright (c) 2011,2013,2014,2015 Olly Betts -// -// Distributed under the Boost Software License, Version 1.0. -// -// Boost Software License - Version 1.0 - August 17th, 2003 -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation. -// - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include - -namespace Xapian { -namespace Internal { - -/// Base class for objects managed by intrusive_ptr. -class intrusive_base { - /// Prevent copying. - intrusive_base(const intrusive_base&); - - /// Prevent assignment. - void operator=(const intrusive_base&); - - public: - /** Construct with no references. - * - * The references get added if/when this object is put into an - * intrusive_ptr. - */ - intrusive_base() : _refs(0) { } - - /* There's no need for a virtual destructor here as we never delete a - * subclass of intrusive_base by calling delete on intrusive_base*. - */ - - /** Reference count. - * - * This needs to be mutable so we can add/remove references through const - * pointers. - */ - mutable unsigned _refs; -}; - -// -// intrusive_ptr -// - -/// A smart pointer that uses intrusive reference counting. -template class intrusive_ptr -{ -private: - - typedef intrusive_ptr this_type; - -public: - - intrusive_ptr(): px( 0 ) - { - } - - intrusive_ptr( T * p): px( p ) - { - if( px != 0 ) ++px->_refs; - } - - template - intrusive_ptr( intrusive_ptr const & rhs ) - : px( rhs.get() ) - { - if( px != 0 ) ++px->_refs; - } - - intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px ) - { - if( px != 0 ) ++px->_refs; - } - - ~intrusive_ptr() - { - if( px != 0 && --px->_refs == 0 ) delete px; - } - -#ifdef XAPIAN_MOVE_SEMANTICS - intrusive_ptr(intrusive_ptr && rhs) : px( rhs.px ) - { - rhs.px = 0; - } - - intrusive_ptr & operator=(intrusive_ptr && rhs) - { - this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); - return *this; - } - - template friend class intrusive_ptr; - - template - intrusive_ptr(intrusive_ptr && rhs) : px( rhs.px ) - { - rhs.px = 0; - } - - template - intrusive_ptr & operator=(intrusive_ptr && rhs) - { - this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); - return *this; - } -#endif - - intrusive_ptr & operator=(intrusive_ptr const & rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - intrusive_ptr & operator=(T * rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - T * get() const - { - return px; - } - - T & operator*() const - { - return *px; - } - - T * operator->() const - { - return px; - } - - void swap(intrusive_ptr & rhs) - { - T * tmp = px; - px = rhs.px; - rhs.px = tmp; - } - -private: - - T * px; -}; - -template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() != b.get(); -} - -template inline bool operator==(intrusive_ptr const & a, U * b) -{ - return a.get() == b; -} - -template inline bool operator!=(intrusive_ptr const & a, U * b) -{ - return a.get() != b; -} - -template inline bool operator==(T * a, intrusive_ptr const & b) -{ - return a == b.get(); -} - -template inline bool operator!=(T * a, intrusive_ptr const & b) -{ - return a != b.get(); -} - -/// Base class for objects managed by opt_intrusive_ptr. -class XAPIAN_VISIBILITY_DEFAULT opt_intrusive_base { - public: - opt_intrusive_base(const opt_intrusive_base&) : _refs(0) { } - - opt_intrusive_base& operator=(const opt_intrusive_base&) { - // Don't touch _refs. - return *this; - } - - /** Construct object which is initially not reference counted. - * - * The reference counting starts if release() is called. - */ - opt_intrusive_base() : _refs(0) { } - - /* Subclasses of opt_intrusive_base may be deleted by calling delete on a - * pointer to opt_intrusive_base. - */ - virtual ~opt_intrusive_base() { } - - void ref() const { - if (_refs == 0) - _refs = 2; - else - ++_refs; - } - - void unref() const { - if (--_refs == 1) - delete this; - } - - /** Reference count. - * - * This needs to be mutable so we can add/remove references through const - * pointers. - */ - mutable unsigned _refs; - - protected: - /** Start reference counting. - * - * The object is constructed with _refs set to 0, meaning it isn't being - * reference counted. - * - * Calling release() sets _refs to 1 if it is 0, and from then - * opt_intrusive_ptr will increment and decrement _refs. If it is - * decremented to 1, the object is deleted. - */ - void release() const { - if (_refs == 0) - _refs = 1; - } -}; - -// -// opt_intrusive_ptr -// - -/// A smart pointer that optionally uses intrusive reference counting. -template class opt_intrusive_ptr -{ -private: - - typedef opt_intrusive_ptr this_type; - -public: - - opt_intrusive_ptr(): px( 0 ), counting( false ) - { - } - - opt_intrusive_ptr( T * p): px( p ), counting( px != 0 && px->_refs ) - { - if( counting ) ++px->_refs; - } - - template - opt_intrusive_ptr( opt_intrusive_ptr const & rhs ) - : px( rhs.get() ), counting( rhs.counting ) - { - if( counting ) ++px->_refs; - } - - opt_intrusive_ptr(opt_intrusive_ptr const & rhs) - : px( rhs.px ), counting( rhs.counting ) - { - if( counting ) ++px->_refs; - } - - ~opt_intrusive_ptr() - { - if( counting && --px->_refs == 1 ) delete px; - } - -#ifdef XAPIAN_MOVE_SEMANTICS - opt_intrusive_ptr(opt_intrusive_ptr && rhs) - : px( rhs.px ), counting( rhs.counting ) - { - rhs.px = 0; - rhs.counting = 0; - } - - opt_intrusive_ptr & operator=(opt_intrusive_ptr && rhs) - { - this_type( static_cast< opt_intrusive_ptr && >( rhs ) ).swap(*this); - return *this; - } - - template friend class opt_intrusive_ptr; - - template - opt_intrusive_ptr(opt_intrusive_ptr && rhs) - : px( rhs.px ), counting( rhs.counting ) - { - rhs.px = 0; - rhs.counting = 0; - } - - template - opt_intrusive_ptr & operator=(opt_intrusive_ptr && rhs) - { - this_type( static_cast< opt_intrusive_ptr && >( rhs ) ).swap(*this); - return *this; - } -#endif - - opt_intrusive_ptr & operator=(opt_intrusive_ptr const & rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - opt_intrusive_ptr & operator=(T * rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - T * get() const - { - return px; - } - - T & operator*() const - { - return *px; - } - - T * operator->() const - { - return px; - } - - void swap(opt_intrusive_ptr & rhs) - { - T * tmp = px; - px = rhs.px; - rhs.px = tmp; - bool tmp2 = counting; - counting = rhs.counting; - rhs.counting = tmp2; - } - -private: - - T * px; - - bool counting; -}; - -template inline bool operator==(opt_intrusive_ptr const & a, opt_intrusive_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(opt_intrusive_ptr const & a, opt_intrusive_ptr const & b) -{ - return a.get() != b.get(); -} - -template inline bool operator==(opt_intrusive_ptr const & a, U * b) -{ - return a.get() == b; -} - -template inline bool operator!=(opt_intrusive_ptr const & a, U * b) -{ - return a.get() != b; -} - -template inline bool operator==(T * a, opt_intrusive_ptr const & b) -{ - return a == b.get(); -} - -template inline bool operator!=(T * a, opt_intrusive_ptr const & b) -{ - return a != b.get(); -} - -} -} - -#endif // XAPIAN_INCLUDED_INTRUSIVE_PTR_H diff --git a/winlibs/include/xapian/iterator.h b/winlibs/include/xapian/iterator.h deleted file mode 100644 index 2f56a3a90..000000000 --- a/winlibs/include/xapian/iterator.h +++ /dev/null @@ -1,103 +0,0 @@ -/** @file - * @brief Functions to assist creating language-idiomatic iterator wrappers. - */ -/* Copyright (C) 2014,2016,2017,2019 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_ITERATOR_H -#define XAPIAN_INCLUDED_ITERATOR_H - -/* These functions are not intended to be used from user C++ code - they are - * provided to make implementing language-idiomatic wrappers around Xapian's - * iterator classes easier in bindings for other languages. - * - * If you make use of this API, please let us know on xapian-devel so we can - * coordinate any incompatible changes which might be required in the future. - * - * Currently known users: - * - * * xapian-bindings: - * + Java - * + PHP - * * xapian-core: - * + examples/xapian-pos.cc - * * xapian-glib - */ - -#include - -namespace Xapian { - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::ESetIterator& it) { - return it.off_from_end != 0; -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::MSetIterator& it) { - return it.off_from_end != 0; -} - -/** @internal Rewind iterator. */ -inline void iterator_rewind(Xapian::ESetIterator& it) { - it.off_from_end = it.eset.size(); -} - -/** @internal Rewind iterator. */ -inline void iterator_rewind(Xapian::MSetIterator& it) { - it.off_from_end = it.mset.size(); -} - -/** @internal Is the iterator at the start? */ -inline bool iterator_rewound(Xapian::ESetIterator& it) { - return it.off_from_end == it.eset.size(); -} - -/** @internal Is the iterator at the start? */ -inline bool iterator_rewound(Xapian::MSetIterator& it) { - return it.off_from_end == it.mset.size(); -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::PositionIterator& it) { - return it.internal != NULL; -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::PostingIterator& it) { - return it.internal != NULL; -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::TermIterator& it) { - return it.internal != NULL; -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::ValueIterator& it) { - return it.internal != NULL; -} - -/** @internal Determine if iterator is valid to dereference. */ -inline bool iterator_valid(const Xapian::Utf8Iterator& it) { - return it != Xapian::Utf8Iterator(); -} - -} - -#endif // XAPIAN_INCLUDED_ITERATOR_H diff --git a/winlibs/include/xapian/keymaker.h b/winlibs/include/xapian/keymaker.h deleted file mode 100644 index ba8fac2f7..000000000 --- a/winlibs/include/xapian/keymaker.h +++ /dev/null @@ -1,151 +0,0 @@ -/** @file - * @brief Build key strings for MSet ordering or collapsing. - */ -/* Copyright (C) 2007,2009,2011,2013,2014,2015,2016 Olly Betts - * Copyright (C) 2010 Richard Boulton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_KEYMAKER_H -#define XAPIAN_INCLUDED_KEYMAKER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include - -namespace Xapian { - -class Document; - -/** Virtual base class for key making functors. */ -class XAPIAN_VISIBILITY_DEFAULT KeyMaker - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const KeyMaker &); - - /// Don't allow copying. - KeyMaker(const KeyMaker &); - - public: - /// Default constructor. - KeyMaker() { } - - /** Build a key string for a Document. - * - * These keys can be used for sorting or collapsing matching documents. - * - * @param doc Document object to build a key for. - */ - virtual std::string operator()(const Xapian::Document & doc) const = 0; - - /** Virtual destructor, because we have virtual methods. */ - virtual ~KeyMaker(); - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated KeyMaker - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - KeyMaker * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated KeyMaker - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const KeyMaker * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/** KeyMaker subclass which combines several values. - * - * When the result is used for sorting, results are ordered by the first - * value. In the event of a tie, the second is used. If this is the same for - * both, the third is used, and so on. If @a reverse is true for a value, - * then the sort order for that value is reversed. - * - * When used for collapsing, the documents will only be considered equal if - * all the values specified match. If none of the specified values are set - * then the generated key will be empty, so such documents won't be collapsed - * (which is consistent with the behaviour in the "collapse on a value" case). - * If you'd prefer that documents with none of the keys set are collapsed - * together, then you can set @a reverse for at least one of the values. - * Other than this, it isn't useful to set @a reverse for collapsing. - */ -class XAPIAN_VISIBILITY_DEFAULT MultiValueKeyMaker : public KeyMaker { - struct KeySpec { - Xapian::valueno slot; - bool reverse; - std::string defvalue; - KeySpec(Xapian::valueno slot_, bool reverse_, - const std::string & defvalue_) - : slot(slot_), reverse(reverse_), defvalue(defvalue_) - {} - }; - std::vector slots; - - public: - MultiValueKeyMaker() { } - - /** Construct a MultiValueKeyMaker from a pair of iterators. - * - * The iterators must be a begin/end pair returning Xapian::valueno (or - * a compatible type) when dereferenced. - */ - template - MultiValueKeyMaker(Iterator begin, Iterator end) { - while (begin != end) add_value(*begin++); - } - - virtual std::string operator()(const Xapian::Document & doc) const; - - /** Add a value slot to the list to build a key from. - * - * @param slot The value slot to add - * @param reverse Adjust values from this slot to reverse their sort - * order (default: false) - * @param defvalue Value to use for documents which don't have a value - * set in this slot (default: empty). This can be used - * to make such documents sort after all others by - * passing get_value_upper_bound(slot) + "x" - * - this is guaranteed to be greater than any value in - * this slot. - */ - void add_value(Xapian::valueno slot, bool reverse = false, - const std::string & defvalue = std::string()) { - slots.push_back(KeySpec(slot, reverse, defvalue)); - } -}; - -} - -#endif // XAPIAN_INCLUDED_KEYMAKER_H diff --git a/winlibs/include/xapian/matchspy.h b/winlibs/include/xapian/matchspy.h deleted file mode 100644 index bdff2fc04..000000000 --- a/winlibs/include/xapian/matchspy.h +++ /dev/null @@ -1,297 +0,0 @@ -/** @file - * @brief MatchSpy implementation. - */ -/* Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts - * Copyright (C) 2007,2009 Lemur Consulting Ltd - * Copyright (C) 2010 Richard Boulton - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_MATCHSPY_H -#define XAPIAN_INCLUDED_MATCHSPY_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include -#include - -#include -#include - -namespace Xapian { - -class Document; -class Registry; - -/** Abstract base class for match spies. - * - * The subclasses will generally accumulate information seen during the match, - * to calculate aggregate functions, or other profiles of the matching - * documents. - */ -class XAPIAN_VISIBILITY_DEFAULT MatchSpy - : public Xapian::Internal::opt_intrusive_base { - private: - /// Don't allow assignment. - void operator=(const MatchSpy &); - - /// Don't allow copying. - MatchSpy(const MatchSpy &); - - public: - /// Default constructor, needed by subclass constructors. - XAPIAN_NOTHROW(MatchSpy()) {} - - /** Virtual destructor, because we have virtual methods. */ - virtual ~MatchSpy(); - - /** Register a document with the match spy. - * - * This is called by the matcher once with each document seen by the - * matcher during the match process. Note that the matcher will often not - * see all the documents which match the query, due to optimisations which - * allow low-weighted documents to be skipped, and allow the match process - * to be terminated early. - * - * @param doc The document seen by the match spy. - * @param wt The weight of the document. - */ - virtual void operator()(const Xapian::Document &doc, - double wt) = 0; - - /** Clone the match spy. - * - * The clone should inherit the configuration of the parent, but need not - * inherit the state. ie, the clone does not need to be passed - * information about the results seen by the parent. - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - */ - virtual MatchSpy * clone() const; - - /** Return the name of this match spy. - * - * This name is used by the remote backend. It is passed with the - * serialised parameters to the remote server so that it knows which class - * to create. - * - * Return the full namespace-qualified name of your class here - if your - * class is called MyApp::FooMatchSpy, return "MyApp::FooMatchSpy" from - * this method. - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - */ - virtual std::string name() const; - - /** Return this object's parameters serialised as a single string. - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - */ - virtual std::string serialise() const; - - /** Unserialise parameters. - * - * This method unserialises parameters serialised by the @a serialise() - * method and allocates and returns a new object initialised with them. - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - * - * @param serialised A string containing the serialised results. - * @param context Registry object to use for unserialisation to permit - * MatchSpy subclasses with sub-MatchSpy objects to be - * implemented. - */ - virtual MatchSpy * unserialise(const std::string & serialised, - const Registry & context) const; - - /** Serialise the results of this match spy. - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - */ - virtual std::string serialise_results() const; - - /** Unserialise some results, and merge them into this matchspy. - * - * The order in which results are merged should not be significant, since - * this order is not specified (and will vary depending on the speed of - * the search in each sub-database). - * - * If you don't want to support the remote backend in your match spy, you - * can use the default implementation which simply throws - * Xapian::UnimplementedError. - * - * @param serialised A string containing the serialised results. - */ - virtual void merge_results(const std::string & serialised); - - /** Return a string describing this object. - * - * This default implementation returns a generic answer, to avoid forcing - * those deriving their own MatchSpy subclasses from having to implement - * this (they may not care what get_description() gives for their - * subclass). - */ - virtual std::string get_description() const; - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated MatchSpy - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - MatchSpy * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated MatchSpy - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const MatchSpy * release() const { - opt_intrusive_base::release(); - return this; - } -}; - - -/** Class for counting the frequencies of values in the matching documents. - */ -class XAPIAN_VISIBILITY_DEFAULT ValueCountMatchSpy : public MatchSpy { - public: - struct Internal; - -#ifndef SWIG // SWIG doesn't need to know about the internal class - /// @private @internal - struct XAPIAN_VISIBILITY_DEFAULT Internal - : public Xapian::Internal::intrusive_base - { - /// The slot to count. - Xapian::valueno slot; - - /// Total number of documents seen by the match spy. - Xapian::doccount total; - - /// The values seen so far, together with their frequency. - std::map values; - - Internal() : slot(Xapian::BAD_VALUENO), total(0) {} - explicit Internal(Xapian::valueno slot_) : slot(slot_), total(0) {} - }; -#endif - - protected: - /** @private @internal Reference counted internals. */ - Xapian::Internal::intrusive_ptr internal; - - public: - /// Construct an empty ValueCountMatchSpy. - ValueCountMatchSpy() {} - - /// Construct a MatchSpy which counts the values in a particular slot. - explicit ValueCountMatchSpy(Xapian::valueno slot_) - : internal(new Internal(slot_)) {} - - /** Return the total number of documents tallied. */ - size_t XAPIAN_NOTHROW(get_total() const) { - return internal.get() ? internal->total : 0; - } - - /** Get an iterator over the values seen in the slot. - * - * Items will be returned in ascending alphabetical order. - * - * During the iteration, the frequency of the current value can be - * obtained with the get_termfreq() method on the iterator. - */ - TermIterator values_begin() const; - - /** End iterator corresponding to values_begin() */ - TermIterator XAPIAN_NOTHROW(values_end() const) { - return TermIterator(); - } - - /** Get an iterator over the most frequent values seen in the slot. - * - * Items will be returned in descending order of frequency. Values with - * the same frequency will be returned in ascending alphabetical order. - * - * During the iteration, the frequency of the current value can be - * obtained with the get_termfreq() method on the iterator. - * - * @param maxvalues The maximum number of values to return. - */ - TermIterator top_values_begin(size_t maxvalues) const; - - /** End iterator corresponding to top_values_begin() */ - TermIterator XAPIAN_NOTHROW(top_values_end(size_t) const) { - return TermIterator(); - } - - /** Implementation of virtual operator(). - * - * This implementation tallies values for a matching document. - * - * @param doc The document to tally values for. - * @param wt The weight of the document (ignored by this class). - */ - void operator()(const Xapian::Document &doc, double wt); - - virtual MatchSpy * clone() const; - virtual std::string name() const; - virtual std::string serialise() const; - virtual MatchSpy * unserialise(const std::string & serialised, - const Registry & context) const; - virtual std::string serialise_results() const; - virtual void merge_results(const std::string & serialised); - virtual std::string get_description() const; -}; - -} - -#endif // XAPIAN_INCLUDED_MATCHSPY_H diff --git a/winlibs/include/xapian/mset.h b/winlibs/include/xapian/mset.h deleted file mode 100644 index 7e924a005..000000000 --- a/winlibs/include/xapian/mset.h +++ /dev/null @@ -1,635 +0,0 @@ -/** @file - * @brief Class representing a list of search results - */ -/* Copyright (C) 2015,2016,2019 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_MSET_H -#define XAPIAN_INCLUDED_MSET_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace Xapian { - -class MSetIterator; - -/// Class representing a list of search results. -class XAPIAN_VISIBILITY_DEFAULT MSet { - friend class MSetIterator; - - // Helper function for fetch() methods. - void fetch_(Xapian::doccount first, Xapian::doccount last) const; - - public: - /// Class representing the MSet internals. - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /** Copying is allowed. - * - * The internals are reference counted, so copying is cheap. - */ - MSet(const MSet & o); - - /** Copying is allowed. - * - * The internals are reference counted, so assignment is cheap. - */ - MSet & operator=(const MSet & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - MSet(MSet && o); - - /// Move assignment operator. - MSet & operator=(MSet && o); -#endif - - /** Default constructor. - * - * Creates an empty MSet, mostly useful as a placeholder. - */ - MSet(); - - /// Destructor. - ~MSet(); - - /** Convert a weight to a percentage. - * - * The matching document with the highest weight will get 100% if it - * matches all the weighted query terms, and proportionally less if it - * only matches some, and other weights are scaled by the same factor. - * - * Documents with a non-zero score will always score at least 1%. - * - * Note that these generally aren't percentages of anything meaningful - * (unless you use a custom weighting formula where they are!) - */ - int convert_to_percent(double weight) const; - - /** Convert the weight of the current iterator position to a percentage. - * - * The matching document with the highest weight will get 100% if it - * matches all the weighted query terms, and proportionally less if it - * only matches some, and other weights are scaled by the same factor. - * - * Documents with a non-zero score will always score at least 1%. - * - * Note that these generally aren't percentages of anything meaningful - * (unless you use a custom weighting formula where they are!) - */ - int convert_to_percent(const MSetIterator & it) const; - - /** Get the termfreq of a term. - * - * @return The number of documents which @a term occurs in. This - * considers all documents in the database being searched, so - * gives the same answer as db.get_termfreq(term) - * (but is more efficient for query terms as it returns a - * value cached during the search.) - */ - Xapian::doccount get_termfreq(const std::string & term) const; - - /** Get the term weight of a term. - * - * @return The maximum weight that @a term could have contributed to a - * document. - */ - double get_termweight(const std::string & term) const; - - /** Rank of first item in this MSet. - * - * This is the parameter `first` passed to Xapian::Enquire::get_mset(). - */ - Xapian::doccount get_firstitem() const; - - /** Lower bound on the total number of matching documents. */ - Xapian::doccount get_matches_lower_bound() const; - /** Estimate of the total number of matching documents. */ - Xapian::doccount get_matches_estimated() const; - /** Upper bound on the total number of matching documents. */ - Xapian::doccount get_matches_upper_bound() const; - - /** Lower bound on the total number of matching documents before collapsing. - * - * Conceptually the same as get_matches_lower_bound() for the same query - * without any collapse part (though the actual value may differ). - */ - Xapian::doccount get_uncollapsed_matches_lower_bound() const; - /** Estimate of the total number of matching documents before collapsing. - * - * Conceptually the same as get_matches_estimated() for the same query - * without any collapse part (though the actual value may differ). - */ - Xapian::doccount get_uncollapsed_matches_estimated() const; - /** Upper bound on the total number of matching documents before collapsing. - * - * Conceptually the same as get_matches_upper_bound() for the same query - * without any collapse part (though the actual value may differ). - */ - Xapian::doccount get_uncollapsed_matches_upper_bound() const; - - /** The maximum weight attained by any document. */ - double get_max_attained() const; - /** The maximum possible weight any document could achieve. */ - double get_max_possible() const; - - enum { - /** Model the relevancy of non-query terms in MSet::snippet(). - * - * Non-query terms will be assigned a small weight, and the snippet - * will tend to prefer snippets which contain a more interesting - * background (where the query term content is equivalent). - */ - SNIPPET_BACKGROUND_MODEL = 1, - /** Exhaustively evaluate candidate snippets in MSet::snippet(). - * - * Without this flag, snippet generation will stop once it thinks - * it has found a "good enough" snippet, which will generally reduce - * the time taken to generate a snippet. - */ - SNIPPET_EXHAUSTIVE = 2, - /** Return the empty string if no term got matched. - * - * If enabled, snippet() returns an empty string if not a single match - * was found in text. If not enabled, snippet() returns a (sub)string - * of text without any highlighted terms. - */ - SNIPPET_EMPTY_WITHOUT_MATCH = 4, - - /** Enable generation of n-grams from CJK text. - * - * This option highlights CJK searches made using the QueryParser - * FLAG_CJK_NGRAM flag. Non-CJK characters are split into words as - * normal. - * - * The TermGenerator FLAG_CJK_NGRAM flag needs to have been used at - * index time. - * - * This mode can also be enabled by setting environment variable - * XAPIAN_CJK_NGRAM to a non-empty value (but doing so was deprecated - * in 1.4.11). - * - * @since Added in Xapian 1.4.11. - */ - SNIPPET_CJK_NGRAM = 2048 - }; - - /** Generate a snippet. - * - * This method selects a continuous run of words from @a text, based - * mainly on where the query matches (currently terms, exact phrases and - * wildcards are taken into account). If flag SNIPPET_BACKGROUND_MODEL is - * used (which it is by default) then the selection algorithm also - * considers the non-query terms in the text with the aim of showing - * a context which provides more useful information. - * - * The size of the text selected can be controlled by the @a length - * parameter, which specifies a number of bytes of text to aim to select. - * However slightly more text may be selected. Also the size of any - * escaping, highlighting or omission markers is not considered. - * - * The returned text is escaped to make it suitable for use in HTML - * (though beware that in upstream releases 1.4.5 and earlier this - * escaping was sometimes incomplete), and matches with the query will be - * highlighted using @a hi_start and @a hi_end. - * - * If the snippet seems to start or end mid-sentence, then @a omit is - * prepended or append (respectively) to indicate this. - * - * The same stemming algorithm which was used to build the query should be - * specified in @a stemmer. - * - * And @a flags contains flags controlling behaviour. - * - * Added in 1.3.5. - */ - std::string snippet(const std::string & text, - size_t length = 500, - const Xapian::Stem & stemmer = Xapian::Stem(), - unsigned flags = SNIPPET_BACKGROUND_MODEL|SNIPPET_EXHAUSTIVE, - const std::string & hi_start = "", - const std::string & hi_end = "", - const std::string & omit = "...") const; - - /** Prefetch hint a range of items. - * - * For a remote database, this may start a pipelined fetch of the - * requested documents from the remote server. - * - * For a disk-based database, this may send prefetch hints to the - * operating system such that the disk blocks the requested documents - * are stored in are more likely to be in the cache when we come to - * actually read them. - */ - void fetch(const MSetIterator &begin, const MSetIterator &end) const; - - /** Prefetch hint a single MSet item. - * - * For a remote database, this may start a pipelined fetch of the - * requested documents from the remote server. - * - * For a disk-based database, this may send prefetch hints to the - * operating system such that the disk blocks the requested documents - * are stored in are more likely to be in the cache when we come to - * actually read them. - */ - void fetch(const MSetIterator &item) const; - - /** Prefetch hint the whole MSet. - * - * For a remote database, this may start a pipelined fetch of the - * requested documents from the remote server. - * - * For a disk-based database, this may send prefetch hints to the - * operating system such that the disk blocks the requested documents - * are stored in are more likely to be in the cache when we come to - * actually read them. - */ - void fetch() const { fetch_(0, Xapian::doccount(-1)); } - - /** Return number of items in this MSet object. */ - Xapian::doccount size() const; - - /** Return true if this MSet object is empty. */ - bool empty() const { return size() == 0; } - - /** Efficiently swap this MSet object with another. */ - void swap(MSet & o) { internal.swap(o.internal); } - - /** Return iterator pointing to the first item in this MSet. */ - MSetIterator begin() const; - - /** Return iterator pointing to just after the last item in this MSet. */ - MSetIterator end() const; - - /** Return iterator pointing to the i-th object in this MSet. */ - MSetIterator operator[](Xapian::doccount i) const; - - /** Return iterator pointing to the last object in this MSet. */ - MSetIterator back() const; - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal MSet is what the C++ STL calls a container. - * - * The following typedefs allow the class to be used in templates in the - * same way the standard containers can be. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian container classes are compatible with the STL. - * - * See "The C++ Programming Language", 3rd ed. section 16.3.1: - */ - // @{ - /// @private - typedef Xapian::MSetIterator value_type; - /// @private - typedef Xapian::doccount size_type; - /// @private - typedef Xapian::doccount_diff difference_type; - /// @private - typedef Xapian::MSetIterator iterator; - /// @private - typedef Xapian::MSetIterator const_iterator; - /// @private - typedef value_type * pointer; - /// @private - typedef const value_type * const_pointer; - /// @private - typedef value_type & reference; - /// @private - typedef const value_type & const_reference; - // @} - // - /** @private @internal MSet is what the C++ STL calls a container. - * - * The following methods allow the class to be used in templates in the - * same way the standard containers can be. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian container classes are compatible with the STL. - */ - // @{ - // The size is fixed once created. - Xapian::doccount max_size() const { return size(); } - // @} -}; - -/// Iterator over a Xapian::MSet. -class XAPIAN_VISIBILITY_DEFAULT MSetIterator { - friend class MSet; - - MSetIterator(const Xapian::MSet & mset_, Xapian::doccount off_from_end_) - : mset(mset_), off_from_end(off_from_end_) { } - - public: - /** @private @internal The MSet we are iterating over. */ - Xapian::MSet mset; - - /** @private @internal The current position of the iterator. - * - * We store the offset from the end of @a mset, since that means - * MSet::end() just needs to set this member to 0. - */ - Xapian::MSet::size_type off_from_end; - - /** Create an unpositioned MSetIterator. */ - MSetIterator() : off_from_end(0) { } - - /** Get the numeric document id for the current position. */ - Xapian::docid operator*() const; - - /// Advance the iterator to the next position. - MSetIterator & operator++() { - --off_from_end; - return *this; - } - - /// Advance the iterator to the next position (postfix version). - MSetIterator operator++(int) { - MSetIterator retval = *this; - --off_from_end; - return retval; - } - - /// Move the iterator to the previous position. - MSetIterator & operator--() { - ++off_from_end; - return *this; - } - - /// Move the iterator to the previous position (postfix version). - MSetIterator operator--(int) { - MSetIterator retval = *this; - ++off_from_end; - return retval; - } - - /** @private @internal MSetIterator is what the C++ STL calls an - * random_access_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::random_access_iterator_tag iterator_category; - /// @private - typedef std::string value_type; - /// @private - typedef Xapian::termcount_diff difference_type; - /// @private - typedef std::string * pointer; - /// @private - typedef std::string & reference; - // @} - - /// Move the iterator forwards by n positions. - MSetIterator & operator+=(difference_type n) { - off_from_end -= n; - return *this; - } - - /// Move the iterator back by n positions. - MSetIterator & operator-=(difference_type n) { - off_from_end += n; - return *this; - } - - /** Return the iterator incremented by @a n positions. - * - * If @a n is negative, decrements by (-n) positions. - */ - MSetIterator operator+(difference_type n) const { - return MSetIterator(mset, off_from_end - n); - } - - /** Return the iterator decremented by @a n positions. - * - * If @a n is negative, increments by (-n) positions. - */ - MSetIterator operator-(difference_type n) const { - return MSetIterator(mset, off_from_end + n); - } - - /** Return the number of positions between @a o and this iterator. */ - difference_type operator-(const MSetIterator& o) const { - return difference_type(o.off_from_end) - difference_type(off_from_end); - } - - /** Return the MSet rank for the current position. - * - * The rank of mset[0] is mset.get_firstitem(). - */ - Xapian::doccount get_rank() const { - return mset.get_firstitem() + (mset.size() - off_from_end); - } - - /** Get the Document object for the current position. */ - Xapian::Document get_document() const; - - /** Get the weight for the current position. */ - double get_weight() const; - - /** Return the collapse key for the current position. - * - * If collapsing isn't in use, an empty string will be returned. - */ - std::string get_collapse_key() const; - - /** Return a count of the number of collapses done onto the current key. - * - * This starts at 0, and is incremented each time an item is eliminated - * because its key is the same as that of the current item (as returned - * by get_collapse_key()). - * - * Note that this is NOT necessarily one less than the total number of - * matching documents with this collapse key due to various optimisations - * implemented in the matcher - for example, it can skip documents - * completely if it can prove their weight wouldn't be enough to make the - * result set. - * - * You can say is that if get_collapse_count() > 0 then there are - * >= get_collapse_count() other documents with the current collapse - * key. But if get_collapse_count() == 0 then there may or may not be - * other such documents. - */ - Xapian::doccount get_collapse_count() const; - - /** Return the sort key for the current position. - * - * If sorting didn't use a key then an empty string will be returned. - * - * @since Added in Xapian 1.4.6. - */ - std::string get_sort_key() const; - - /** Convert the weight of the current iterator position to a percentage. - * - * The matching document with the highest weight will get 100% if it - * matches all the weighted query terms, and proportionally less if it - * only matches some, and other weights are scaled by the same factor. - * - * Documents with a non-zero score will always score at least 1%. - * - * Note that these generally aren't percentages of anything meaningful - * (unless you use a custom weighting formula where they are!) - */ - int get_percent() const { - return mset.convert_to_percent(get_weight()); - } - - /// Return a string describing this object. - std::string get_description() const; -}; - -bool -XAPIAN_NOTHROW(operator==(const MSetIterator &a, const MSetIterator &b)); - -/// Equality test for MSetIterator objects. -inline bool -operator==(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return a.off_from_end == b.off_from_end; -} - -inline bool -XAPIAN_NOTHROW(operator!=(const MSetIterator &a, const MSetIterator &b)); - -/// Inequality test for MSetIterator objects. -inline bool -operator!=(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -bool -XAPIAN_NOTHROW(operator<(const MSetIterator &a, const MSetIterator &b)); - -/// Inequality test for MSetIterator objects. -inline bool -operator<(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return a.off_from_end > b.off_from_end; -} - -inline bool -XAPIAN_NOTHROW(operator>(const MSetIterator &a, const MSetIterator &b)); - -/// Inequality test for MSetIterator objects. -inline bool -operator>(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return b < a; -} - -inline bool -XAPIAN_NOTHROW(operator>=(const MSetIterator &a, const MSetIterator &b)); - -/// Inequality test for MSetIterator objects. -inline bool -operator>=(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return !(a < b); -} - -inline bool -XAPIAN_NOTHROW(operator<=(const MSetIterator &a, const MSetIterator &b)); - -/// Inequality test for MSetIterator objects. -inline bool -operator<=(const MSetIterator &a, const MSetIterator &b) XAPIAN_NOEXCEPT -{ - return !(b < a); -} - -/** Return MSetIterator @a it incremented by @a n positions. - * - * If @a n is negative, decrements by (-n) positions. - */ -inline MSetIterator -operator+(MSetIterator::difference_type n, const MSetIterator& it) -{ - return it + n; -} - -// Inlined methods of MSet which need MSetIterator to have been defined: - -inline void -MSet::fetch(const MSetIterator &begin_it, const MSetIterator &end_it) const -{ - fetch_(begin_it.off_from_end, end_it.off_from_end); -} - -inline void -MSet::fetch(const MSetIterator &item) const -{ - fetch_(item.off_from_end, item.off_from_end); -} - -inline MSetIterator -MSet::begin() const { - return MSetIterator(*this, size()); -} - -inline MSetIterator -MSet::end() const { - // Decrementing the result of end() needs to work, so we must pass in - // *this here. - return MSetIterator(*this, 0); -} - -inline MSetIterator -MSet::operator[](Xapian::doccount i) const { - return MSetIterator(*this, size() - i); -} - -inline MSetIterator -MSet::back() const { - return MSetIterator(*this, 1); -} - -inline int -MSet::convert_to_percent(const MSetIterator & it) const { - return convert_to_percent(it.get_weight()); -} - -} - -#endif // XAPIAN_INCLUDED_MSET_H diff --git a/winlibs/include/xapian/positioniterator.h b/winlibs/include/xapian/positioniterator.h deleted file mode 100644 index 87ff7f00f..000000000 --- a/winlibs/include/xapian/positioniterator.h +++ /dev/null @@ -1,161 +0,0 @@ -/** @file - * @brief Class for iterating over term positions. - */ -/* Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_POSITIONITERATOR_H -#define XAPIAN_INCLUDED_POSITIONITERATOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include - -namespace Xapian { - -/// Class for iterating over term positions. -class XAPIAN_VISIBILITY_DEFAULT PositionIterator { - void decref(); - - public: - /// Class representing the PositionIterator internals. - class Internal; - /// @private @internal Reference counted internals. - Internal * internal; - - /// @private @internal Construct given internals. - explicit PositionIterator(Internal *internal_); - - /// Copy constructor. - PositionIterator(const PositionIterator & o); - - /// Assignment. - PositionIterator & operator=(const PositionIterator & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - PositionIterator(PositionIterator && o) - : internal(o.internal) { - o.internal = nullptr; - } - - /// Move assignment operator. - PositionIterator & operator=(PositionIterator && o) { - if (this != &o) { - if (internal) decref(); - internal = o.internal; - o.internal = nullptr; - } - return *this; - } -#endif - - /** Default constructor. - * - * Creates an uninitialised iterator, which can't be used before being - * assigned to, but is sometimes syntactically convenient. - */ - XAPIAN_NOTHROW(PositionIterator()) - : internal(0) { } - - /// Destructor. - ~PositionIterator() { - if (internal) decref(); - } - - /// Return the term position at the current iterator position. - Xapian::termpos operator*() const; - - /// Advance the iterator to the next position. - PositionIterator & operator++(); - - /// Advance the iterator to the next position (postfix version). - DerefWrapper_ operator++(int) { - Xapian::termpos pos(**this); - operator++(); - return DerefWrapper_(pos); - } - - /** Advance the iterator to term position @a termpos. - * - * @param termpos The position to advance to. If this position isn't in - * the stream being iterated, then the iterator is moved - * to the next term position after it which is. - */ - void skip_to(Xapian::termpos termpos); - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal PositionIterator is what the C++ STL calls an - * input_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::input_iterator_tag iterator_category; - /// @private - typedef Xapian::termpos value_type; - /// @private - typedef Xapian::termpos_diff difference_type; - /// @private - typedef Xapian::termpos * pointer; - /// @private - typedef Xapian::termpos & reference; - // @} -}; - -bool -XAPIAN_NOTHROW(operator==(const PositionIterator &a, const PositionIterator &b)); - -/// Equality test for PositionIterator objects. -inline bool -operator==(const PositionIterator &a, const PositionIterator &b) XAPIAN_NOEXCEPT -{ - // Use a pointer comparison - this ensures both that (a == a) and correct - // handling of end iterators (which we ensure have NULL internals). - return a.internal == b.internal; -} - -bool -XAPIAN_NOTHROW(operator!=(const PositionIterator &a, const PositionIterator &b)); - -/// Inequality test for PositionIterator objects. -inline bool -operator!=(const PositionIterator &a, const PositionIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -} - -#endif // XAPIAN_INCLUDED_POSITIONITERATOR_H diff --git a/winlibs/include/xapian/postingiterator.h b/winlibs/include/xapian/postingiterator.h deleted file mode 100644 index c02150f1f..000000000 --- a/winlibs/include/xapian/postingiterator.h +++ /dev/null @@ -1,187 +0,0 @@ -/** @file - * @brief Class for iterating over a list of document ids - */ -/* Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_POSTINGITERATOR_H -#define XAPIAN_INCLUDED_POSTINGITERATOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include -#include - -namespace Xapian { - -/// Class for iterating over a list of terms. -class XAPIAN_VISIBILITY_DEFAULT PostingIterator { - public: - /// Class representing the PostingIterator internals. - class Internal; - /// @private @internal Reference counted internals. - Internal * internal; - - /// @private @internal Construct given internals. - explicit PostingIterator(Internal *internal_); - - /// Copy constructor. - PostingIterator(const PostingIterator & o); - - /// Assignment. - PostingIterator & operator=(const PostingIterator & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - PostingIterator(PostingIterator && o) - : internal(o.internal) { - o.internal = nullptr; - } - - /// Move assignment operator. - PostingIterator & operator=(PostingIterator && o) { - if (this != &o) { - if (internal) decref(); - internal = o.internal; - o.internal = nullptr; - } - return *this; - } -#endif - - /** Default constructor. - * - * Creates an uninitialised iterator, which can't be used before being - * assigned to, but is sometimes syntactically convenient. - */ - XAPIAN_NOTHROW(PostingIterator()) - : internal(0) { } - - /// Destructor. - ~PostingIterator() { - if (internal) decref(); - } - - /// Return the document id at the current position. - Xapian::docid operator*() const; - - /// Return the wdf for the document at the current position. - Xapian::termcount get_wdf() const; - - /// Return the length of the document at the current position. - Xapian::termcount get_doclength() const; - - /// Return the number of unique terms in the current document. - Xapian::termcount get_unique_terms() const; - -#if 0 // FIXME: TermIterator supports this, so PostingIterator really ought to. - /// Return the length of the position list for the current position. - Xapian::termcount positionlist_count() const; -#endif - - /// Return a PositionIterator for the current document. - PositionIterator positionlist_begin() const; - - /// Return an end PositionIterator for the current document. - PositionIterator XAPIAN_NOTHROW(positionlist_end() const) { - return PositionIterator(); - } - - /// Advance the iterator to the next position. - PostingIterator & operator++(); - - /// Advance the iterator to the next position (postfix version). - DerefWrapper_ operator++(int) { - Xapian::docid did(**this); - operator++(); - return DerefWrapper_(did); - } - - /** Advance the iterator to document @a did. - * - * @param did The document id to advance to. If this document id - * isn't in the stream being iterated, then the iterator - * is moved to the next document id after it which is. - */ - void skip_to(Xapian::docid did); - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal PostingIterator is what the C++ STL calls an - * input_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::input_iterator_tag iterator_category; - /// @private - typedef Xapian::docid value_type; - /// @private - typedef Xapian::doccount_diff difference_type; - /// @private - typedef Xapian::docid * pointer; - /// @private - typedef Xapian::docid & reference; - // @} - - private: - void decref(); - - void post_advance(Internal * res); -}; - -bool -XAPIAN_NOTHROW(operator==(const PostingIterator &a, const PostingIterator &b)); - -/// Equality test for PostingIterator objects. -inline bool -operator==(const PostingIterator &a, const PostingIterator &b) XAPIAN_NOEXCEPT -{ - // Use a pointer comparison - this ensures both that (a == a) and correct - // handling of end iterators (which we ensure have NULL internals). - return a.internal == b.internal; -} - -inline bool -XAPIAN_NOTHROW(operator!=(const PostingIterator &a, const PostingIterator &b)); - -/// Inequality test for PostingIterator objects. -inline bool -operator!=(const PostingIterator &a, const PostingIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -} - -#endif // XAPIAN_INCLUDED_POSTINGITERATOR_H diff --git a/winlibs/include/xapian/postingsource.h b/winlibs/include/xapian/postingsource.h deleted file mode 100644 index 1ca9b26e8..000000000 --- a/winlibs/include/xapian/postingsource.h +++ /dev/null @@ -1,783 +0,0 @@ -/** @file - * @brief External sources of posting information - */ -/* Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Olly Betts - * Copyright (C) 2008,2009 Lemur Consulting Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_POSTINGSOURCE_H -#define XAPIAN_INCLUDED_POSTINGSOURCE_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace Xapian { - -class Registry; - -/** Base class which provides an "external" source of postings. - */ -class XAPIAN_VISIBILITY_DEFAULT PostingSource - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const PostingSource &); - - /// Don't allow copying. - PostingSource(const PostingSource &); - - /// The current upper bound on what get_weight() can return. - double max_weight_; - - /** The object to inform of maxweight changes. - * - * We store this as a (void*) to avoid needing to declare an internal - * type in an external header. It's actually (MultiMatch *). - */ - void * matcher_; - - public: - /// Allow subclasses to be instantiated. - XAPIAN_NOTHROW(PostingSource()) - : max_weight_(0), matcher_(NULL) { } - - /** @private @internal Set the object to inform of maxweight changes. - * - * This method is for internal use only - it would be private except that - * would force us to forward declare an internal class in an external API - * header just to make it a friend. - */ - void register_matcher_(void * matcher) { matcher_ = matcher; } - - // Destructor. - virtual ~PostingSource(); - - /** A lower bound on the number of documents this object can return. - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - */ - virtual Xapian::doccount get_termfreq_min() const = 0; - - /** An estimate of the number of documents this object can return. - * - * It must always be true that: - * - * get_termfreq_min() <= get_termfreq_est() <= get_termfreq_max() - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - */ - virtual Xapian::doccount get_termfreq_est() const = 0; - - /** An upper bound on the number of documents this object can return. - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - */ - virtual Xapian::doccount get_termfreq_max() const = 0; - - /** Specify an upper bound on what get_weight() will return from now on. - * - * This upper bound is used by the matcher to perform various - * optimisations, so if you can return a good bound, then matches - * will generally run faster. - * - * This method should be called after calling init(), and may be called - * during iteration if the upper bound drops. It is probably only useful - * to call from subclasses (it was actually a "protected" method prior to - * Xapian 1.3.4, but that makes it tricky to wrap for other languages). - * - * It is valid for the posting source to have returned a higher value from - * get_weight() earlier in the iteration, but the posting source must not - * return a higher value from get_weight() than the currently set upper - * bound, and the upper bound must not be increased (until init() has been - * called). - * - * If you don't call this method, the upper bound will default to 0, for - * convenience when implementing "weight-less" PostingSource subclasses. - * - * @param max_weight The upper bound to set. - */ - void set_maxweight(double max_weight); - - /// Return the currently set upper bound on what get_weight() can return. - double XAPIAN_NOTHROW(get_maxweight() const) { return max_weight_; } - - /** Return the weight contribution for the current document. - * - * This default implementation always returns 0, for convenience when - * implementing "weight-less" PostingSource subclasses. - * - * This method may assume that it will only be called when there is a - * "current document". In detail: Xapian will always call init() on a - * PostingSource before calling this for the first time. It will also - * only call this if the PostingSource reports that it is pointing to a - * valid document (ie, it will not call it before calling at least one of - * next(), skip_to() or check(), and will ensure that the PostingSource is - * not at the end by calling at_end()). - */ - virtual double get_weight() const; - - /** Return the current docid. - * - * This method may assume that it will only be called when there is a - * "current document". See @a get_weight() for details. - * - * Note: in the case of a multi-database search, the returned docid should - * be in the single subdatabase relevant to this posting source. See the - * @a init() method for details. - */ - virtual Xapian::docid get_docid() const = 0; - - /** Advance the current position to the next matching document. - * - * The PostingSource starts before the first entry in the list, so next(), - * skip_to() or check() must be called before any methods which need the - * context of the current position. - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - * - * @param min_wt The minimum weight contribution that is needed (this is - * just a hint which subclasses may ignore). - */ - virtual void next(double min_wt) = 0; - - /** Advance to the specified docid. - * - * If the specified docid isn't in the list, position ourselves on the - * first document after it (or at_end() if no greater docids are present). - * - * If the current position is already the specified docid, this method will - * leave the position unmodified. - * - * If the specified docid is earlier than the current position, the - * behaviour is unspecified. A sensible behaviour would be to leave the - * current position unmodified, but it is also reasonable to move to the - * specified docid. - * - * The default implementation calls next() repeatedly, which works but - * skip_to() can often be implemented much more efficiently. - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - * - * Note: in the case of a multi-database search, the docid specified is - * the docid in the single subdatabase relevant to this posting source. - * See the @a init() method for details. - * - * @param did The document id to advance to. - * @param min_wt The minimum weight contribution that is needed (this is - * just a hint which subclasses may ignore). - */ - virtual void skip_to(Xapian::docid did, double min_wt); - - /** Check if the specified docid occurs. - * - * The caller is required to ensure that the specified document id @a did - * actually exists in the database. If it does, it must move to that - * document id, and return true. If it does not, it may either: - * - * - return true, having moved to a definite position (including - * "at_end"), which must be the same position as skip_to() would have - * moved to. - * - * or - * - * - return false, having moved to an "indeterminate" position, such that - * a subsequent call to next() or skip_to() will move to the next - * matching position after @a did. - * - * Generally, this method should act like skip_to() and return true if - * that can be done at little extra cost. - * - * Otherwise it should simply check if a particular docid is present, - * returning true if it is, and false if it isn't. - * - * The default implementation calls skip_to() and always returns true. - * - * Xapian will always call init() on a PostingSource before calling this - * for the first time. - * - * Note: in the case of a multi-database search, the docid specified is - * the docid in the single subdatabase relevant to this posting source. - * See the @a init() method for details. - * - * @param did The document id to check. - * @param min_wt The minimum weight contribution that is needed (this is - * just a hint which subclasses may ignore). - */ - virtual bool check(Xapian::docid did, double min_wt); - - /** Return true if the current position is past the last entry in this list. - * - * At least one of @a next(), @a skip_to() or @a check() will be called - * before this method is first called. - */ - virtual bool at_end() const = 0; - - /** Clone the posting source. - * - * The clone should inherit the configuration of the parent, but need not - * inherit the state. ie, the clone does not need to be in the same - * iteration position as the original: the matcher will always call - * init() on the clone before attempting to move the iterator, or read - * the information about the current position of the iterator. - * - * This may return NULL to indicate that cloning is not supported. In - * this case, the PostingSource may only be used with a single-database - * search. - * - * The default implementation returns NULL. - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - */ - virtual PostingSource * clone() const; - - /** Name of the posting source class. - * - * This is used when serialising and unserialising posting sources; for - * example, for performing remote searches. - * - * If the subclass is in a C++ namespace, the namespace should be included - * in the name, using "::" as a separator. For example, for a - * PostingSource subclass called "FooPostingSource" in the "Xapian" - * namespace the result of this call should be "Xapian::FooPostingSource". - * - * This should only be implemented if serialise() and unserialise() are - * also implemented. The default implementation returns an empty string. - * - * If this returns an empty string, Xapian will assume that serialise() - * and unserialise() are not implemented. - */ - virtual std::string name() const; - - /** Serialise object parameters into a string. - * - * The serialised parameters should represent the configuration of the - * posting source, but need not (indeed, should not) represent the current - * iteration state. - * - * If you don't want to support the remote backend, you can use the - * default implementation which simply throws Xapian::UnimplementedError. - */ - virtual std::string serialise() const; - - /** Create object given string serialisation returned by serialise(). - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - * - * If you don't want to support the remote backend, you can use the - * default implementation which simply throws Xapian::UnimplementedError. - * - * @param serialised A serialised instance of this PostingSource subclass. - */ - virtual PostingSource * unserialise(const std::string &serialised) const; - - /** Create object given string serialisation returned by serialise(). - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - * - * This method is supplied with a Registry object, which can be used when - * unserialising objects contained within the posting source. The default - * implementation simply calls unserialise() which doesn't take the - * Registry object, so you do not need to implement this method unless you - * want to take advantage of the Registry object when unserialising. - * - * @param serialised A serialised instance of this PostingSource subclass. - * @param registry The Xapian::Registry object to use. - */ - virtual PostingSource * unserialise_with_registry(const std::string &serialised, - const Registry & registry) const; - - /** Set this PostingSource to the start of the list of postings. - * - * This is called automatically by the matcher prior to each query being - * processed. - * - * If a PostingSource is used for multiple searches, @a init() will - * therefore be called multiple times, and must handle this by using the - * database passed in the most recent call. - * - * @param db The database which the PostingSource should iterate through. - * - * Note: in the case of a multi-database search, a separate PostingSource - * will be used for each database (the separate PostingSources will be - * obtained using @a clone()), and each PostingSource will be passed one of - * the sub-databases as the @a db parameter here. The @a db parameter - * will therefore always refer to a single database. All docids passed - * to, or returned from, the PostingSource refer to docids in that single - * database, rather than in the multi-database. - */ - virtual void init(const Database & db) = 0; - - /** Return a string describing this object. - * - * This default implementation returns a generic answer. This default - * it provided to avoid forcing those deriving their own PostingSource - * subclass from having to implement this (they may not care what - * get_description() gives for their subclass). - */ - virtual std::string get_description() const; - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated PostingSource - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - PostingSource * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated PostingSource - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const PostingSource * release() const { - opt_intrusive_base::release(); - return this; - } -}; - - -/** A posting source which generates weights from a value slot. - * - * This is a base class for classes which generate weights using values stored - * in the specified slot. For example, ValueWeightPostingSource uses - * sortable_unserialise to convert values directly to weights. - * - * The upper bound on the weight returned is set to DBL_MAX. Subclasses - * should call set_maxweight() in their init() methods after calling - * ValuePostingSource::init() if they know a tighter bound on the weight. - */ -class XAPIAN_VISIBILITY_DEFAULT ValuePostingSource : public PostingSource { - // We want to give a deprecation warning for uses of the members from user - // code, but we also want to be able to inline functions to access them, - // without those functions generating deprecated warnings. To achieve - // this, we make the old names references to members with a "real_" prefix - // and then use the latter in the inlined accessor functions. The - // constructor initialises all the references to point to their "real_" - // counterparts. - Xapian::Database real_db; - - Xapian::valueno real_slot; - - Xapian::ValueIterator real_value_it; - - bool real_started; - - Xapian::doccount real_termfreq_min; - - Xapian::doccount real_termfreq_est; - - Xapian::doccount real_termfreq_max; - - protected: - /** The database we're reading values from. - * - * @deprecated Use @a get_database() in preference. - */ - XAPIAN_DEPRECATED(Xapian::Database& db); - - /** The slot we're reading values from. - * - * @deprecated Use @a get_slot() in preference. - */ - XAPIAN_DEPRECATED(Xapian::valueno& slot); - - /** Value stream iterator. - * - * @deprecated Use @a get_value() in preference to *value_it, and other - * methods of ValuePostingSource in preference to calling methods of - * value_it. - */ - XAPIAN_DEPRECATED(Xapian::ValueIterator& value_it); - - /** Flag indicating if we've started (true if we have). - * - * @deprecated Use @a get_started() in preference. - */ - XAPIAN_DEPRECATED(bool& started); - - /** A lower bound on the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods to return fewer documents. - * - * @deprecated Use @a set_termfreq_min() in preference. - */ - XAPIAN_DEPRECATED(Xapian::doccount& termfreq_min); - - /** An estimate of the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods. - * - * @deprecated Use @a set_termfreq_est() in preference. - */ - XAPIAN_DEPRECATED(Xapian::doccount& termfreq_est); - - /** An upper bound on the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods. - * - * @deprecated Use @a set_termfreq_max() in preference. - */ - XAPIAN_DEPRECATED(Xapian::doccount& termfreq_max); - - public: - /** Construct a ValuePostingSource. - * - * @param slot_ The value slot to read values from. - */ - explicit ValuePostingSource(Xapian::valueno slot_); - - Xapian::doccount get_termfreq_min() const; - Xapian::doccount get_termfreq_est() const; - Xapian::doccount get_termfreq_max() const; - - void next(double min_wt); - void skip_to(Xapian::docid min_docid, double min_wt); - bool check(Xapian::docid min_docid, double min_wt); - - bool at_end() const; - - Xapian::docid get_docid() const; - - void init(const Database & db_); - - /** The database we're reading values from. - * - * Added in 1.2.23 and 1.3.5. - */ - Xapian::Database get_database() const { return real_db; } - - /** The slot we're reading values from. - * - * Added in 1.2.23 and 1.3.5. - */ - Xapian::valueno get_slot() const { return real_slot; } - - /** Read current value. - * - * Added in 1.2.23 and 1.3.5. - */ - std::string get_value() const { return *real_value_it; } - - /** End the iteration. - * - * Calls to at_end() will return true after calling this method. - * - * Added in 1.2.23 and 1.3.5. - */ - void done() { - real_value_it = real_db.valuestream_end(real_slot); - real_started = true; - } - - /** Flag indicating if we've started (true if we have). - * - * Added in 1.2.23 and 1.3.5. - */ - bool get_started() const { return real_started; } - - /** Set a lower bound on the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods to return fewer documents. - * - * Added in 1.2.23 and 1.3.5. - */ - void set_termfreq_min(Xapian::doccount termfreq_min_) { - real_termfreq_min = termfreq_min_; - } - - /** An estimate of the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods. - * - * Added in 1.2.23 and 1.3.5. - */ - void set_termfreq_est(Xapian::doccount termfreq_est_) { - real_termfreq_est = termfreq_est_; - } - - /** An upper bound on the term frequency. - * - * Subclasses should set this if they are overriding the next(), skip_to() - * or check() methods. - * - * Added in 1.2.23 and 1.3.5. - */ - void set_termfreq_max(Xapian::doccount termfreq_max_) { - real_termfreq_max = termfreq_max_; - } -}; - - -/** A posting source which reads weights from a value slot. - * - * This returns entries for all documents in the given database which have a - * non empty values in the specified slot. It returns a weight calculated by - * applying sortable_unserialise to the value stored in the slot (so the - * values stored should probably have been calculated by applying - * sortable_serialise to a floating point number at index time). - * - * The upper bound on the weight returned is set using the upper bound on the - * values in the specified slot, or DBL_MAX if value bounds aren't supported - * by the current backend. - * - * For efficiency, this posting source doesn't check that the stored values - * are valid in any way, so it will never raise an exception due to invalid - * stored values. In particular, it doesn't ensure that the unserialised - * values are positive, which is a requirement for weights. The behaviour if - * the slot contains values which unserialise to negative values is undefined. - */ -class XAPIAN_VISIBILITY_DEFAULT ValueWeightPostingSource - : public ValuePostingSource { - public: - /** Construct a ValueWeightPostingSource. - * - * @param slot_ The value slot to read values from. - */ - explicit ValueWeightPostingSource(Xapian::valueno slot_); - - double get_weight() const; - ValueWeightPostingSource * clone() const; - std::string name() const; - std::string serialise() const; - ValueWeightPostingSource * unserialise(const std::string &serialised) const; - void init(const Database & db_); - - std::string get_description() const; -}; - - -/** Read weights from a value which is known to decrease as docid increases. - * - * This posting source can be used, like ValueWeightPostingSource, to add a - * weight contribution to a query based on the values stored in a slot. The - * values in the slot must be serialised as by @a sortable_serialise(). - * - * However, this posting source is additionally given a range of document IDs, - * within which the weight is known to be decreasing. ie, for all documents - * with ids A and B within this range (including the endpoints), where A is - * less than B, the weight of A is less than or equal to the weight of B. - * This can allow the posting source to skip to the end of the range quickly - * if insufficient weight is left in the posting source for a particular - * source. - * - * By default, the range is assumed to cover all document IDs. - * - * The ordering property can be arranged at index time, or by sorting an - * indexed database to produce a new, sorted, database. - */ -class XAPIAN_VISIBILITY_DEFAULT DecreasingValueWeightPostingSource - : public Xapian::ValueWeightPostingSource { - protected: - /** Start of range of docids for which weights are known to be decreasing. - * - * 0 => first docid. - */ - Xapian::docid range_start; - - /** End of range of docids for which weights are known to be decreasing. - * - * 0 => last docid. - */ - Xapian::docid range_end; - - /// Weight at current position. - double curr_weight; - - /// Flag, set to true if there are docs after the end of the range. - bool items_at_end; - - /// Skip the iterator forward if in the decreasing range, and weight is low. - void skip_if_in_range(double min_wt); - - public: - /** Construct a DecreasingValueWeightPostingSource. - * - * @param slot_ The value slot to read values from. - * @param range_start_ Start of range of docids for which weights are - * known to be decreasing (default: first docid) - * @param range_end_ End of range of docids for which weights are - * known to be decreasing (default: last docid) - */ - DecreasingValueWeightPostingSource(Xapian::valueno slot_, - Xapian::docid range_start_ = 0, - Xapian::docid range_end_ = 0); - - double get_weight() const; - DecreasingValueWeightPostingSource * clone() const; - std::string name() const; - std::string serialise() const; - DecreasingValueWeightPostingSource * unserialise(const std::string &serialised) const; - void init(const Xapian::Database & db_); - - void next(double min_wt); - void skip_to(Xapian::docid min_docid, double min_wt); - bool check(Xapian::docid min_docid, double min_wt); - - std::string get_description() const; -}; - - -/** A posting source which looks up weights in a map using values as the key. - * - * This allows will return entries for all documents in the given database - * which have a value in the slot specified. The values will be mapped to the - * corresponding weight in the weight map. If there is no mapping for a - * particular value, the default weight will be returned (which itself - * defaults to 0.0). - */ -class XAPIAN_VISIBILITY_DEFAULT ValueMapPostingSource - : public ValuePostingSource { - /// The default weight - double default_weight; - - /// The maximum weight in weight_map. - double max_weight_in_map; - - /// The value -> weight map - std::map weight_map; - - public: - /** Construct a ValueMapPostingSource. - * - * @param slot_ The value slot to read values from. - */ - explicit ValueMapPostingSource(Xapian::valueno slot_); - - /** Add a mapping. - * - * @param key The key looked up from the value slot. - * @param wt The weight to give this key. - */ - void add_mapping(const std::string &key, double wt); - - /** Clear all mappings. */ - void clear_mappings(); - - /** Set a default weight for document values not in the map. - * - * @param wt The weight to set as the default. - */ - void set_default_weight(double wt); - - double get_weight() const; - ValueMapPostingSource * clone() const; - std::string name() const; - std::string serialise() const; - ValueMapPostingSource * unserialise(const std::string &serialised) const; - void init(const Database & db_); - - std::string get_description() const; -}; - - -/** A posting source which returns a fixed weight for all documents. - * - * This returns entries for all documents in the given database, with a fixed - * weight (specified by a parameter to the constructor). - */ -class XAPIAN_VISIBILITY_DEFAULT FixedWeightPostingSource : public PostingSource { - /// The database we're reading documents from. - Xapian::Database db; - - /// Number of documents in the posting source. - Xapian::doccount termfreq; - - /// Iterator over all documents. - Xapian::PostingIterator it; - - /// Flag indicating if we've started (true if we have). - bool started; - - /// The docid last passed to check() (0 if check() wasn't the last move). - Xapian::docid check_docid; - - public: - /** Construct a FixedWeightPostingSource. - * - * @param wt The fixed weight to return. - */ - explicit FixedWeightPostingSource(double wt); - - Xapian::doccount get_termfreq_min() const; - Xapian::doccount get_termfreq_est() const; - Xapian::doccount get_termfreq_max() const; - - double get_weight() const; - - void next(double min_wt); - void skip_to(Xapian::docid min_docid, double min_wt); - bool check(Xapian::docid min_docid, double min_wt); - - bool at_end() const; - - Xapian::docid get_docid() const; - - FixedWeightPostingSource * clone() const; - std::string name() const; - std::string serialise() const; - FixedWeightPostingSource * unserialise(const std::string &serialised) const; - void init(const Database & db_); - - std::string get_description() const; -}; - -} - -#endif // XAPIAN_INCLUDED_POSTINGSOURCE_H diff --git a/winlibs/include/xapian/query.h b/winlibs/include/xapian/query.h deleted file mode 100644 index ebf002846..000000000 --- a/winlibs/include/xapian/query.h +++ /dev/null @@ -1,848 +0,0 @@ -/** @file - * @brief Xapian::Query API class - */ -/* Copyright (C) 2011,2012,2013,2014,2015,2016,2017,2018,2019 Olly Betts - * Copyright (C) 2008 Richard Boulton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_QUERY_H -#define XAPIAN_INCLUDED_QUERY_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -class QueryOptimiser; // FIXME - -namespace Xapian { - -class PostingSource; - -/// Class representing a query. -class XAPIAN_VISIBILITY_DEFAULT Query { - public: - /// Class representing the query internals. - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /** A query matching no documents. - * - * This is a static instance of a default-constructed Xapian::Query - * object. It is safe to use concurrently from different threads, - * unlike @a MatchAll (this is because MatchNothing has a NULL - * internal object so there's no reference counting happening). - * - * When combined with other Query objects using the various supported - * operators, MatchNothing works like @c false in boolean logic, so - * MatchNothing & q is @c MatchNothing, while - * MatchNothing | q is @c q. - */ - static const Xapian::Query MatchNothing; - - /** A query matching all documents. - * - * This is a static instance of Xapian::Query(std::string()). - * If you are constructing Query objects which use @a MatchAll in - * different threads then the reference counting of the static object can - * get messed up by concurrent access so you should instead use - * Xapian::Query(std::string()) directly. - */ - static const Xapian::Query MatchAll; - - /** Query operators. */ - enum op { - /** Match only documents which all subqueries match. - * - * When used in a weighted context, the weight is the sum of the - * weights for all the subqueries. - */ - OP_AND = 0, - - /** Match documents which at least one subquery matches. - * - * When used in a weighted context, the weight is the sum of the - * weights for matching subqueries (so additional matching subqueries - * will mean a higher weight). - */ - OP_OR = 1, - - /** Match documents which the first subquery matches but no others do. - * - * When used in a weighted context, the weight is just the weight of - * the first subquery. - */ - OP_AND_NOT = 2, - - /** Match documents which an odd number of subqueries match. - * - * When used in a weighted context, the weight is the sum of the - * weights for matching subqueries (so additional matching subqueries - * will mean a higher weight). - */ - OP_XOR = 3, - - /** Match the first subquery taking extra weight from other subqueries. - * - * When used in a weighted context, the weight is the sum of the - * weights for matching subqueries (so additional matching subqueries - * will mean a higher weight). - * - * Because only the first subquery determines which documents are - * matched, in a non-weighted context only the first subquery matters. - */ - OP_AND_MAYBE = 4, - - /** Match like OP_AND but only taking weight from the first subquery. - * - * When used in a non-weighted context, OP_FILTER and OP_AND are - * equivalent. - * - * In older 1.4.x, the third and subsequent subqueries were ignored - * in some situations. This was fixed in 1.4.15. - */ - OP_FILTER = 5, - - /** Match only documents where all subqueries match near each other. - * - * The subqueries must match at term positions within the specified - * window size, in any order. - * - * Currently subqueries must be terms or terms composed with OP_OR. - * - * When used in a weighted context, the weight is the sum of the - * weights for all the subqueries. - */ - OP_NEAR = 6, - - /** Match only documents where all subqueries match near and in order. - * - * The subqueries must match at term positions within the specified - * window size, in the same term position order as subquery order. - * - * Currently subqueries must be terms or terms composed with OP_OR. - * - * When used in a weighted context, the weight is the sum of the - * weights for all the subqueries. - */ - OP_PHRASE = 7, - - /** Match only documents where a value slot is within a given range. - * - * This operator never contributes weight. - */ - OP_VALUE_RANGE = 8, - - /** Scale the weight contributed by a subquery. - * - * The weight is the weight of the subquery multiplied by the - * specified non-negative scale factor (so if the scale factor is - * zero then the subquery contributes no weight). - */ - OP_SCALE_WEIGHT = 9, - - /** Pick the best N subqueries and combine with OP_OR. - * - * If you want to implement a feature which finds documents similar to - * a piece of text, an obvious approach is to build an "OR" query from - * all the terms in the text, and run this query against a database - * containing the documents. However such a query can contain a lots - * of terms and be quite slow to perform, yet many of these terms - * don't contribute usefully to the results. - * - * The OP_ELITE_SET operator can be used instead of OP_OR in this - * situation. OP_ELITE_SET selects the most important ''N'' terms and - * then acts as an OP_OR query with just these, ignoring any other - * terms. This will usually return results just as good as the full - * OP_OR query, but much faster. - * - * In general, the OP_ELITE_SET operator can be used when you have a - * large OR query, but it doesn't matter if the search completely - * ignores some of the less important terms in the query. - * - * The subqueries don't have to be terms. If they aren't then - * OP_ELITE_SET could potentially pick a subset which doesn't - * actually match any documents even if the full OR would match some - * (because OP_ELITE_SET currently selects those subqueries which can - * return the highest weights). This is probably rare in practice - * though. - * - * You can specify a parameter to the query constructor which controls - * the number of subqueries which OP_ELITE_SET will pick. If not - * specified, this defaults to 10 (Xapian used to default to - * ceil(sqrt(number_of_subqueries)) if there are more - * than 100 subqueries, but this rather arbitrary special case was - * dropped in 1.3.0). For example, this will pick the best 7 terms: - * - *
-	 *  Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin(), subqs.end(), 7);
-	 *  
- * - * If the number of subqueries is less than this threshold, - * OP_ELITE_SET behaves identically to OP_OR. - * - * When used with a sharded database, OP_ELITE_SET currently picks - * the subqueries to use separately for each shard based on the - * maximum weight they can return in that shard. This means it - * probably won't select exactly the same terms, and so the results - * of the search may not be exactly the same as for a single database - * with equivalent contents. - */ - OP_ELITE_SET = 10, - - /** Match only documents where a value slot is >= a given value. - * - * Similar to @a OP_VALUE_RANGE, but open-ended. - * - * This operator never contributes weight. - */ - OP_VALUE_GE = 11, - - /** Match only documents where a value slot is <= a given value. - * - * Similar to @a OP_VALUE_RANGE, but open-ended. - * - * This operator never contributes weight. - */ - OP_VALUE_LE = 12, - - /** Match like OP_OR but weighting as if a single term. - * - * The weight is calculated combining the statistics for the - * subqueries to approximate the weight of a single term occurring - * with those statistics. - */ - OP_SYNONYM = 13, - - /** Pick the maximum weight of any subquery. - * - * Matches the same documents as @a OP_OR, but the weight contributed - * is the maximum weight from any matching subquery (for OP_OR, it's - * the sum of the weights from the matching subqueries). - * - * Added in Xapian 1.3.2. - */ - OP_MAX = 14, - - /** Wildcard expansion. - * - * Added in Xapian 1.3.3. - */ - OP_WILDCARD = 15, - - /** Construct an invalid query. - * - * This can be useful as a placeholder - for example @a RangeProcessor - * uses it as a return value to indicate that a range hasn't been - * recognised. - */ - OP_INVALID = 99, - - /** Value returned by get_type() for a term. */ - LEAF_TERM = 100, - - /** Value returned by get_type() for a PostingSource. */ - LEAF_POSTING_SOURCE, - - /** Value returned by get_type() for MatchAll or equivalent. - * - * This is returned for any Xapian::Query(std::string()) - * object. - */ - LEAF_MATCH_ALL, - - /** Value returned by get_type() for MatchNothing or equivalent. - * - * This is returned for any Xapian::Query() object. - */ - LEAF_MATCH_NOTHING - }; - - enum { - /** Throw an error if OP_WILDCARD exceeds its expansion limit. - * - * Xapian::WildcardError will be thrown when the query is actually - * run. - */ - WILDCARD_LIMIT_ERROR, - /** Stop expanding when OP_WILDCARD reaches its expansion limit. - * - * This makes the wildcard expand to only the first N terms (sorted - * by byte order). - */ - WILDCARD_LIMIT_FIRST, - /** Limit OP_WILDCARD expansion to the most frequent terms. - * - * If OP_WILDCARD would expand to more than its expansion limit, the - * most frequent terms are taken. This approach works well for cases - * such as expanding a partial term at the end of a query string which - * the user hasn't finished typing yet - as well as being less expense - * to evaluate than the full expansion, using only the most frequent - * terms tends to give better results too. - */ - WILDCARD_LIMIT_MOST_FREQUENT - }; - - /** Construct a query matching no documents. - * - * @a MatchNothing is a static instance of this. - * - * When combined with other Query objects using the various supported - * operators, Query() works like @c false in boolean logic, - * so Query() & q is @c Query(), while - * Query() | q is @c q. - */ - XAPIAN_NOTHROW(Query()) { } - - /// Destructor. - ~Query() { } - - /** Copying is allowed. - * - * The internals are reference counted, so copying is cheap. - */ - Query(const Query & o) : internal(o.internal) { } - - /** Copying is allowed. - * - * The internals are reference counted, so assignment is cheap. - */ - Query & operator=(const Query & o) { internal = o.internal; return *this; } - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - Query(Query &&) = default; - - /// Move assignment operator. - Query & operator=(Query &&) = default; -#endif - - /** Construct a Query object for a term. - * - * @param term The term. An empty string constructs a query matching - * all documents (@a MatchAll is a static instance of this). - * @param wqf The within-query frequency. (default: 1) - * @param pos The query position. Currently this is mainly used to - * determine the order of terms obtained via - * get_terms_begin(). (default: 0) - */ - Query(const std::string & term, - Xapian::termcount wqf = 1, - Xapian::termpos pos = 0); - - /** Construct a Query object for a PostingSource. */ - explicit Query(Xapian::PostingSource * source); - - /** Scale using OP_SCALE_WEIGHT. - * - * @param factor Non-negative real number to multiply weights by. - * @param subquery Query object to scale weights from. - */ - Query(double factor, const Xapian::Query & subquery); - - /** Scale using OP_SCALE_WEIGHT. - * - * In this form, the op_ parameter is totally redundant - use - * Query(factor, subquery) in preference. - * - * @param op_ Must be OP_SCALE_WEIGHT. - * @param factor Non-negative real number to multiply weights by. - * @param subquery Query object to scale weights from. - */ - Query(op op_, const Xapian::Query & subquery, double factor); - - /** Construct a Query object by combining two others. - * - * @param op_ The operator to combine the queries with. - * @param a First subquery. - * @param b Second subquery. - */ - Query(op op_, const Xapian::Query & a, const Xapian::Query & b) - { - init(op_, 2); - bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE); - add_subquery(positional, a); - add_subquery(positional, b); - done(); - } - - /** Construct a Query object by combining two terms. - * - * @param op_ The operator to combine the terms with. - * @param a First term. - * @param b Second term. - */ - Query(op op_, const std::string & a, const std::string & b) - { - init(op_, 2); - add_subquery(false, a); - add_subquery(false, b); - done(); - } - - /** Construct a Query object for a single-ended value range. - * - * @param op_ Must be OP_VALUE_LE or OP_VALUE_GE currently. - * @param slot The value slot to work over. - * @param range_limit The limit of the range. - */ - Query(op op_, Xapian::valueno slot, const std::string & range_limit); - - /** Construct a Query object for a value range. - * - * @param op_ Must be OP_VALUE_RANGE currently. - * @param slot The value slot to work over. - * @param range_lower Lower end of the range. - * @param range_upper Upper end of the range. - */ - Query(op op_, Xapian::valueno slot, - const std::string & range_lower, const std::string & range_upper); - - /** Query constructor for OP_WILDCARD queries. - * - * @param op_ Must be OP_WILDCARD - * @param pattern The wildcard pattern - currently this is just a string - * and the wildcard expands to terms which start with - * exactly this string. - * @param max_expansion The maximum number of terms to expand to - * (default: 0, which means no limit) - * @param max_type How to enforce max_expansion - one of - * @a WILDCARD_LIMIT_ERROR (the default), - * @a WILDCARD_LIMIT_FIRST or - * @a WILDCARD_LIMIT_MOST_FREQUENT. - * When searching multiple databases, the expansion limit - * is currently applied independently for each database, - * so the total number of terms may be higher than the - * limit. This is arguably a bug, and may change in - * future versions. - * @param combiner The @a Query::op to combine the terms with - one of - * @a OP_SYNONYM (the default), @a OP_OR or @a OP_MAX. - */ - Query(op op_, - const std::string & pattern, - Xapian::termcount max_expansion = 0, - int max_type = WILDCARD_LIMIT_ERROR, - op combiner = OP_SYNONYM); - - /** Construct a Query object from a begin/end iterator pair. - * - * Dereferencing the iterator should return a Xapian::Query, a non-NULL - * Xapian::Query*, a std::string or a type which converts to one of - * these (e.g. const char*). - * - * If begin == end then there are no subqueries and the resulting Query - * won't match anything. - * - * @param op_ The operator to combine the queries with. - * @param begin Begin iterator. - * @param end End iterator. - * @param window Window size for OP_NEAR and OP_PHRASE, or 0 to use the - * number of subqueries as the window size (default: 0). - */ - template - Query(op op_, I begin, I end, Xapian::termcount window = 0) - { - if (begin != end) { - typedef typename std::iterator_traits::iterator_category iterator_category; - init(op_, window, begin, end, iterator_category()); - bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE); - for (I i = begin; i != end; ++i) { - add_subquery(positional, *i); - } - done(); - } - } - -#ifdef SWIG - // SWIG's %template doesn't seem to handle a templated ctor so we - // provide this fake specialised form of the above prototype. - Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qend, - Xapian::termcount parameter = 0); - -# ifdef SWIGJAVA - Query(op op_, XapianSWIGStrItor qbegin, XapianSWIGStrItor qend, - Xapian::termcount parameter = 0); -# endif -#endif - - /** Begin iterator for terms in the query object. - * - * The iterator returns terms in ascending query position order, and - * will return the same term in each unique position it occurs in. - * If you want the terms in sorted order and without duplicates, see - * get_unique_terms_begin(). - */ - const TermIterator get_terms_begin() const; - - /// End iterator for terms in the query object. - const TermIterator XAPIAN_NOTHROW(get_terms_end() const) { - return TermIterator(); - } - - /** Begin iterator for unique terms in the query object. - * - * Terms are sorted and terms with the same name removed from the list. - * - * If you want the terms in ascending query position order, see - * get_terms_begin(). - */ - const TermIterator get_unique_terms_begin() const; - - /// End iterator for unique terms in the query object. - const TermIterator XAPIAN_NOTHROW(get_unique_terms_end() const) { - return TermIterator(); - } - - /** Return the length of this query object. */ - Xapian::termcount XAPIAN_NOTHROW(get_length() const) XAPIAN_PURE_FUNCTION; - - /** Check if this query is Xapian::Query::MatchNothing. */ - bool XAPIAN_NOTHROW(empty() const) { - return internal.get() == 0; - } - - /** Serialise this object into a string. */ - std::string serialise() const; - - /** Unserialise a string and return a Query object. - * - * @param serialised the string to unserialise. - * @param reg Xapian::Registry object to use to unserialise - * user-subclasses of Xapian::PostingSource - * (default: standard registry). - */ - static const Query unserialise(const std::string & serialised, - const Registry & reg = Registry()); - - /** Get the type of the top level of the query. */ - op XAPIAN_NOTHROW(get_type() const) XAPIAN_PURE_FUNCTION; - - /** Get the number of subqueries of the top level query. */ - size_t XAPIAN_NOTHROW(get_num_subqueries() const) XAPIAN_PURE_FUNCTION; - - /** Read a top level subquery. - * - * @param n Return the n-th subquery (starting from 0) - only valid when - * 0 <= n < get_num_subqueries(). - */ - const Query get_subquery(size_t n) const; - - /// Return a string describing this object. - std::string get_description() const; - - /** Combine with another Xapian::Query object using OP_AND. - * - * @since Since Xapian 1.4.10, when called on a Query object which is - * OP_AND and has a reference count of 1, then @a o is appended as a new - * subquery (provided @a o is a different Query object and - * !o.empty()). - */ - const Query operator&=(const Query & o); - - /** Combine with another Xapian::Query object using OP_OR. - * - * @since Since Xapian 1.4.10, when called on a Query object which is - * OP_OR and has a reference count of 1, then @a o is appended as a new - * subquery (provided @a o is a different Query object and - * !o.empty()). - */ - const Query operator|=(const Query & o); - - /** Combine with another Xapian::Query object using OP_XOR. - * - * @since Since Xapian 1.4.10, when called on a Query object which is - * OP_XOR and has a reference count of 1, then @a o is appended as a new - * subquery (provided @a o is a different Query object and - * !o.empty()). - */ - const Query operator^=(const Query & o); - - /** Scale using OP_SCALE_WEIGHT. - * - * @param factor Non-negative real number to multiply weights by. - */ - const Query operator*=(double factor) { - return (*this = Query(factor, *this)); - } - - /** Inverse scale using OP_SCALE_WEIGHT. - * - * @param factor Positive real number to divide weights by. - */ - const Query operator/=(double factor) { - return (*this = Query(1.0 / factor, *this)); - } - - /** @private @internal */ - explicit Query(Internal * internal_) : internal(internal_) { } - - /** Construct with just an operator. - * - * @param op_ The operator to use - currently only OP_INVALID is useful. - */ - explicit Query(Query::op op_) { - init(op_, 0); - if (op_ != Query::OP_INVALID) done(); - } - - private: - void init(Query::op op_, size_t n_subqueries, Xapian::termcount window = 0); - - template - void init(Query::op op_, Xapian::termcount window, - const I & begin, const I & end, std::random_access_iterator_tag) - { - init(op_, end - begin, window); - } - - template - void init(Query::op op_, Xapian::termcount window, - const I &, const I &, std::input_iterator_tag) - { - init(op_, 0, window); - } - - void add_subquery(bool positional, const Xapian::Query & subquery); - - void add_subquery(bool, const std::string & subquery) { - add_subquery(false, Xapian::Query(subquery)); - } - - void add_subquery(bool positional, const Xapian::Query * subquery) { - // FIXME: subquery NULL? - add_subquery(positional, *subquery); - } - - void done(); -}; - -/** Combine two Xapian::Query objects using OP_AND. */ -inline const Query -operator&(const Query & a, const Query & b) -{ - return Query(Query::OP_AND, a, b); -} - -/** Combine two Xapian::Query objects using OP_OR. */ -inline const Query -operator|(const Query & a, const Query & b) -{ - return Query(Query::OP_OR, a, b); -} - -/** Combine two Xapian::Query objects using OP_XOR. */ -inline const Query -operator^(const Query & a, const Query & b) -{ - return Query(Query::OP_XOR, a, b); -} - -/** Scale a Xapian::Query object using OP_SCALE_WEIGHT. - * - * @param factor Non-negative real number to multiply weights by. - * @param q Xapian::Query object. - */ -inline const Query -operator*(double factor, const Query & q) -{ - return Query(factor, q); -} - -/** Scale a Xapian::Query object using OP_SCALE_WEIGHT. - * - * @param q Xapian::Query object. - * @param factor Non-negative real number to multiply weights by. - */ -inline const Query -operator*(const Query & q, double factor) -{ - return Query(factor, q); -} - -/** Inverse-scale a Xapian::Query object using OP_SCALE_WEIGHT. - * - * @param factor Positive real number to divide weights by. - * @param q Xapian::Query object. - */ -inline const Query -operator/(const Query & q, double factor) -{ - return Query(1.0 / factor, q); -} - -/** @private @internal */ -class InvertedQuery_ { - const Query & query; - - void operator=(const InvertedQuery_ &); - - explicit InvertedQuery_(const Query & query_) : query(query_) { } - - public: - // GCC 4.2 seems to needs a copy ctor. - InvertedQuery_(const InvertedQuery_ & o) : query(o.query) { } - - operator Query() const { - return Query(Query::OP_AND_NOT, Query(std::string()), query); - } - - friend const InvertedQuery_ operator~(const Query &q); - - friend const Query operator&(const Query & a, const InvertedQuery_ & b); - - friend const Query operator&=(Query & a, const InvertedQuery_ & b); -}; - -/** Combine two Xapian::Query objects using OP_AND_NOT. - * - * E.g. Xapian::Query q = q1 &~ q2; - */ -inline const Query -operator&(const Query & a, const InvertedQuery_ & b) -{ - return Query(Query::OP_AND_NOT, a, b.query); -} - -/** Combine two Xapian::Query objects using OP_AND_NOT with result in the first. - * - * E.g. q1 &=~ q2; - */ -inline const Query -operator&=(Query & a, const InvertedQuery_ & b) -{ - return (a = Query(Query::OP_AND_NOT, a, b.query)); -} - -#ifndef DOXYGEN /* @internal doesn't seem to avoid a warning here. */ -/** @internal Helper to allow q1 &~ q2 to work. */ -inline const InvertedQuery_ -operator~(const Query &q) -{ - return InvertedQuery_(q); -} -#endif - -namespace Internal { -class AndContext; -class OrContext; -class XorContext; -} - -/** @private @internal */ -class Query::Internal : public Xapian::Internal::intrusive_base { - public: - XAPIAN_NOTHROW(Internal()) { } - - virtual ~Internal(); - - virtual PostingIterator::Internal * postlist(QueryOptimiser * qopt, double factor) const = 0; - - virtual void postlist_sub_and_like(Xapian::Internal::AndContext& ctx, - QueryOptimiser * qopt, - double factor) const; - - virtual void postlist_sub_or_like(Xapian::Internal::OrContext& ctx, - QueryOptimiser * qopt, - double factor) const; - - virtual void postlist_sub_xor(Xapian::Internal::XorContext& ctx, - QueryOptimiser * qopt, - double factor) const; - - virtual termcount XAPIAN_NOTHROW(get_length() const) XAPIAN_PURE_FUNCTION; - - virtual void serialise(std::string & result) const = 0; - - static Query::Internal * unserialise(const char ** p, const char * end, const Registry & reg); - - virtual Query::op XAPIAN_NOTHROW(get_type() const) XAPIAN_PURE_FUNCTION = 0; - virtual size_t XAPIAN_NOTHROW(get_num_subqueries() const) XAPIAN_PURE_FUNCTION; - virtual const Query get_subquery(size_t n) const; - - virtual std::string get_description() const = 0; - - // Pass argument as void* to avoid need to include . - virtual void gather_terms(void * void_terms) const; -}; - -inline const Query -Query::operator&=(const Query & o) -{ - if (o.empty()) { - // q &= empty_query sets q to empty_query. - *this = o; - } else if (this != &o && - internal.get() && - internal->_refs == 1 && - get_type() == OP_AND) { - // Appending a subquery to an existing AND. - add_subquery(false, o); - } else { - *this = Query(OP_AND, *this, o); - } - return *this; -} - -inline const Query -Query::operator|=(const Query & o) -{ - if (o.empty()) { - // q |= empty_query is a no-op. - } else if (this != &o && - internal.get() && - internal->_refs == 1 && - get_type() == OP_OR) { - // Appending a subquery to an existing OR. - add_subquery(false, o); - } else { - *this = Query(OP_OR, *this, o); - } - return *this; -} - -inline const Query -Query::operator^=(const Query & o) -{ - if (o.empty()) { - // q ^= empty_query is a no-op. - } else if (internal.get() == o.internal.get()) { - // q ^= q gives MatchNothing. - internal = NULL; - } else if (internal.get() && - internal->_refs == 1 && - get_type() == OP_XOR) { - // Appending a subquery to an existing XOR. - add_subquery(false, o); - } else { - *this = Query(OP_XOR, *this, o); - } - return *this; -} - -} - -#endif // XAPIAN_INCLUDED_QUERY_H diff --git a/winlibs/include/xapian/queryparser.h b/winlibs/include/xapian/queryparser.h deleted file mode 100644 index 5395708d0..000000000 --- a/winlibs/include/xapian/queryparser.h +++ /dev/null @@ -1,1371 +0,0 @@ -/** @file - * @brief parsing a user query string to build a Xapian::Query object - */ -/* Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2021 Olly Betts - * Copyright (C) 2010 Adam Sjøgren - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_QUERYPARSER_H -#define XAPIAN_INCLUDED_QUERYPARSER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace Xapian { - -class Database; -class Stem; - -/** Abstract base class for stop-word decision functor. - * - * If you just want to use an existing stopword list, see - * Xapian::SimpleStopper. - */ -class XAPIAN_VISIBILITY_DEFAULT Stopper - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const Stopper &); - - /// Don't allow copying. - Stopper(const Stopper &); - - public: - /// Default constructor. - Stopper() { } - - /** Is term a stop-word? - * - * @param term The term to test. - */ - virtual bool operator()(const std::string & term) const = 0; - - /// Class has virtual methods, so provide a virtual destructor. - virtual ~Stopper() { } - - /// Return a string describing this object. - virtual std::string get_description() const; - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated Stopper - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - Stopper * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated Stopper - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const Stopper * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/// Simple implementation of Stopper class - this will suit most users. -class XAPIAN_VISIBILITY_DEFAULT SimpleStopper : public Stopper { - std::set stop_words; - - public: - /// Default constructor. - SimpleStopper() { } - - /** Initialise from a pair of iterators. - * - * Xapian includes stopword list files for many languages. You can - * initialise from a file like so: - * @code - * std::ifstream words("stopwords/english/stop.txt"); - * Xapian::SimplerStopper stopper(std::istream_iterator(words), std::istream_iterator()); - * @endcode - * - * In bindings for other languages it isn't possible to pass a C++ - * iterator pair, so instead this constructor is wrapped to allow - * passing a filename. - */ - template - SimpleStopper(Iterator begin, Iterator end) : stop_words(begin, end) { } - - /// Add a single stop word. - void add(const std::string & word) { stop_words.insert(word); } - - virtual bool operator()(const std::string & term) const { - return stop_words.find(term) != stop_words.end(); - } - - virtual std::string get_description() const; -}; - -enum { - RP_SUFFIX = 1, - RP_REPEATED = 2, - RP_DATE_PREFER_MDY = 4 -}; - -/// Base class for range processors. -class XAPIAN_VISIBILITY_DEFAULT RangeProcessor - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const RangeProcessor &); - - /// Don't allow copying. - RangeProcessor(const RangeProcessor &); - - protected: - /** The value slot to process. - * - * If this range processor isn't value-based, it can ignore this member. - */ - Xapian::valueno slot; - - /** The prefix (or suffix with RP_SUFFIX) string to look for. */ - std::string str; - - /** Flags. - * - * Bitwise-or (| in C++) of zero or more of the following: - * * Xapian::RP_SUFFIX - require @a str as a suffix - * instead of a prefix. - * * Xapian::RP_REPEATED - optionally allow @a str - * on both ends of the range - e.g. $1..$10 or - * 5m..50m. By default a prefix is only checked for on - * the start (e.g. date:1/1/1980..31/12/1989), and a - * suffix only on the end (e.g. 2..12kg). - */ - unsigned flags; - - public: - /** Default constructor. */ - RangeProcessor() : slot(Xapian::BAD_VALUENO), flags(0) { } - - /** Constructor. - * - * @param slot_ Which value slot to generate ranges over. - * @param str_ A string to look for to recognise values as belonging - * to this range (as a prefix by default, or as a suffix - * if flags Xapian::RP_SUFFIX is specified). - * @param flags_ Zero or more of the following flags, combined with - * bitwise-or (| in C++): - * * Xapian::RP_SUFFIX - require @a str_ as a suffix - * instead of a prefix. - * * Xapian::RP_REPEATED - optionally allow @a str_ - * on both ends of the range - e.g. $1..$10 or - * 5m..50m. By default a prefix is only checked for on - * the start (e.g. date:1/1/1980..31/12/1989), and a - * suffix only on the end (e.g. 2..12kg). - */ - explicit RangeProcessor(Xapian::valueno slot_, - const std::string& str_ = std::string(), - unsigned flags_ = 0) - : slot(slot_), str(str_), flags(flags_) { } - - /// Destructor. - virtual ~RangeProcessor(); - - /** Check prefix/suffix on range. - * - * If they match, remove the prefix/suffix and then call operator()() - * to try to handle the range. - */ - Xapian::Query check_range(const std::string& b, const std::string& e); - - /** Check for a valid range of this type. - * - * Override this method to implement your own range handling. - * - * @param begin The start of the range as specified in the query string - * by the user. - * @param end The end of the range as specified in the query string - * by the user (empty string for no upper limit). - * - * @return An OP_VALUE_RANGE Query object (or if end.empty(), an - * OP_VALUE_GE Query object). Or if the range isn't one - * which this object can handle then - * Xapian::Query(Xapian::Query::OP_INVALID) will be - * returned. - */ - virtual Xapian::Query - operator()(const std::string &begin, const std::string &end); - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated RangeProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - RangeProcessor * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated RangeProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const RangeProcessor * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/** Handle a date range. - * - * Begin and end must be dates in a recognised format. - */ -class XAPIAN_VISIBILITY_DEFAULT DateRangeProcessor : public RangeProcessor { - int epoch_year; - - public: - /** Constructor. - * - * @param slot_ The value number to return from operator(). - * - * @param flags_ Zero or more of the following flags, combined with - * bitwise-or: - * * Xapian::RP_DATE_PREFER_MDY - interpret ambiguous - * dates as month/day/year rather than day/month/year. - * - * @param epoch_year_ Year to use as the epoch for dates with 2 digit - * years (default: 1970, so 1/1/69 is 2069 while - * 1/1/70 is 1970). - */ - explicit DateRangeProcessor(Xapian::valueno slot_, - unsigned flags_ = 0, - int epoch_year_ = 1970) - : RangeProcessor(slot_, std::string(), flags_), - epoch_year(epoch_year_) { } - - /** Constructor. - * - * @param slot_ The value slot number to query. - * - * @param str_ A string to look for to recognise values as belonging - * to this date range. - * - * @param flags_ Zero or more of the following flags, combined with - * bitwise-or: - * * Xapian::RP_SUFFIX - require @a str_ as a suffix - * instead of a prefix. - * * Xapian::RP_REPEATED - optionally allow @a str_ - * on both ends of the range - e.g. $1..$10 or - * 5m..50m. By default a prefix is only checked for on - * the start (e.g. date:1/1/1980..31/12/1989), and a - * suffix only on the end (e.g. 2..12kg). - * * Xapian::RP_DATE_PREFER_MDY - interpret ambiguous - * dates as month/day/year rather than day/month/year. - * - * @param epoch_year_ Year to use as the epoch for dates with 2 digit - * years (default: 1970, so 1/1/69 is 2069 while - * 1/1/70 is 1970). - * - * The string supplied in str_ is used by @a operator() to decide whether - * the pair of strings supplied to it constitute a valid range. If - * prefix_ is true, the first value in a range must begin with str_ (and - * the second value may optionally begin with str_); - * if prefix_ is false, the second value in a range must end with str_ - * (and the first value may optionally end with str_). - * - * If str_ is empty, the Xapian::RP_SUFFIX and Xapian::RP_REPEATED are - * irrelevant, and no special strings are required at the start or end of - * the strings defining the range. - * - * The remainder of both strings defining the endpoints must be valid - * dates. - * - * For example, if str_ is "created:", Xapian::RP_SUFFIX is not specified, - * and the range processor has been added to the queryparser, the - * queryparser will accept "created:1/1/2000..31/12/2001". - */ - DateRangeProcessor(Xapian::valueno slot_, const std::string &str_, - unsigned flags_ = 0, int epoch_year_ = 1970) - : RangeProcessor(slot_, str_, flags_), - epoch_year(epoch_year_) { } - - /** Check for a valid date range. - * - * If any specified prefix is present, and the range looks like a - * date range, the dates are converted to the format YYYYMMDD and - * combined into a value range query. - * - * @param begin The start of the range as specified in the query string - * by the user. - * @param end The end of the range as specified in the query string - * by the user. - */ - Xapian::Query operator()(const std::string& begin, const std::string& end); -}; - -/** Handle a number range. - * - * This class must be used on values which have been encoded using - * Xapian::sortable_serialise() which turns numbers into strings which - * will sort in the same order as the numbers (the same values can be - * used to implement a numeric sort). - */ -class XAPIAN_VISIBILITY_DEFAULT NumberRangeProcessor : public RangeProcessor { - public: - /** Constructor. - * - * @param slot_ The value slot number to query. - * - * @param str_ A string to look for to recognise values as belonging - * to this numeric range. - * - * @param flags_ Zero or more of the following flags, combined with - * bitwise-or: - * * Xapian::RP_SUFFIX - require @a str_ as a suffix - * instead of a prefix. - * * Xapian::RP_REPEATED - optionally allow @a str_ - * on both ends of the range - e.g. $1..$10 or - * 5m..50m. By default a prefix is only checked for on - * the start (e.g. date:1/1/1980..31/12/1989), and a - * suffix only on the end (e.g. 2..12kg). - * - * The string supplied in str_ is used by @a operator() to decide whether - * the pair of strings supplied to it constitute a valid range. If - * prefix_ is true, the first value in a range must begin with str_ (and - * the second value may optionally begin with str_); - * if prefix_ is false, the second value in a range must end with str_ - * (and the first value may optionally end with str_). - * - * If str_ is empty, the setting of prefix_ is irrelevant, and no special - * strings are required at the start or end of the strings defining the - * range. - * - * The remainder of both strings defining the endpoints must be valid - * floating point numbers. (FIXME: define format recognised). - * - * For example, if str_ is "$" and prefix_ is true, and the range - * processor has been added to the queryparser, the queryparser will - * accept "$10..50" or "$10..$50", but not "10..50" or "10..$50" as valid - * ranges. If str_ is "kg" and prefix_ is false, the queryparser will - * accept "10..50kg" or "10kg..50kg", but not "10..50" or "10kg..50" as - * valid ranges. - */ - NumberRangeProcessor(Xapian::valueno slot_, - const std::string &str_ = std::string(), - unsigned flags_ = 0) - : RangeProcessor(slot_, str_, flags_) { } - - /** Check for a valid numeric range. - * - * If BEGIN..END is a valid numeric range with the specified prefix/suffix - * (if one was specified), the prefix/suffix is removed, the string - * converted to a number, and encoded with Xapian::sortable_serialise(), - * and a value range query is built. - * - * @param begin The start of the range as specified in the query string - * by the user. - * @param end The end of the range as specified in the query string - * by the user. - */ - Xapian::Query operator()(const std::string& begin, const std::string& end); -}; - -/// Base class for value range processors. -class XAPIAN_VISIBILITY_DEFAULT ValueRangeProcessor - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const ValueRangeProcessor &); - - /// Don't allow copying. - ValueRangeProcessor(const ValueRangeProcessor &); - - public: - /// Default constructor. - ValueRangeProcessor() { } - - /// Destructor. - virtual ~ValueRangeProcessor(); - - /** Check for a valid range of this type. - * - * @param[in,out] begin The start of the range as specified in the query - * string by the user. This parameter is a - * non-const reference so the ValueRangeProcessor - * can modify it to return the value to start the - * range with. - * @param[in,out] end The end of the range. This is also a non-const - * reference so it can be modified. - * - * @return If this ValueRangeProcessor recognises the range BEGIN..END it - * returns the value slot number to range filter on. Otherwise it - * returns Xapian::BAD_VALUENO. - */ - virtual Xapian::valueno operator()(std::string &begin, std::string &end) = 0; - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ValueRangeProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - ValueRangeProcessor * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated ValueRangeProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const ValueRangeProcessor * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/** Handle a string range. - * - * The end points can be any strings. - * - * @deprecated Use Xapian::RangeProcessor instead (added in 1.3.6). - */ -class XAPIAN_DEPRECATED_CLASS_EX XAPIAN_VISIBILITY_DEFAULT StringValueRangeProcessor : public ValueRangeProcessor { - protected: - /** The value slot to process. */ - Xapian::valueno valno; - - /** Whether to look for @a str as a prefix or suffix. */ - bool prefix; - - /** The prefix (or suffix if prefix==false) string to look for. */ - std::string str; - - public: - /** Constructor. - * - * @param slot_ The value number to return from operator(). - */ - explicit StringValueRangeProcessor(Xapian::valueno slot_) - : valno(slot_), str() { } - - /** Constructor. - * - * @param slot_ The value number to return from operator(). - * @param str_ A string to look for to recognise values as belonging - * to this range. - * @param prefix_ Flag specifying whether to check for str_ as a prefix - * or a suffix. - */ - StringValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, - bool prefix_ = true) - : valno(slot_), prefix(prefix_), str(str_) { } - - /** Check for a valid string range. - * - * @param[in,out] begin The start of the range as specified in the - * query string by the user. This parameter is a - * non-const reference so the ValueRangeProcessor - * can modify it to return the value to start the - * range with. - * @param[in,out] end The end of the range. This is also a non-const - * reference so it can be modified. - * - * @return A StringValueRangeProcessor always accepts a range it is - * offered, and returns the value of slot_ passed at construction - * time. It doesn't modify @a begin or @a end. - */ - Xapian::valueno operator()(std::string &begin, std::string &end); -}; - -/** Handle a date range. - * - * Begin and end must be dates in a recognised format. - * - * @deprecated Use Xapian::DateRangeProcessor instead (added in 1.3.6). - */ -class XAPIAN_DEPRECATED_CLASS_EX XAPIAN_VISIBILITY_DEFAULT DateValueRangeProcessor : public StringValueRangeProcessor { - bool prefer_mdy; - int epoch_year; - - public: - /** Constructor. - * - * @param slot_ The value number to return from operator(). - * @param prefer_mdy_ Should ambiguous dates be interpreted as - * month/day/year rather than day/month/year? - * (default: false) - * @param epoch_year_ Year to use as the epoch for dates with 2 digit - * years (default: 1970, so 1/1/69 is 2069 while - * 1/1/70 is 1970). - */ - DateValueRangeProcessor(Xapian::valueno slot_, bool prefer_mdy_ = false, - int epoch_year_ = 1970) - : StringValueRangeProcessor(slot_), - prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } - - /** Constructor. - * - * @param slot_ The value number to return from operator(). - * - * @param str_ A string to look for to recognise values as belonging - * to this date range. - * - * @param prefix_ Whether to look for the string at the start or end of - * the values. If true, the string is a prefix; if - * false, the string is a suffix (default: true). - * - * @param prefer_mdy_ Should ambiguous dates be interpreted as - * month/day/year rather than day/month/year? - * (default: false) - * - * @param epoch_year_ Year to use as the epoch for dates with 2 digit - * years (default: 1970, so 1/1/69 is 2069 while - * 1/1/70 is 1970). - * - * The string supplied in str_ is used by @a operator() to decide whether - * the pair of strings supplied to it constitute a valid range. If - * prefix_ is true, the first value in a range must begin with str_ (and - * the second value may optionally begin with str_); - * if prefix_ is false, the second value in a range must end with str_ - * (and the first value may optionally end with str_). - * - * If str_ is empty, the setting of prefix_ is irrelevant, and no special - * strings are required at the start or end of the strings defining the - * range. - * - * The remainder of both strings defining the endpoints must be valid - * dates. - * - * For example, if str_ is "created:" and prefix_ is true, and the range - * processor has been added to the queryparser, the queryparser will - * accept "created:1/1/2000..31/12/2001". - */ - DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, - bool prefix_ = true, - bool prefer_mdy_ = false, int epoch_year_ = 1970) - : StringValueRangeProcessor(slot_, str_, prefix_), - prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } - -#ifndef SWIG - /** Constructor. - * - * This is like the previous version, but with const char * instead of - * std::string - we need this overload as otherwise - * DateValueRangeProcessor(1, "date:") quietly interprets the second - * argument as a boolean in preference to std::string. If you want to - * be compatible with 1.2.12 and earlier, then explicitly convert to - * std::string, i.e.: DateValueRangeProcessor(1, std::string("date:")) - * - * @param slot_ The value number to return from operator(). - * - * @param str_ A string to look for to recognise values as belonging - * to this date range. - * - * @param prefix_ Whether to look for the string at the start or end of - * the values. If true, the string is a prefix; if - * false, the string is a suffix (default: true). - * - * @param prefer_mdy_ Should ambiguous dates be interpreted as - * month/day/year rather than day/month/year? - * (default: false) - * - * @param epoch_year_ Year to use as the epoch for dates with 2 digit - * years (default: 1970, so 1/1/69 is 2069 while - * 1/1/70 is 1970). - * - * The string supplied in str_ is used by @a operator() to decide whether - * the pair of strings supplied to it constitute a valid range. If - * prefix_ is true, the first value in a range must begin with str_ (and - * the second value may optionally begin with str_); - * if prefix_ is false, the second value in a range must end with str_ - * (and the first value may optionally end with str_). - * - * If str_ is empty, the setting of prefix_ is irrelevant, and no special - * strings are required at the start or end of the strings defining the - * range. - * - * The remainder of both strings defining the endpoints must be valid - * dates. - * - * For example, if str_ is "created:" and prefix_ is true, and the range - * processor has been added to the queryparser, the queryparser will - * accept "created:1/1/2000..31/12/2001". - */ - DateValueRangeProcessor(Xapian::valueno slot_, const char * str_, - bool prefix_ = true, - bool prefer_mdy_ = false, int epoch_year_ = 1970) - : StringValueRangeProcessor(slot_, str_, prefix_), - prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } -#endif - - /** Check for a valid date range. - * - * @param[in,out] begin The start of the range as specified in the - * query string by the user. This parameter is a - * non-const reference so the ValueRangeProcessor - * can modify it to return the value to start the - * range with. - * @param[in,out] end The end of the range. This is also a non-const - * reference so it can be modified. - * - * @return If BEGIN..END is a sensible date range, this method modifies - * them into the format YYYYMMDD and returns the value of slot_ - * passed at construction time. Otherwise it returns - * Xapian::BAD_VALUENO. - */ - Xapian::valueno operator()(std::string &begin, std::string &end); -}; - -/** Handle a number range. - * - * This class must be used on values which have been encoded using - * Xapian::sortable_serialise() which turns numbers into strings which - * will sort in the same order as the numbers (the same values can be - * used to implement a numeric sort). - * - * @deprecated Use Xapian::NumberRangeProcessor instead (added in 1.3.6). - */ -class XAPIAN_DEPRECATED_CLASS_EX XAPIAN_VISIBILITY_DEFAULT NumberValueRangeProcessor : public StringValueRangeProcessor { - public: - /** Constructor. - * - * @param slot_ The value number to return from operator(). - */ - explicit NumberValueRangeProcessor(Xapian::valueno slot_) - : StringValueRangeProcessor(slot_) { } - - /** Constructor. - * - * @param slot_ The value number to return from operator(). - * - * @param str_ A string to look for to recognise values as belonging - * to this numeric range. - * - * @param prefix_ Whether to look for the string at the start or end of - * the values. If true, the string is a prefix; if - * false, the string is a suffix (default: true). - * - * The string supplied in str_ is used by @a operator() to decide whether - * the pair of strings supplied to it constitute a valid range. If - * prefix_ is true, the first value in a range must begin with str_ (and - * the second value may optionally begin with str_); - * if prefix_ is false, the second value in a range must end with str_ - * (and the first value may optionally end with str_). - * - * If str_ is empty, the setting of prefix_ is irrelevant, and no special - * strings are required at the start or end of the strings defining the - * range. - * - * The remainder of both strings defining the endpoints must be valid - * floating point numbers. (FIXME: define format recognised). - * - * For example, if str_ is "$" and prefix_ is true, and the range - * processor has been added to the queryparser, the queryparser will - * accept "$10..50" or "$10..$50", but not "10..50" or "10..$50" as valid - * ranges. If str_ is "kg" and prefix_ is false, the queryparser will - * accept "10..50kg" or "10kg..50kg", but not "10..50" or "10kg..50" as - * valid ranges. - */ - NumberValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, - bool prefix_ = true) - : StringValueRangeProcessor(slot_, str_, prefix_) { } - - /** Check for a valid numeric range. - * - * @param[in,out] begin The start of the range as specified in the - * query string by the user. This parameter is a - * non-const reference so the ValueRangeProcessor - * can modify it to return the value to start the - * range with. - * @param[in,out] end The end of the range. This is also a non-const - * reference so it can be modified. - * - * @return If BEGIN..END is a valid numeric range with the specified - * prefix/suffix (if one was specified), this method modifies - * them by removing the prefix/suffix, converting to a number, - * and encoding with Xapian::sortable_serialise(), and returns the - * value of slot_ passed at construction time. Otherwise it - * returns Xapian::BAD_VALUENO. - */ - Xapian::valueno operator()(std::string &begin, std::string &end); -}; - -/** Base class for field processors. - */ -class XAPIAN_VISIBILITY_DEFAULT FieldProcessor - : public Xapian::Internal::opt_intrusive_base { - /// Don't allow assignment. - void operator=(const FieldProcessor &); - - /// Don't allow copying. - FieldProcessor(const FieldProcessor &); - - public: - /// Default constructor. - FieldProcessor() { } - - /// Destructor. - virtual ~FieldProcessor(); - - /** Convert a field-prefixed string to a Query object. - * - * @param str The string to convert. - * - * @return Query object corresponding to @a str. - */ - virtual Xapian::Query operator()(const std::string &str) = 0; - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated FieldProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - FieldProcessor * release() { - opt_intrusive_base::release(); - return this; - } - - /** Start reference counting this object. - * - * You can hand ownership of a dynamically allocated FieldProcessor - * object to Xapian by calling release() and then passing the object to a - * Xapian method. Xapian will arrange to delete the object once it is no - * longer required. - */ - const FieldProcessor * release() const { - opt_intrusive_base::release(); - return this; - } -}; - -/// Build a Xapian::Query object from a user query string. -class XAPIAN_VISIBILITY_DEFAULT QueryParser { - public: - /// Class representing the queryparser internals. - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /// Enum of feature flags. - typedef enum { - /// Support AND, OR, etc and bracketed subexpressions. - FLAG_BOOLEAN = 1, - /// Support quoted phrases. - FLAG_PHRASE = 2, - /// Support + and -. - FLAG_LOVEHATE = 4, - /// Support AND, OR, etc even if they aren't in ALLCAPS. - FLAG_BOOLEAN_ANY_CASE = 8, - /** Support wildcards. - * - * At present only right truncation (e.g. Xap*) is supported. - * - * Currently you can't use wildcards with boolean filter prefixes, - * or in a phrase (either an explicitly quoted one, or one implicitly - * generated by hyphens or other punctuation). - * - * In Xapian 1.2.x, you needed to tell the QueryParser object which - * database to expand wildcards from by calling set_database(). In - * Xapian 1.3.3, OP_WILDCARD was added and wildcards are now - * expanded when Enquire::get_mset() is called, with the expansion - * using the database being searched. - */ - FLAG_WILDCARD = 16, - /** Allow queries such as 'NOT apples'. - * - * These require the use of a list of all documents in the database - * which is potentially expensive, so this feature isn't enabled by - * default. - */ - FLAG_PURE_NOT = 32, - /** Enable partial matching. - * - * Partial matching causes the parser to treat the query as a - * "partially entered" search. This will automatically treat the - * final word as a wildcarded match, unless it is followed by - * whitespace, to produce more stable results from interactive - * searches. - * - * Currently FLAG_PARTIAL doesn't do anything if the final word - * in the query has a boolean filter prefix, or if it is in a phrase - * (either an explicitly quoted one, or one implicitly generated by - * hyphens or other punctuation). It also doesn't do anything if - * if the final word is part of a value range. - * - * In Xapian 1.2.x, you needed to tell the QueryParser object which - * database to expand wildcards from by calling set_database(). In - * Xapian 1.3.3, OP_WILDCARD was added and wildcards are now - * expanded when Enquire::get_mset() is called, with the expansion - * using the database being searched. - */ - FLAG_PARTIAL = 64, - - /** Enable spelling correction. - * - * For each word in the query which doesn't exist as a term in the - * database, Database::get_spelling_suggestion() will be called and if - * a suggestion is returned, a corrected version of the query string - * will be built up which can be read using - * QueryParser::get_corrected_query_string(). The query returned is - * based on the uncorrected query string however - if you want a - * parsed query based on the corrected query string, you must call - * QueryParser::parse_query() again. - * - * NB: You must also call set_database() for this to work. - */ - FLAG_SPELLING_CORRECTION = 128, - - /** Enable synonym operator '~'. - * - * NB: You must also call set_database() for this to work. - */ - FLAG_SYNONYM = 256, - - /** Enable automatic use of synonyms for single terms. - * - * NB: You must also call set_database() for this to work. - */ - FLAG_AUTO_SYNONYMS = 512, - - /** Enable automatic use of synonyms for single terms and groups of - * terms. - * - * NB: You must also call set_database() for this to work. - */ - FLAG_AUTO_MULTIWORD_SYNONYMS = 1024, - - /** Enable generation of n-grams from CJK text. - * - * With this enabled, spans of CJK characters are split into unigrams - * and bigrams, with the unigrams carrying positional information. - * Non-CJK characters are split into words as normal. - * - * The corresponding option needs to have been used at index time. - * - * Flag added in Xapian 1.3.4 and 1.2.22. This mode can be - * enabled in 1.2.8 and later by setting environment variable - * XAPIAN_CJK_NGRAM to a non-empty value (but doing so was deprecated - * in 1.4.11). - */ - FLAG_CJK_NGRAM = 2048, - - /** Accumulate unstem and stoplist results. - * - * By default, the unstem and stoplist data is reset by a call to - * parse_query(), which makes sense if you use the same QueryParser - * object to parse a series of independent queries. - * - * If you're using the same QueryParser object to parse several - * fields on the same query form, you may want to have the unstem - * and stoplist data combined for all of them, in which case you - * can use this flag to prevent this data from being reset. - * - * @since Added in Xapian 1.4.18. - */ - FLAG_ACCUMULATE = 65536, - - /** Produce a query which doesn't use positional information. - * - * With this flag enabled, no positional information will be used - * and any query operations which would use it are replaced by - * the nearest equivalent which doesn't (so phrase searches, NEAR - * and ADJ will result in OP_AND). - * - * @since Added in Xapian 1.4.19. - */ - FLAG_NO_POSITIONS = 0x20000, - - /** The default flags. - * - * Used if you don't explicitly pass any to @a parse_query(). - * The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE. - * - * Added in Xapian 1.0.11. - */ - FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE - } feature_flag; - - /// Stemming strategies, for use with set_stemming_strategy(). - typedef enum { - STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS - } stem_strategy; - - /// Copy constructor. - QueryParser(const QueryParser & o); - - /// Assignment. - QueryParser & operator=(const QueryParser & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - QueryParser(QueryParser && o); - - /// Move assignment operator. - QueryParser & operator=(QueryParser && o); -#endif - - /// Default constructor. - QueryParser(); - - /// Destructor. - ~QueryParser(); - - /** Set the stemmer. - * - * This sets the stemming algorithm which will be used by the query - * parser. The stemming algorithm will be used according to the stemming - * strategy set by set_stemming_strategy(). As of 1.3.1, this defaults - * to STEM_SOME, but in earlier versions the default was STEM_NONE. If - * you want to work with older versions, you should explicitly set - * a stemming strategy as well as setting a stemmer, otherwise your - * stemmer won't actually be used. - * - * @param stemmer The Xapian::Stem object to set. - */ - void set_stemmer(const Xapian::Stem & stemmer); - - /** Set the stemming strategy. - * - * This controls how the query parser will apply the stemming algorithm. - * Note that the stemming algorithm is only applied to words in free-text - * fields - boolean filter terms are never stemmed. - * - * @param strategy The strategy to use - possible values are: - * - STEM_NONE: Don't perform any stemming. (default in Xapian <= - * 1.3.0) - * - STEM_SOME: Stem all terms except for those which start with a - * capital letter, or are followed by certain characters - * (currently: (/\@<>=*[{" ), or are used - * with operators which need positional information. - * Stemmed terms are prefixed with 'Z'. (default in - * Xapian >= 1.3.1) - * - STEM_SOME_FULL_POS: - * Like STEM_SOME but also stems terms used with operators - * which need positional information. Added in Xapian - * 1.4.8. - * - STEM_ALL: Stem all terms (note: no 'Z' prefix is added). - * - STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in - * Xapian 1.2.11 and 1.3.1) - */ - void set_stemming_strategy(stem_strategy strategy); - - /** Set the stopper. - * - * @param stop The Stopper object to set (default NULL, which means no - * stopwords). - */ - void set_stopper(const Stopper *stop = NULL); - - /** Set the default operator. - * - * @param default_op The operator to use to combine non-filter - * query items when no explicit operator is used. - * - * So for example, 'weather forecast' is parsed as - * if it were 'weather OR forecast' by default. - * - * The most useful values for this are OP_OR (the - * default) and OP_AND. OP_NEAR, OP_PHRASE, - * OP_ELITE_SET, OP_SYNONYM and OP_MAX are also - * permitted. Passing other values will result in - * InvalidArgumentError being thrown. - */ - void set_default_op(Query::op default_op); - - /** Get the current default operator. */ - Query::op get_default_op() const; - - /** Specify the database being searched. - * - * @param db The database to use for spelling correction - * (FLAG_SPELLING_CORRECTION), and synonyms (FLAG_SYNONYM, - * FLAG_AUTO_SYNONYMS, and FLAG_AUTO_MULTIWORD_SYNONYMS). - */ - void set_database(const Database &db); - - /** Specify the maximum expansion of a wildcard and/or partial term. - * - * Note: you must also set FLAG_WILDCARD and/or FLAG_PARTIAL in the flags - * parameter to @a parse_query() for this setting to have anything to - * affect. - * - * If you don't call this method, the default settings are no limit on - * wildcard expansion, and partial terms expanding to the most frequent - * 100 terms - i.e. as if you'd called: - * - * set_max_expansion(0); - * set_max_expansion(100, Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT, Xapian::QueryParser::FLAG_PARTIAL); - * - * @param max_expansion The maximum number of terms each wildcard in the - * query can expand to, or 0 for no limit (which is the - * default). - * @param max_type @a Xapian::Query::WILDCARD_LIMIT_ERROR, - * @a Xapian::Query::WILDCARD_LIMIT_FIRST or - * @a Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT - * (default: Xapian::Query::WILDCARD_LIMIT_ERROR). - * @param flags What to set the limit for (default: - * FLAG_WILDCARD|FLAG_PARTIAL, setting the limit for both - * wildcards and partial terms). - * - * @since 1.3.3 - */ - void set_max_expansion(Xapian::termcount max_expansion, - int max_type = Xapian::Query::WILDCARD_LIMIT_ERROR, - unsigned flags = FLAG_WILDCARD|FLAG_PARTIAL); - - /** Specify the maximum expansion of a wildcard. - * - * If any wildcard expands to more than @a max_expansion terms, an - * exception will be thrown. - * - * This method is provided for API compatibility with Xapian 1.2.x and is - * deprecated - replace it with: - * - * set_max_wildcard_expansion(max_expansion, - * Xapian::Query::WILDCARD_LIMIT_ERROR, - * Xapian::QueryParser::FLAG_WILDCARD); - */ - XAPIAN_DEPRECATED(void set_max_wildcard_expansion(Xapian::termcount)); - - /** Parse a query. - * - * @param query_string A free-text query as entered by a user - * @param flags Zero or more QueryParser::feature_flag specifying - * what features the QueryParser should support. Combine - * multiple values with bitwise-or (|) (default FLAG_DEFAULT). - * @param default_prefix The default term prefix to use (default none). - * For example, you can pass "A" when parsing an "Author" field. - * - * @exception If the query string can't be parsed, then - * Xapian::QueryParserError is thrown. You can get an English - * error message to report to the user by catching it and - * calling get_msg() on the caught exception. The current - * possible values (in case you want to translate them) are: - * - * @li Unknown range operation - * @li parse error - * @li Syntax: <expression> AND <expression> - * @li Syntax: <expression> AND NOT <expression> - * @li Syntax: <expression> NOT <expression> - * @li Syntax: <expression> OR <expression> - * @li Syntax: <expression> XOR <expression> - */ - Query parse_query(const std::string &query_string, - unsigned flags = FLAG_DEFAULT, - const std::string &default_prefix = std::string()); - - /** Add a free-text field term prefix. - * - * For example: - * - * @code - * qp.add_prefix("author", "A"); - * @endcode - * - * This allows the user to search for author:Orwell which will be - * converted to a search for the term "Aorwell". - * - * Multiple fields can be mapped to the same prefix. For example, you - * can make title: and subject: aliases for each other. - * - * As of 1.0.4, you can call this method multiple times with the same - * value of field to allow a single field to be mapped to multiple - * prefixes. Multiple terms being generated for such a field, and - * combined with @c Xapian::Query::OP_OR. - * - * If any prefixes are specified for the empty field name (i.e. you - * call this method with an empty string as the first parameter) - * these prefixes will be used for terms without a field specifier. - * If you do this and also specify the @c default_prefix parameter to @c - * parse_query(), then the @c default_prefix parameter will override. - * - * If the prefix parameter is empty, then "field:word" will produce the - * term "word" (and this can be one of several prefixes for a particular - * field, or for terms without a field specifier). - * - * If you call @c add_prefix() and @c add_boolean_prefix() for the - * same value of @a field, a @c Xapian::InvalidOperationError exception - * will be thrown. - * - * In 1.0.3 and earlier, subsequent calls to this method with the same - * value of @a field had no effect. - * - * @param field The user visible field name - * @param prefix The term prefix to map this to - */ - void add_prefix(const std::string& field, const std::string& prefix); - - /** Register a FieldProcessor. - */ - void add_prefix(const std::string& field, Xapian::FieldProcessor * proc); - - /** Add a boolean term prefix allowing the user to restrict a - * search with a boolean filter specified in the free text query. - * - * For example: - * - * @code - * qp.add_boolean_prefix("site", "H"); - * @endcode - * - * This allows the user to restrict a search with site:xapian.org which - * will be converted to Hxapian.org combined with any weighted - * query with @c Xapian::Query::OP_FILTER. - * - * If multiple boolean filters are specified in a query for the same - * prefix, they will be combined with the @c Xapian::Query::OP_OR - * operator. Then, if there are boolean filters for different prefixes, - * they will be combined with the @c Xapian::Query::OP_AND operator. - * - * Multiple fields can be mapped to the same prefix (so for example - * you can make site: and domain: aliases for each other). Instances of - * fields with different aliases but the same prefix will still be - * combined with the OR operator. - * - * For example, if "site" and "domain" map to "H", but author maps to "A", - * a search for "site:foo domain:bar author:Fred" will map to - * "(Hfoo OR Hbar) AND Afred". - * - * As of 1.0.4, you can call this method multiple times with the same - * value of field to allow a single field to be mapped to multiple - * prefixes. Multiple terms being generated for such a field, and - * combined with @c Xapian::Query::OP_OR. - * - * Calling this method with an empty string for @a field will cause - * a @c Xapian::InvalidArgumentError. - * - * If you call @c add_prefix() and @c add_boolean_prefix() for the - * same value of @a field, a @c Xapian::InvalidOperationError exception - * will be thrown. - * - * In 1.0.3 and earlier, subsequent calls to this method with the same - * value of @a field had no effect. - * - * @param field The user visible field name - * @param prefix The term prefix to map this to - * @param grouping Controls how multiple filters are combined - filters - * with the same grouping value are combined with OP_OR, - * then the resulting queries are combined with OP_AND. - * If NULL, then @a field is used for grouping. If an - * empty string, then a unique grouping is created for - * each filter (this is sometimes useful when each - * document can have multiple terms with this prefix). - * [default: NULL] - */ - void add_boolean_prefix(const std::string &field, const std::string &prefix, - const std::string* grouping = NULL); - - /** Add a boolean term prefix allowing the user to restrict a - * search with a boolean filter specified in the free text query. - * - * This is an older version of this method - use the version with - * the `grouping` parameter in preference to this one. - * - * @param field The user visible field name - * @param prefix The term prefix to map this to - * @param exclusive Controls how multiple filters are combined. If - * true then @a prefix is used as the `grouping` value, - * so terms with the same prefix are combined with OP_OR, - * then the resulting queries are combined with OP_AND. - * If false, then a unique grouping is created for - * each filter (this is sometimes useful when each - * document can have multiple terms with this prefix). - */ - void add_boolean_prefix(const std::string &field, const std::string &prefix, - bool exclusive) { - if (exclusive) { - add_boolean_prefix(field, prefix); - } else { - std::string empty_grouping; - add_boolean_prefix(field, prefix, &empty_grouping); - } - } - - /** Register a FieldProcessor for a boolean prefix. - */ - void add_boolean_prefix(const std::string &field, Xapian::FieldProcessor *proc, - const std::string* grouping = NULL); - - /** Register a FieldProcessor for a boolean prefix. - * - * This is an older version of this method - use the version with - * the `grouping` parameter in preference to this one. - */ - void add_boolean_prefix(const std::string &field, Xapian::FieldProcessor *proc, - bool exclusive) { - if (exclusive) { - add_boolean_prefix(field, proc); - } else { - std::string empty_grouping; - add_boolean_prefix(field, proc, &empty_grouping); - } - } - - /// Begin iterator over terms omitted from the query as stopwords. - TermIterator stoplist_begin() const; - - /// End iterator over terms omitted from the query as stopwords. - TermIterator XAPIAN_NOTHROW(stoplist_end() const) { - return TermIterator(); - } - - /// Begin iterator over unstemmed forms of the given stemmed query term. - TermIterator unstem_begin(const std::string &term) const; - - /// End iterator over unstemmed forms of the given stemmed query term. - TermIterator XAPIAN_NOTHROW(unstem_end(const std::string &) const) { - return TermIterator(); - } - - /// Register a RangeProcessor. - void add_rangeprocessor(Xapian::RangeProcessor * range_proc, - const std::string* grouping = NULL); - - /** Register a ValueRangeProcessor. - * - * This method is provided for API compatibility with Xapian 1.2.x and is - * deprecated - use @a add_rangeprocessor() with a RangeProcessor instead. - */ - XAPIAN_DEPRECATED(void add_valuerangeprocessor(Xapian::ValueRangeProcessor * vrproc)) { -#ifdef __GNUC__ -// Avoid deprecation warnings if compiling without optimisation. -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - /// Compatibility shim. - class ShimRangeProcessor : public RangeProcessor { - Xapian::Internal::opt_intrusive_ptr vrp; - - public: - ShimRangeProcessor(Xapian::ValueRangeProcessor * vrp_) - : RangeProcessor(Xapian::BAD_VALUENO), vrp(vrp_) { } - - Xapian::Query - operator()(const std::string &begin, const std::string &end) - { - std::string b = begin, e = end; - slot = (*vrp)(b, e); - if (slot == Xapian::BAD_VALUENO) - return Xapian::Query(Xapian::Query::OP_INVALID); - return RangeProcessor::operator()(b, e); - } - }; - - add_rangeprocessor((new ShimRangeProcessor(vrproc))->release()); -#ifdef __GNUC__ -# pragma GCC diagnostic pop -#endif - } - - /** Get the spelling-corrected query string. - * - * This will only be set if FLAG_SPELLING_CORRECTION is specified when - * QueryParser::parse_query() was last called. - * - * If there were no corrections, an empty string is returned. - */ - std::string get_corrected_query_string() const; - - /// Return a string describing this object. - std::string get_description() const; -}; - -inline void -QueryParser::set_max_wildcard_expansion(Xapian::termcount max_expansion) -{ - set_max_expansion(max_expansion, - Xapian::Query::WILDCARD_LIMIT_ERROR, - FLAG_WILDCARD); -} - -/// @private @internal Helper for sortable_serialise(). -XAPIAN_VISIBILITY_DEFAULT -size_t XAPIAN_NOTHROW(sortable_serialise_(double value, char * buf)); - -/** Convert a floating point number to a string, preserving sort order. - * - * This method converts a floating point number to a string, suitable for - * using as a value for numeric range restriction, or for use as a sort - * key. - * - * The conversion is platform independent. - * - * The conversion attempts to ensure that, for any pair of values supplied - * to the conversion algorithm, the result of comparing the original - * values (with a numeric comparison operator) will be the same as the - * result of comparing the resulting values (with a string comparison - * operator). On platforms which represent doubles with the precisions - * specified by IEEE_754, this will be the case: if the representation of - * doubles is more precise, it is possible that two very close doubles - * will be mapped to the same string, so will compare equal. - * - * Note also that both zero and -zero will be converted to the same - * representation: since these compare equal, this satisfies the - * comparison constraint, but it's worth knowing this if you wish to use - * the encoding in some situation where this distinction matters. - * - * Handling of NaN isn't (currently) guaranteed to be sensible. - * - * @param value The number to serialise. - */ -inline std::string sortable_serialise(double value) { - char buf[9]; - return std::string(buf, sortable_serialise_(value, buf)); -} - -/** Convert a string encoded using @a sortable_serialise back to a floating - * point number. - * - * This expects the input to be a string produced by @a sortable_serialise(). - * If the input is not such a string, the value returned is undefined (but - * no error will be thrown). - * - * The result of the conversion will be exactly the value which was - * supplied to @a sortable_serialise() when making the string on platforms - * which represent doubles with the precisions specified by IEEE_754, but - * may be a different (nearby) value on other platforms. - * - * @param serialised The serialised string to decode. - */ -XAPIAN_VISIBILITY_DEFAULT -double XAPIAN_NOTHROW(sortable_unserialise(const std::string & serialised)); - -} - -#endif // XAPIAN_INCLUDED_QUERYPARSER_H diff --git a/winlibs/include/xapian/registry.h b/winlibs/include/xapian/registry.h deleted file mode 100644 index 3099d6bbb..000000000 --- a/winlibs/include/xapian/registry.h +++ /dev/null @@ -1,163 +0,0 @@ -/** @file - * @brief Class for looking up user subclasses during unserialisation. - */ -/* Copyright 2009 Lemur Consulting Ltd - * Copyright 2009,2011,2013,2014 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_REGISTRY_H -#define XAPIAN_INCLUDED_REGISTRY_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include - -namespace Xapian { - -// Forward declarations. -class LatLongMetric; -class MatchSpy; -class PostingSource; -class Weight; - -/** Registry for user subclasses. - * - * This class provides a way for the remote server to look up user subclasses - * when unserialising. - */ -class XAPIAN_VISIBILITY_DEFAULT Registry { - public: - /// Class holding details of the registry. - class Internal; - - private: - /// @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - public: - /** Copy constructor. - * - * The internals are reference counted, so copying is cheap. - * - * @param other The object to copy. - */ - Registry(const Registry & other); - - /** Assignment operator. - * - * The internals are reference counted, so assignment is cheap. - * - * @param other The object to copy. - */ - Registry & operator=(const Registry & other); - -#ifdef XAPIAN_MOVE_SEMANTICS - /** Move constructor. - * - * @param other The object to move. - */ - Registry(Registry && other); - - /** Move assignment operator. - * - * @param other The object to move. - */ - Registry & operator=(Registry && other); -#endif - - /** Default constructor. - * - * The registry will contain all standard subclasses of user-subclassable - * classes. - */ - Registry(); - - ~Registry(); - - /** Register a weighting scheme. - * - * @param wt The weighting scheme to register. - */ - void register_weighting_scheme(const Xapian::Weight &wt); - - /** Get the weighting scheme given a name. - * - * @param name The name of the weighting scheme to find. - * @return An object with the requested name, or NULL if the - * weighting scheme could not be found. The returned - * object is owned by the registry and so must not be - * deleted by the caller. - */ - const Xapian::Weight * - get_weighting_scheme(const std::string & name) const; - - /** Register a user-defined posting source class. - * - * @param source The posting source to register. - */ - void register_posting_source(const Xapian::PostingSource &source); - - /** Get a posting source given a name. - * - * @param name The name of the posting source to find. - * @return An object with the requested name, or NULL if the - * posting source could not be found. The returned - * object is owned by the registry and so must not be - * deleted by the caller. - */ - const Xapian::PostingSource * - get_posting_source(const std::string & name) const; - - /** Register a user-defined match spy class. - * - * @param spy The match spy to register. - */ - void register_match_spy(const Xapian::MatchSpy &spy); - - /** Get a match spy given a name. - * - * @param name The name of the match spy to find. - * @return An object with the requested name, or NULL if the - * match spy could not be found. The returned - * object is owned by the registry and so must not be - * deleted by the caller. - */ - const Xapian::MatchSpy * - get_match_spy(const std::string & name) const; - - /// Register a user-defined lat-long metric class. - void register_lat_long_metric(const Xapian::LatLongMetric &metric); - - /** Get a lat-long metric given a name. - * - * The returned metric is owned by the registry object. - * - * Returns NULL if the metric could not be found. - */ - const Xapian::LatLongMetric * - get_lat_long_metric(const std::string & name) const; - -}; - -} - -#endif /* XAPIAN_INCLUDED_REGISTRY_H */ diff --git a/winlibs/include/xapian/stem.h b/winlibs/include/xapian/stem.h deleted file mode 100644 index 47ed9edfe..000000000 --- a/winlibs/include/xapian/stem.h +++ /dev/null @@ -1,190 +0,0 @@ -/** @file - * @brief stemming algorithms - */ -/* Copyright (C) 2005,2007,2010,2011,2013,2014,2015,2018,2019 Olly Betts - * Copyright (C) 2010 Evgeny Sizikov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_STEM_H -#define XAPIAN_INCLUDED_STEM_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include - -#include - -namespace Xapian { - -/// Class representing a stemming algorithm implementation. -class XAPIAN_VISIBILITY_DEFAULT StemImplementation - : public Xapian::Internal::intrusive_base -{ - /// Don't allow assignment. - void operator=(const StemImplementation &); - - /// Don't allow copying. - StemImplementation(const StemImplementation &); - - public: - /// Default constructor. - StemImplementation() { } - - /// Virtual destructor. - virtual ~StemImplementation(); - - /// Stem the specified word. - virtual std::string operator()(const std::string & word) = 0; - - /// Return a string describing this object. - virtual std::string get_description() const = 0; -}; - -/// Class representing a stemming algorithm. -class XAPIAN_VISIBILITY_DEFAULT Stem { - public: - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /// Copy constructor. - Stem(const Stem & o); - - /// Assignment. - Stem & operator=(const Stem & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - Stem(Stem && o); - - /// Move assignment operator. - Stem & operator=(Stem && o); -#endif - - /** Construct a Xapian::Stem object which doesn't change terms. - * - * Equivalent to Stem("none"). - */ - Stem(); - - /** Construct a Xapian::Stem object for a particular language. - * - * @param language Either the English name for the language - * or the two letter ISO639 code. - * - * The following language names are understood (aliases follow the - * name): - * - * - none - don't stem terms - * - arabic (ar) - Since Xapian 1.3.5 - * - armenian (hy) - Since Xapian 1.3.0 - * - basque (eu) - Since Xapian 1.3.0 - * - catalan (ca) - Since Xapian 1.3.0 - * - danish (da) - * - dutch (nl) - * - english (en) - Martin Porter's 2002 revision of his stemmer - * - earlyenglish - Early English (e.g. Shakespeare, Dickens) stemmer - * (since Xapian 1.3.2) - * - english_lovins (lovins) - Lovin's stemmer - * - english_porter (porter) - Porter's stemmer as described in - * his 1980 paper - * - finnish (fi) - * - french (fr) - * - german (de) - * - german2 - Normalises umlauts and ß - * - hungarian (hu) - * - indonesian (id) - Since Xapian 1.4.6 - * - irish (ga) - Since Xapian 1.4.7 - * - italian (it) - * - kraaij_pohlmann - A different Dutch stemmer - * - lithuanian (lt) - Since Xapian 1.4.7 - * - nepali (ne) - Since Xapian 1.4.7 - * - norwegian (nb, nn, no) - * - portuguese (pt) - * - romanian (ro) - * - russian (ru) - * - spanish (es) - * - swedish (sv) - * - tamil (ta) - Since Xapian 1.4.7 - * - turkish (tr) - * - * @param fallback If true then treat unknown @a language as "none", - * otherwise an exception is thrown (default: false). - * Parameter added in Xapian 1.4.14 - older versions - * always threw an exception. - * - * @exception Xapian::InvalidArgumentError is thrown if - * @a language isn't recognised and @a fallback is false. - * - * @{ - */ - explicit Stem(const std::string& language); - Stem(const std::string& language, bool fallback); - /** @} */ - - /** Construct a Xapian::Stem object with a user-provided stemming algorithm. - * - * You can subclass Xapian::StemImplementation to implement your own - * stemming algorithm (or to wrap a third-party algorithm) and then wrap - * your implementation in a Xapian::Stem object to pass to the Xapian API. - * - * @param p The user-subclassed StemImplementation object. This - * is reference counted, and so will be automatically - * deleted by the Xapian::Stem wrapper when no longer - * required. - */ - explicit Stem(StemImplementation * p); - - /// Destructor. - ~Stem(); - - /** Stem a word. - * - * @param word a word to stem. - * @return the stem - */ - std::string operator()(const std::string &word) const; - - /// Return true if this is a no-op stemmer. - bool is_none() const { return !internal.get(); } - - /// Return a string describing this object. - std::string get_description() const; - - /** Return a list of available languages. - * - * Each stemmer is only included once in the list (not once for - * each alias). The name included is the English name of the - * language. - * - * The list is returned as a string, with language names separated by - * spaces. This is a static method, so a Xapian::Stem object is not - * required for this operation. - */ - static std::string get_available_languages() { - const struct Xapian::Internal::constinfo * info = - Xapian::Internal::get_constinfo_(); - return std::string(info->stemmer_data, info->stemmer_name_len); - } -}; - -} - -#endif // XAPIAN_INCLUDED_STEM_H diff --git a/winlibs/include/xapian/termgenerator.h b/winlibs/include/xapian/termgenerator.h deleted file mode 100644 index 070e1e33c..000000000 --- a/winlibs/include/xapian/termgenerator.h +++ /dev/null @@ -1,277 +0,0 @@ -/** @file - * @brief parse free text and generate terms - */ -/* Copyright (C) 2007,2009,2011,2012,2013,2014,2018 Olly Betts - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_TERMGENERATOR_H -#define XAPIAN_INCLUDED_TERMGENERATOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include -#include - -#include - -namespace Xapian { - -class Document; -class Stem; -class Stopper; -class WritableDatabase; - -/** Parses a piece of text and generate terms. - * - * This module takes a piece of text and parses it to produce words which are - * then used to generate suitable terms for indexing. The terms generated are - * suitable for use with Query objects produced by the QueryParser class. - */ -class XAPIAN_VISIBILITY_DEFAULT TermGenerator { - public: - /// @private @internal Class representing the TermGenerator internals. - class Internal; - /// @private @internal Reference counted internals. - Xapian::Internal::intrusive_ptr internal; - - /// Copy constructor. - TermGenerator(const TermGenerator & o); - - /// Assignment. - TermGenerator & operator=(const TermGenerator & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - TermGenerator(TermGenerator && o); - - /// Move assignment operator. - TermGenerator & operator=(TermGenerator && o); -#endif - - /// Default constructor. - TermGenerator(); - - /// Destructor. - ~TermGenerator(); - - /// Set the Xapian::Stem object to be used for generating stemmed terms. - void set_stemmer(const Xapian::Stem & stemmer); - - /** Set the Xapian::Stopper object to be used for identifying stopwords. - * - * Stemmed forms of stopwords aren't indexed, but unstemmed forms still - * are so that searches for phrases including stop words still work. - * - * @param stop The Stopper object to set (default NULL, which means no - * stopwords). - */ - void set_stopper(const Xapian::Stopper *stop = NULL); - - /// Set the current document. - void set_document(const Xapian::Document & doc); - - /// Get the current document. - const Xapian::Document & get_document() const; - - /// Set the database to index spelling data to. - void set_database(const Xapian::WritableDatabase &db); - - /// For backward compatibility with Xapian 1.2 - typedef int flags; - - /// Flags to OR together and pass to TermGenerator::set_flags(). - enum { - /// Index data required for spelling correction. - FLAG_SPELLING = 128, // Value matches QueryParser flag. - - /** Enable generation of n-grams from CJK text. - * - * With this enabled, spans of CJK characters are split into unigrams - * and bigrams, with the unigrams carrying positional information. - * Non-CJK characters are split into words as normal. - * - * The corresponding option needs to be passed to QueryParser. - * - * Flag added in Xapian 1.3.4 and 1.2.22. This mode can be - * enabled in 1.2.8 and later by setting environment variable - * XAPIAN_CJK_NGRAM to a non-empty value (but doing so was deprecated - * in 1.4.11). - */ - FLAG_CJK_NGRAM = 2048 // Value matches QueryParser flag. - }; - - /// Stemming strategies, for use with set_stemming_strategy(). - typedef enum { - STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS - } stem_strategy; - - /// Stopper strategies, for use with set_stopper_strategy(). - typedef enum { STOP_NONE, STOP_ALL, STOP_STEMMED } stop_strategy; - - /** Set flags. - * - * The new value of flags is: (flags & mask) ^ toggle - * - * To just set the flags, pass the new flags in toggle and the - * default value for mask. - * - * @param toggle Flags to XOR. - * @param mask Flags to AND with first. - * - * @return The old flags setting. - */ - flags set_flags(flags toggle, flags mask = flags(0)); - - /** Set the stemming strategy. - * - * This method controls how the stemming algorithm is applied. It was - * new in Xapian 1.3.1. - * - * @param strategy The strategy to use - possible values are: - * - STEM_NONE: Don't perform any stemming - only unstemmed terms - * are generated. - * - STEM_SOME: Generate both stemmed (with a "Z" prefix) and unstemmed - * terms. No positional information is stored for - * unstemmed terms. This is the default strategy. - * - STEM_SOME_FULL_POS: - * Like STEM_SOME but positional information is stored - * for both stemmed and unstemmed terms. Added in Xapian - * 1.4.8. - * - STEM_ALL: Generate only stemmed terms (but without a "Z" prefix). - * - STEM_ALL_Z: Generate only stemmed terms (with a "Z" prefix). - */ - void set_stemming_strategy(stem_strategy strategy); - - /** Set the stopper strategy. - * - * The method controls how the stopper is used. It was added in Xapian - * 1.4.1. - * - * You need to also call @a set_stopper() for this to have any effect. - * - * @param strategy The strategy to use - possible values are: - * - STOP_NONE: Don't use the stopper. - * - STOP_ALL: If a word is identified as a stop word, skip it - * completely. - * - STOP_STEMMED: If a word is identified as a stop word, index its - * unstemmed form but skip the stem. Unstemmed forms - * are indexed with positional information by default, - * so this allows searches for phrases containing - * stopwords to be supported. (This is the default - * mode). - */ - void set_stopper_strategy(stop_strategy strategy); - - /** Set the maximum length word to index. - * - * The limit is on the length of a word prior to stemming and prior to - * adding any term prefix. - * - * The backends mostly impose a limit on the length of terms (often of - * about 240 bytes), but it's generally useful to have a lower limit to - * help prevent the index being bloated by useless junk terms from trying - * to indexing things like binary data, uuencoded data, ASCII art, etc. - * - * This method was new in Xapian 1.3.1. - * - * @param max_word_length The maximum length word to index, in bytes in - * UTF-8 representation. Default is 64. - */ - void set_max_word_length(unsigned max_word_length); - - /** Index some text. - * - * @param itor Utf8Iterator pointing to the text to index. - * @param wdf_inc The wdf increment (default 1). - * @param prefix The term prefix to use (default is no prefix). - */ - void index_text(const Xapian::Utf8Iterator & itor, - Xapian::termcount wdf_inc = 1, - const std::string & prefix = std::string()); - - /** Index some text in a std::string. - * - * @param text The text to index. - * @param wdf_inc The wdf increment (default 1). - * @param prefix The term prefix to use (default is no prefix). - */ - void index_text(const std::string & text, - Xapian::termcount wdf_inc = 1, - const std::string & prefix = std::string()) { - index_text(Utf8Iterator(text), wdf_inc, prefix); - } - - /** Index some text without positional information. - * - * Just like index_text, but no positional information is generated. This - * means that the database will be significantly smaller, but that phrase - * searching and NEAR won't be supported. - * - * @param itor Utf8Iterator pointing to the text to index. - * @param wdf_inc The wdf increment (default 1). - * @param prefix The term prefix to use (default is no prefix). - */ - void index_text_without_positions(const Xapian::Utf8Iterator & itor, - Xapian::termcount wdf_inc = 1, - const std::string & prefix = std::string()); - - /** Index some text in a std::string without positional information. - * - * Just like index_text, but no positional information is generated. This - * means that the database will be significantly smaller, but that phrase - * searching and NEAR won't be supported. - * - * @param text The text to index. - * @param wdf_inc The wdf increment (default 1). - * @param prefix The term prefix to use (default is no prefix). - */ - void index_text_without_positions(const std::string & text, - Xapian::termcount wdf_inc = 1, - const std::string & prefix = std::string()) { - index_text_without_positions(Utf8Iterator(text), wdf_inc, prefix); - } - - /** Increase the term position used by index_text. - * - * This can be used between indexing text from different fields or other - * places to prevent phrase searches from spanning between them (e.g. - * between the title and body text, or between two chapters in a book). - * - * @param delta Amount to increase the term position by (default: 100). - */ - void increase_termpos(Xapian::termpos delta = 100); - - /// Get the current term position. - Xapian::termpos get_termpos() const; - - /** Set the current term position. - * - * @param termpos The new term position to set. - */ - void set_termpos(Xapian::termpos termpos); - - /// Return a string describing this object. - std::string get_description() const; -}; - -} - -#endif // XAPIAN_INCLUDED_TERMGENERATOR_H diff --git a/winlibs/include/xapian/termiterator.h b/winlibs/include/xapian/termiterator.h deleted file mode 100644 index 95eea0402..000000000 --- a/winlibs/include/xapian/termiterator.h +++ /dev/null @@ -1,185 +0,0 @@ -/** @file - * @brief Class for iterating over a list of terms - */ -/* Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_TERMITERATOR_H -#define XAPIAN_INCLUDED_TERMITERATOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include -#include - -namespace Xapian { - -/// Class for iterating over a list of terms. -class XAPIAN_VISIBILITY_DEFAULT TermIterator { - public: - /// Class representing the TermIterator internals. - class Internal; - /// @private @internal Reference counted internals. - Internal * internal; - - /// @private @internal Construct given internals. - explicit TermIterator(Internal *internal_); - - /// Copy constructor. - TermIterator(const TermIterator & o); - - /// Assignment. - TermIterator & operator=(const TermIterator & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - TermIterator(TermIterator && o) - : internal(o.internal) { - o.internal = nullptr; - } - - /// Move assignment operator. - TermIterator & operator=(TermIterator && o) { - if (this != &o) { - if (internal) decref(); - internal = o.internal; - o.internal = nullptr; - } - return *this; - } -#endif - - /** Default constructor. - * - * Creates an uninitialised iterator, which can't be used before being - * assigned to, but is sometimes syntactically convenient. - */ - XAPIAN_NOTHROW(TermIterator()) - : internal(0) { } - - /// Destructor. - ~TermIterator() { - if (internal) decref(); - } - - /// Return the term at the current position. - std::string operator*() const; - - /// Return the wdf for the term at the current position. - Xapian::termcount get_wdf() const; - - /// Return the term frequency for the term at the current position. - Xapian::doccount get_termfreq() const; - - /// Return the length of the position list for the current position. - Xapian::termcount positionlist_count() const; - - /// Return a PositionIterator for the current term. - PositionIterator positionlist_begin() const; - - /// Return an end PositionIterator for the current term. - PositionIterator XAPIAN_NOTHROW(positionlist_end() const) { - return PositionIterator(); - } - - /// Advance the iterator to the next position. - TermIterator & operator++(); - - /// Advance the iterator to the next position (postfix version). - DerefWrapper_ operator++(int) { - const std::string & term(**this); - operator++(); - return DerefWrapper_(term); - } - - /** Advance the iterator to term @a term. - * - * If the iteration is over an unsorted list of terms, then this method - * will throw Xapian::InvalidOperationError. - * - * @param term The term to advance to. If this term isn't in - * the stream being iterated, then the iterator is moved - * to the next term after it which is. - */ - void skip_to(const std::string &term); - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal TermIterator is what the C++ STL calls an - * input_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::input_iterator_tag iterator_category; - /// @private - typedef std::string value_type; - /// @private - typedef Xapian::termcount_diff difference_type; - /// @private - typedef std::string * pointer; - /// @private - typedef std::string & reference; - // @} - - private: - void decref(); - - void post_advance(Internal * res); -}; - -bool -XAPIAN_NOTHROW(operator==(const TermIterator &a, const TermIterator &b)); - -/// Equality test for TermIterator objects. -inline bool -operator==(const TermIterator &a, const TermIterator &b) XAPIAN_NOEXCEPT -{ - // Use a pointer comparison - this ensures both that (a == a) and correct - // handling of end iterators (which we ensure have NULL internals). - return a.internal == b.internal; -} - -bool -XAPIAN_NOTHROW(operator!=(const TermIterator &a, const TermIterator &b)); - -/// Inequality test for TermIterator objects. -inline bool -operator!=(const TermIterator &a, const TermIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -} - -#endif // XAPIAN_INCLUDED_TERMITERATOR_H diff --git a/winlibs/include/xapian/types.h b/winlibs/include/xapian/types.h deleted file mode 100644 index f6205456e..000000000 --- a/winlibs/include/xapian/types.h +++ /dev/null @@ -1,143 +0,0 @@ -/** @file - * @brief typedefs for Xapian - */ -/* Copyright (C) 2007,2010,2011,2013,2014,2017,2018 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_TYPES_H -#define XAPIAN_INCLUDED_TYPES_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -namespace Xapian { - -/** A count of documents. - * - * This is used to hold values such as the number of documents in a database - * and the frequency of a term in the database. - */ -typedef unsigned XAPIAN_DOCID_BASE_TYPE doccount; - -/** A signed difference between two counts of documents. - * - * This is used by the Xapian classes which are STL containers of documents - * for "difference_type". - */ -typedef XAPIAN_DOCID_BASE_TYPE doccount_diff; - -/** A unique identifier for a document. - * - * Docid 0 is invalid, providing an "out of range" value which can be - * used to mean "not a valid document". - */ -typedef unsigned XAPIAN_DOCID_BASE_TYPE docid; - -/** A normalised document length. - * - * The normalised document length is the document length divided by the - * average document length in the database. - */ -typedef double doclength; - -/** The percentage score for a document in an MSet. - * - * @deprecated This type is deprecated as of Xapian 1.3.0 - use the standard - * type int instead, which should work with older Xapian too. - */ -XAPIAN_DEPRECATED(typedef int percent); - -/** A counts of terms. - * - * This is used to hold values such as the Within Document Frequency (wdf). - */ -typedef unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount; - -/** A signed difference between two counts of terms. - * - * This is used by the Xapian classes which are STL containers of terms - * for "difference_type". - */ -typedef XAPIAN_TERMCOUNT_BASE_TYPE termcount_diff; - -/** A term position within a document or query. - */ -typedef unsigned XAPIAN_TERMPOS_BASE_TYPE termpos; - -/** A signed difference between two term positions. - * - * This is used by the Xapian classes which are STL containers of positions - * for "difference_type". - */ -typedef XAPIAN_TERMPOS_BASE_TYPE termpos_diff; /* FIXME: can overflow. */ - -/** A timeout value in milliseconds. - * - * There are 1000 milliseconds in a second, so for example, to set a - * timeout of 5 seconds use 5000. - * - * @deprecated This type is deprecated as of Xapian 1.3.0 - use the standard - * POSIX type useconds_t instead, which should work with older Xapian too. - */ -XAPIAN_DEPRECATED(typedef unsigned timeout); - -/** The number for a value slot in a document. - * - * Value slot numbers are unsigned and (currently) a 32-bit quantity, with - * Xapian::BAD_VALUENO being represented by the largest possible value. - * Therefore value slots 0 to 0xFFFFFFFE are available for use. - */ -typedef unsigned valueno; - -/** A signed difference between two value slot numbers. - * - * This is used by the Xapian classes which are STL containers of values - * for "difference_type". - */ -typedef int valueno_diff; /* FIXME: can overflow. */ - -/** The weight of a document or term. - * - * @deprecated This type is deprecated as of Xapian 1.3.0 - use the standard - * C++ type double instead, which should work with older Xapian too. - */ -XAPIAN_DEPRECATED(typedef double weight); - -/** Reserved value to indicate "no valueno". */ -const valueno BAD_VALUENO = 0xffffffff; - -/** Revision number of a database. - * - * For databases which support this, it increases with each commit. - * - * Experimental - see https://xapian.org/docs/deprecation#experimental-features - */ -typedef XAPIAN_REVISION_TYPE rev; - -/** The total length of all documents in a database. - * - * Added in Xapian 1.4.5. - */ -typedef XAPIAN_TOTALLENGTH_TYPE totallength; - -} - -#endif /* XAPIAN_INCLUDED_TYPES_H */ diff --git a/winlibs/include/xapian/unicode.h b/winlibs/include/xapian/unicode.h deleted file mode 100644 index 825152986..000000000 --- a/winlibs/include/xapian/unicode.h +++ /dev/null @@ -1,419 +0,0 @@ -/** @file - * @brief Unicode and UTF-8 related classes and functions. - */ -/* Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2019 Olly Betts - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_UNICODE_H -#define XAPIAN_INCLUDED_UNICODE_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include - -namespace Xapian { - -/** An iterator which returns Unicode character values from a UTF-8 encoded - * string. - */ -class XAPIAN_VISIBILITY_DEFAULT Utf8Iterator { - const unsigned char* p; - const unsigned char* end; - mutable unsigned seqlen; - - bool XAPIAN_NOTHROW(calculate_sequence_length() const); - - unsigned get_char() const; - - Utf8Iterator(const unsigned char* p_, - const unsigned char* end_, - unsigned seqlen_) - : p(p_), end(end_), seqlen(seqlen_) { } - - public: - /** Return the raw const char* pointer for the current position. */ - const char* raw() const { - return reinterpret_cast(p ? p : end); - } - - /** Return the number of bytes left in the iterator's buffer. */ - size_t left() const { return p ? end - p : 0; } - - /** Assign a new string to the iterator. - * - * The iterator will forget the string it was iterating through, and - * return characters from the start of the new string when next called. - * The string is not copied into the iterator, so it must remain valid - * while the iteration is in progress. - * - * @param p_ A pointer to the start of the string to read. - * - * @param len The length of the string to read. - */ - void assign(const char* p_, size_t len) { - if (len) { - p = reinterpret_cast(p_); - end = p + len; - seqlen = 0; - } else { - p = NULL; - } - } - - /** Assign a new string to the iterator. - * - * The iterator will forget the string it was iterating through, and - * return characters from the start of the new string when next called. - * The string is not copied into the iterator, so it must remain valid - * while the iteration is in progress. - * - * @param s The string to read. Must not be modified while the iteration - * is in progress. - */ - void assign(const std::string& s) { assign(s.data(), s.size()); } - - /** Create an iterator given a pointer to a null terminated string. - * - * The iterator will return characters from the start of the string when - * next called. The string is not copied into the iterator, so it must - * remain valid while the iteration is in progress. - * - * @param p_ A pointer to the start of the null terminated string to read. - */ - explicit Utf8Iterator(const char* p_); - - /** Create an iterator given a pointer and a length. - * - * The iterator will return characters from the start of the string when - * next called. The string is not copied into the iterator, so it must - * remain valid while the iteration is in progress. - * - * @param p_ A pointer to the start of the string to read. - * - * @param len The length of the string to read. - */ - Utf8Iterator(const char* p_, size_t len) { assign(p_, len); } - - /** Create an iterator given a string. - * - * The iterator will return characters from the start of the string when - * next called. The string is not copied into the iterator, so it must - * remain valid while the iteration is in progress. - * - * @param s The string to read. Must not be modified while the iteration - * is in progress. - */ - Utf8Iterator(const std::string& s) { assign(s.data(), s.size()); } - - /** Create an iterator which is at the end of its iteration. - * - * This can be compared to another iterator to check if the other iterator - * has reached its end. - */ - XAPIAN_NOTHROW(Utf8Iterator()) - : p(NULL), end(0), seqlen(0) { } - - /** Get the current Unicode character value pointed to by the iterator. - * - * If an invalid UTF-8 sequence is encountered, then the byte values - * comprising it are returned until valid UTF-8 or the end of the input is - * reached. - * - * Returns unsigned(-1) if the iterator has reached the end of its buffer. - */ - unsigned XAPIAN_NOTHROW(operator*() const) XAPIAN_PURE_FUNCTION; - - /** @private @internal Get the current Unicode character - * value pointed to by the iterator. - * - * If an invalid UTF-8 sequence is encountered, then the byte values - * comprising it are returned with the top bit set (so the caller can - * differentiate these from the same values arising from valid UTF-8) - * until valid UTF-8 or the end of the input is reached. - * - * Returns unsigned(-1) if the iterator has reached the end of its buffer. - */ - unsigned XAPIAN_NOTHROW(strict_deref() const) XAPIAN_PURE_FUNCTION; - - /** Move forward to the next Unicode character. - * - * @return An iterator pointing to the position before the move. - */ - Utf8Iterator operator++(int) { - // If we've not calculated seqlen yet, do so. - if (seqlen == 0) calculate_sequence_length(); - const unsigned char* old_p = p; - unsigned old_seqlen = seqlen; - p += seqlen; - if (p == end) p = NULL; - seqlen = 0; - return Utf8Iterator(old_p, end, old_seqlen); - } - - /** Move forward to the next Unicode character. - * - * @return A reference to this object. - */ - Utf8Iterator& operator++() { - if (seqlen == 0) calculate_sequence_length(); - p += seqlen; - if (p == end) p = NULL; - seqlen = 0; - return *this; - } - - /** Test two Utf8Iterators for equality. - * - * @param other The Utf8Iterator to compare this one with. - * @return true iff the iterators point to the same position. - */ - bool XAPIAN_NOTHROW(operator==(const Utf8Iterator& other) const) { - return p == other.p; - } - - /** Test two Utf8Iterators for inequality. - * - * @param other The Utf8Iterator to compare this one with. - * @return true iff the iterators do not point to the same position. - */ - bool XAPIAN_NOTHROW(operator!=(const Utf8Iterator& other) const) { - return p != other.p; - } - - /// We implement the semantics of an STL input_iterator. - //@{ - typedef std::input_iterator_tag iterator_category; - typedef unsigned value_type; - typedef size_t difference_type; - typedef const unsigned* pointer; - typedef const unsigned& reference; - //@} -}; - -/// Functions associated with handling Unicode characters. -namespace Unicode { - -/** Each Unicode character is in exactly one of these categories. - * - * The Unicode standard calls this the "General Category", and uses a - * "Major, minor" convention to derive a two letter code. - */ -typedef enum { - UNASSIGNED, /**< Other, not assigned (Cn) */ - UPPERCASE_LETTER, /**< Letter, uppercase (Lu) */ - LOWERCASE_LETTER, /**< Letter, lowercase (Ll) */ - TITLECASE_LETTER, /**< Letter, titlecase (Lt) */ - MODIFIER_LETTER, /**< Letter, modifier (Lm) */ - OTHER_LETTER, /**< Letter, other (Lo) */ - NON_SPACING_MARK, /**< Mark, nonspacing (Mn) */ - ENCLOSING_MARK, /**< Mark, enclosing (Me) */ - COMBINING_SPACING_MARK, /**< Mark, spacing combining (Mc) */ - DECIMAL_DIGIT_NUMBER, /**< Number, decimal digit (Nd) */ - LETTER_NUMBER, /**< Number, letter (Nl) */ - OTHER_NUMBER, /**< Number, other (No) */ - SPACE_SEPARATOR, /**< Separator, space (Zs) */ - LINE_SEPARATOR, /**< Separator, line (Zl) */ - PARAGRAPH_SEPARATOR, /**< Separator, paragraph (Zp) */ - CONTROL, /**< Other, control (Cc) */ - FORMAT, /**< Other, format (Cf) */ - PRIVATE_USE, /**< Other, private use (Co) */ - SURROGATE, /**< Other, surrogate (Cs) */ - CONNECTOR_PUNCTUATION, /**< Punctuation, connector (Pc) */ - DASH_PUNCTUATION, /**< Punctuation, dash (Pd) */ - OPEN_PUNCTUATION, /**< Punctuation, open (Ps) */ - CLOSE_PUNCTUATION, /**< Punctuation, close (Pe) */ - INITIAL_QUOTE_PUNCTUATION, /**< Punctuation, initial quote (Pi) */ - FINAL_QUOTE_PUNCTUATION, /**< Punctuation, final quote (Pf) */ - OTHER_PUNCTUATION, /**< Punctuation, other (Po) */ - MATH_SYMBOL, /**< Symbol, math (Sm) */ - CURRENCY_SYMBOL, /**< Symbol, currency (Sc) */ - MODIFIER_SYMBOL, /**< Symbol, modified (Sk) */ - OTHER_SYMBOL /**< Symbol, other (So) */ -} category; - -namespace Internal { - /** @private @internal Extract the information about a character from the - * Unicode character tables. - * - * Characters outside of the Unicode range (i.e. ch >= 0x110000) are - * treated as UNASSIGNED with no case variants. - */ - XAPIAN_VISIBILITY_DEFAULT - int XAPIAN_NOTHROW(get_character_info(unsigned ch)) XAPIAN_CONST_FUNCTION; - - /** @private @internal Extract how to convert the case of a Unicode - * character from its info. - */ - inline int get_case_type(int info) { return ((info & 0xe0) >> 5); } - - /** @private @internal Extract the category of a Unicode character from its - * info. - */ - inline category get_category(int info) { - return static_cast(info & 0x1f); - } - - /** @private @internal Extract the delta to use for case conversion of a - * character from its info. - */ - inline int get_delta(int info) { - /* It's implementation defined if sign extension happens when right - * shifting a signed int, although in practice sign extension is what - * most compilers implement. - * - * Some compilers are smart enough to spot common idioms for sign - * extension, but not all (e.g. GCC < 7 doesn't spot the one used - * below), so check what the implementation-defined behaviour is with - * a constant conditional which should get optimised away. - * - * We use the ternary operator here to avoid various compiler - * warnings which writing this as an `if` results in. - */ - return ((-1 >> 1) == -1 ? - // Right shift sign-extends. - info >> 8 : - // Right shift shifts in zeros so bitwise-not before and after - // the shift for negative values. - (info >= 0) ? (info >> 8) : (~(~info >> 8))); - } -} - -/** Convert a single non-ASCII Unicode character to UTF-8. - * - * This is intended mainly as a helper method for to_utf8(). - * - * @param ch The character (which must be > 128) to write to @a buf. - * @param buf The buffer to write the character to - it must have - * space for (at least) 4 bytes. - * - * @return The length of the resultant UTF-8 character in bytes. - */ -XAPIAN_VISIBILITY_DEFAULT -unsigned nonascii_to_utf8(unsigned ch, char* buf); - -/** Convert a single Unicode character to UTF-8. - * - * @param ch The character to write to @a buf. - * @param buf The buffer to write the character to - it must have - * space for (at least) 4 bytes. - * - * @return The length of the resultant UTF-8 character in bytes. - */ -inline unsigned to_utf8(unsigned ch, char* buf) { - if (ch < 128) { - *buf = static_cast(ch); - return 1; - } - return Xapian::Unicode::nonascii_to_utf8(ch, buf); -} - -/** Append the UTF-8 representation of a single Unicode character to a - * std::string. - */ -inline void append_utf8(std::string& s, unsigned ch) { - char buf[4]; - s.append(buf, to_utf8(ch, buf)); -} - -/// Return the category which a given Unicode character falls into. -inline category get_category(unsigned ch) { - return Internal::get_category(Internal::get_character_info(ch)); -} - -/// Test if a given Unicode character is "word character". -inline bool is_wordchar(unsigned ch) { - const unsigned int WORDCHAR_MASK = - (1 << Xapian::Unicode::UPPERCASE_LETTER) | - (1 << Xapian::Unicode::LOWERCASE_LETTER) | - (1 << Xapian::Unicode::TITLECASE_LETTER) | - (1 << Xapian::Unicode::MODIFIER_LETTER) | - (1 << Xapian::Unicode::OTHER_LETTER) | - (1 << Xapian::Unicode::NON_SPACING_MARK) | - (1 << Xapian::Unicode::ENCLOSING_MARK) | - (1 << Xapian::Unicode::COMBINING_SPACING_MARK) | - (1 << Xapian::Unicode::DECIMAL_DIGIT_NUMBER) | - (1 << Xapian::Unicode::LETTER_NUMBER) | - (1 << Xapian::Unicode::OTHER_NUMBER) | - (1 << Xapian::Unicode::CONNECTOR_PUNCTUATION); - return ((WORDCHAR_MASK >> get_category(ch)) & 1); -} - -/// Test if a given Unicode character is a whitespace character. -inline bool is_whitespace(unsigned ch) { - const unsigned int WHITESPACE_MASK = - (1 << Xapian::Unicode::CONTROL) | // For TAB, CR, LF, FF. - (1 << Xapian::Unicode::SPACE_SEPARATOR) | - (1 << Xapian::Unicode::LINE_SEPARATOR) | - (1 << Xapian::Unicode::PARAGRAPH_SEPARATOR); - return ((WHITESPACE_MASK >> get_category(ch)) & 1); -} - -/// Test if a given Unicode character is a currency symbol. -inline bool is_currency(unsigned ch) { - return (get_category(ch) == Xapian::Unicode::CURRENCY_SYMBOL); -} - -/// Convert a Unicode character to lowercase. -inline unsigned tolower(unsigned ch) { - int info = Xapian::Unicode::Internal::get_character_info(ch); - if (!(Internal::get_case_type(info) & 2)) - return ch; - return ch + Internal::get_delta(info); -} - -/// Convert a Unicode character to uppercase. -inline unsigned toupper(unsigned ch) { - int info = Xapian::Unicode::Internal::get_character_info(ch); - if (!(Internal::get_case_type(info) & 4)) - return ch; - return ch - Internal::get_delta(info); -} - -/// Convert a UTF-8 std::string to lowercase. -inline std::string -tolower(const std::string& term) -{ - std::string result; - result.reserve(term.size()); - for (Utf8Iterator i(term); i != Utf8Iterator(); ++i) { - append_utf8(result, tolower(*i)); - } - return result; -} - -/// Convert a UTF-8 std::string to uppercase. -inline std::string -toupper(const std::string& term) -{ - std::string result; - result.reserve(term.size()); - for (Utf8Iterator i(term); i != Utf8Iterator(); ++i) { - append_utf8(result, toupper(*i)); - } - return result; -} - -} - -} - -#endif // XAPIAN_INCLUDED_UNICODE_H diff --git a/winlibs/include/xapian/valueiterator.h b/winlibs/include/xapian/valueiterator.h deleted file mode 100644 index e7c05d58e..000000000 --- a/winlibs/include/xapian/valueiterator.h +++ /dev/null @@ -1,227 +0,0 @@ -/** @file - * @brief Class for iterating over document values. - */ -/* Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2015 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_VALUEITERATOR_H -#define XAPIAN_INCLUDED_VALUEITERATOR_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include - -#include -#include -#include -#include - -namespace Xapian { - -/// Class for iterating over document values. -class XAPIAN_VISIBILITY_DEFAULT ValueIterator { - void decref(); - - public: - /// Class representing the ValueIterator internals. - class Internal; - /// @private @internal Reference counted internals. - Internal * internal; - - /// @private @internal Construct given internals. - explicit ValueIterator(Internal *internal_); - - /// Copy constructor. - ValueIterator(const ValueIterator & o); - - /// Assignment. - ValueIterator & operator=(const ValueIterator & o); - -#ifdef XAPIAN_MOVE_SEMANTICS - /// Move constructor. - ValueIterator(ValueIterator && o) - : internal(o.internal) { - o.internal = nullptr; - } - - /// Move assignment operator. - ValueIterator & operator=(ValueIterator && o) { - if (this != &o) { - if (internal) decref(); - internal = o.internal; - o.internal = nullptr; - } - return *this; - } -#endif - - /** Default constructor. - * - * Creates an uninitialised iterator, which can't be used before being - * assigned to, but is sometimes syntactically convenient. - */ - XAPIAN_NOTHROW(ValueIterator()) - : internal(0) { } - - /// Destructor. - ~ValueIterator() { - if (internal) decref(); - } - - /// Return the value at the current position. - std::string operator*() const; - - /// Advance the iterator to the next position. - ValueIterator & operator++(); - - /// Advance the iterator to the next position (postfix version). - DerefWrapper_ operator++(int) { - const std::string & value(**this); - operator++(); - return DerefWrapper_(value); - } - - /** Return the docid at the current position. - * - * If we're iterating over values of a document, this method will throw - * Xapian::InvalidOperationError. - */ - Xapian::docid get_docid() const; - - /** Return the value slot number for the current position. - * - * If the iterator is over all values in a slot, this returns that slot's - * number. If the iterator is over the values in a particular document, - * it returns the number of each slot in turn. - */ - Xapian::valueno get_valueno() const; - - /** Advance the iterator to document id or value slot @a docid_or_slot. - * - * If this iterator is over values in a document, then this method - * advances the iterator to value slot @a docid_or_slot, or the first slot - * after it if there is no value in slot @a slot. - * - * If this iterator is over values in a particular slot, then this - * method advances the iterator to document id @a docid_or_slot, or the - * first document id after it if there is no value in the slot we're - * iterating over for document @a docid_or_slot. - * - * Note: The "two-faced" nature of this method is due to how C++ - * overloading works. Xapian::docid and Xapian::valueno are both typedefs - * for the same unsigned integer type, so overloading can't distinguish - * them. - * - * @param docid_or_slot The docid/slot to advance to. - */ - void skip_to(Xapian::docid docid_or_slot); - - /** Check if the specified docid occurs. - * - * The caller is required to ensure that the specified document id - * @a did actually exists in the database. - * - * This method acts like skip_to() if that can be done at little extra - * cost, in which case it then returns true. This is how chert and - * glass databases behave because they store values in streams which allow - * for an efficient implementation of skip_to(). - * - * Otherwise it simply checks if a particular docid is present. If it - * is, it returns true. If it isn't, it returns false, and leaves the - * position unspecified (and hence the result of calling methods which - * depend on the current position, such as get_docid(), are also - * unspecified). In this state, next() will advance to the first matching - * position after document @a did, and skip_to() will act as it would if - * the position was the first matching position after document @a did. - * - * Currently the inmemory and remote backends behave in the - * latter way because they don't support streamed values and so skip_to() - * must check each document it skips over which is significantly slower. - * - * @param docid The document id to check. - */ -#ifndef check - bool check(Xapian::docid docid); -#else - // The AssertMacros.h header in the macOS SDK currently defines a check - // macro. Apple have deprecated check() in favour of __Check() and - // plan to remove check() in a "future release", but for now prevent - // expansion of check by adding parentheses in the method prototype: - // https://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h - // - // We do this conditionally, as these parentheses trip up SWIG's - // parser: - // https://github.com/swig/swig/issues/45 - bool (check)(Xapian::docid docid); -#endif - - /// Return a string describing this object. - std::string get_description() const; - - /** @private @internal ValueIterator is what the C++ STL calls an - * input_iterator. - * - * The following typedefs allow std::iterator_traits<> to work so that - * this iterator can be used with the STL. - * - * These are deliberately hidden from the Doxygen-generated docs, as the - * machinery here isn't interesting to API users. They just need to know - * that Xapian iterator classes are compatible with the STL. - */ - // @{ - /// @private - typedef std::input_iterator_tag iterator_category; - /// @private - typedef std::string value_type; - /// @private - typedef Xapian::doccount_diff difference_type; - /// @private - typedef std::string * pointer; - /// @private - typedef std::string & reference; - // @} -}; - -bool -XAPIAN_NOTHROW(operator==(const ValueIterator &a, const ValueIterator &b)); - -/// Equality test for ValueIterator objects. -inline bool -operator==(const ValueIterator &a, const ValueIterator &b) XAPIAN_NOEXCEPT -{ - // Use a pointer comparison - this ensures both that (a == a) and correct - // handling of end iterators (which we ensure have NULL internals). - return a.internal == b.internal; -} - -bool -XAPIAN_NOTHROW(operator!=(const ValueIterator &a, const ValueIterator &b)); - -/// Inequality test for ValueIterator objects. -inline bool -operator!=(const ValueIterator &a, const ValueIterator &b) XAPIAN_NOEXCEPT -{ - return !(a == b); -} - -} - -#endif // XAPIAN_INCLUDED_VALUEITERATOR_H diff --git a/winlibs/include/xapian/valuesetmatchdecider.h b/winlibs/include/xapian/valuesetmatchdecider.h deleted file mode 100644 index 24375e29e..000000000 --- a/winlibs/include/xapian/valuesetmatchdecider.h +++ /dev/null @@ -1,100 +0,0 @@ -/** @file - * @brief MatchDecider subclass for filtering results by value. - */ -/* Copyright 2008 Lemur Consulting Ltd - * Copyright 2008,2009,2011,2013,2014 Olly Betts - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H -#define XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H - -#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD -# error Never use directly; include instead. -#endif - -#include -#include -#include - -#include -#include - -namespace Xapian { - -class Document; - -/** MatchDecider filtering results based on whether document values are in a - * user-defined set. - */ -class XAPIAN_VISIBILITY_DEFAULT ValueSetMatchDecider : public MatchDecider { - /** Set of values to test for. */ - std::set testset; - - /** The value slot to look in. */ - valueno valuenum; - - /** Whether to include or exclude documents with the specified values. - * - * If true, documents with a value in the set are returned. - * If false, documents with a value not in the set are returned. - */ - bool inclusive; - - public: - /** Construct a ValueSetMatchDecider. - * - * @param slot The value slot number to look in. - * - * @param inclusive_ If true, match decider accepts documents which have a - * value in the specified slot which is a member of the test set; if - * false, match decider accepts documents which do not have a value in the - * specified slot. - */ - ValueSetMatchDecider(Xapian::valueno slot, bool inclusive_) - : valuenum(slot), inclusive(inclusive_) { } - - /** Add a value to the test set. - * - * @param value The value to add to the test set. - */ - void add_value(const std::string& value) - { - testset.insert(value); - } - - /** Remove a value from the test set. - * - * @param value The value to remove from the test set. - */ - void remove_value(const std::string& value) - { - testset.erase(value); - } - - /** Decide whether we want a particular document to be in the MSet. - * - * @param doc The document to test. - * @return true if the document is acceptable, or false if the - * document should be excluded from the MSet. - */ - bool operator()(const Xapian::Document& doc) const; -}; - -} - -#endif /* XAPIAN_INCLUDED_VALUESETMATCHDECIDER_H */ diff --git a/winlibs/include/xapian/version.h b/winlibs/include/xapian/version.h deleted file mode 100644 index b6cede4f2..000000000 --- a/winlibs/include/xapian/version.h +++ /dev/null @@ -1,100 +0,0 @@ -/** @file - * @brief Define preprocessor symbols for the library version - */ -// Copyright (C) 2002-2022 Olly Betts -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_VERSION_H -#define XAPIAN_INCLUDED_VERSION_H - -/// The version of Xapian as a C string literal. -#define XAPIAN_VERSION "1.4.22" - -/** The major component of the Xapian version. - * E.g. for Xapian 1.0.14 this would be: 1 - */ -#define XAPIAN_MAJOR_VERSION 1 - -/** The minor component of the Xapian version. - * E.g. for Xapian 1.0.14 this would be: 0 - */ -#define XAPIAN_MINOR_VERSION 4 - -/** The revision component of the Xapian version. - * E.g. for Xapian 1.0.14 this would be: 14 - */ -#define XAPIAN_REVISION 22 - -/// Base (signed) type for Xapian::docid and related types. -#define XAPIAN_DOCID_BASE_TYPE int - -/// Base (signed) type for Xapian::termcount and related types. -#define XAPIAN_TERMCOUNT_BASE_TYPE int - -/// Base (signed) type for Xapian::termpos. -#define XAPIAN_TERMPOS_BASE_TYPE int - -/// Type for returning total document length. -#define XAPIAN_TOTALLENGTH_TYPE unsigned long long - -/// Underlying type for Xapian::rev. -#define XAPIAN_REVISION_TYPE unsigned long long - -/// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled. -#define XAPIAN_HAS_CHERT_BACKEND 1 - -/// XAPIAN_HAS_GLASS_BACKEND Defined if the glass backend is enabled. -#define XAPIAN_HAS_GLASS_BACKEND 1 - -/// XAPIAN_HAS_INMEMORY_BACKEND Defined if the inmemory backend is enabled. -#define XAPIAN_HAS_INMEMORY_BACKEND 1 - -/// XAPIAN_HAS_REMOTE_BACKEND Defined if the remote backend is enabled. -#define XAPIAN_HAS_REMOTE_BACKEND 1 - -/// XAPIAN_AT_LEAST(A,B,C) checks for xapian-core >= A.B.C - use like so: -/// -/// @code -/// #if XAPIAN_AT_LEAST(1,4,2) -/// /* Code needing features needing Xapian >= 1.4.2. */ -/// #endif -/// @endcode -/// -/// Added in Xapian 1.4.2. -#define XAPIAN_AT_LEAST(A,B,C) \ - (XAPIAN_MAJOR_VERSION > (A) || \ - (XAPIAN_MAJOR_VERSION == (A) && \ - (XAPIAN_MINOR_VERSION > (B) || \ - (XAPIAN_MINOR_VERSION == (B) && XAPIAN_REVISION >= (C))))) - -/// We support move semantics when we're confident the compiler supports it. -/// -/// C++11 move semantics are very useful in threaded code that wants to -/// hand-off Xapian objects to worker threads, but in this case it's very -/// unhelpful for availability of these semantics to vary by compiler as it -/// quietly leads to a build with non-threadsafe behaviour. -/// -/// User code can #define XAPIAN_MOVE_SEMANTICS to force this on, and will -/// then get a compilation failure if the compiler lacks suitable support. -#ifndef XAPIAN_MOVE_SEMANTICS -# if __cplusplus >= 201103L || \ - (defined _MSC_VER && _MSC_VER >= 1900) || \ - defined XAPIAN_LIB_BUILD -# define XAPIAN_MOVE_SEMANTICS -# endif -#endif - -#endif /* XAPIAN_INCLUDED_VERSION_H */ diff --git a/winlibs/include/xapian/visibility.h b/winlibs/include/xapian/visibility.h deleted file mode 100644 index 7657910b6..000000000 --- a/winlibs/include/xapian/visibility.h +++ /dev/null @@ -1,33 +0,0 @@ -/** @file - * @brief Define XAPIAN_VISIBILITY_* macros. - */ -// Copyright (C) 2007,2010,2014,2019 Olly Betts -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef XAPIAN_INCLUDED_VISIBILITY_H -#define XAPIAN_INCLUDED_VISIBILITY_H - -// See https://gcc.gnu.org/wiki/Visibility for more information about GCC's -// symbol visibility support. - -#include "xapian/version.h" -#ifdef XAPIAN_ENABLE_VISIBILITY -# define XAPIAN_VISIBILITY_DEFAULT __attribute__((visibility("default"))) -#else -# define XAPIAN_VISIBILITY_DEFAULT -#endif - -#endif diff --git a/winlibs/include/xapian/weight.h b/winlibs/include/xapian/weight.h deleted file mode 100644 index 99d313cb9..000000000 --- a/winlibs/include/xapian/weight.h +++ /dev/null @@ -1,1537 +0,0 @@ -/** @file - * @brief Weighting scheme API. - */ -/* Copyright (C) 2004,2007,2008,2009,2010,2011,2012,2015,2016,2019 Olly Betts - * Copyright (C) 2009 Lemur Consulting Ltd - * Copyright (C) 2013,2014 Aarsh Shah - * Copyright (C) 2016 Vivek Pal - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef XAPIAN_INCLUDED_WEIGHT_H -#define XAPIAN_INCLUDED_WEIGHT_H - -#include - -#include -#include - -namespace Xapian { - -/** Abstract base class for weighting schemes. */ -class XAPIAN_VISIBILITY_DEFAULT Weight { - protected: - /// Stats which the weighting scheme can use (see @a need_stat()). - typedef enum { - /// Number of documents in the collection. - COLLECTION_SIZE = 1, - /// Number of documents in the RSet. - RSET_SIZE = 2, - /// Average length of documents in the collection. - AVERAGE_LENGTH = 4, - /// How many documents the current term is in. - TERMFREQ = 8, - /// How many documents in the RSet the current term is in. - RELTERMFREQ = 16, - /// Sum of wqf for terms in the query. - QUERY_LENGTH = 32, - /// Within-query-frequency of the current term. - WQF = 64, - /// Within-document-frequency of the current term in the current document. - WDF = 128, - /// Length of the current document (sum wdf). - DOC_LENGTH = 256, - /// Lower bound on (non-zero) document lengths. - DOC_LENGTH_MIN = 512, - /// Upper bound on document lengths. - DOC_LENGTH_MAX = 1024, - /// Upper bound on wdf. - WDF_MAX = 2048, - /// Sum of wdf over the whole collection for the current term. - COLLECTION_FREQ = 4096, - /// Number of unique terms in the current document. - UNIQUE_TERMS = 8192, - /** Sum of lengths of all documents in the collection. - * - * This gives the total number of term occurrences. - */ - TOTAL_LENGTH = COLLECTION_SIZE | AVERAGE_LENGTH - } stat_flags; - - /** Tell Xapian that your subclass will want a particular statistic. - * - * Some of the statistics can be costly to fetch or calculate, so - * Xapian needs to know which are actually going to be used. You - * should call need_stat() from your constructor for each such - * statistic. - * - * @param flag The stat_flags value for a required statistic. - */ - void need_stat(stat_flags flag) { - stats_needed = stat_flags(stats_needed | flag); - } - - /** Allow the subclass to perform any initialisation it needs to. - * - * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). - * If the Weight object is for the term-independent - * weight supplied by get_sumextra()/get_maxextra(), - * then init(0.0) is called (starting from Xapian - * 1.2.11 and 1.3.1 - earlier versions failed to - * call init() for such Weight objects). - */ - virtual void init(double factor) = 0; - - private: - /// Don't allow assignment. - void operator=(const Weight &); - - /// A bitmask of the statistics this weighting scheme needs. - stat_flags stats_needed; - - /// The number of documents in the collection. - Xapian::doccount collection_size_; - - /// The number of documents marked as relevant. - Xapian::doccount rset_size_; - - /// The average length of a document in the collection. - Xapian::doclength average_length_; - - /// The number of documents which this term indexes. - Xapian::doccount termfreq_; - - // The collection frequency of the term. - Xapian::termcount collectionfreq_; - - /// The number of relevant documents which this term indexes. - Xapian::doccount reltermfreq_; - - /// The length of the query. - Xapian::termcount query_length_; - - /// The within-query-frequency of this term. - Xapian::termcount wqf_; - - /// A lower bound on the minimum length of any document in the database. - Xapian::termcount doclength_lower_bound_; - - /// An upper bound on the maximum length of any document in the database. - Xapian::termcount doclength_upper_bound_; - - /// An upper bound on the wdf of this term. - Xapian::termcount wdf_upper_bound_; - - public: - - /// Default constructor, needed by subclass constructors. - Weight() : stats_needed() { } - - /** Type of smoothing to use with the Language Model Weighting scheme. - * - * Default is TWO_STAGE_SMOOTHING. - */ - typedef enum { - TWO_STAGE_SMOOTHING = 1, - DIRICHLET_SMOOTHING = 2, - ABSOLUTE_DISCOUNT_SMOOTHING = 3, - JELINEK_MERCER_SMOOTHING = 4, - DIRICHLET_PLUS_SMOOTHING = 5 - } type_smoothing; - - class Internal; - - /** Virtual destructor, because we have virtual methods. */ - virtual ~Weight(); - - /** Clone this object. - * - * This method allocates and returns a copy of the object it is called on. - * - * If your subclass is called FooWeight and has parameters a and b, then - * you would implement FooWeight::clone() like so: - * - * FooWeight * FooWeight::clone() const { return new FooWeight(a, b); } - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - */ - virtual Weight * clone() const = 0; - - /** Return the name of this weighting scheme. - * - * This name is used by the remote backend. It is passed along with the - * serialised parameters to the remote server so that it knows which class - * to create. - * - * Return the full namespace-qualified name of your class here - if - * your class is called FooWeight, return "FooWeight" from this method - * (Xapian::BM25Weight returns "Xapian::BM25Weight" here). - * - * If you don't want to support the remote backend, you can use the - * default implementation which simply returns an empty string. - */ - virtual std::string name() const; - - /** Return this object's parameters serialised as a single string. - * - * If you don't want to support the remote backend, you can use the - * default implementation which simply throws Xapian::UnimplementedError. - */ - virtual std::string serialise() const; - - /** Unserialise parameters. - * - * This method unserialises parameters serialised by the @a serialise() - * method and allocates and returns a new object initialised with them. - * - * If you don't want to support the remote backend, you can use the - * default implementation which simply throws Xapian::UnimplementedError. - * - * Note that the returned object will be deallocated by Xapian after use - * with "delete". If you want to handle the deletion in a special way - * (for example when wrapping the Xapian API for use from another - * language) then you can define a static operator delete - * method in your subclass as shown here: - * https://trac.xapian.org/ticket/554#comment:1 - * - * @param serialised A string containing the serialised parameters. - */ - virtual Weight * unserialise(const std::string & serialised) const; - - /** Calculate the weight contribution for this object's term to a document. - * - * The parameters give information about the document which may be used - * in the calculations: - * - * @param wdf The within document frequency of the term in the document. - * @param doclen The document's length (unnormalised). - * @param uniqterms Number of unique terms in the document (used - * for absolute smoothing). - */ - virtual double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const = 0; - - /** Return an upper bound on what get_sumpart() can return for any document. - * - * This information is used by the matcher to perform various - * optimisations, so strive to make the bound as tight as possible. - */ - virtual double get_maxpart() const = 0; - - /** Calculate the term-independent weight component for a document. - * - * The parameter gives information about the document which may be used - * in the calculations: - * - * @param doclen The document's length (unnormalised). - * @param uniqterms The number of unique terms in the document. - */ - virtual double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const = 0; - - /** Return an upper bound on what get_sumextra() can return for any - * document. - * - * This information is used by the matcher to perform various - * optimisations, so strive to make the bound as tight as possible. - */ - virtual double get_maxextra() const = 0; - - /** @private @internal Initialise this object to calculate weights for term - * @a term. - * - * Old version of method, as used by 1.4.18 and earlier. This - * should only be referenced from inside the library and 1.4.19 and - * later will call the new version instead. We continue to provide it - * mainly to avoid triggering ABI checking tools. - * - * @param stats Source of statistics. - * @param query_len_ Query length. - * @param term The term for the new object. - * @param wqf_ The within-query-frequency of @a term. - * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). - */ - void init_(const Internal & stats, Xapian::termcount query_len_, - const std::string & term, Xapian::termcount wqf_, - double factor); - - /** @private @internal Initialise this object to calculate weights for term - * @a term. - * - * @param stats Source of statistics. - * @param query_len_ Query length. - * @param term The term for the new object. - * @param wqf_ The within-query-frequency of @a term. - * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). - * @param postlist Pointer to a LeafPostList for the term (cast to void* - * to avoid needing to forward declare class - * LeafPostList in public API headers) which can be used - * to get wdf upper bound - */ - void init_(const Internal & stats, Xapian::termcount query_len_, - const std::string & term, Xapian::termcount wqf_, - double factor, void* postlist); - - /** @private @internal Initialise this object to calculate weights for a - * synonym. - * - * @param stats Source of statistics. - * @param query_len_ Query length. - * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). - * @param termfreq The termfreq to use. - * @param reltermfreq The reltermfreq to use. - * @param collection_freq The collection frequency to use. - */ - void init_(const Internal & stats, Xapian::termcount query_len_, - double factor, Xapian::doccount termfreq, - Xapian::doccount reltermfreq, Xapian::termcount collection_freq); - - /** @private @internal Initialise this object to calculate the extra weight - * component. - * - * @param stats Source of statistics. - * @param query_len_ Query length. - */ - void init_(const Internal & stats, Xapian::termcount query_len_); - - /** @private @internal Return true if the document length is needed. - * - * If this method returns true, then the document length will be fetched - * and passed to @a get_sumpart(). Otherwise 0 may be passed for the - * document length. - */ - bool get_sumpart_needs_doclength_() const { - return stats_needed & DOC_LENGTH; - } - - /** @private @internal Return true if the WDF is needed. - * - * If this method returns true, then the WDF will be fetched and passed to - * @a get_sumpart(). Otherwise 0 may be passed for the wdf. - */ - bool get_sumpart_needs_wdf_() const { - return stats_needed & WDF; - } - - /** @private @internal Return true if the number of unique terms is needed. - * - * If this method returns true, then the number of unique terms will be - * fetched and passed to @a get_sumpart(). Otherwise 0 may be passed for - * the number of unique terms. - */ - bool get_sumpart_needs_uniqueterms_() const { - return stats_needed & UNIQUE_TERMS; - } - - /// @private @internal Test if this is a BoolWeight object. - bool is_bool_weight_() const { - // Checking the name isn't ideal, but (get_maxpart() == 0.0) isn't - // required to work without init() having been called. We can at - // least avoid the virtual method call in most non-BoolWeight cases - // as most other classes will need at least some stats. - return stats_needed == 0 && name() == "Xapian::BoolWeight"; - } - - protected: - /** Don't allow copying. - * - * This would ideally be private, but that causes a compilation error - * with GCC 4.1 (which appears to be a bug). - */ - Weight(const Weight &); - - /// The number of documents in the collection. - Xapian::doccount get_collection_size() const { return collection_size_; } - - /// The number of documents marked as relevant. - Xapian::doccount get_rset_size() const { return rset_size_; } - - /// The average length of a document in the collection. - Xapian::doclength get_average_length() const { return average_length_; } - - /// The number of documents which this term indexes. - Xapian::doccount get_termfreq() const { return termfreq_; } - - /// The number of relevant documents which this term indexes. - Xapian::doccount get_reltermfreq() const { return reltermfreq_; } - - /// The collection frequency of the term. - Xapian::termcount get_collection_freq() const { return collectionfreq_; } - - /// The length of the query. - Xapian::termcount get_query_length() const { return query_length_; } - - /// The within-query-frequency of this term. - Xapian::termcount get_wqf() const { return wqf_; } - - /** An upper bound on the maximum length of any document in the database. - * - * This should only be used by get_maxpart() and get_maxextra(). - */ - Xapian::termcount get_doclength_upper_bound() const { - return doclength_upper_bound_; - } - - /** A lower bound on the minimum length of any document in the database. - * - * This bound does not include any zero-length documents. - * - * This should only be used by get_maxpart() and get_maxextra(). - */ - Xapian::termcount get_doclength_lower_bound() const { - return doclength_lower_bound_; - } - - /** An upper bound on the wdf of this term. - * - * This should only be used by get_maxpart() and get_maxextra(). - */ - Xapian::termcount get_wdf_upper_bound() const { - return wdf_upper_bound_; - } - - /// Total length of all documents in the collection. - Xapian::totallength get_total_length() const { - return Xapian::totallength(average_length_ * collection_size_ + 0.5); - } -}; - -/** Class implementing a "boolean" weighting scheme. - * - * This weighting scheme gives all documents zero weight. - */ -class XAPIAN_VISIBILITY_DEFAULT BoolWeight : public Weight { - BoolWeight * clone() const; - - void init(double factor); - - public: - /** Construct a BoolWeight. */ - BoolWeight() { } - - std::string name() const; - - std::string serialise() const; - BoolWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/// Xapian::Weight subclass implementing the tf-idf weighting scheme. -class XAPIAN_VISIBILITY_DEFAULT TfIdfWeight : public Weight { - /* Three character string indicating the normalizations for tf(wdf), idf and - tfidf weight. */ - std::string normalizations; - - /// The factor to multiply with the weight. - double factor; - - TfIdfWeight * clone() const; - - void init(double factor); - - /* When additional normalizations are implemented in the future, the additional statistics for them - should be accessed by these functions. */ - double get_wdfn(Xapian::termcount wdf, char c) const; - double get_idfn(Xapian::doccount termfreq, char c) const; - double get_wtn(double wt, char c) const; - - public: - /** Construct a TfIdfWeight - * - * @param normalizations A three character string indicating the - * normalizations to be used for the tf(wdf), idf - * and document weight. (default: "ntn") - * - * The @a normalizations string works like so: - * - * @li The first character specifies the normalization for the wdf. The - * following normalizations are currently supported: - * - * @li 'n': None. wdfn=wdf - * @li 'b': Boolean wdfn=1 if term in document else wdfn=0 - * @li 's': Square wdfn=wdf*wdf - * @li 'l': Logarithmic wdfn=1+loge(wdf) - * @li 'L': Log average wdfn=(1+log(wdf))/(1+log(doclen/unique_terms)) - * - * The Max-wdf and Augmented Max wdf normalizations haven't yet been - * implemented. - * - * @li The second character indicates the normalization for the idf. The - * following normalizations are currently supported: - * - * @li 'n': None idfn=1 - * @li 't': TfIdf idfn=log(N/Termfreq) where N is the number of - * documents in collection and Termfreq is the number of documents - * which are indexed by the term t. - * @li 'p': Prob idfn=log((N-Termfreq)/Termfreq) - * @li 'f': Freq idfn=1/Termfreq - * @li 's': Squared idfn=(log(N/Termfreq))² - * - * @li The third and the final character indicates the normalization for - * the document weight. The following normalizations are currently - * supported: - * - * @li 'n': None wtn=tfn*idfn - * - * Implementing support for more normalizations of each type would require - * extending the backend to track more statistics. - */ - explicit TfIdfWeight(const std::string &normalizations); - - /** Construct a TfIdfWeight using the default normalizations ("ntn"). */ - TfIdfWeight() - : normalizations("ntn") - { - need_stat(TERMFREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(COLLECTION_SIZE); - } - - std::string name() const; - - std::string serialise() const; - TfIdfWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - - -/// Xapian::Weight subclass implementing the BM25 probabilistic formula. -class XAPIAN_VISIBILITY_DEFAULT BM25Weight : public Weight { - /// Factor to multiply the document length by. - mutable Xapian::doclength len_factor; - - /// Factor combining all the document independent factors. - mutable double termweight; - - /// The BM25 parameters. - double param_k1, param_k2, param_k3, param_b; - - /// The minimum normalised document length value. - Xapian::doclength param_min_normlen; - - BM25Weight * clone() const; - - void init(double factor); - - public: - /** Construct a BM25Weight. - * - * @param k1 A non-negative parameter controlling how influential - * within-document-frequency (wdf) is. k1=0 means that - * wdf doesn't affect the weights. The larger k1 is, the more - * wdf influences the weights. (default 1) - * - * @param k2 A non-negative parameter which controls the strength of a - * correction factor which depends upon query length and - * normalised document length. k2=0 disable this factor; larger - * k2 makes it stronger. (default 0) - * - * @param k3 A non-negative parameter controlling how influential - * within-query-frequency (wqf) is. k3=0 means that wqf - * doesn't affect the weights. The larger k3 is, the more - * wqf influences the weights. (default 1) - * - * @param b A parameter between 0 and 1, controlling how strong the - * document length normalisation of wdf is. 0 means no - * normalisation; 1 means full normalisation. (default 0.5) - * - * @param min_normlen A parameter specifying a minimum value for - * normalised document length. Normalised document length - * values less than this will be clamped to this value, helping - * to prevent very short documents getting large weights. - * (default 0.5) - */ - BM25Weight(double k1, double k2, double k3, double b, double min_normlen) - : param_k1(k1), param_k2(k2), param_k3(k3), param_b(b), - param_min_normlen(min_normlen) - { - if (param_k1 < 0) param_k1 = 0; - if (param_k2 < 0) param_k2 = 0; - if (param_k3 < 0) param_k3 = 0; - if (param_b < 0) { - param_b = 0; - } else if (param_b > 1) { - param_b = 1; - } - need_stat(COLLECTION_SIZE); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(WDF); - need_stat(WDF_MAX); - if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) { - need_stat(DOC_LENGTH_MIN); - need_stat(AVERAGE_LENGTH); - } - if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH); - if (param_k2 != 0) need_stat(QUERY_LENGTH); - if (param_k3 != 0) need_stat(WQF); - } - - BM25Weight() - : param_k1(1), param_k2(0), param_k3(1), param_b(0.5), - param_min_normlen(0.5) - { - need_stat(COLLECTION_SIZE); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(DOC_LENGTH_MIN); - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(WQF); - } - - std::string name() const; - - std::string serialise() const; - BM25Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/// Xapian::Weight subclass implementing the BM25+ probabilistic formula. -class XAPIAN_VISIBILITY_DEFAULT BM25PlusWeight : public Weight { - /// Factor to multiply the document length by. - mutable Xapian::doclength len_factor; - - /// Factor combining all the document independent factors. - mutable double termweight; - - /// The BM25+ parameters. - double param_k1, param_k2, param_k3, param_b; - - /// The minimum normalised document length value. - Xapian::doclength param_min_normlen; - - /// Additional parameter delta in the BM25+ formula. - double param_delta; - - BM25PlusWeight * clone() const; - - void init(double factor); - - public: - /** Construct a BM25PlusWeight. - * - * @param k1 A non-negative parameter controlling how influential - * within-document-frequency (wdf) is. k1=0 means that - * wdf doesn't affect the weights. The larger k1 is, the more - * wdf influences the weights. (default 1) - * - * @param k2 A non-negative parameter which controls the strength of a - * correction factor which depends upon query length and - * normalised document length. k2=0 disable this factor; larger - * k2 makes it stronger. The paper which describes BM25+ - * ignores BM25's document-independent component (so implicitly - * k2=0), but we support non-zero k2 too. (default 0) - * - * @param k3 A non-negative parameter controlling how influential - * within-query-frequency (wqf) is. k3=0 means that wqf - * doesn't affect the weights. The larger k3 is, the more - * wqf influences the weights. (default 1) - * - * @param b A parameter between 0 and 1, controlling how strong the - * document length normalisation of wdf is. 0 means no - * normalisation; 1 means full normalisation. (default 0.5) - * - * @param min_normlen A parameter specifying a minimum value for - * normalised document length. Normalised document length - * values less than this will be clamped to this value, helping - * to prevent very short documents getting large weights. - * (default 0.5) - * - * @param delta A parameter for pseudo tf value to control the scale - * of the tf lower bound. Delta(δ) can be tuned for example - * from 0.0 to 1.5 but BM25+ can still work effectively - * across collections with a fixed δ = 1.0. (default 1.0) - */ - BM25PlusWeight(double k1, double k2, double k3, double b, - double min_normlen, double delta) - : param_k1(k1), param_k2(k2), param_k3(k3), param_b(b), - param_min_normlen(min_normlen), param_delta(delta) - { - if (param_k1 < 0) param_k1 = 0; - if (param_k2 < 0) param_k2 = 0; - if (param_k3 < 0) param_k3 = 0; - if (param_delta < 0) param_delta = 0; - if (param_b < 0) { - param_b = 0; - } else if (param_b > 1) { - param_b = 1; - } - need_stat(COLLECTION_SIZE); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(WDF); - need_stat(WDF_MAX); - if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) { - need_stat(DOC_LENGTH_MIN); - need_stat(AVERAGE_LENGTH); - } - if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH); - if (param_k2 != 0) need_stat(QUERY_LENGTH); - if (param_k3 != 0) need_stat(WQF); - if (param_delta != 0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(WQF); - } - } - - BM25PlusWeight() - : param_k1(1), param_k2(0), param_k3(1), param_b(0.5), - param_min_normlen(0.5), param_delta(1) - { - need_stat(COLLECTION_SIZE); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(DOC_LENGTH_MIN); - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(WQF); - } - - std::string name() const; - - std::string serialise() const; - BM25PlusWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** Xapian::Weight subclass implementing the traditional probabilistic formula. - * - * This class implements the "traditional" Probabilistic Weighting scheme, as - * described by the early papers on Probabilistic Retrieval. BM25 generally - * gives better results. - * - * TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that - * the latter returns weights (k+1) times larger. - */ -class XAPIAN_VISIBILITY_DEFAULT TradWeight : public Weight { - /// Factor to multiply the document length by. - mutable Xapian::doclength len_factor; - - /// Factor combining all the document independent factors. - mutable double termweight; - - /// The parameter in the formula. - double param_k; - - TradWeight * clone() const; - - void init(double factor); - - public: - /** Construct a TradWeight. - * - * @param k A non-negative parameter controlling how influential - * within-document-frequency (wdf) and document length are. - * k=0 means that wdf and document length don't affect the - * weights. The larger k is, the more they do. (default 1) - */ - explicit TradWeight(double k = 1.0) : param_k(k) { - if (param_k < 0) param_k = 0; - if (param_k != 0.0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - } - need_stat(COLLECTION_SIZE); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(DOC_LENGTH_MIN); - need_stat(WDF); - need_stat(WDF_MAX); - } - - std::string name() const; - - std::string serialise() const; - TradWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqueterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the InL2 weighting scheme. - * - * InL2 is a representative scheme of the Divergence from Randomness Framework - * by Gianni Amati. - * - * This weighting scheme is useful for tasks that require early precision. - * - * It uses the Inverse document frequency model (In), the Laplace method to - * find the aftereffect of sampling (L) and the second wdf normalization - * proposed by Amati to normalize the wdf in the document to the length of the - * document (H2). - * - * For more information about the DFR Framework and the InL2 scheme, please - * refer to: Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic - * models of information retrieval based on measuring the divergence from - * randomness ACM Transactions on Information Systems (TOIS) 20, (4), 2002, - * pp. 357-389. - */ -class XAPIAN_VISIBILITY_DEFAULT InL2Weight : public Weight { - /// The wdf normalization parameter in the formula. - double param_c; - - /// The upper bound on the weight a term can give to a document. - double upper_bound; - - /// The constant values which are used on every call to get_sumpart(). - double wqf_product_idf; - double c_product_avlen; - - InL2Weight * clone() const; - - void init(double factor); - - public: - /** Construct an InL2Weight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. The - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis. - */ - explicit InL2Weight(double c); - - InL2Weight() - : param_c(1.0) - { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - need_stat(TERMFREQ); - } - - std::string name() const; - - std::string serialise() const; - InL2Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the IfB2 weighting scheme. - * - * IfB2 is a representative scheme of the Divergence from Randomness Framework - * by Gianni Amati. - * - * It uses the Inverse term frequency model (If), the Bernoulli method to find - * the aftereffect of sampling (B) and the second wdf normalization proposed - * by Amati to normalize the wdf in the document to the length of the document - * (H2). - * - * For more information about the DFR Framework and the IfB2 scheme, please - * refer to: Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic - * models of information retrieval based on measuring the divergence from - * randomness ACM Transactions on Information Systems (TOIS) 20, (4), 2002, - * pp. 357-389. - */ -class XAPIAN_VISIBILITY_DEFAULT IfB2Weight : public Weight { - /// The wdf normalization parameter in the formula. - double param_c; - - /// The upper bound on the weight. - double upper_bound; - - /// The constant values which are used for calculations in get_sumpart(). - double wqf_product_idf; - double c_product_avlen; - double B_constant; - - IfB2Weight * clone() const; - - void init(double factor); - - public: - /** Construct an IfB2Weight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. The - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis titled - * Probabilistic Models for Information Retrieval based on - * Divergence from Randomness. - */ - explicit IfB2Weight(double c); - - IfB2Weight() : param_c(1.0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - need_stat(TERMFREQ); - } - - std::string name() const; - - std::string serialise() const; - IfB2Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the IneB2 weighting scheme. - * - * IneB2 is a representative scheme of the Divergence from Randomness - * Framework by Gianni Amati. - * - * It uses the Inverse expected document frequency model (Ine), the Bernoulli - * method to find the aftereffect of sampling (B) and the second wdf - * normalization proposed by Amati to normalize the wdf in the document to the - * length of the document (H2). - * - * For more information about the DFR Framework and the IneB2 scheme, please - * refer to: Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic - * models of information retrieval based on measuring the divergence from - * randomness ACM Transactions on Information Systems (TOIS) 20, (4), 2002, - * pp. 357-389. - */ -class XAPIAN_VISIBILITY_DEFAULT IneB2Weight : public Weight { - /// The wdf normalization parameter in the formula. - double param_c; - - /// The upper bound of the weight. - double upper_bound; - - /// Constant values used in get_sumpart(). - double wqf_product_idf; - double c_product_avlen; - double B_constant; - - IneB2Weight * clone() const; - - void init(double factor); - - public: - /** Construct an IneB2Weight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. The - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis. - */ - explicit IneB2Weight(double c); - - IneB2Weight() : param_c(1.0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - need_stat(COLLECTION_FREQ); - need_stat(TERMFREQ); - } - - std::string name() const; - - std::string serialise() const; - IneB2Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the BB2 weighting scheme. - * - * BB2 is a representative scheme of the Divergence from Randomness Framework - * by Gianni Amati. - * - * It uses the Bose-Einstein probabilistic distribution (B) along with - * Stirling's power approximation, the Bernoulli method to find the - * aftereffect of sampling (B) and the second wdf normalization proposed by - * Amati to normalize the wdf in the document to the length of the document - * (H2). - * - * For more information about the DFR Framework and the BB2 scheme, please - * refer to : Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic - * models of information retrieval based on measuring the divergence from - * randomness ACM Transactions on Information Systems (TOIS) 20, (4), 2002, - * pp. 357-389. - */ -class XAPIAN_VISIBILITY_DEFAULT BB2Weight : public Weight { - /// The wdf normalization parameter in the formula. - double param_c; - - /// The upper bound on the weight. - double upper_bound; - - /// The constant values to be used in get_sumpart(). - double c_product_avlen; - double B_constant; - double wt; - double stirling_constant_1; - double stirling_constant_2; - - BB2Weight * clone() const; - - void init(double factor); - - public: - /** Construct a BB2Weight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. A - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis titled - * Probabilistic Models for Information Retrieval based on - * Divergence from Randomness. - */ - explicit BB2Weight(double c); - - BB2Weight() : param_c(1.0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - need_stat(TERMFREQ); - } - - std::string name() const; - - std::string serialise() const; - BB2Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the DLH weighting scheme, which is a representative - * scheme of the Divergence from Randomness Framework by Gianni Amati. - * - * This is a parameter free weighting scheme and it should be used with query - * expansion to obtain better results. It uses the HyperGeometric Probabilistic - * model and Laplace's normalization to calculate the risk gain. - * - * For more information about the DFR Framework and the DLH scheme, please - * refer to : - * a.) Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic - * models of information retrieval based on measuring the divergence from - * randomness ACM Transactions on Information Systems (TOIS) 20, (4), 2002, pp. - * 357-389. - * b.) FUB, IASI-CNR and University of Tor Vergata at TREC 2007 Blog Track. - * G. Amati and E. Ambrosi and M. Bianchi and C. Gaibisso and G. Gambosi. - * Proceedings of the 16th Text REtrieval Conference (TREC-2007), 2008. - */ -class XAPIAN_VISIBILITY_DEFAULT DLHWeight : public Weight { - /// Now unused but left in place in 1.4.x for ABI compatibility. - double lower_bound; - - /// The upper bound on the weight. - double upper_bound; - - /// The constant value to be used in get_sumpart(). - double log_constant; - double wqf_product_factor; - - DLHWeight * clone() const; - - void init(double factor); - - public: - DLHWeight() { - need_stat(DOC_LENGTH); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WQF); - need_stat(WDF_MAX); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(TOTAL_LENGTH); - } - - std::string name() const; - - std::string serialise() const; - DLHWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the PL2 weighting scheme. - * - * PL2 is a representative scheme of the Divergence from Randomness Framework - * by Gianni Amati. - * - * This weighting scheme is useful for tasks that require early precision. - * - * It uses the Poisson approximation of the Binomial Probabilistic distribution - * (P) along with Stirling's approximation for the factorial value, the Laplace - * method to find the aftereffect of sampling (L) and the second wdf - * normalization proposed by Amati to normalize the wdf in the document to the - * length of the document (H2). - * - * For more information about the DFR Framework and the PL2 scheme, please - * refer to : Gianni Amati and Cornelis Joost Van Rijsbergen Probabilistic models - * of information retrieval based on measuring the divergence from randomness - * ACM Transactions on Information Systems (TOIS) 20, (4), 2002, pp. 357-389. - */ -class XAPIAN_VISIBILITY_DEFAULT PL2Weight : public Weight { - /// The wdf normalization parameter in the formula. - double param_c; - - /** The factor to multiply weights by. - * - * The misleading name is due to this having been used to store a lower - * bound in 1.4.0. We no longer need to store that, and so this member - * has been repurposed in 1.4.1 and later (but the name left the same to - * ensure ABI compatibility with 1.4.0). - */ - double lower_bound; - - /// The upper bound on the weight. - double upper_bound; - - /// Constants for a given term in a given query. - double P1, P2; - - /// Set by init() to (param_c * get_average_length()) - double cl; - - PL2Weight * clone() const; - - void init(double factor); - - public: - /** Construct a PL2Weight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. The - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis titled - * Probabilistic Models for Information Retrieval based on - * Divergence from Randomness. - */ - explicit PL2Weight(double c); - - PL2Weight() : param_c(1.0) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - } - - std::string name() const; - - std::string serialise() const; - PL2Weight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/// Xapian::Weight subclass implementing the PL2+ probabilistic formula. -class XAPIAN_VISIBILITY_DEFAULT PL2PlusWeight : public Weight { - /// The factor to multiply weights by. - double factor; - - /// The wdf normalization parameter in the formula. - double param_c; - - /// Additional parameter delta in the PL2+ weighting formula. - double param_delta; - - /// The upper bound on the weight. - double upper_bound; - - /// Constants for a given term in a given query. - double P1, P2; - - /// Set by init() to (param_c * get_average_length()) - double cl; - - /// Set by init() to get_collection_freq()) / get_collection_size() - double mean; - - /// Weight contribution of delta term in the PL2+ function - double dw; - - PL2PlusWeight * clone() const; - - void init(double factor_); - - public: - /** Construct a PL2PlusWeight. - * - * @param c A strictly positive parameter controlling the extent - * of the normalization of the wdf to the document length. The - * default value of 1 is suitable for longer queries but it may - * need to be changed for shorter queries. For more information, - * please refer to Gianni Amati's PHD thesis titled - * Probabilistic Models for Information Retrieval based on - * Divergence from Randomness. - * - * @param delta A parameter for pseudo tf value to control the scale - * of the tf lower bound. Delta(δ) should be a positive - * real number. It can be tuned for example from 0.1 to 1.5 - * in increments of 0.1 or so. Experiments have shown that - * PL2+ works effectively across collections with a fixed δ = 0.8 - * (default 0.8) - */ - PL2PlusWeight(double c, double delta); - - PL2PlusWeight() - : param_c(1.0), param_delta(0.8) { - need_stat(AVERAGE_LENGTH); - need_stat(DOC_LENGTH); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(COLLECTION_SIZE); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(WQF); - } - - std::string name() const; - - std::string serialise() const; - PL2PlusWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - -/** This class implements the DPH weighting scheme. - * - * DPH is a representative scheme of the Divergence from Randomness Framework - * by Gianni Amati. - * - * This is a parameter free weighting scheme and it should be used with query - * expansion to obtain better results. It uses the HyperGeometric Probabilistic - * model and Popper's normalization to calculate the risk gain. - * - * For more information about the DFR Framework and the DPH scheme, please - * refer to : - * a.) Gianni Amati and Cornelis Joost Van Rijsbergen - * Probabilistic models of information retrieval based on measuring the - * divergence from randomness ACM Transactions on Information Systems (TOIS) 20, - * (4), 2002, pp. 357-389. - * b.) FUB, IASI-CNR and University of Tor Vergata at TREC 2007 Blog Track. - * G. Amati and E. Ambrosi and M. Bianchi and C. Gaibisso and G. Gambosi. - * Proceedings of the 16th Text Retrieval Conference (TREC-2007), 2008. - */ -class XAPIAN_VISIBILITY_DEFAULT DPHWeight : public Weight { - /// The upper bound on the weight. - double upper_bound; - - /// Now unused but left in place in 1.4.x for ABI compatibility. - double lower_bound; - - /// The constant value used in get_sumpart() . - double log_constant; - double wqf_product_factor; - - DPHWeight * clone() const; - - void init(double factor); - - public: - /** Construct a DPHWeight. */ - DPHWeight() { - need_stat(DOC_LENGTH); - need_stat(COLLECTION_FREQ); - need_stat(WDF); - need_stat(WQF); - need_stat(WDF_MAX); - need_stat(DOC_LENGTH_MIN); - need_stat(DOC_LENGTH_MAX); - need_stat(TOTAL_LENGTH); - } - - std::string name() const; - - std::string serialise() const; - DPHWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, - Xapian::termcount uniqterms) const; - double get_maxextra() const; -}; - - -/** Xapian::Weight subclass implementing the Language Model formula. - * - * This class implements the "Language Model" Weighting scheme, as - * described by the early papers on LM by Bruce Croft. - * - * LM works by comparing the query to a Language Model of the document. - * The language model itself is parameter-free, though LMWeight takes - * parameters which specify the smoothing used. - */ -class XAPIAN_VISIBILITY_DEFAULT LMWeight : public Weight { - /** The type of smoothing to use. */ - type_smoothing select_smoothing; - - // Parameters for handling negative value of log, and for smoothing. - double param_log, param_smoothing1, param_smoothing2; - - /** The factor to multiply weights by. - * - * The misleading name is due to this having been used to store some - * other value in 1.4.0. However, that value only takes one - * multiplication and one division to calculate, so for 1.4.x we can just - * recalculate it each time we need it, and so this member has been - * repurposed in 1.4.1 and later (but the name left the same to ensure ABI - * compatibility with 1.4.0). - */ - double weight_collection; - - LMWeight * clone() const; - - void init(double factor); - - public: - /** Construct a LMWeight. - * - * @param param_log_ A non-negative parameter controlling how much - * to clamp negative values returned by the log. - * The log is calculated by multiplying the - * actual weight by param_log. If param_log is - * 0.0, then the document length upper bound will - * be used (default: document length upper bound) - * - * @param select_smoothing_ A parameter of type enum - * type_smoothing. This parameter - * controls which smoothing type to use. - * (default: TWO_STAGE_SMOOTHING) - * - * @param param_smoothing1_ A non-negative parameter for smoothing - * whose meaning depends on - * select_smoothing_. In - * JELINEK_MERCER_SMOOTHING, it plays the - * role of estimation and in - * DIRICHLET_SMOOTHING the role of query - * modelling. (default JELINEK_MERCER, - * ABSOLUTE, TWOSTAGE(0.7), - * DIRCHLET(2000)) - * - * @param param_smoothing2_ A non-negative parameter which is used - * with TWO_STAGE_SMOOTHING as parameter for Dirichlet's - * smoothing (default: 2000) and as parameter delta to - * control the scale of the tf lower bound in the - * DIRICHLET_PLUS_SMOOTHING (default 0.05). - * - */ - // Unigram LM Constructor to specifically mention all parameters for handling negative log value and smoothing. - explicit LMWeight(double param_log_ = 0.0, - type_smoothing select_smoothing_ = TWO_STAGE_SMOOTHING, - double param_smoothing1_ = -1.0, - double param_smoothing2_ = -1.0) - : select_smoothing(select_smoothing_), param_log(param_log_), param_smoothing1(param_smoothing1_), - param_smoothing2(param_smoothing2_) - { - if (param_smoothing1 < 0) param_smoothing1 = 0.7; - if (param_smoothing2 < 0) { - if (select_smoothing == TWO_STAGE_SMOOTHING) - param_smoothing2 = 2000.0; - else - param_smoothing2 = 0.05; - } - need_stat(DOC_LENGTH); - need_stat(RSET_SIZE); - need_stat(TERMFREQ); - need_stat(RELTERMFREQ); - need_stat(DOC_LENGTH_MAX); - need_stat(WDF); - need_stat(WDF_MAX); - need_stat(COLLECTION_FREQ); - need_stat(TOTAL_LENGTH); - if (select_smoothing == ABSOLUTE_DISCOUNT_SMOOTHING) - need_stat(UNIQUE_TERMS); - if (select_smoothing == DIRICHLET_PLUS_SMOOTHING) - need_stat(DOC_LENGTH_MIN); - } - - std::string name() const; - - std::string serialise() const; - LMWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount doclen, Xapian::termcount) const; - double get_maxextra() const; -}; - -/** Xapian::Weight subclass implementing Coordinate Matching. - * - * Each matching term score one point. See Managing Gigabytes, Second Edition - * p181. - */ -class XAPIAN_VISIBILITY_DEFAULT CoordWeight : public Weight { - /// The factor to multiply weights by. - double factor; - - public: - CoordWeight * clone() const; - - void init(double factor_); - - /** Construct a CoordWeight. */ - CoordWeight() { } - - std::string name() const; - - std::string serialise() const; - CoordWeight * unserialise(const std::string & serialised) const; - - double get_sumpart(Xapian::termcount wdf, - Xapian::termcount doclen, - Xapian::termcount uniqterm) const; - double get_maxpart() const; - - double get_sumextra(Xapian::termcount, Xapian::termcount) const; - double get_maxextra() const; -}; - -} - -#endif // XAPIAN_INCLUDED_WEIGHT_H diff --git a/winlibs/include/zconf.h b/winlibs/include/zconf.h deleted file mode 100644 index e614f9d32..000000000 --- a/winlibs/include/zconf.h +++ /dev/null @@ -1,553 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H -/* #undef Z_PREFIX */ -/* #undef Z_HAVE_UNISTD_H */ - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_combine_gen z_crc32_combine_gen -# define crc32_combine_gen64 z_crc32_combine_gen64 -# define crc32_combine_op z_crc32_combine_op -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO -# ifdef _WIN64 - typedef unsigned long long z_size_t; -# else - typedef unsigned long z_size_t; -# endif -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# if 1 -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# if 1 -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 -# define Z_HAVE_UNISTD_H -# elif HAVE_UNISTD_H != 0 -# define Z_HAVE_UNISTD_H -# endif -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 -# define Z_HAVE_STDARG_H -# elif HAVE_STDARG_H != 0 -# define Z_HAVE_STDARG_H -# endif -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#ifndef Z_HAVE_UNISTD_H -# ifdef __WATCOMC__ -# define Z_HAVE_UNISTD_H -# endif -#endif -#ifndef Z_HAVE_UNISTD_H -# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) -# define Z_HAVE_UNISTD_H -# endif -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/winlibs/include/zdict.h b/winlibs/include/zdict.h deleted file mode 100644 index 422db0962..000000000 --- a/winlibs/include/zdict.h +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#if defined (__cplusplus) -extern "C" { -#endif - -#ifndef ZSTD_ZDICT_H -#define ZSTD_ZDICT_H - -/*====== Dependencies ======*/ -#include /* size_t */ - - -/* ===== ZDICTLIB_API : control library symbols visibility ===== */ -#ifndef ZDICTLIB_VISIBLE - /* Backwards compatibility with old macro name */ -# ifdef ZDICTLIB_VISIBILITY -# define ZDICTLIB_VISIBLE ZDICTLIB_VISIBILITY -# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) -# define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default"))) -# else -# define ZDICTLIB_VISIBLE -# endif -#endif - -#ifndef ZDICTLIB_HIDDEN -# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__) -# define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden"))) -# else -# define ZDICTLIB_HIDDEN -# endif -#endif - -#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) -# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBLE -#elif 1 -# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ -#else -# define ZDICTLIB_API ZDICTLIB_VISIBLE -#endif - -/******************************************************************************* - * Zstd dictionary builder - * - * FAQ - * === - * Why should I use a dictionary? - * ------------------------------ - * - * Zstd can use dictionaries to improve compression ratio of small data. - * Traditionally small files don't compress well because there is very little - * repetition in a single sample, since it is small. But, if you are compressing - * many similar files, like a bunch of JSON records that share the same - * structure, you can train a dictionary on ahead of time on some samples of - * these files. Then, zstd can use the dictionary to find repetitions that are - * present across samples. This can vastly improve compression ratio. - * - * When is a dictionary useful? - * ---------------------------- - * - * Dictionaries are useful when compressing many small files that are similar. - * The larger a file is, the less benefit a dictionary will have. Generally, - * we don't expect dictionary compression to be effective past 100KB. And the - * smaller a file is, the more we would expect the dictionary to help. - * - * How do I use a dictionary? - * -------------------------- - * - * Simply pass the dictionary to the zstd compressor with - * `ZSTD_CCtx_loadDictionary()`. The same dictionary must then be passed to - * the decompressor, using `ZSTD_DCtx_loadDictionary()`. There are other - * more advanced functions that allow selecting some options, see zstd.h for - * complete documentation. - * - * What is a zstd dictionary? - * -------------------------- - * - * A zstd dictionary has two pieces: Its header, and its content. The header - * contains a magic number, the dictionary ID, and entropy tables. These - * entropy tables allow zstd to save on header costs in the compressed file, - * which really matters for small data. The content is just bytes, which are - * repeated content that is common across many samples. - * - * What is a raw content dictionary? - * --------------------------------- - * - * A raw content dictionary is just bytes. It doesn't have a zstd dictionary - * header, a dictionary ID, or entropy tables. Any buffer is a valid raw - * content dictionary. - * - * How do I train a dictionary? - * ---------------------------- - * - * Gather samples from your use case. These samples should be similar to each - * other. If you have several use cases, you could try to train one dictionary - * per use case. - * - * Pass those samples to `ZDICT_trainFromBuffer()` and that will train your - * dictionary. There are a few advanced versions of this function, but this - * is a great starting point. If you want to further tune your dictionary - * you could try `ZDICT_optimizeTrainFromBuffer_cover()`. If that is too slow - * you can try `ZDICT_optimizeTrainFromBuffer_fastCover()`. - * - * If the dictionary training function fails, that is likely because you - * either passed too few samples, or a dictionary would not be effective - * for your data. Look at the messages that the dictionary trainer printed, - * if it doesn't say too few samples, then a dictionary would not be effective. - * - * How large should my dictionary be? - * ---------------------------------- - * - * A reasonable dictionary size, the `dictBufferCapacity`, is about 100KB. - * The zstd CLI defaults to a 110KB dictionary. You likely don't need a - * dictionary larger than that. But, most use cases can get away with a - * smaller dictionary. The advanced dictionary builders can automatically - * shrink the dictionary for you, and select the smallest size that doesn't - * hurt compression ratio too much. See the `shrinkDict` parameter. - * A smaller dictionary can save memory, and potentially speed up - * compression. - * - * How many samples should I provide to the dictionary builder? - * ------------------------------------------------------------ - * - * We generally recommend passing ~100x the size of the dictionary - * in samples. A few thousand should suffice. Having too few samples - * can hurt the dictionaries effectiveness. Having more samples will - * only improve the dictionaries effectiveness. But having too many - * samples can slow down the dictionary builder. - * - * How do I determine if a dictionary will be effective? - * ----------------------------------------------------- - * - * Simply train a dictionary and try it out. You can use zstd's built in - * benchmarking tool to test the dictionary effectiveness. - * - * # Benchmark levels 1-3 without a dictionary - * zstd -b1e3 -r /path/to/my/files - * # Benchmark levels 1-3 with a dictionary - * zstd -b1e3 -r /path/to/my/files -D /path/to/my/dictionary - * - * When should I retrain a dictionary? - * ----------------------------------- - * - * You should retrain a dictionary when its effectiveness drops. Dictionary - * effectiveness drops as the data you are compressing changes. Generally, we do - * expect dictionaries to "decay" over time, as your data changes, but the rate - * at which they decay depends on your use case. Internally, we regularly - * retrain dictionaries, and if the new dictionary performs significantly - * better than the old dictionary, we will ship the new dictionary. - * - * I have a raw content dictionary, how do I turn it into a zstd dictionary? - * ------------------------------------------------------------------------- - * - * If you have a raw content dictionary, e.g. by manually constructing it, or - * using a third-party dictionary builder, you can turn it into a zstd - * dictionary by using `ZDICT_finalizeDictionary()`. You'll also have to - * provide some samples of the data. It will add the zstd header to the - * raw content, which contains a dictionary ID and entropy tables, which - * will improve compression ratio, and allow zstd to write the dictionary ID - * into the frame, if you so choose. - * - * Do I have to use zstd's dictionary builder? - * ------------------------------------------- - * - * No! You can construct dictionary content however you please, it is just - * bytes. It will always be valid as a raw content dictionary. If you want - * a zstd dictionary, which can improve compression ratio, use - * `ZDICT_finalizeDictionary()`. - * - * What is the attack surface of a zstd dictionary? - * ------------------------------------------------ - * - * Zstd is heavily fuzz tested, including loading fuzzed dictionaries, so - * zstd should never crash, or access out-of-bounds memory no matter what - * the dictionary is. However, if an attacker can control the dictionary - * during decompression, they can cause zstd to generate arbitrary bytes, - * just like if they controlled the compressed data. - * - ******************************************************************************/ - - -/*! ZDICT_trainFromBuffer(): - * Train a dictionary from an array of samples. - * Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4, - * f=20, and accel=1. - * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, - * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. - * The resulting dictionary will be saved into `dictBuffer`. - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * Note: Dictionary training will fail if there are not enough samples to construct a - * dictionary, or if most of the samples are too small (< 8 bytes being the lower limit). - * If dictionary training fails, you should use zstd without a dictionary, as the dictionary - * would've been ineffective anyways. If you believe your samples would benefit from a dictionary - * please open an issue with details, and we can look into it. - * Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB. - * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. - * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. - * In general, it's recommended to provide a few thousands samples, though this can vary a lot. - * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. - */ -ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity, - const void* samplesBuffer, - const size_t* samplesSizes, unsigned nbSamples); - -typedef struct { - int compressionLevel; /**< optimize for a specific zstd compression level; 0 means default */ - unsigned notificationLevel; /**< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */ - unsigned dictID; /**< force dictID value; 0 means auto mode (32-bits random value) - * NOTE: The zstd format reserves some dictionary IDs for future use. - * You may use them in private settings, but be warned that they - * may be used by zstd in a public dictionary registry in the future. - * These dictionary IDs are: - * - low range : <= 32767 - * - high range : >= (2^31) - */ -} ZDICT_params_t; - -/*! ZDICT_finalizeDictionary(): - * Given a custom content as a basis for dictionary, and a set of samples, - * finalize dictionary by adding headers and statistics according to the zstd - * dictionary format. - * - * Samples must be stored concatenated in a flat buffer `samplesBuffer`, - * supplied with an array of sizes `samplesSizes`, providing the size of each - * sample in order. The samples are used to construct the statistics, so they - * should be representative of what you will compress with this dictionary. - * - * The compression level can be set in `parameters`. You should pass the - * compression level you expect to use in production. The statistics for each - * compression level differ, so tuning the dictionary for the compression level - * can help quite a bit. - * - * You can set an explicit dictionary ID in `parameters`, or allow us to pick - * a random dictionary ID for you, but we can't guarantee no collisions. - * - * The dstDictBuffer and the dictContent may overlap, and the content will be - * appended to the end of the header. If the header + the content doesn't fit in - * maxDictSize the beginning of the content is truncated to make room, since it - * is presumed that the most profitable content is at the end of the dictionary, - * since that is the cheapest to reference. - * - * `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN). - * - * @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`), - * or an error code, which can be tested by ZDICT_isError(). - * Note: ZDICT_finalizeDictionary() will push notifications into stderr if - * instructed to, using notificationLevel>0. - * NOTE: This function currently may fail in several edge cases including: - * * Not enough samples - * * Samples are uncompressible - * * Samples are all exactly the same - */ -ZDICTLIB_API size_t ZDICT_finalizeDictionary(void* dstDictBuffer, size_t maxDictSize, - const void* dictContent, size_t dictContentSize, - const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, - ZDICT_params_t parameters); - - -/*====== Helper functions ======*/ -ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */ -ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns a ZSTD error code on failure */ -ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode); -ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode); - -#endif /* ZSTD_ZDICT_H */ - -#if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC) -#define ZSTD_ZDICT_H_STATIC - -/* This can be overridden externally to hide static symbols. */ -#ifndef ZDICTLIB_STATIC_API -# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) -# define ZDICTLIB_STATIC_API __declspec(dllexport) ZDICTLIB_VISIBLE -# elif 1 -# define ZDICTLIB_STATIC_API __declspec(dllimport) ZDICTLIB_VISIBLE -# else -# define ZDICTLIB_STATIC_API ZDICTLIB_VISIBLE -# endif -#endif - -/* ==================================================================================== - * The definitions in this section are considered experimental. - * They should never be used with a dynamic library, as they may change in the future. - * They are provided for advanced usages. - * Use them only in association with static linking. - * ==================================================================================== */ - -#define ZDICT_DICTSIZE_MIN 256 -/* Deprecated: Remove in v1.6.0 */ -#define ZDICT_CONTENTSIZE_MIN 128 - -/*! ZDICT_cover_params_t: - * k and d are the only required parameters. - * For others, value 0 means default. - */ -typedef struct { - unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */ - unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */ - unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */ - unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */ - double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (1.0), 1.0 when all samples are used for both training and testing */ - unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */ - unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */ - ZDICT_params_t zParams; -} ZDICT_cover_params_t; - -typedef struct { - unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */ - unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */ - unsigned f; /* log of size of frequency array : constraint: 0 < f <= 31 : 1 means default(20)*/ - unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */ - unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */ - double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (0.75), 1.0 when all samples are used for both training and testing */ - unsigned accel; /* Acceleration level: constraint: 0 < accel <= 10, higher means faster and less accurate, 0 means default(1) */ - unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */ - unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */ - - ZDICT_params_t zParams; -} ZDICT_fastCover_params_t; - -/*! ZDICT_trainFromBuffer_cover(): - * Train a dictionary from an array of samples using the COVER algorithm. - * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, - * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. - * The resulting dictionary will be saved into `dictBuffer`. - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * See ZDICT_trainFromBuffer() for details on failure modes. - * Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte. - * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. - * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. - * In general, it's recommended to provide a few thousands samples, though this can vary a lot. - * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. - */ -ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover( - void *dictBuffer, size_t dictBufferCapacity, - const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples, - ZDICT_cover_params_t parameters); - -/*! ZDICT_optimizeTrainFromBuffer_cover(): - * The same requirements as above hold for all the parameters except `parameters`. - * This function tries many parameter combinations and picks the best parameters. - * `*parameters` is filled with the best parameters found, - * dictionary constructed with those parameters is stored in `dictBuffer`. - * - * All of the parameters d, k, steps are optional. - * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}. - * if steps is zero it defaults to its default value. - * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]. - * - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * On success `*parameters` contains the parameters selected. - * See ZDICT_trainFromBuffer() for details on failure modes. - * Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread. - */ -ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover( - void* dictBuffer, size_t dictBufferCapacity, - const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, - ZDICT_cover_params_t* parameters); - -/*! ZDICT_trainFromBuffer_fastCover(): - * Train a dictionary from an array of samples using a modified version of COVER algorithm. - * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, - * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. - * d and k are required. - * All other parameters are optional, will use default values if not provided - * The resulting dictionary will be saved into `dictBuffer`. - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * See ZDICT_trainFromBuffer() for details on failure modes. - * Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory. - * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. - * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. - * In general, it's recommended to provide a few thousands samples, though this can vary a lot. - * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. - */ -ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer, - size_t dictBufferCapacity, const void *samplesBuffer, - const size_t *samplesSizes, unsigned nbSamples, - ZDICT_fastCover_params_t parameters); - -/*! ZDICT_optimizeTrainFromBuffer_fastCover(): - * The same requirements as above hold for all the parameters except `parameters`. - * This function tries many parameter combinations (specifically, k and d combinations) - * and picks the best parameters. `*parameters` is filled with the best parameters found, - * dictionary constructed with those parameters is stored in `dictBuffer`. - * All of the parameters d, k, steps, f, and accel are optional. - * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}. - * if steps is zero it defaults to its default value. - * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]. - * If f is zero, default value of 20 is used. - * If accel is zero, default value of 1 is used. - * - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * On success `*parameters` contains the parameters selected. - * See ZDICT_trainFromBuffer() for details on failure modes. - * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread. - */ -ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer, - size_t dictBufferCapacity, const void* samplesBuffer, - const size_t* samplesSizes, unsigned nbSamples, - ZDICT_fastCover_params_t* parameters); - -typedef struct { - unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */ - ZDICT_params_t zParams; -} ZDICT_legacy_params_t; - -/*! ZDICT_trainFromBuffer_legacy(): - * Train a dictionary from an array of samples. - * Samples must be stored concatenated in a single flat buffer `samplesBuffer`, - * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order. - * The resulting dictionary will be saved into `dictBuffer`. - * `parameters` is optional and can be provided with values set to 0 to mean "default". - * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`) - * or an error code, which can be tested with ZDICT_isError(). - * See ZDICT_trainFromBuffer() for details on failure modes. - * Tips: In general, a reasonable dictionary has a size of ~ 100 KB. - * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`. - * In general, it's recommended to provide a few thousands samples, though this can vary a lot. - * It's recommended that total size of all samples be about ~x100 times the target size of dictionary. - * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0. - */ -ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy( - void* dictBuffer, size_t dictBufferCapacity, - const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, - ZDICT_legacy_params_t parameters); - - -/* Deprecation warnings */ -/* It is generally possible to disable deprecation warnings from compiler, - for example with -Wno-deprecated-declarations for gcc - or _CRT_SECURE_NO_WARNINGS in Visual. - Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */ -#ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS -# define ZDICT_DEPRECATED(message) /* disable deprecation warnings */ -#else -# define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ -# define ZDICT_DEPRECATED(message) [[deprecated(message)]] -# elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405) -# define ZDICT_DEPRECATED(message) __attribute__((deprecated(message))) -# elif (ZDICT_GCC_VERSION >= 301) -# define ZDICT_DEPRECATED(message) __attribute__((deprecated)) -# elif defined(_MSC_VER) -# define ZDICT_DEPRECATED(message) __declspec(deprecated(message)) -# else -# pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler") -# define ZDICT_DEPRECATED(message) -# endif -#endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */ - -ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead") -ZDICTLIB_STATIC_API -size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity, - const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples); - - -#endif /* ZSTD_ZDICT_H_STATIC */ - -#if defined (__cplusplus) -} -#endif diff --git a/winlibs/include/zim/archive.h b/winlibs/include/zim/archive.h deleted file mode 100644 index 7539b96c6..000000000 --- a/winlibs/include/zim/archive.h +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Copyright (C) 2020-2021 Matthieu Gautier - * Copyright (C) 2021 Maneesh P M - * Copyright (C) 2020 Veloman Yunkan - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_ARCHIVE_H -#define ZIM_ARCHIVE_H - -#include "zim.h" -#include "entry.h" -#include "uuid.h" - -#include -#include -#include -#include -#include - -namespace zim -{ - class FileImpl; - - enum class EntryOrder { - pathOrder, - titleOrder, - efficientOrder - }; - - /** - * The Archive class to access content in a zim file. - * - * The `Archive` is the main class to access content in a zim file. - * `Archive` are lightweight object and can be copied easily. - * - * An `Archive` is read-only, and internal states (as caches) are protected - * from race-condition. Therefore, all methods of `Archive` are threadsafe. - * - * All methods of archive may throw an `ZimFileFormatError` if the file is invalid. - */ - class LIBZIM_API Archive - { - public: - template class EntryRange; - template class iterator; - - /** Archive constructor. - * - * Construct an archive from a filename. - * The file is open readonly. - * - * The filename is the "logical" path. - * So if you want to open a split zim file (foo.zimaa, foo.zimab, ...) - * you must pass the `foo.zim` path. - * - * @param fname The filename to the file to open (utf8 encoded) - */ - explicit Archive(const std::string& fname); - -#ifndef _WIN32 - /** Archive constructor. - * - * Construct an archive from a file descriptor. - * - * Note: This function is not available under Windows. - * - * @param fd The descriptor of a seekable file representing a ZIM archive - */ - explicit Archive(int fd); - - /** Archive constructor. - * - * Construct an archive from a descriptor of a file with an embedded ZIM - * archive inside. - * - * Note: This function is not available under Windows. - * - * @param fd The descriptor of a seekable file with a continuous segment - * representing a complete ZIM archive. - * @param offset The offset of the ZIM archive relative to the beginning - * of the file (rather than the current position associated with fd). - * @param size The size of the ZIM archive. - */ - Archive(int fd, offset_type offset, size_type size); -#endif - - /** Return the filename of the zim file. - * - * Return the filename as passed to the constructor - * (So foo.zim). - * - * @return The logical filename of the archive. - */ - const std::string& getFilename() const; - - /** Return the logical archive size. - * - * Return the size of the full archive, not the size of the file on the fs. - * If the zim is split, return the sum of the size of the parts. - * - * @return The logical size of the archive. - */ - size_type getFilesize() const; - - /** Return the number of entries in the archive. - * - * Return the total number of entries in the archive, including - * internal entries created by libzim itself, metadata, indexes, ... - * - * @return the number of all entries in the archive. - */ - entry_index_type getAllEntryCount() const; - - /** Return the number of user entries in the archive. - * - * If the notion of "user entries" doesn't exist in the zim archive, - * returns `getAllEntryCount()`. - * - * @return the number of user entries in the archive. - */ - entry_index_type getEntryCount() const; - - /** Return the number of articles in the archive. - * - * The definition of "article" depends of the zim archive. - * On recent archives, this correspond to all entries marked as "FRONT_ARTICLE" - * at creaton time. - * On old archives, this corresponds to all "text/html*" entries. - * - * @return the number of articles in the archive. - */ - entry_index_type getArticleCount() const; - - /** Return the number of media in the archive. - * - * This definition of "media" is based on the mimetype. - * - * @return the number of media in the archive. - */ - entry_index_type getMediaCount() const; - - /** The uuid of the archive. - * - * @return the uuid of the archive. - */ - Uuid getUuid() const; - - /** Get a specific metadata content. - * - * Get the content of a metadata stored in the archive. - * - * @param name The name of the metadata. - * @return The content of the metadata. - * @exception EntryNotFound If the metadata is not in the arcthive. - */ - std::string getMetadata(const std::string& name) const; - - /** Get a specific metadata item. - * - * Get the item associated to a metadata stored in the archive. - * - * @param name The name of the metadata. - * @return The item associated to the metadata. - * @exception EntryNotFound If the metadata in not in the archive. - */ - Item getMetadataItem(const std::string& name) const; - - /** Get the list of metadata stored in the archive. - * - * @return The list of metadata in the archive. - */ - std::vector getMetadataKeys() const; - - /** Get the illustration item of the archive. - * - * Illustration is a icon for the archive that can be used in catalog and so to illustrate the archive. - * - * @param size The size (width and height) of the illustration to get. Default to 48 (48x48px icon) - * @return The illustration item. - * @exception EntryNotFound If no illustration item can be found. - */ - Item getIllustrationItem(unsigned int size=48) const; - - /** Return a list of available sizes (width) for the illustations in the archive. - * - * Illustration is an icon for the archive that can be used in catalog and elsewehere to illustrate the archive. - * An Archive may contains several illustrations with different size. - * This method allows to know which illustration are in the archive (by size: width) - * - * @return A set of size. - */ - std::set getIllustrationSizes() const; - - - /** Get an entry using its "path" index. - * - * Use the index of the entry to get the idx'th entry - * (entry being sorted by path). - * - * @param idx The index of the entry. - * @return The Entry. - * @exception std::out_of_range If idx is greater than the number of entry. - */ - Entry getEntryByPath(entry_index_type idx) const; - - /** Get an entry using a path. - * - * Get an entry using its path. - * The path must contains the namespace. - * - * @param path The entry's path. - * @return The Entry. - * @exception EntryNotFound If no entry has the asked path. - */ - Entry getEntryByPath(const std::string& path) const; - - /** Get an entry using its "title" index. - * - * Use the index of the entry to get the idx'th entry - * (entry being sorted by title). - * - * @param idx The index of the entry. - * @return The Entry. - * @exception std::out_of_range If idx is greater than the number of entry. - */ - Entry getEntryByTitle(entry_index_type idx) const; - - /** Get an entry using a title. - * - * Get an entry using its path. - * - * @param title The entry's title. - * @return The Entry. - * @exception EntryNotFound If no entry has the asked title. - */ - Entry getEntryByTitle(const std::string& title) const; - - /** Get an entry using its "cluster" index. - * - * Use the index of the entry to get the idx'th entry - * The actual order of the entry is not really specified. - * It is infered from the internal way the entry are stored. - * - * This method is probably not relevent and is provided for completeness. - * You should probably use a iterator using the `efficientOrder`. - * - * @param idx The index of the entry. - * @return The Entry. - * @exception std::out_of_range If idx is greater than the number of entry. - */ - Entry getEntryByClusterOrder(entry_index_type idx) const; - - /** Get the main entry of the archive. - * - * @return The Main entry. - * @exception EntryNotFound If no main entry has been specified in the archive. - */ - Entry getMainEntry() const; - - /** Get a random entry. - * - * The entry is picked randomly from the front artice list. - * - * @return A random entry. - * @exception EntryNotFound If no valid random entry can be found. - */ - Entry getRandomEntry() const; - - /** Check in an entry has path in the archive. - * - * @param path The entry's path. - * @return True if the path in the archive, false else. - */ - bool hasEntryByPath(const std::string& path) const { - try{ - getEntryByPath(path); - return true; - } catch(...) { return false; } - } - - /** Check in an entry has title in the archive. - * - * @param title The entry's title. - * @return True if the title in the archive, false else. - */ - bool hasEntryByTitle(const std::string& title) const { - try{ - getEntryByTitle(title); - return true; - } catch(...) { return false; } - } - - /** Check if archive has a main entry - * - * @return True if the archive has a main entry. - */ - bool hasMainEntry() const; - - /** Check if archive has a favicon entry - * - * @param size The size (width and height) of the illustration to check. Default to 48 (48x48px icon) - * @return True if the archive has a corresponding illustration entry. - * (Always True if the archive has no illustration, but a favicon) - */ - bool hasIllustration(unsigned int size=48) const; - - /** Check if the archive has a fulltext index. - * - * @return True if the archive has a fulltext index - */ - bool hasFulltextIndex() const; - - /** Check if the archive has a title index. - * - * @return True if the archive has a title index - */ - bool hasTitleIndex() const; - - - /** Get a "iterable" by path order. - * - * This method allow to iterate on all user entries using a path order. - * If the notion of "user entries" doesn't exists (for old zim archive), - * this iterate on all entries in the zim file. - * - * ``` - * for(auto& entry:archive.iterByPath()) { - * ... - * } - * ``` - * - * @return A range on all the entries, in path order. - */ - EntryRange iterByPath() const; - - /** Get a "iterable" by title order. - * - * This method allow to iterate on all articles using a title order. - * The definition of "article" depends of the zim archive. - * On recent archives, this correspond to all entries marked as "FRONT_ARTICLE" - * at creaton time. - * On old archives, this correspond to all entries in 'A' namespace. - * Few archives may have been created without namespace but also without specific - * article listing. In this case, this iterate on all user entries. - * - * ``` - * for(auto& entry:archive.iterByTitle()) { - * ... - * } - * ``` - * - * @return A range on all the entries, in title order. - */ - EntryRange iterByTitle() const; - - /** Get a "iterable" by a efficient order. - * - * This method allow to iterate on all user entries using a effictient order. - * If the notion of "user entries" doesn't exists (for old zim archive), - * this iterate on all entries in the zim file. - * - * ``` - * for(auto& entry:archive.iterEfficient()) { - * ... - * } - * ``` - * - * @return A range on all the entries, in efficitent order. - */ - EntryRange iterEfficient() const; - - /** Find a range of entries starting with path. - * - * The path is the "long path". (Ie, with the namespace) - * - * @param path The path prefix to search for. - * @return A range starting from the first entry starting with path - * and ending past the last entry. - * If no entry starts with `path`, begin == end. - */ - EntryRange findByPath(std::string path) const; - - /** Find a range of entry starting with title. - * - * The entry title is search in `A` namespace. - * - * @param title The title prefix to search for. - * @return A range starting from the first entry starting with title - * and ending past the last entry. - * If no entry starts with `title`, begin == end. - */ - EntryRange findByTitle(std::string title) const; - - /** hasChecksum. - * - * The checksum is not the checksum of the file. - * It is an internal checksum stored in the zim file. - * - * @return True if the archive has a checksum. - */ - bool hasChecksum() const; - - /** getChecksum. - * - * @return the checksum stored in the archive. - * If the archive has no checksum return an empty string. - */ - std::string getChecksum() const; - - /** Check that the zim file is valid (in regard to its checksum). - * - * If the zim file has no checksum return false. - * - * @return True if the file is valid. - */ - bool check() const; - - /** Check the integrity of the zim file. - * - * Run different type of checks to verify the zim file is valid - * (in regard to the zim format). - * This may be time consuming. - * - * @return True if the file is valid. - */ - bool checkIntegrity(IntegrityCheck checkType); - - /** Check if the file is split in the filesystem. - * - * @return True if the archive is split in different file (foo.zimaa, foo.zimbb). - */ - bool isMultiPart() const; - - /** Get if the zim archive uses the new namespace scheme. - * - * Recent zim file use the new namespace scheme. - * - * On user perspective, it means that : - * - On old namespace scheme : - * . All entries are accessible, either using `getEntryByPath` with a specific namespace - * or simply iterating over the entries (with `iter*` methods). - * . Entry's path has namespace included ("A/foo.html") - * - On new namespace scheme : - * . Only the "user" entries are accessible with `getEntryByPath` and `iter*` methods. - * To access metadatas, use `getMetadata` method. - * . Entry's path do not contains namespace ("foo.html") - */ - bool hasNewNamespaceScheme() const; - - /** Get a shared ptr on the FileImpl - * - * @internal - * @return The shared_ptr - */ - std::shared_ptr getImpl() const { return m_impl; } - -#ifdef ZIM_PRIVATE - cluster_index_type getClusterCount() const; - offset_type getClusterOffset(cluster_index_type idx) const; - entry_index_type getMainEntryIndex() const; -#endif - - private: - std::shared_ptr m_impl; - }; - - template - LIBZIM_API entry_index_type _toPathOrder(const FileImpl& file, entry_index_type idx); - - template<> - LIBZIM_API entry_index_type _toPathOrder(const FileImpl& file, entry_index_type idx); - template<> - LIBZIM_API entry_index_type _toPathOrder(const FileImpl& file, entry_index_type idx); - template<> - LIBZIM_API entry_index_type _toPathOrder(const FileImpl& file, entry_index_type idx); - - - /** - * A range of entries in an `Archive`. - * - * `EntryRange` represents a range of entries in a specific order. - * - * An `EntryRange` can't be modified is consequently threadsafe. - */ - template - class LIBZIM_API Archive::EntryRange { - public: - explicit EntryRange(const std::shared_ptr file, entry_index_type begin, entry_index_type end) - : m_file(file), - m_begin(begin), - m_end(end) - {} - - iterator begin() const - { return iterator(m_file, entry_index_type(m_begin)); } - iterator end() const - { return iterator(m_file, entry_index_type(m_end)); } - int size() const - { return m_end - m_begin; } - - EntryRange offset(int start, int maxResults) const - { - auto begin = m_begin + start; - if (begin > m_end) { - begin = m_end; - } - auto end = m_end; - if (begin + maxResults < end) { - end = begin + maxResults; - } - return EntryRange(m_file, begin, end); - } - -private: - std::shared_ptr m_file; - entry_index_type m_begin; - entry_index_type m_end; - }; - - /** - * An iterator on an `Archive`. - * - * `Archive::iterator` stores an internal state which is not protected - * from race-condition. It is not threadsafe. - * - * An `EntryRange` can't be modified and is consequently threadsafe. - * - * Be aware that the referenced/pointed Entry is generated and stored - * in the iterator itself. - * Once the iterator is destructed or incremented/decremented, you must NOT - * use the Entry. - */ - template - class LIBZIM_API Archive::iterator - { - public: - /* SuggestionIterator is conceptually a bidirectional iterator. - * But std *LegayBidirectionalIterator* is also a *LegacyForwardIterator* and - * it would impose us that : - * > Given a and b, dereferenceable iterators of type It: - * > If a and b compare equal (a == b is contextually convertible to true) - * > then either they are both non-dereferenceable or *a and *b are references bound to the same object. - * and - * > the LegacyForwardIterator requirements requires dereference to return a reference. - * Which cannot be as we create the entry on demand. - * - * So we are stick with declaring ourselves at `input_iterator`. - */ - using iterator_category = std::input_iterator_tag; - using value_type = Entry; - using pointer = Entry*; - using reference = Entry&; - - explicit iterator(const std::shared_ptr file, entry_index_type idx) - : m_file(file), - m_idx(idx), - m_entry(nullptr) - {} - - iterator(const iterator& other) - : m_file(other.m_file), - m_idx(other.m_idx), - m_entry(other.m_entry?new Entry(*other.m_entry):nullptr) - {} - - bool operator== (const iterator& it) const - { return m_file == it.m_file && m_idx == it.m_idx; } - bool operator!= (const iterator& it) const - { return !operator==(it); } - - iterator& operator=(iterator&& it) = default; - - iterator& operator=(iterator& it) - { - m_entry.reset(); - m_idx = it.m_idx; - m_file = it.m_file; - return *this; - } - - iterator& operator++() - { - ++m_idx; - m_entry.reset(); - return *this; - } - - iterator operator++(int) - { - auto it = *this; - operator++(); - return it; - } - - iterator& operator--() - { - --m_idx; - m_entry.reset(); - return *this; - } - - iterator operator--(int) - { - auto it = *this; - operator--(); - return it; - } - - const Entry& operator*() const - { - if (!m_entry) { - m_entry.reset(new Entry(m_file, _toPathOrder(*m_file, m_idx))); - } - return *m_entry; - } - - const Entry* operator->() const - { - operator*(); - return m_entry.get(); - } - - private: - std::shared_ptr m_file; - entry_index_type m_idx; - mutable std::unique_ptr m_entry; - }; - - /** - * The set of the integrity checks to be performed by `zim::validate()`. - */ - typedef std::bitset IntegrityCheckList; - - /** Check the integrity of the zim file. - * - * Run the specified checks to verify the zim file is valid - * (with regard to the zim format). Some checks can be quite slow. - * - * @param zimPath The path of the ZIM archive to be checked. - * @param checksToRun The set of checks to perform. - * @return False if any check fails, true otherwise. - */ - bool validate(const std::string& zimPath, IntegrityCheckList checksToRun); -} - -#endif // ZIM_ARCHIVE_H - diff --git a/winlibs/include/zim/blob.h b/winlibs/include/zim/blob.h deleted file mode 100644 index 23f2fdcad..000000000 --- a/winlibs/include/zim/blob.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2018 Matthieu Gautier - * Copyright (C) 2009 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_BLOB_H -#define ZIM_BLOB_H - -#include "zim.h" - -#include -#include -#include -#include - -namespace zim -{ - /** - * A blob is a pointer to data, potentially stored in an `Archive`. - * - * All `Blob`'s methods are threadsafe. - */ - class LIBZIM_API Blob - { - public: // types - using DataPtr = std::shared_ptr; - - public: // functions - /** - * Constuct a empty `Blob` - */ - Blob(); - - /** - * Constuct `Blob` pointing to `data`. - * - * The created blob only point to the data and doesn't own it. - * User must care that data is not freed before using the blob. - */ - Blob(const char* data, size_type size); - - /** - * Constuct `Blob` pointing to `data`. - * - * The created blob shares the ownership on data. - */ - Blob(const DataPtr& buffer, size_type size); - - operator std::string() const { return std::string(_data.get(), _size); } - const char* data() const { return _data.get(); } - const char* end() const { return _data.get() + _size; } - size_type size() const { return _size; } - - private: - DataPtr _data; - size_type _size; - }; - - inline std::ostream& operator<< (std::ostream& out, const Blob& blob) - { - if (blob.data()) - out.write(blob.data(), blob.size()); - return out; - } - - inline bool operator== (const Blob& b1, const Blob& b2) - { - return b1.size() == b2.size() - && std::equal(b1.data(), b1.data() + b1.size(), b2.data()); - } -} - -#endif // ZIM_BLOB_H diff --git a/winlibs/include/zim/entry.h b/winlibs/include/zim/entry.h deleted file mode 100644 index 0ab4f7f42..000000000 --- a/winlibs/include/zim/entry.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2020 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_ENTRY_H -#define ZIM_ENTRY_H - -#include "zim.h" - -#include -#include - -namespace zim -{ - class Item; - class Dirent; - class FileImpl; - - /** - * An entry in an `Archive`. - * - * All `Entry`'s methods are threadsafe. - */ - class LIBZIM_API Entry - { - public: - explicit Entry(std::shared_ptr file_, entry_index_type idx_); - - bool isRedirect() const; - std::string getTitle() const; - std::string getPath() const; - - /** Get the item associated to the entry. - * - * An item is associated only if the entry is not a redirect. - * For convenience, if follow is true, return the item associated to the targeted entry. - * - * @param follow True if the redirection is resolved before getting the item. (false by default) - * @return The Item associated to the entry. - * @exception InvalidType if the entry is a redirection and follow is false. - */ - Item getItem(bool follow=false) const; - - /** Get the item associated to the target entry. - * - * If there is a chain of redirection, the whole chain is resolved - * and the item associted to the last entry is returned. - * - * @return the Item associated with the targeted entry. - * @exception InvalidType if the entry is not a redirection. - */ - Item getRedirect() const; - - /** Get the Entry targeted by the entry. - * - * @return The entry directly targeted by this redirect entry. - * @exception InvalidEntry if the entry is not a redirection. - */ - Entry getRedirectEntry() const; - - /** Get the index of the Entry targeted by the entry. - * - * @return The index of the entry directly targeted by this redirect - * entry. - * @exception InvalidEntry if the entry is not a redirection. - */ - entry_index_type getRedirectEntryIndex() const; - - entry_index_type getIndex() const { return m_idx; } - - protected: // so that Item can be implemented as a wrapper over Entry - std::shared_ptr m_file; - entry_index_type m_idx; - std::shared_ptr m_dirent; - }; - -} - -#endif // ZIM_ENTRY_H - diff --git a/winlibs/include/zim/error.h b/winlibs/include/zim/error.h deleted file mode 100644 index 25f2b74b3..000000000 --- a/winlibs/include/zim/error.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2020 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_ERROR_H -#define ZIM_ERROR_H - -#include "zim.h" - -#include -#include -#include - -namespace zim -{ - class LIBZIM_API ZimFileFormatError : public std::runtime_error - { - public: - explicit ZimFileFormatError(const std::string& msg) - : std::runtime_error(msg) - { } - }; - - class LIBZIM_API InvalidType: public std::logic_error - { - public: - explicit InvalidType(const std::string& msg) - : std::logic_error(msg) - {} - }; - - class LIBZIM_API EntryNotFound : public std::runtime_error - { - public: - explicit EntryNotFound(const std::string& msg) - : std::runtime_error(msg) - {} - }; - - /* Exception thrown by the Creator in case of error. - * - * Most exceptions actually thrown are inheriting this exception. - */ - class LIBZIM_API CreatorError : public std::runtime_error - { - public: - explicit CreatorError(const std::string& message) - : std::runtime_error(message) - {} - }; - - /* Exception thrown when a entry cannot be added to the Creator.*/ - class LIBZIM_API InvalidEntry : public CreatorError - { - public: - explicit InvalidEntry(const std::string& message) - : CreatorError(message) - {} - }; - - /* Exception thrown if a incoherence in the user implementation has been detected. - * - * Users need to implement interfaces such as: - * - ContentProvider - * - IndexData - * - Item - * - * If a incoherence has been detected in those implementations a - * `IncoherentImplementationError` will be thrown. - */ - class LIBZIM_API IncoherentImplementationError : public CreatorError - { - public: - explicit IncoherentImplementationError(const std::string& message) - : CreatorError(message) - {} - }; - - /* Exception thrown in the main thread when another exception has been - * thrown in another worker thread. - * - * Creator uses different worker threads to do background work. - * If an exception is thrown in one of this threads, it is catched and - * "rethrown" in the main thread as soon as possible with a `AsyncError`. - * - * AsyncError contains the original exception. You can rethrow the original - * exception using `rethrow`: - * - * ``` - * try { - * creator->addStuff(...); - * } catch (const zim::AsyncError& e) { - * // An exception has been thrown in a worker thread - * try { - * e.rethrow(); - * } catch (const std::exception& original_exception) { - * // original_exception is the exception thrown in the worker thread - * ... - * } - * } - * ``` - */ - class LIBZIM_API AsyncError : public CreatorError - { - public: - explicit AsyncError(const std::exception_ptr exception) - : CreatorError(buildErrorMessage(exception)), - m_exception(exception) - {} - - [[noreturn]] void rethrow() const { - std::rethrow_exception(m_exception); - } - - private: // data - std::exception_ptr m_exception; - - private: // function - static std::string buildErrorMessage(const std::exception_ptr exception) { - try { - std::rethrow_exception(exception); - } catch (const std::exception& e) { - std::stringstream ss; - ss << "Asynchronous error: "; - ss << typeid(e).name() << std::endl; - ss << e.what(); - return ss.str(); - } catch (...) { - return "Unknown asynchronous exception"; - } - } - }; - - /* Exception thrown when the creator is in error state. - * - * If the creator is in error state (mostly because a AsyncError has already - * being thrown), any call to any method on it will thrown a `CreatorStateError`. - */ - class LIBZIM_API CreatorStateError : public CreatorError - { - public: - explicit CreatorStateError() - : CreatorError("Creator is in error state.") - {} - }; -} - -#endif // ZIM_ERROR_H - diff --git a/winlibs/include/zim/item.h b/winlibs/include/zim/item.h deleted file mode 100644 index e66c00f42..000000000 --- a/winlibs/include/zim/item.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2021 Veloman Yunkan - * Copyright (C) 2020 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_ITEM_H -#define ZIM_ITEM_H - -#include "zim.h" -#include "blob.h" -#include "entry.h" -#include - -namespace zim -{ - /** - * An `Item` in an `Archive` - * - * There is no public constructor - the only way to obtain an `Item` - * is via `Entry::getItem()` or `Entry::getRedirect()`. - * - * All `Item`'s methods are threadsafe. - */ - class LIBZIM_API Item : private Entry - { - public: // types - typedef std::pair DirectAccessInfo; - - public: // functions - std::string getTitle() const { return Entry::getTitle(); } - std::string getPath() const { return Entry::getPath(); } - std::string getMimetype() const; - - /** Get the data associated to the item - * - * Get the data of the item, starting at offset. - * - * @param offset The number of byte to skip at begining of the data. - * @return A blob corresponding to the data. - */ - Blob getData(offset_type offset=0) const; - - /** Get the data associated to the item - * - * Get the `size` bytes of data of the item, starting at offset. - * - * @param offset The number of byte to skip at begining of the data. - * @param size The number of byte to read. - * @return A blob corresponding to the data. - */ - Blob getData(offset_type offset, size_type size) const; - - /** The size of the item. - * - * @return The size (in byte) of the item. - */ - size_type getSize() const; - - /** Direct access information. - * - * Some item are stored raw in the zim file. - * If possible, this function give information about which file - * and at which to read to get the data. - * - * It can be usefull as an optimisation when interacting with other system - * by reopeing the file and reading the content bypassing the libzim. - * - * @return A pair of filename/offset specifying where read the content. - * If it is not possible to have direct access for this item, - * return a pair of `{"", 0}` - */ - DirectAccessInfo getDirectAccessInformation() const; - - entry_index_type getIndex() const { return Entry::getIndex(); } - -#ifdef ZIM_PRIVATE - cluster_index_type getClusterIndex() const; -#endif - - private: // functions - explicit Item(const Entry& entry); - friend class Entry; - }; - -} - -#endif // ZIM_ITEM_H - diff --git a/winlibs/include/zim/suggestion.h b/winlibs/include/zim/suggestion.h deleted file mode 100644 index 3f534898d..000000000 --- a/winlibs/include/zim/suggestion.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2021 Maneesh P M - * Copyright (C) 2017-2021 Matthieu Gautier - * Copyright (C) 2007 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_SUGGESTION_H -#define ZIM_SUGGESTION_H - -#include "suggestion_iterator.h" -#include "archive.h" - -#if defined(LIBZIM_WITH_XAPIAN) -namespace Xapian { - class Enquire; - class MSet; -}; -#endif - -namespace zim -{ - -class SuggestionSearcher; -class SuggestionSearch; -class SuggestionIterator; -class SuggestionDataBase; - -/** - * A SuggestionSearcher is a object suggesting over titles of an Archive - * - * A SuggestionSearcher is mainly used to create new `SuggestionSearch` - * Internaly, this is a wrapper around a SuggestionDataBase with may or may not - * include a Xapian index. - * - * You should consider that all search operations are NOT threadsafe. - * It is up to you to protect your calls to avoid race competition. - * However, SuggestionSearcher (and subsequent classes) do not maintain a global/ - * share state You can create several Searchers and use them in different threads. - */ -class LIBZIM_API SuggestionSearcher -{ - public: - /** SuggestionSearcher constructor. - * - * Construct a SuggestionSearcher on top of an archive. - * - * @param archive An archive to suggest on. - */ - explicit SuggestionSearcher(const Archive& archive); - - SuggestionSearcher(const SuggestionSearcher& other); - SuggestionSearcher& operator=(const SuggestionSearcher& other); - SuggestionSearcher(SuggestionSearcher&& other); - SuggestionSearcher& operator=(SuggestionSearcher&& other); - ~SuggestionSearcher(); - - /** Create a SuggestionSearch for a specific query. - * - * The search is made on the archive under the SuggestionSearcher. - * - * @param query The SuggestionQuery to search. - */ - SuggestionSearch suggest(const std::string& query); - - /** Set the verbosity of search operations. - * - * @param verbose The verbose mode to set - */ - void setVerbose(bool verbose); - - private: // methods - void initDatabase(); - - private: // data - std::shared_ptr mp_internalDb; - Archive m_archive; - bool m_verbose; -}; - -/** - * A SuggestionSearch represent a particular suggestion search, based on a `SuggestionSearcher`. - */ -class LIBZIM_API SuggestionSearch -{ - public: - SuggestionSearch(SuggestionSearch&& s); - SuggestionSearch& operator=(SuggestionSearch&& s); - ~SuggestionSearch(); - - /** Get a set of results for this search. - * - * @param start The begining of the range to get - * (offset of the first result). - * @param maxResults The maximum number of results to return - * (offset of last result from the start of range). - */ - const SuggestionResultSet getResults(int start, int maxResults) const; - - /** Get the number of estimated results for this suggestion search. - * - * As the name suggest, it is a estimation of the number of results. - */ - int getEstimatedMatches() const; - - private: // methods - SuggestionSearch(std::shared_ptr p_internalDb, const std::string& query); - - private: // data - std::shared_ptr mp_internalDb; - std::string m_query; - - friend class SuggestionSearcher; - -#ifdef ZIM_PRIVATE - public: - // Close Xapian db to force range based search - const void forceRangeSuggestion(); -#endif - -// Xapian based methods and data -#if defined(LIBZIM_WITH_XAPIAN) - private: // Xapian based methods - Xapian::Enquire& getEnquire() const; - - private: // Xapian based data - mutable std::unique_ptr mp_enquire; -#endif // LIBZIM_WITH_XAPIAN -}; - -/** - * The `SuggestionResultSet` represent a range of results corresponding to a `SuggestionSearch`. - * - * It mainly allows to get a iterator either based on an MSetIterator or a RangeIterator. - */ -class LIBZIM_API SuggestionResultSet -{ - public: - typedef SuggestionIterator iterator; - typedef Archive::EntryRange EntryRange; - - /** The begin iterator on the result range. */ - iterator begin() const; - - /** The end iterator on the result range. */ - iterator end() const; - - /** The size of the SearchResult (end()-begin()) */ - int size() const; - - private: // data - std::shared_ptr mp_internalDb; - std::shared_ptr mp_entryRange; - - private: - SuggestionResultSet(EntryRange entryRange); - - friend class SuggestionSearch; - -// Xapian based methods and data -#if defined(LIBZIM_WITH_XAPIAN) - - private: // Xapian based methods - SuggestionResultSet(std::shared_ptr p_internalDb, Xapian::MSet&& mset); - - private: // Xapian based data - std::shared_ptr mp_mset; - -#endif // LIBZIM_WITH_XAPIAN -}; - -} // namespace zim - -#endif // ZIM_SUGGESTION_H diff --git a/winlibs/include/zim/suggestion_iterator.h b/winlibs/include/zim/suggestion_iterator.h deleted file mode 100644 index 9af2dd6b5..000000000 --- a/winlibs/include/zim/suggestion_iterator.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2021 Maneesh P M - * Copyright (C) 2020 Matthieu Gautier - * Copyright (C) 2006 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_SUGGESTION_ITERATOR_H -#define ZIM_SUGGESTION_ITERATOR_H - -#include "archive.h" -#include - -namespace zim -{ -class SuggestionResultSet; -class SuggestionItem; -class SearchIterator; - -/** - * A interator on suggestion. - * - * Be aware that the referenced/pointed SuggestionItem is generated and stored - * in the iterator itself. - * Once the iterator is destructed or incremented/decremented, you must NOT - * use the SuggestionItem. - */ -class LIBZIM_API SuggestionIterator -{ - typedef Archive::iterator RangeIterator; - friend class SuggestionResultSet; - public: - /* SuggestionIterator is conceptually a bidirectional iterator. - * But std *LegayBidirectionalIterator* is also a *LegacyForwardIterator* and - * it would impose us that : - * > Given a and b, dereferenceable iterators of type It: - * > If a and b compare equal (a == b is contextually convertible to true) - * > then either they are both non-dereferenceable or *a and *b are references bound to the same object. - * and - * > the LegacyForwardIterator requirements requires dereference to return a reference. - * Which cannot be as we create the entry on demand. - * - * So we are stick with declaring ourselves at `input_iterator`. - */ - using iterator_category = std::input_iterator_tag; - using value_type = SuggestionItem; - using pointer = SuggestionItem*; - using reference = SuggestionItem&; - - SuggestionIterator() = delete; - SuggestionIterator(const SuggestionIterator& it); - SuggestionIterator& operator=(const SuggestionIterator& it); - SuggestionIterator(SuggestionIterator&& it); - SuggestionIterator& operator=(SuggestionIterator&& it); - ~SuggestionIterator(); - - bool operator== (const SuggestionIterator& it) const; - bool operator!= (const SuggestionIterator& it) const; - - SuggestionIterator& operator++(); - SuggestionIterator operator++(int); - SuggestionIterator& operator--(); - SuggestionIterator operator--(int); - - Entry getEntry() const; - - const SuggestionItem& operator*(); - const SuggestionItem* operator->(); - - private: // data - struct SuggestionInternalData; - std::unique_ptr mp_rangeIterator; - std::unique_ptr m_suggestionItem; - - private: // methods - SuggestionIterator(RangeIterator rangeIterator); - -// Xapian based methods and data -#if defined(LIBZIM_WITH_XAPIAN) -#ifdef ZIM_PRIVATE - public: - std::string getDbData() const; -#endif - private: // xapian based data - std::unique_ptr mp_internal; - - private: // xapian based methods - std::string getIndexPath() const; - std::string getIndexTitle() const; - std::string getIndexSnippet() const; - SuggestionIterator(SuggestionInternalData* internal_data); -#endif // LIBZIM_WITH_XAPIAN -}; - -class LIBZIM_API SuggestionItem -{ - public: // methods - SuggestionItem(std::string title, std::string path, std::string snippet = "") - : title(title), - path(path), - snippet(snippet) {} - - std::string getTitle() const { return title; } - std::string getPath() const { return path; } - std::string getSnippet() const { return snippet; } - - bool hasSnippet() const { return !snippet.empty(); } - - private: // data - std::string title; - std::string path; - std::string snippet; -}; - -} // namespace zim - -#endif // ZIM_SUGGESTION_ITERATOR_H diff --git a/winlibs/include/zim/tools.h b/winlibs/include/zim/tools.h deleted file mode 100644 index e5341fdec..000000000 --- a/winlibs/include/zim/tools.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2022 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_TOOLS_H -#define ZIM_TOOLS_H - -#include "zim.h" - -namespace zim { -#if defined(LIBZIM_WITH_XAPIAN) - - /** Helper function to set the icu data directory. - * - * On Android, we compile ICU without data integrated - * in the library. So android application needs to set - * the data directory where ICU can find its data. - */ - LIBZIM_API void setICUDataDirectory(const std::string& path); - -#endif -} - -#endif // ZIM_TOOLS_H diff --git a/winlibs/include/zim/uuid.h b/winlibs/include/zim/uuid.h deleted file mode 100644 index b8cec8482..000000000 --- a/winlibs/include/zim/uuid.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2021 Mannesh P M - * Copyright (C) 2018 Matthieu Gautier - * Copyright (C) 2009 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_UUID_H -#define ZIM_UUID_H - -#include "zim.h" - -#include -#include -#include -#include - -namespace zim -{ - struct LIBZIM_API Uuid - { - Uuid() - { - std::memset(data, 0, 16); - } - - Uuid(const char uuid[16]) - { - std::copy(uuid, uuid+16, data); - } - - static Uuid generate(std::string value = ""); - - bool operator== (const Uuid& other) const - { return std::equal(data, data+16, other.data); } - bool operator!= (const Uuid& other) const - { return !(*this == other); } - unsigned size() const { return 16; } - - explicit operator std::string() const; - - char data[16]; - }; - - LIBZIM_API std::ostream& operator<< (std::ostream& out, const Uuid& uuid); - -} - -#endif // ZIM_UUID_H diff --git a/winlibs/include/zim/version.h b/winlibs/include/zim/version.h deleted file mode 100644 index 55c4f4835..000000000 --- a/winlibs/include/zim/version.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2021 Emmanuel Engelhart - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_VERSION_H -#define ZIM_VERSION_H - -#include "zim.h" -#include -#include - -namespace zim -{ - typedef std::vector> LibVersions; - LIBZIM_API LibVersions getVersions(); - LIBZIM_API void printVersions(std::ostream& out = std::cout); -} - -#endif // ZIM_VERSION_H - diff --git a/winlibs/include/zim/writer/contentProvider.h b/winlibs/include/zim/writer/contentProvider.h deleted file mode 100644 index 19cd18cb1..000000000 --- a/winlibs/include/zim/writer/contentProvider.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2020 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_WRITER_CONTENTPROVIDER_H -#define ZIM_WRITER_CONTENTPROVIDER_H - -#include -#include -#include -#include - -namespace zim -{ -#ifdef _WIN32 - #define DEFAULTFD zim::windows::FD - namespace windows { -#else - #define DEFAULTFD zim::unix::FD - namespace unix { -#endif - class FD; - } - namespace writer - { - /** - * `ContentProvider` is an abstract class in charge of providing the content to - * add in the archive to the creator. - */ - class LIBZIM_API ContentProvider { - public: - virtual ~ContentProvider() = default; - /** - * The size of the content to add into the archive. - * - * @return the total size of the content. - */ - virtual zim::size_type getSize() const = 0; - - /** - * Return a blob to add to the archive. - * - * The returned blob doesn't have to represent the whole content. - * The feed method can return the whole content chunk by chunk or in - * one step. - * When the whole content has been returned, feed must return an empty blob - * (size == 0). - * - * This method will be called several times (at least twice) for - * each content to add. - * - * It is up to the implementation to manage correctly the data pointed by - * the returned blob. - * It may (re)use the same buffer between calls (rewriting its content), - * create a new buffer each time or make the blob point to a new region of - * a big buffer. - * It is up to the implementation to free any allocated memory. - * - * The data pointed by the blob must stay valid until the next call to feed. - * A call to feed ensure that the data returned by a previous call will not - * be used anymore. - */ - virtual Blob feed() = 0; - }; - - /** - * StringProvider provide the content stored in a string. - */ - class LIBZIM_API StringProvider : public ContentProvider { - public: - /** - * Create a provider using a string as content. - * The string content is copied and the reference don't have to be "keep" alive. - * - * @param content the content to serve. - */ - explicit StringProvider(const std::string& content) - : content(content), - feeded(false) - {} - zim::size_type getSize() const { return content.size(); } - Blob feed(); - - protected: - std::string content; - bool feeded; - }; - - /** - * SharedStringProvider provide the content stored in a shared string. - * - * It is mostly the same thing that `StringProvider` but use a shared_ptr - * to avoid copy. - */ - class LIBZIM_API SharedStringProvider : public ContentProvider { - public: - /** - * Create a provider using a string as content. - * The string content is not copied. - * - * @param content the content to serve. - */ - explicit SharedStringProvider(std::shared_ptr content) - : content(content), - feeded(false) - {} - zim::size_type getSize() const { return content->size(); } - Blob feed(); - - protected: - std::shared_ptr content; - bool feeded; - }; - - /** - * FileProvider provide the content stored in file. - */ - class LIBZIM_API FileProvider : public ContentProvider { - public: - /** - * Create a provider using file as content. - * - * @param filepath the path to the file to serve. - */ - explicit FileProvider(const std::string& filepath); - ~FileProvider(); - zim::size_type getSize() const { return size; } - Blob feed(); - - protected: - std::string filepath; - zim::size_type size; - - private: - std::unique_ptr buffer; - std::unique_ptr fd; - zim::offset_type offset; - }; - - } -} - -#undef DEFAULTFD - -#endif // ZIM_WRITER_CONTENTPROVIDER_H diff --git a/winlibs/include/zim/writer/creator.h b/winlibs/include/zim/writer/creator.h deleted file mode 100644 index b2cad01dd..000000000 --- a/winlibs/include/zim/writer/creator.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2017-2021 Matthieu Gautier - * Copyright (C) 2020 Veloman Yunkan - * Copyright (C) 2009 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_WRITER_CREATOR_H -#define ZIM_WRITER_CREATOR_H - -#include -#include -#include - -namespace zim -{ - class Fileheader; - namespace writer - { - class CreatorData; - - /** - * The `Creator` is responsible to create a zim file. - * - * Once the `Creator` is instantiated, it can be configured with the - * `config*` methods. - * Then the creation process must be started with `startZimCreation`. - * Elements of the zim file can be added using the `add*` methods. - * The final steps is to call `finishZimCreation`. - * - * During the creation of the zim file (and before the call to `finishZimCreation`), - * some values must be set using the `set*` methods. - * - * All `add*` methods and `finishZimCreation` can throw a exception. - * (most of the time zim::CreatorError child but not limited to) - * It is up to the user to catch this exception and handle the error. - * The current (documented) conditions when a exception is thrown are: - * - When a entry cannot be added (mainly because a entry with the same path has already been added) - * A `zim::InvalidEntry` will be thrown. The creator will still be in a valid state and the creation can continue. - * - An exception has been thrown in a worker thread. - * This exception will be catch and rethrown through a `zim::AsyncError`. - * The creator will be set in a invalid state and creation cannot continue. - * - The creator is in error state. - * A `zim::CreatorStateError` will be thrown. - * - Any exception thrown by user implementation itself. - * Note that this exception may be thrown in a worker thread and so being "catch" by a AsyncError. - * - Any other exception thrown for unknown reason. - * By default, creator status is not changed by thrown exception and creation should stop. - */ - class LIBZIM_API Creator - { - public: - /** - * Creator constructor. - * - * @param verbose If the creator print verbose information. - * @param comptype The compression algorithm to use. - */ - Creator(); - virtual ~Creator(); - - /** - * Configure the verbosity of the creator - * - * @param verbose if the creator print verbose information. - * @return a reference to itself. - */ - Creator& configVerbose(bool verbose); - - /** - * Configure the compression algorithm to use. - * - * @param comptype the compression algorithm to use. - * @return a reference to itself. - */ - Creator& configCompression(Compression compression); - - /** - * Set the size of the created clusters. - * - * The creator will try to create cluster with (uncompressed) size - * as close as possible to targetSize without exceeding that limit. - * If not possible, the only such case being an item larger than targetSize, - * a separated cluster will be allocated for that oversized item. - * - * Be carefull with this value. - * Bigger value means more content put together, so a better compression ratio. - * But it means also that more decompression has to be made when reading a blob. - * If you don't know which value to put, don't use this method and let libzim - * use the default value. - * - * @param targetSize The target size of a cluster (in byte). - * @return a reference to itself. - */ - Creator& configClusterSize(zim::size_type targetSize); - - /** - * Configure the fulltext indexing feature. - * - * @param indexing True if we must fulltext index the content. - * @param language Language to use for the indexation. - * @return a reference to itself. - */ - Creator& configIndexing(bool indexing, const std::string& language); - - /** - * Set the number of thread to use for the internal worker. - * - * @param nbWorkers The number of workers to use. - * @return a reference to itself. - */ - Creator& configNbWorkers(unsigned nbWorkers); - - /** - * Start the zim creation. - * - * The creator must have been configured before calling this method. - * - * @param filepath the path of the zim file to create. - */ - void startZimCreation(const std::string& filepath); - - /** - * Add a item to the archive. - * - * @param item The item to add. - */ - void addItem(std::shared_ptr item); - - /** - * Add a metadata to the archive. - * - * @param name the name of the metadata - * @param content the content of the metadata - * @param mimetype the mimetype of the metadata. - * Only used to detect if the metadata must be compressed or not. - */ - void addMetadata(const std::string& name, const std::string& content, const std::string& mimetype = "text/plain;charset=utf-8"); - - /** - * Add a metadata to the archive using a contentProvider instead of plain string. - * - * @param name the name of the metadata. - * @param provider the provider of the content of the metadata. - * @param mimetype the mimetype of the metadata. - * Only used to detect if the metadata must be compressed. - */ - void addMetadata(const std::string& name, std::unique_ptr provider, const std::string& mimetype = "text/plain;charset=utf-8"); - - /** - * Add illustration to the archive. - * - * @param size the size (width and height) of the illustration. - * @param content the content of the illustration (must be a png content) - */ - void addIllustration(unsigned int size, const std::string& content); - - /** - * Add illustration to the archive. - * - * @param size the size (width and height) of the illustration. - * @param provider the provider of the content of the illustration (must be a png content) - */ - void addIllustration(unsigned int size, std::unique_ptr provider); - - /** - * Add a redirection to the archive. - * - * Hints (especially FRONT_ARTICLE) can be used to put the redirection - * in the front articles list. - * By default, redirections are not front article. - * - * @param path the path of the redirection. - * @param title the title of the redirection. - * @param targetpath the path of the target of the redirection. - * @param hints hints associated to the redirection. - */ - void addRedirection( - const std::string& path, - const std::string& title, - const std::string& targetpath, - const Hints& hints = Hints()); - - /** - * Finalize the zim creation. - */ - void finishZimCreation(); - - /** - * Set the path of the main page. - * - * @param mainPath The path of the main page. - */ - void setMainPath(const std::string& mainPath) { m_mainPath = mainPath; } - - /** - * Set the uuid of the the archive. - * - * @param uuid The uuid of the archive. - */ - void setUuid(const zim::Uuid& uuid) { m_uuid = uuid; } - - private: - std::unique_ptr data; - - // configuration - bool m_verbose = false; - Compression m_compression = Compression::Zstd; - bool m_withIndex = false; - size_t m_clusterSize; - std::string m_indexingLanguage; - unsigned m_nbWorkers = 4; - - // zim data - std::string m_mainPath; - Uuid m_uuid = Uuid::generate(); - - void fillHeader(Fileheader* header) const; - void writeLastParts() const; - void checkError(); - }; - } - -} - -#endif // ZIM_WRITER_CREATOR_H diff --git a/winlibs/include/zim/writer/item.h b/winlibs/include/zim/writer/item.h deleted file mode 100644 index 8d916719b..000000000 --- a/winlibs/include/zim/writer/item.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2020-2021 Matthieu Gautier - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_WRITER_ITEM_H -#define ZIM_WRITER_ITEM_H - -#include -#include -#include -#include -#include - -#include - -namespace zim -{ - namespace writer - { - enum HintKeys { - COMPRESS, - FRONT_ARTICLE, - }; - using Hints = std::map; - - class ContentProvider; - - /** - * IndexData represent data of an Item to be indexed in the archive. - * - * This is a abstract class the user need to implement. - * (But default `Item::getIndexData` returns a default implementation - * for IndexData which works for html content.) - */ - class LIBZIM_API IndexData { - public: - using GeoPosition = std::tuple; - virtual ~IndexData() = default; - - /** - * If the IndexData actually has data to index. - * - * It can be used to create `IndexData` for all your content - * but discard some indexation based on some criteria. - * - * @return true if the item associated to this IndexData must be indexed. - */ - virtual bool hasIndexData() const = 0; - - /** - * The title to use when indexing the item. - * - * May be different than `Item::getTitle()`, even if most of the time - * it will be the same. - * - * @return the title to use. - */ - virtual std::string getTitle() const = 0; - - /** - * The content to use when indexing the item. - * - * This is probably the most important method of `IndexData`. - * Most item's contents are not applicable for a direct indexation. - * We don't want to index html tags or menu/footer of an article. - * This method allow you to return a currated plain text to indexe. - * - * @return the content to use. - */ - virtual std::string getContent() const = 0; - - /** - * The keywords to use when indexing the item. - * - * Return a set of keywords, separated by space for the content. - * Keywords are indexed using a higher score than text in `getContent` - * - * @return a string containing keywords separated by space. - */ - virtual std::string getKeywords() const = 0; - - /** - * The number of words in the content. - * - * This value is not directly used to index the content but it - * is stored in the xapian database, which may be used later to query - * articles. - * - * @return the number of words in the item. - */ - virtual uint32_t getWordCount() const = 0; - - /** - * The Geographical position of the subject covered by the item. - * (When applicable) - * - * @return a 3 tuple (true, latitude, longitude) if the item is - * about a geo positioned thing. - * a 3 tuple (false, _, _) if having a GeoPosition is not - * relevant. - */ - virtual GeoPosition getGeoPosition() const = 0; - }; - - /** - * Item represent data to be added to the archive. - * - * This is a abstract class the user need to implement. - * libzim provides `BasicItem`, `StringItem` and `FileItem` - * to simplify (or avoid) this reimplementation. - */ - class LIBZIM_API Item - { - public: - /** - * The path of the item. - * - * The path must be absolute. - * Path must be unique. - * - * @return the path of the item. - */ - virtual std::string getPath() const = 0; - - /** - * The title of the item. - * - * Item's title is indexed and is used for the suggestion system. - * Title don't have to be unique. - * - * @return the title of the item. - */ - virtual std::string getTitle() const = 0; - - /** - * The mimetype of the item. - * - * Mimetype is store within the content. - * It is also used to detect if the content must be compressed or not. - * - * @return the mimetype of the item. - */ - virtual std::string getMimeType() const = 0; - - /** - * The content provider of the item. - * - * The content provider is responsible to provide the content to the creator. - * The returned content provider must stay valid even after creator release - * its reference to the item. - * - * This method will be called once by libzim, in the main thread - * (but will be used in a different thread). - * The default IndexData will also call this method once (more) - * in the main thread (and use it in another thread). - * - * @return the contentProvider of the item. - */ - virtual std::unique_ptr getContentProvider() const = 0; - - /** - * The index data of the item. - * - * The index data is the data to index. (May be different from the content - * to store). - * The returned index data must stay valid even after creator release - * its reference to the item. - * This method will be called once by libzim if it is compiled with xapian - * (and is configured to index data). - * - * The returned IndexData will be used as source to index the item. - * If you don't want the item to be indexed, you can return a nullptr here - * or return a valid IndexData pointer which will return false to `hasIndexData`. - * - * If you don't implement this method, a default implementation will be used. - * The default implementation first checks for the mimetype and if the mimetype - * contains `text/html` it will use a contentProvider to get the content to index. - * The contentProvider will be created in the main thread but the data reading and - * parsing will occur in a different thread. - * - * All methods of `IndexData` will be called in a different (same) thread. - * - * @return the indexData of the item. - * May return a nullptr if there is no indexData. - */ - virtual std::shared_ptr getIndexData() const; - - /** - * Hints to help the creator takes decision about the item. - * - * For now two hints are supported: - * - COMPRESS: Can be used to force the creator to put the item content - * in a compressed cluster (if true) or not (if false). - * If the hint is not provided, the decision is taken based on the - * mimetype (textual or binary content ?) - * - FRONT_ARTICLE: Can (Should) be used to specify if the item is - * a front article or not. - * If the hint is not provided, the decision is taken based on the - * mimetype (html or not ?) - * - * @return A list of hints. - */ - virtual Hints getHints() const; - - /** - * Returns the getHints() amended with default values based on mimetypes. - */ - Hints getAmendedHints() const; - virtual ~Item() = default; - }; - - /** - * A BasicItem is a partial implementation of a Item. - * - * `BasicItem` provides a basic implementation for everything about an `Item` - * but the actual content of the item. - */ - class LIBZIM_API BasicItem : public Item - { - public: - /** - * Create a BasicItem with the given path, mimetype and title. - * - * @param path the path of the item. - * @param mimetype the mimetype of the item. - * @param title the title of the item. - */ - BasicItem(const std::string& path, const std::string& mimetype, const std::string& title, Hints hints) - : path(path), - mimetype(mimetype), - title(title), - hints(hints) - {} - - std::string getPath() const { return path; } - std::string getTitle() const { return title; } - std::string getMimeType() const { return mimetype; } - Hints getHints() const { return hints; } - - protected: - std::string path; - std::string mimetype; - std::string title; - Hints hints; - }; - - /** - * A `StringItem` is a full implemented item where the content is stored in a string. - */ - class LIBZIM_API StringItem : public BasicItem, public std::enable_shared_from_this - { - public: - /** - * Create a StringItem with the given path, mimetype, title and content. - * - * The parameters are the ones of the private constructor. - * - * @param path the path of the item. - * @param mimetype the mimetype of the item. - * @param title the title of the item. - * @param content the content of the item. - */ - template - static std::shared_ptr create(Ts&&... params) { - return std::shared_ptr(new StringItem(std::forward(params)...)); - } - - std::unique_ptr getContentProvider() const; - - protected: - std::string content; - - private: - StringItem(const std::string& path, const std::string& mimetype, - const std::string& title, Hints hints, const std::string& content) - : BasicItem(path, mimetype, title, hints), - content(content) - {} - }; - - /** - * A `FileItem` is a full implemented item where the content is file. - */ - class LIBZIM_API FileItem : public BasicItem - { - public: - /** - * Create a FileItem with the given path, mimetype, title and filenpath. - * - * @param path the path of the item. - * @param mimetype the mimetype of the item. - * @param title the title of the item. - * @param filepath the path of the file in the filesystem. - */ - FileItem(const std::string& path, const std::string& mimetype, - const std::string& title, Hints hints, const std::string& filepath) - : BasicItem(path, mimetype, title, hints), - filepath(filepath) - {} - - std::unique_ptr getContentProvider() const; - - protected: - std::string filepath; - }; - - } -} - -#endif // ZIM_WRITER_ITEM_H diff --git a/winlibs/include/zim/zim.h b/winlibs/include/zim/zim.h deleted file mode 100644 index dd6b97ba8..000000000 --- a/winlibs/include/zim/zim.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2020-2021 Veloman Yunkan - * Copyright (C) 2018-2020 Matthieu Gautier - * Copyright (C) 2006 Tommi Maekitalo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and - * NON-INFRINGEMENT. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ZIM_ZIM_H -#define ZIM_ZIM_H - -#include - -#ifdef __GNUC__ -#define DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) -#define DEPRECATED __declspec(deprecated) -#else -#praga message("WARNING: You need to implement DEPRECATED for this compiler") -#define DEPRECATED -#endif - -#include - -#if defined(_WIN32) && defined(LIBZIM_EXPORT_DLL) - #define LIBZIM_API __declspec(dllexport) -#elif defined(_WIN32) && 1 - #define LIBZIM_API __declspec(dllimport) -#else - #define LIBZIM_API -#endif - -namespace zim -{ - // An index of an entry (in a zim file) - typedef uint32_t entry_index_type; - - // An index of an cluster (in a zim file) - typedef uint32_t cluster_index_type; - - // An index of a blog (in a cluster) - typedef uint32_t blob_index_type; - - // The size of something (entry, zim, cluster, blob, ...) - typedef uint64_t size_type; - - // An offset. - typedef uint64_t offset_type; - - enum class Compression - { - None = 1, - - // intermediate values correspond to compression - // methods that are no longer supported - - Zstd = 5 - }; - - static const char MimeHtmlTemplate[] = "text/x-zim-htmltemplate"; - - /** - * Various types of integrity checks performed by `zim::validate()`. - */ - enum class IntegrityCheck - { - /** - * Validates the checksum of the ZIM file. - */ - CHECKSUM, - - /** - * Checks that offsets in UrlPtrList are valid. - */ - DIRENT_PTRS, - - /** - * Checks that dirents are properly sorted. - */ - DIRENT_ORDER, - - /** - * Checks that entries in the title index are valid and properly sorted. - */ - TITLE_INDEX, - - /** - * Checks that offsets in ClusterPtrList are valid. - */ - CLUSTER_PTRS, - - /** - * Checks that mime-type values in dirents are valid. - */ - DIRENT_MIMETYPES, - - //////////////////////////////////////////////////////////////////////////// - // End of integrity check types. - // COUNT must be the last one and denotes the count of all checks - //////////////////////////////////////////////////////////////////////////// - - /** - * `COUNT` is not a valid integrity check type. It exists to tell the - * number of all supported integrity checks. - */ - COUNT - }; -} - -#endif // ZIM_ZIM_H - diff --git a/winlibs/include/zim/zim_config.h b/winlibs/include/zim/zim_config.h deleted file mode 100644 index 66124d7c9..000000000 --- a/winlibs/include/zim/zim_config.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Autogenerated by the Meson build system. - * Do not edit, your changes will be lost. - */ - -#pragma once - -#define LIBZIM_EXPORT_DLL - -#define LIBZIM_VERSION "9.0.0" - -#undef LIBZIM_WITH_XAPIAN - diff --git a/winlibs/include/zlib.h b/winlibs/include/zlib.h deleted file mode 100644 index 8d4b932ea..000000000 --- a/winlibs/include/zlib.h +++ /dev/null @@ -1,1938 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.3.1, January 22nd, 2024 - - Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.3.1" -#define ZLIB_VERNUM 0x1310 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 3 -#define ZLIB_VER_REVISION 1 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip and raw deflate streams in - memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in the case of corrupted input. -*/ - -typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); -typedef void (*free_func)(voidpf opaque, voidpf address); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte will go here */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text - for deflate, or the decoding state for inflate */ - uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. In that case, zlib is thread-safe. When zalloc and zfree are - Z_NULL on entry to the initialization function, they are set to internal - routines that use the standard library functions malloc() and free(). - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use by the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field for deflate() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion(void); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. total_in, total_out, adler, and msg are initialized. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary. Some output may be provided even if - flush is zero. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. See deflatePending(), - which can be used if desired to determine whether or not there is more output - in that case. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed - codes block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six when the flush marker begins, in order to avoid - repeated flush markers upon calling deflate() again when avail_out == 0. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this - function must be called again with Z_FINISH and more output space (updated - avail_out) but no more input data, until it returns with Z_STREAM_END or an - error. After deflate has returned Z_STREAM_END, the only possible operations - on the stream are deflateReset or deflateEnd. - - Z_FINISH can be used in the first deflate call after deflateInit if all the - compression is to be done in a single step. In order to complete in one - call, avail_out must be at least the value returned by deflateBound (see - below). Then deflate is guaranteed to return Z_STREAM_END. If not enough - output space is provided, deflate will not return Z_STREAM_END, and it must - be called again as described above. - - deflate() sets strm->adler to the Adler-32 checksum of all input read - so far (that is, total_in bytes). If a gzip stream is being generated, then - strm->adler will be the CRC-32 checksum of the input read so far. (See - deflateInit2 below.) - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is - considered binary. This field is only for information purposes and does not - affect the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL or the state was inadvertently written over - by the application), or Z_BUF_ERROR if no progress is possible (for example - avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and - deflate() can be called again with more input and more output space to - continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit(z_streamp strm); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. In the current version of inflate, the provided input is not - read or consumed. The allocation of a sliding window will be deferred to - the first call of inflate (if the decompression does not complete on the - first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. total_in, total_out, adler, and - msg are initialized. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression. - Actual decompression will be done by inflate(). So next_in, and avail_in, - next_out, and avail_out are unused and unchanged. The current - implementation of inflateInit() does not process any header information -- - that is deferred until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), then next_in and avail_in are updated - accordingly, and processing will resume at this point for the next call of - inflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. If the - caller of inflate() does not provide both available input and available - output space, it is possible that there will be no progress made. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - To assist in this, on return inflate() always sets strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed Adler-32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained unless inflateGetHeader() is used. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - produced so far. The CRC-32 is checked against the gzip trailer, as is the - uncompressed length, modulo 2^32. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value, in which case strm->msg points to a string with a more specific - error), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL, or the state was inadvertently written over - by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR - if no progress was possible or if there was not enough room in the output - buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is to be attempted. -*/ - - -ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state - was inconsistent. -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy); - - This is another version of deflateInit with more compression options. The - fields zalloc, zfree and opaque must be initialized before by the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - For the current implementation of deflate(), a windowBits value of 8 (a - window size of 256 bytes) is not supported. As a result, a request for 8 - will result in 9 (a 512-byte window). In that case, providing 8 to - inflateInit2() will result in an error when the zlib header with 9 is - checked against the initialization of inflate(). The remedy is to not use 8 - with deflateInit2() with this initialization, or at least in that case use 9 - with inflateInit2(). - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute a check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to the appropriate value, - if the operating system was determined at compile time. If a gzip stream is - being written, strm->adler is a CRC-32 instead of an Adler-32. - - For raw deflate or gzip encoding, a request for a 256-byte window is - rejected as invalid, since only the zlib header provides a means of - transmitting the window size to the decompressor. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, - const Bytef *dictionary, - uInt dictLength); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the Adler-32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler-32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - Adler-32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, - Bytef *dictionary, - uInt *dictLength); -/* - Returns the sliding dictionary being maintained by deflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If deflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similarly, if dictLength is Z_NULL, then it is not set. - - deflateGetDictionary() may return a length less than the window size, even - when more than the window size in input has been provided. It may return up - to 258 bytes less in that case, due to how zlib's implementation of deflate - manages the sliding window and lookahead for matches, where matches can be - up to 258 bytes long. If the application needs the last window-size bytes of - input, then that would need to be saved by the application outside of zlib. - - deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, - z_streamp source); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset(z_streamp strm); -/* - This function is equivalent to deflateEnd followed by deflateInit, but - does not free and reallocate the internal compression state. The stream - will leave the compression level and any other attributes that may have been - set unchanged. total_in, total_out, adler, and msg are initialized. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams(z_streamp strm, - int level, - int strategy); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2(). This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression approach (which is a function of the level) or the - strategy is changed, and if there have been any deflate() calls since the - state was initialized or reset, then the input available so far is - compressed with the old level and strategy using deflate(strm, Z_BLOCK). - There are three approaches for the compression levels 0, 1..3, and 4..9 - respectively. The new level and strategy will take effect at the next call - of deflate(). - - If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does - not have enough output space to complete, then the parameter change will not - take effect. In this case, deflateParams() can be called again with the - same parameters and more output space to try again. - - In order to assure a change in the parameters on the first try, the - deflate stream should be flushed using deflate() with Z_BLOCK or other flush - request until strm.avail_out is not zero, before calling deflateParams(). - Then no more input data should be provided before the deflateParams() call. - If this is done, the old level and strategy will be applied to the data - compressed before deflateParams(), and the new level and strategy will be - applied to the data compressed after deflateParams(). - - deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream - state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if - there was not enough output space to complete the compression of the - available input data before a change in the strategy or approach. Note that - in the case of a Z_BUF_ERROR, the parameters are not changed. A return - value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be - retried with more output space. -*/ - -ZEXTERN int ZEXPORT deflateTune(z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, - uLong sourceLen); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending(z_streamp strm, - unsigned *pending, - int *bits); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, - int bits, - int value); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, - gz_headerp head); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to the current operating system, with no - extra, name, or comment fields. The gzip header is returned to the default - state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, - int windowBits); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an Adler-32 or a CRC-32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will *not* automatically decode concatenated gzip members. - inflate() will return Z_STREAM_END at the end of the gzip member. The state - would need to be reset to continue decoding a subsequent gzip member. This - *must* be done if there is more data after a gzip member, in order for the - decompression to be compliant with the gzip standard (RFC 1952). - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, - const Bytef *dictionary, - uInt dictLength); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler-32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler-32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, - Bytef *dictionary, - uInt *dictLength); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similarly, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync(z_streamp strm); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current value of total_in - which indicates where valid compressed data was found. In the error case, - the application may repeatedly call inflateSync, providing more input each - time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, - z_streamp source); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset(z_streamp strm); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - total_in, total_out, adler, and msg are initialized. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, - int windowBits); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. If the window size is changed, then the - memory allocated for the window is freed, and the window will be reallocated - by inflate() if needed. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, - int bits, - int value); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark(z_streamp strm); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above, or -65536 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, - gz_headerp head); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, - unsigned char FAR *window); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func)(void FAR *, - z_const unsigned char FAR * FAR *); -typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); - -ZEXTERN int ZEXPORT inflateBack(z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the default - behavior of inflate(), which expects a zlib header and trailer around the - deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero -- buf is ignored in that - case -- and inflateBack() will return a buffer error. inflateBack() will - call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. - out() should return zero on success, or non-zero on failure. If out() - returns non-zero, inflateBack() will return with an error. Neither in() nor - out() are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags(void); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: ZLIB_DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. compress() is equivalent to compress2() with a level - parameter of Z_DEFAULT_COMPRESSION. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed data. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - -ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen); -/* - Same as uncompress, except that sourceLen is a pointer, where the - length of the source is *sourceLen. On return, *sourceLen is the number of - source bytes consumed. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); - - Open the gzip (.gz) file at path for reading and decompressing, or - compressing and writing. The mode parameter is as in fopen ("rb" or "wb") - but can also include a compression level ("wb9") or a strategy: 'f' for - filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", - 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression - as in "wb9F". (See the description of deflateInit2 for more information - about the strategy parameter.) 'T' will request transparent writing or - appending with no compression and not using the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); -/* - Associate a gzFile with the file descriptor fd. File descriptors are - obtained from calls like open, dup, creat, pipe or fileno (if the file has - been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); -/* - Set the internal buffer size used by this library's functions for file to - size. The default buffer size is 8192 bytes. This function must be called - after gzopen() or gzdopen(), and before any other calls that read or write - the file. The buffer memory allocation is always deferred to the first read - or write. Three times that size in buffer space is allocated. A larger - buffer size of, for example, 64K or 128K bytes will noticeably increase the - speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); -/* - Dynamically update the compression level and strategy for file. See the - description of deflateInit2 for the meaning of these parameters. Previously - provided data is flushed before applying the parameter changes. - - gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not - opened for writing, Z_ERRNO if there is an error writing the flushed data, - or Z_MEM_ERROR if there is a memory allocation error. -*/ - -ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); -/* - Read and decompress up to len uncompressed bytes from file into buf. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. If len is too large to fit in an int, - then nothing is read, -1 is returned, and the error state is set to - Z_STREAM_ERROR. -*/ - -ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, - gzFile file); -/* - Read and decompress up to nitems items of size size from file into buf, - otherwise operating as gzread() does. This duplicates the interface of - stdio's fread(), with size_t request and return types. If the library - defines size_t, then z_size_t is identical to size_t. If not, then z_size_t - is an unsigned integer type that can contain a pointer. - - gzfread() returns the number of full items read of size size, or zero if - the end of the file was reached and a full item could not be read, or if - there was an error. gzerror() must be consulted if zero is returned in - order to determine if there was an error. If the multiplication of size and - nitems overflows, i.e. the product does not fit in a z_size_t, then nothing - is read, zero is returned, and the error state is set to Z_STREAM_ERROR. - - In the event that the end of file is reached and only a partial item is - available at the end, i.e. the remaining uncompressed data length is not a - multiple of size, then the final partial item is nevertheless read into buf - and the end-of-file flag is set. The length of the partial item read is not - provided, but could be inferred from the result of gztell(). This behavior - is the same as the behavior of fread() implementations in common libraries, - but it prevents the direct use of gzfread() to read a concurrently written - file, resetting and retrying on end-of-file, when size is not 1. -*/ - -ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); -/* - Compress and write the len uncompressed bytes at buf to file. gzwrite - returns the number of uncompressed bytes written or 0 in case of error. -*/ - -ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, - z_size_t nitems, gzFile file); -/* - Compress and write nitems items of size size from buf to file, duplicating - the interface of stdio's fwrite(), with size_t request and return types. If - the library defines size_t, then z_size_t is identical to size_t. If not, - then z_size_t is an unsigned integer type that can contain a pointer. - - gzfwrite() returns the number of full items written of size size, or zero - if there was an error. If the multiplication of size and nitems overflows, - i.e. the product does not fit in a z_size_t, then nothing is written, zero - is returned, and the error state is set to Z_STREAM_ERROR. -*/ - -ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); -/* - Convert, format, compress, and write the arguments (...) to file under - control of the string format, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or a negative zlib error code in case - of error. The number of uncompressed bytes written is limited to 8191, or - one less than the buffer size given to gzbuffer(). The caller should assure - that this limit is not exceeded. If it is exceeded, then gzprintf() will - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf(), - because the secure snprintf() or vsnprintf() functions were not available. - This can be determined using zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); -/* - Compress and write the given null-terminated string s to file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); -/* - Read and decompress bytes from file into buf, until len-1 characters are - read, or until a newline character is read and transferred to buf, or an - end-of-file condition is encountered. If any characters are read or if len - is one, the string is terminated with a null character. If no characters - are read due to an end-of-file or len is less than one, then the buffer is - left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc(gzFile file, int c); -/* - Compress and write c, converted to an unsigned char, into file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc(gzFile file); -/* - Read and decompress one byte from file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); -/* - Push c back onto the stream for file to be read as the first character on - the next read. At least one character of push-back is always allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); -/* - Flush all pending output to file. The parameter flush is as in the - deflate() function. The return value is the zlib error number (see function - gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatenated gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, - z_off_t offset, int whence); - - Set the starting position to offset relative to whence for the next gzread - or gzwrite on file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind(gzFile file); -/* - Rewind file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell(gzFile file); - - Return the starting position for the next gzread or gzwrite on file. - This position represents a number of bytes in the uncompressed data stream, - and is zero when starting, even if appending or reading a gzip stream from - the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); - - Return the current compressed (actual) read or write offset of file. This - offset includes the count of bytes that precede the gzip stream, for example - when appending or when using gzdopen() for reading. When reading, the - offset does not include as yet unused buffered input. This information can - be used for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof(gzFile file); -/* - Return true (1) if the end-of-file indicator for file has been set while - reading, false (0) otherwise. Note that the end-of-file indicator is set - only if the read tried to go past the end of the input, but came up short. - Therefore, just like feof(), gzeof() may return false even if there is no - more data to read, in the event that the last read request was for the exact - number of bytes remaining in the input file. This will happen if the input - file size is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect(gzFile file); -/* - Return true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose(gzFile file); -/* - Flush all pending output for file, if necessary, close file and - deallocate the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r(gzFile file); -ZEXTERN int ZEXPORT gzclose_w(gzFile file); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); -/* - Return the error message for the last error which occurred on file. - errnum is set to zlib error number. If an error occurred in the file system - and not in the compression library, errnum is set to Z_ERRNO and the - application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr(gzFile file); -/* - Clear the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. An Adler-32 value is in the range of a 32-bit - unsigned integer. If buf is Z_NULL, this function returns the required - initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, - z_size_t len); -/* - Same as adler32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, - z_off_t len2); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. - If buf is Z_NULL, this function returns the required initial value for the - crc. Pre- and post-conditioning (one's complement) is performed within this - function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, - z_size_t len); -/* - Same as crc32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. len2 must be non-negative. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); - - Return the operator corresponding to length len2, to be used with - crc32_combine_op(). len2 must be non-negative. -*/ - -ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); -/* - Give the same result as crc32_combine(), using op in place of len2. op is - is generated from len2 by crc32_combine_gen(). This will be faster than - crc32_combine() if the generated op is used more than once. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, - const char *version, int stream_size); -ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, - const char *version, int stream_size); -ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size); -ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, - const char *version, int stream_size); -ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size); -#ifdef Z_PREFIX_SET -# define z_deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define z_inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#else -# define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#endif - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); - ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); - ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); - ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); - ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); - ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); - ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# define z_crc32_combine_gen z_crc32_combine_gen64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# define crc32_combine_gen crc32_combine_gen64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); - ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); - ZEXTERN z_off_t ZEXPORT gztell64(gzFile); - ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); - ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); - ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); - ZEXTERN z_off_t ZEXPORT gztell(gzFile); - ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); - ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); - ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); - -#endif /* !Z_SOLO */ - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError(int); -ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); -ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); -ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); -ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); -ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); -#if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, - const char *mode); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, - const char *format, - va_list va); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/winlibs/include/zstd.h b/winlibs/include/zstd.h deleted file mode 100644 index 1b1bfde98..000000000 --- a/winlibs/include/zstd.h +++ /dev/null @@ -1,3105 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#if defined (__cplusplus) -extern "C" { -#endif - -#ifndef ZSTD_H_235446 -#define ZSTD_H_235446 - - /* ====== Dependencies ======*/ - #include /* INT_MAX */ - #include /* size_t */ - - - /* ===== ZSTDLIB_API : control library symbols visibility ===== */ - #ifndef ZSTDLIB_VISIBLE - /* Backwards compatibility with old macro name */ - #ifdef ZSTDLIB_VISIBILITY - #define ZSTDLIB_VISIBLE ZSTDLIB_VISIBILITY - #elif defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && !defined( __MINGW32__ ) - #define ZSTDLIB_VISIBLE __attribute__( ( visibility( "default" ) ) ) - #else - #define ZSTDLIB_VISIBLE - #endif - #endif - - #ifndef ZSTDLIB_HIDDEN - #if defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && !defined( __MINGW32__ ) - #define ZSTDLIB_HIDDEN __attribute__( ( visibility( "hidden" ) ) ) - #else - #define ZSTDLIB_HIDDEN - #endif - #endif - - #if defined( ZSTD_DLL_EXPORT ) && ( ZSTD_DLL_EXPORT == 1 ) - #define ZSTDLIB_API __declspec( dllexport ) ZSTDLIB_VISIBLE - #elif 1 - #define ZSTDLIB_API \ - __declspec( dllimport ) \ - ZSTDLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ - #else - #define ZSTDLIB_API ZSTDLIB_VISIBLE - #endif - - /* Deprecation warnings : - * Should these warnings be a problem, it is generally possible to disable them, - * typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual. - * Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS. - */ - #ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS - #define ZSTD_DEPRECATED( message ) /* disable deprecation warnings */ - #else - #if defined( __cplusplus ) && ( __cplusplus >= 201402 ) /* C++14 or greater */ - #define ZSTD_DEPRECATED( message ) [[deprecated( message )]] - #elif ( defined( GNUC ) && ( GNUC > 4 || ( GNUC == 4 && GNUC_MINOR >= 5 ) ) ) || defined( __clang__ ) - #define ZSTD_DEPRECATED( message ) __attribute__( ( deprecated( message ) ) ) - #elif defined( __GNUC__ ) && ( __GNUC__ >= 3 ) - #define ZSTD_DEPRECATED( message ) __attribute__( ( deprecated ) ) - #elif defined( _MSC_VER ) - #define ZSTD_DEPRECATED( message ) __declspec( deprecated( message ) ) - #else - #pragma message( "WARNING: You need to implement ZSTD_DEPRECATED for this compiler" ) - #define ZSTD_DEPRECATED( message ) - #endif - #endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */ - - - /******************************************************************************* - Introduction - - zstd, short for Zstandard, is a fast lossless compression algorithm, targeting - real-time compression scenarios at zlib-level and better compression ratios. - The zstd compression library provides in-memory compression and decompression - functions. - - The library supports regular compression levels from 1 up to ZSTD_maxCLevel(), - which is currently 22. Levels >= 20, labeled `--ultra`, should be used with - caution, as they require more memory. The library also offers negative - compression levels, which extend the range of speed vs. ratio preferences. - The lower the level, the faster the speed (at the cost of compression). - - Compression can be done in: - - a single step (described as Simple API) - - a single step, reusing a context (described as Explicit context) - - unbounded multiple steps (described as Streaming compression) - - The compression ratio achievable on small data can be highly improved using - a dictionary. Dictionary compression can be performed in: - - a single step (described as Simple dictionary API) - - a single step, reusing a dictionary (described as Bulk-processing - dictionary API) - - Advanced experimental functions can be accessed using - `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h. - - Advanced experimental APIs should never be used with a dynamically-linked - library. They are not "stable"; their definitions or signatures may change in - the future. Only static linking is allowed. -*******************************************************************************/ - - /*------ Version ------*/ - #define ZSTD_VERSION_MAJOR 1 - #define ZSTD_VERSION_MINOR 5 - #define ZSTD_VERSION_RELEASE 5 - #define ZSTD_VERSION_NUMBER ( ZSTD_VERSION_MAJOR * 100 * 100 + ZSTD_VERSION_MINOR * 100 + ZSTD_VERSION_RELEASE ) - -/*! ZSTD_versionNumber() : - * Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */ -ZSTDLIB_API unsigned ZSTD_versionNumber( void ); - - #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE - #define ZSTD_QUOTE( str ) #str - #define ZSTD_EXPAND_AND_QUOTE( str ) ZSTD_QUOTE( str ) - #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE( ZSTD_LIB_VERSION ) - -/*! ZSTD_versionString() : - * Return runtime library version, like "1.4.5". Requires v1.3.0+. */ -ZSTDLIB_API const char * ZSTD_versionString( void ); - - /* ************************************* - * Default constant - ***************************************/ - #ifndef ZSTD_CLEVEL_DEFAULT - #define ZSTD_CLEVEL_DEFAULT 3 - #endif - - /* ************************************* - * Constants - ***************************************/ - - /* All magic numbers are supposed read/written to/from files/memory using little-endian convention */ - #define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */ - #define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */ - #define ZSTD_MAGIC_SKIPPABLE_START \ - 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */ - #define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0 - - #define ZSTD_BLOCKSIZELOG_MAX 17 - #define ZSTD_BLOCKSIZE_MAX ( 1 << ZSTD_BLOCKSIZELOG_MAX ) - - -/*************************************** -* Simple API -***************************************/ -/*! ZSTD_compress() : - * Compresses `src` content as a single zstd compressed frame into already allocated `dst`. - * NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have - * enough space to successfully compress the data. - * @return : compressed size written into `dst` (<= `dstCapacity), - * or an error code if it fails (which can be tested using ZSTD_isError()). */ -ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - int compressionLevel); - -/*! ZSTD_decompress() : - * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. - * `dstCapacity` is an upper bound of originalSize to regenerate. - * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. - * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), - * or an errorCode if it fails (which can be tested using ZSTD_isError()). */ -ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity, - const void* src, size_t compressedSize); - -/*! ZSTD_getFrameContentSize() : requires v1.3.0+ - * `src` should point to the start of a ZSTD encoded frame. - * `srcSize` must be at least as large as the frame header. - * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough. - * @return : - decompressed size of `src` frame content, if known - * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined - * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) - * note 1 : a 0 return value means the frame is valid but "empty". - * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode. - * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - * In which case, it's necessary to use streaming mode to decompress data. - * Optionally, application can rely on some implicit limit, - * as ZSTD_decompress() only needs an upper bound of decompressed size. - * (For example, data could be necessarily cut into blocks <= 16 KB). - * note 3 : decompressed size is always present when compression is completed using single-pass functions, - * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict(). - * note 4 : decompressed size can be very large (64-bits value), - * potentially larger than what local system can handle as a single memory segment. - * In which case, it's necessary to use streaming mode to decompress data. - * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified. - * Always ensure return value fits within application's authorized limits. - * Each application can set its own limits. - * note 6 : This function replaces ZSTD_getDecompressedSize() */ -#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1) -#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2) -ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize); - -/*! ZSTD_getDecompressedSize() : - * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize(). - * Both functions work the same way, but ZSTD_getDecompressedSize() blends - * "empty", "unknown" and "error" results to the same return value (0), - * while ZSTD_getFrameContentSize() gives them separate return values. - * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */ -ZSTD_DEPRECATED( "Replaced by ZSTD_getFrameContentSize" ) -ZSTDLIB_API -unsigned long long ZSTD_getDecompressedSize( const void * src, size_t srcSize ); - -/*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+ - * `src` should point to the start of a ZSTD frame or skippable frame. - * `srcSize` must be >= first frame size - * @return : the compressed size of the first frame starting at `src`, - * suitable to pass as `srcSize` to `ZSTD_decompress` or similar, - * or an error code if input is invalid */ -ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize); - - -/*====== Helper functions ======*/ -/* ZSTD_compressBound() : - * maximum compressed size in worst case single-pass scenario. - * When invoking `ZSTD_compress()` or any other one-pass compression function, - * it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize) - * as it eliminates one potential failure scenario, - * aka not enough room in dst buffer to write the compressed frame. - * Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE . - * In which case, ZSTD_compressBound() will return an error code - * which can be tested using ZSTD_isError(). - * - * ZSTD_COMPRESSBOUND() : - * same as ZSTD_compressBound(), but as a macro. - * It can be used to produce constants, which can be useful for static allocation, - * for example to size a static array on stack. - * Will produce constant value 0 if srcSize too large. - */ - #define ZSTD_MAX_INPUT_SIZE ( ( sizeof( size_t ) == 8 ) ? 0xFF00FF00FF00FF00LLU : 0xFF00FF00U ) - #define ZSTD_COMPRESSBOUND( srcSize ) \ - ( ( (size_t)( srcSize ) >= ZSTD_MAX_INPUT_SIZE ) ? 0 : \ - ( srcSize ) + ( ( srcSize ) >> 8 ) \ - + ( ( ( srcSize ) < ( 128 << 10 ) ) ? \ - ( ( ( 128 << 10 ) - ( srcSize ) ) >> 11 ) /* margin, from 64 to 0 */ : \ - 0 ) ) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */ -ZSTDLIB_API size_t -ZSTD_compressBound( size_t srcSize ); /*!< maximum compressed size in worst case single-pass scenario */ -/* ZSTD_isError() : - * Most ZSTD_* functions returning a size_t value can be tested for error, - * using ZSTD_isError(). - * @return 1 if error, 0 otherwise - */ -ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */ -ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */ -ZSTDLIB_API int ZSTD_minCLevel( void ); /*!< minimum negative compression level allowed, requires v1.4.0+ */ -ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */ -ZSTDLIB_API int -ZSTD_defaultCLevel( void ); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */ - - -/*************************************** -* Explicit context -***************************************/ -/*= Compression context - * When compressing many times, - * it is recommended to allocate a context just once, - * and re-use it for each successive compression operation. - * This will make workload friendlier for system's memory. - * Note : re-using context is just a speed / resource optimization. - * It doesn't change the compression ratio, which remains identical. - * Note 2 : In multi-threaded environments, - * use one different context per thread for parallel execution. - */ -typedef struct ZSTD_CCtx_s ZSTD_CCtx; -ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void); -ZSTDLIB_API size_t ZSTD_freeCCtx( ZSTD_CCtx * cctx ); /* accept NULL pointer */ - -/*! ZSTD_compressCCtx() : - * Same as ZSTD_compress(), using an explicit ZSTD_CCtx. - * Important : in order to behave similarly to `ZSTD_compress()`, - * this function compresses at requested compression level, - * __ignoring any other parameter__ . - * If any advanced parameter was set using the advanced API, - * they will all be reset. Only `compressionLevel` remains. - */ -ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - int compressionLevel); - -/*= Decompression context - * When decompressing many times, - * it is recommended to allocate a context only once, - * and re-use it for each successive compression operation. - * This will make workload friendlier for system's memory. - * Use one context per thread for parallel execution. */ -typedef struct ZSTD_DCtx_s ZSTD_DCtx; -ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void); -ZSTDLIB_API size_t ZSTD_freeDCtx( ZSTD_DCtx * dctx ); /* accept NULL pointer */ - -/*! ZSTD_decompressDCtx() : - * Same as ZSTD_decompress(), - * requires an allocated ZSTD_DCtx. - * Compatible with sticky parameters. - */ -ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize); - - -/********************************************* -* Advanced compression API (Requires v1.4.0+) -**********************************************/ - -/* API design : - * Parameters are pushed one by one into an existing context, - * using ZSTD_CCtx_set*() functions. - * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame. - * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` ! - * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ . - * - * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset(). - * - * This API supersedes all other "advanced" API entry points in the experimental section. - * In the future, we expect to remove from experimental API entry points which are redundant with this API. - */ - - -/* Compression strategies, listed from fastest to strongest */ -typedef enum { ZSTD_fast=1, - ZSTD_dfast=2, - ZSTD_greedy=3, - ZSTD_lazy=4, - ZSTD_lazy2=5, - ZSTD_btlazy2=6, - ZSTD_btopt=7, - ZSTD_btultra=8, - ZSTD_btultra2=9 - /* note : new strategies _might_ be added in the future. - Only the order (from fast to strong) is guaranteed */ -} ZSTD_strategy; - -typedef enum { - - /* compression parameters - * Note: When compressing with a ZSTD_CDict these parameters are superseded - * by the parameters used to construct the ZSTD_CDict. - * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */ - ZSTD_c_compressionLevel = 100, /* Set compression parameters according to pre-defined cLevel table. - * Note that exact compression parameters are dynamically determined, - * depending on both compression level and srcSize (when known). - * Default level is ZSTD_CLEVEL_DEFAULT==3. - * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT. - * Note 1 : it's possible to pass a negative compression level. - * Note 2 : setting a level does not automatically set all other compression parameters - * to default. Setting this will however eventually dynamically impact the compression - * parameters which have not been manually set. The manually set - * ones will 'stick'. */ - /* Advanced compression parameters : - * It's possible to pin down compression parameters to some specific values. - * In which case, these values are no longer dynamically selected by the compressor */ - ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2. - * This will set a memory budget for streaming decompression, - * with larger values requiring more memory - * and typically compressing more. - * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX. - * Special: value 0 means "use default windowLog". - * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT - * requires explicitly allowing such size at streaming decompression stage. */ - ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2. - * Resulting memory usage is (1 << (hashLog+2)). - * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX. - * Larger tables improve compression ratio of strategies <= dFast, - * and improve speed of strategies > dFast. - * Special: value 0 means "use default hashLog". */ - ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2. - * Resulting memory usage is (1 << (chainLog+2)). - * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX. - * Larger tables result in better and slower compression. - * This parameter is useless for "fast" strategy. - * It's still useful when using "dfast" strategy, - * in which case it defines a secondary probe table. - * Special: value 0 means "use default chainLog". */ - ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2. - * More attempts result in better and slower compression. - * This parameter is useless for "fast" and "dFast" strategies. - * Special: value 0 means "use default searchLog". */ - ZSTD_c_minMatch=105, /* Minimum size of searched matches. - * Note that Zstandard can still find matches of smaller size, - * it just tweaks its search algorithm to look for this size and larger. - * Larger values increase compression and decompression speed, but decrease ratio. - * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX. - * Note that currently, for all strategies < btopt, effective minimum is 4. - * , for all strategies > fast, effective maximum is 6. - * Special: value 0 means "use default minMatchLength". */ - ZSTD_c_targetLength=106, /* Impact of this field depends on strategy. - * For strategies btopt, btultra & btultra2: - * Length of Match considered "good enough" to stop search. - * Larger values make compression stronger, and slower. - * For strategy fast: - * Distance between match sampling. - * Larger values make compression faster, and weaker. - * Special: value 0 means "use default targetLength". */ - ZSTD_c_strategy = 107, /* See ZSTD_strategy enum definition. - * The higher the value of selected strategy, the more complex it is, - * resulting in stronger and slower compression. - * Special: value 0 means "use default strategy". */ - /* LDM mode parameters */ - ZSTD_c_enableLongDistanceMatching = 160, /* Enable long distance matching. - * This parameter is designed to improve compression ratio - * for large inputs, by finding large matches at long distance. - * It increases memory usage and window size. - * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB - * except when expressly set to a different value. - * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and - * compression strategy >= ZSTD_btopt (== compression level 16+) */ - ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2. - * Larger values increase memory usage and compression ratio, - * but decrease compression speed. - * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX - * default: windowlog - 7. - * Special: value 0 means "automatically determine hashlog". */ - ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher. - * Larger/too small values usually decrease compression ratio. - * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX. - * Special: value 0 means "use default value" (default: 64). */ - ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution. - * Larger values improve collision resolution but decrease compression speed. - * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX. - * Special: value 0 means "use default value" (default: 3). */ - ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table. - * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN). - * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage. - * Larger values improve compression speed. - * Deviating far from default value will likely result in a compression ratio decrease. - * Special: value 0 means "automatically determine hashRateLog". */ - - /* frame parameters */ - ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1) - * Content size must be known at the beginning of compression. - * This is automatically the case when using ZSTD_compress2(), - * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */ - ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */ - ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */ - - /* multi-threading parameters */ - /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD). - * Otherwise, trying to set any other value than default (0) will be a no-op and return an error. - * In a situation where it's unknown if the linked library supports multi-threading or not, - * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property. - */ - ZSTD_c_nbWorkers = 400, /* Select how many threads will be spawned to compress in parallel. - * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() : - * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller, - * while compression is performed in parallel, within worker thread(s). - * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end : - * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call). - * More workers improve speed, but also increase memory usage. - * Default value is `0`, aka "single-threaded mode" : no worker is spawned, - * compression is performed inside Caller's thread, and all invocations are blocking */ - ZSTD_c_jobSize = 401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1. - * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads. - * 0 means default, which is dynamically determined based on compression parameters. - * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest. - * The minimum size is automatically and transparently enforced. */ - ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size. - * The overlap size is an amount of data reloaded from previous job at the beginning of a new job. - * It helps preserve compression ratio, while each job is compressed in parallel. - * This value is enforced only when nbWorkers >= 1. - * Larger values increase compression ratio, but decrease speed. - * Possible values range from 0 to 9 : - * - 0 means "default" : value will be determined by the library, depending on strategy - * - 1 means "no overlap" - * - 9 means "full overlap", using a full window size. - * Each intermediate rank increases/decreases load size by a factor 2 : - * 9: full window; 8: w/2; 7: w/4; 6: w/8; 5:w/16; 4: w/32; 3:w/64; 2:w/128; 1:no overlap; 0:default - * default value varies between 6 and 9, depending on strategy */ - - /* note : additional experimental parameters are also available - * within the experimental section of the API. - * At the time of this writing, they include : - * ZSTD_c_rsyncable - * ZSTD_c_format - * ZSTD_c_forceMaxWindow - * ZSTD_c_forceAttachDict - * ZSTD_c_literalCompressionMode - * ZSTD_c_targetCBlockSize - * ZSTD_c_srcSizeHint - * ZSTD_c_enableDedicatedDictSearch - * ZSTD_c_stableInBuffer - * ZSTD_c_stableOutBuffer - * ZSTD_c_blockDelimiters - * ZSTD_c_validateSequences - * ZSTD_c_useBlockSplitter - * ZSTD_c_useRowMatchFinder - * ZSTD_c_prefetchCDictTables - * ZSTD_c_enableSeqProducerFallback - * ZSTD_c_maxBlockSize - * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. - * note : never ever use experimentalParam? names directly; - * also, the enums values themselves are unstable and can still change. - */ - ZSTD_c_experimentalParam1 = 500, - ZSTD_c_experimentalParam2 = 10, - ZSTD_c_experimentalParam3 = 1000, - ZSTD_c_experimentalParam4 = 1001, - ZSTD_c_experimentalParam5 = 1002, - ZSTD_c_experimentalParam6 = 1003, - ZSTD_c_experimentalParam7 = 1004, - ZSTD_c_experimentalParam8 = 1005, - ZSTD_c_experimentalParam9 = 1006, - ZSTD_c_experimentalParam10 = 1007, - ZSTD_c_experimentalParam11 = 1008, - ZSTD_c_experimentalParam12 = 1009, - ZSTD_c_experimentalParam13 = 1010, - ZSTD_c_experimentalParam14 = 1011, - ZSTD_c_experimentalParam15 = 1012, - ZSTD_c_experimentalParam16 = 1013, - ZSTD_c_experimentalParam17 = 1014, - ZSTD_c_experimentalParam18 = 1015, - ZSTD_c_experimentalParam19 = 1016 -} ZSTD_cParameter; - -typedef struct { - size_t error; - int lowerBound; - int upperBound; -} ZSTD_bounds; - -/*! ZSTD_cParam_getBounds() : - * All parameters must belong to an interval with lower and upper bounds, - * otherwise they will either trigger an error or be automatically clamped. - * @return : a structure, ZSTD_bounds, which contains - * - an error status field, which must be tested using ZSTD_isError() - * - lower and upper bounds, both inclusive - */ -ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam); - -/*! ZSTD_CCtx_setParameter() : - * Set one compression parameter, selected by enum ZSTD_cParameter. - * All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds(). - * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - * Setting a parameter is generally only possible during frame initialization (before starting compression). - * Exception : when using multi-threading mode (nbWorkers >= 1), - * the following parameters can be updated _during_ compression (within same frame): - * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. - * new parameters will be active for next job only (after a flush()). - * @return : an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value); - -/*! ZSTD_CCtx_setPledgedSrcSize() : - * Total input data size to be compressed as a single frame. - * Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag. - * This value will also be controlled at end of frame, and trigger an error if not respected. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame. - * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN. - * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame. - * Note 2 : pledgedSrcSize is only valid once, for the next frame. - * It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN. - * Note 3 : Whenever all input data is provided and consumed in a single round, - * for example with ZSTD_compress2(), - * or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end), - * this value is automatically overridden by srcSize instead. - */ -ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize); - -typedef enum { - ZSTD_reset_session_only = 1, - ZSTD_reset_parameters = 2, - ZSTD_reset_session_and_parameters = 3 -} ZSTD_ResetDirective; - -/*! ZSTD_CCtx_reset() : - * There are 2 different things that can be reset, independently or jointly : - * - The session : will stop compressing current frame, and make CCtx ready to start a new one. - * Useful after an error, or to interrupt any ongoing compression. - * Any internal data not yet flushed is cancelled. - * Compression parameters and dictionary remain unchanged. - * They will be used to compress next frame. - * Resetting session never fails. - * - The parameters : changes all parameters back to "default". - * This also removes any reference to any dictionary or external sequence producer. - * Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) - * otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError()) - * - Both : similar to resetting the session, followed by resetting parameters. - */ -ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset); - -/*! ZSTD_compress2() : - * Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. - * ZSTD_compress2() always starts a new frame. - * Should cctx hold data from a previously unfinished frame, everything about it is forgotten. - * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - * - The function is always blocking, returns when compression is completed. - * NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have - * enough space to successfully compress the data, though it is possible it fails for other reasons. - * @return : compressed size written into `dst` (<= `dstCapacity), - * or an error code if it fails (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize); - - -/*********************************************** -* Advanced decompression API (Requires v1.4.0+) -************************************************/ - -/* The advanced API pushes parameters one by one into an existing DCtx context. - * Parameters are sticky, and remain valid for all following frames - * using the same DCtx context. - * It's possible to reset parameters to default values using ZSTD_DCtx_reset(). - * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream(). - * Therefore, no new decompression function is necessary. - */ - -typedef enum { - - ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which - * the streaming API will refuse to allocate memory buffer - * in order to protect the host from unreasonable memory requirements. - * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. - * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT). - * Special: value 0 means "use default maximum windowLog". */ - - /* note : additional experimental parameters are also available - * within the experimental section of the API. - * At the time of this writing, they include : - * ZSTD_d_format - * ZSTD_d_stableOutBuffer - * ZSTD_d_forceIgnoreChecksum - * ZSTD_d_refMultipleDDicts - * ZSTD_d_disableHuffmanAssembly - * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. - * note : never ever use experimentalParam? names directly - */ - ZSTD_d_experimentalParam1 = 1000, - ZSTD_d_experimentalParam2 = 1001, - ZSTD_d_experimentalParam3 = 1002, - ZSTD_d_experimentalParam4 = 1003, - ZSTD_d_experimentalParam5 = 1004 - -} ZSTD_dParameter; - -/*! ZSTD_dParam_getBounds() : - * All parameters must belong to an interval with lower and upper bounds, - * otherwise they will either trigger an error or be automatically clamped. - * @return : a structure, ZSTD_bounds, which contains - * - an error status field, which must be tested using ZSTD_isError() - * - both lower and upper bounds, inclusive - */ -ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam); - -/*! ZSTD_DCtx_setParameter() : - * Set one compression parameter, selected by enum ZSTD_dParameter. - * All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds(). - * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - * Setting a parameter is only possible during frame initialization (before starting decompression). - * @return : 0, or an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value); - -/*! ZSTD_DCtx_reset() : - * Return a DCtx to clean state. - * Session and parameters can be reset jointly or separately. - * Parameters can only be reset when no active frame is being decompressed. - * @return : 0, or an error code, which can be tested with ZSTD_isError() - */ -ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset); - - -/**************************** -* Streaming -****************************/ - -typedef struct ZSTD_inBuffer_s { - const void* src; /**< start of input buffer */ - size_t size; /**< size of input buffer */ - size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */ -} ZSTD_inBuffer; - -typedef struct ZSTD_outBuffer_s { - void* dst; /**< start of output buffer */ - size_t size; /**< size of output buffer */ - size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */ -} ZSTD_outBuffer; - - - -/*-*********************************************************************** -* Streaming compression - HowTo -* -* A ZSTD_CStream object is required to track streaming operation. -* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources. -* ZSTD_CStream objects can be reused multiple times on consecutive compression operations. -* It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory. -* -* For parallel execution, use one separate ZSTD_CStream per thread. -* -* note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing. -* -* Parameters are sticky : when starting a new compression on the same context, -* it will re-use the same sticky parameters as previous compression session. -* When in doubt, it's recommended to fully initialize the context before usage. -* Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(), -* ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to -* set more specific parameters, the pledged source size, or load a dictionary. -* -* Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to -* consume input stream. The function will automatically update both `pos` -* fields within `input` and `output`. -* Note that the function may not consume the entire input, for example, because -* the output buffer is already full, in which case `input.pos < input.size`. -* The caller must check if input has been entirely consumed. -* If not, the caller must make some room to receive more compressed data, -* and then present again remaining input data. -* note: ZSTD_e_continue is guaranteed to make some forward progress when called, -* but doesn't guarantee maximal forward progress. This is especially relevant -* when compressing with multiple threads. The call won't block if it can -* consume some input, but if it can't it will wait for some, but not all, -* output to be flushed. -* @return : provides a minimum amount of data remaining to be flushed from internal buffers -* or an error code, which can be tested using ZSTD_isError(). -* -* At any moment, it's possible to flush whatever data might remain stuck within internal buffer, -* using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated. -* Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0). -* In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush. -* You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the -* operation. -* note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will -* block until the flush is complete or the output buffer is full. -* @return : 0 if internal buffers are entirely flushed, -* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), -* or an error code, which can be tested using ZSTD_isError(). -* -* Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame. -* It will perform a flush and write frame epilogue. -* The epilogue is required for decoders to consider a frame completed. -* flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush. -* You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to -* start a new frame. -* note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will -* block until the flush is complete or the output buffer is full. -* @return : 0 if frame fully completed and fully flushed, -* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), -* or an error code, which can be tested using ZSTD_isError(). -* -* *******************************************************************/ - -typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */ - /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */ -/*===== ZSTD_CStream management functions =====*/ -ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void); -ZSTDLIB_API size_t ZSTD_freeCStream( ZSTD_CStream * zcs ); /* accept NULL pointer */ - -/*===== Streaming compression functions =====*/ -typedef enum { - ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */ - ZSTD_e_flush=1, /* flush any data provided so far, - * it creates (at least) one new block, that can be decoded immediately on reception; - * frame will continue: any future data can still reference previously compressed data, improving compression. - * note : multithreaded compression will block to flush as much output as possible. */ - ZSTD_e_end=2 /* flush any remaining data _and_ close current frame. - * note that frame is only closed after compressed data is fully flushed (return value == 0). - * After that point, any additional data starts a new frame. - * note : each frame is independent (does not reference any content from previous frame). - : note : multithreaded compression will block to flush as much output as possible. */ -} ZSTD_EndDirective; - -/*! ZSTD_compressStream2() : Requires v1.4.0+ - * Behaves about the same as ZSTD_compressStream, with additional control on end directive. - * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode) - * - output->pos must be <= dstCapacity, input->pos must be <= srcSize - * - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit. - * - endOp must be a valid directive - * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller. - * - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available, - * and then immediately returns, just indicating that there is some data remaining to be flushed. - * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. - * - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking. - * - @return provides a minimum amount of data remaining to be flushed from internal buffers - * or an error code, which can be tested using ZSTD_isError(). - * if @return != 0, flush is not fully completed, there is still some data left within internal buffers. - * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. - * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. - * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), - * only ZSTD_e_end or ZSTD_e_flush operations are allowed. - * Before starting a new compression job, or changing compression parameters, - * it is required to fully flush internal buffers. - */ -ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx, - ZSTD_outBuffer* output, - ZSTD_inBuffer* input, - ZSTD_EndDirective endOp); - - -/* These buffer sizes are softly recommended. - * They are not required : ZSTD_compressStream*() happily accepts any buffer size, for both input and output. - * Respecting the recommended size just makes it a bit easier for ZSTD_compressStream*(), - * reducing the amount of memory shuffling and buffering, resulting in minor performance savings. - * - * However, note that these recommendations are from the perspective of a C caller program. - * If the streaming interface is invoked from some other language, - * especially managed ones such as Java or Go, through a foreign function interface such as jni or cgo, - * a major performance rule is to reduce crossing such interface to an absolute minimum. - * It's not rare that performance ends being spent more into the interface, rather than compression itself. - * In which cases, prefer using large buffers, as large as practical, - * for both input and output, to reduce the nb of roundtrips. - */ -ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */ -ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */ - - -/* ***************************************************************************** - * This following is a legacy streaming API, available since v1.0+ . - * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2(). - * It is redundant, but remains fully supported. - ******************************************************************************/ - -/*! - * Equivalent to: - * - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - * - * Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API - * to compress with a dictionary. - */ -ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel); -/*! - * Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue). - * NOTE: The return value is different. ZSTD_compressStream() returns a hint for - * the next read size (if non-zero and not an error). ZSTD_compressStream2() - * returns the minimum nb of bytes left to flush (if non-zero and not an error). - */ -ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input); -/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush). */ -ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); -/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end). */ -ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); - - -/*-*************************************************************************** -* Streaming decompression - HowTo -* -* A ZSTD_DStream object is required to track streaming operations. -* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources. -* ZSTD_DStream objects can be re-used multiple times. -* -* Use ZSTD_initDStream() to start a new decompression operation. -* @return : recommended first input size -* Alternatively, use advanced API to set specific properties. -* -* Use ZSTD_decompressStream() repetitively to consume your input. -* The function will update both `pos` fields. -* If `input.pos < input.size`, some input has not been consumed. -* It's up to the caller to present again remaining data. -* The function tries to flush all data decoded immediately, respecting output buffer size. -* If `output.pos < output.size`, decoder has flushed everything it could. -* But if `output.pos == output.size`, there might be some data left within internal buffers., -* In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer. -* Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX. -* @return : 0 when a frame is completely decoded and fully flushed, -* or an error code, which can be tested using ZSTD_isError(), -* or any other value > 0, which means there is still some decoding or flushing to do to complete current frame : -* the return value is a suggested next input size (just a hint for better latency) -* that will never request more than the remaining frame size. -* *******************************************************************************/ - -typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */ - /* For compatibility with versions <= v1.2.0, prefer differentiating them. */ -/*===== ZSTD_DStream management functions =====*/ -ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void); -ZSTDLIB_API size_t ZSTD_freeDStream( ZSTD_DStream * zds ); /* accept NULL pointer */ - -/*===== Streaming decompression functions =====*/ - -/*! ZSTD_initDStream() : - * Initialize/reset DStream state for new decompression operation. - * Call before new decompression operation using same DStream. - * - * Note : This function is redundant with the advanced API and equivalent to: - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * ZSTD_DCtx_refDDict(zds, NULL); - */ -ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds); - -/*! ZSTD_decompressStream() : - * Streaming decompression function. - * Call repetitively to consume full input updating it as necessary. - * Function will update both input and output `pos` fields exposing current state via these fields: - * - `input.pos < input.size`, some input remaining and caller should provide remaining input - * on the next call. - * - `output.pos < output.size`, decoder finished and flushed all remaining buffers. - * - `output.pos == output.size`, potentially uncflushed data present in the internal buffers, - * call ZSTD_decompressStream() again to flush remaining data to output. - * Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX. - * - * @return : 0 when a frame is completely decoded and fully flushed, - * or an error code, which can be tested using ZSTD_isError(), - * or any other value > 0, which means there is some decoding or flushing to do to complete current frame. - */ -ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input); - -ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ -ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */ - - -/************************** -* Simple dictionary API -***************************/ -/*! ZSTD_compress_usingDict() : - * Compression at an explicit compression level using a Dictionary. - * A dictionary can be any arbitrary data segment (also called a prefix), - * or a buffer with specified information (see zdict.h). - * Note : This function loads the dictionary, resulting in significant startup delay. - * It's intended for a dictionary used only once. - * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */ -ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const void* dict,size_t dictSize, - int compressionLevel); - -/*! ZSTD_decompress_usingDict() : - * Decompression using a known Dictionary. - * Dictionary must be identical to the one used during compression. - * Note : This function loads the dictionary, resulting in significant startup delay. - * It's intended for a dictionary used only once. - * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */ -ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const void* dict,size_t dictSize); - - -/*********************************** - * Bulk processing dictionary API - **********************************/ -typedef struct ZSTD_CDict_s ZSTD_CDict; - -/*! ZSTD_createCDict() : - * When compressing multiple messages or blocks using the same dictionary, - * it's recommended to digest the dictionary only once, since it's a costly operation. - * ZSTD_createCDict() will create a state from digesting a dictionary. - * The resulting state can be used for future compression operations with very limited startup cost. - * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. - * @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict. - * Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content. - * Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer, - * in which case the only thing that it transports is the @compressionLevel. - * This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively, - * expecting a ZSTD_CDict parameter with any data, including those without a known dictionary. */ -ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, - int compressionLevel); - -/*! ZSTD_freeCDict() : - * Function frees memory allocated by ZSTD_createCDict(). - * If a NULL pointer is passed, no operation is performed. */ -ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); - -/*! ZSTD_compress_usingCDict() : - * Compression using a digested Dictionary. - * Recommended when same dictionary is used multiple times. - * Note : compression level is _decided at dictionary creation time_, - * and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) */ -ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_CDict* cdict); - - -typedef struct ZSTD_DDict_s ZSTD_DDict; - -/*! ZSTD_createDDict() : - * Create a digested dictionary, ready to start decompression operation without startup delay. - * dictBuffer can be released after DDict creation, as its content is copied inside DDict. */ -ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize); - -/*! ZSTD_freeDDict() : - * Function frees memory allocated with ZSTD_createDDict() - * If a NULL pointer is passed, no operation is performed. */ -ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); - -/*! ZSTD_decompress_usingDDict() : - * Decompression using a digested Dictionary. - * Recommended when same dictionary is used multiple times. */ -ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_DDict* ddict); - - -/******************************** - * Dictionary helper functions - *******************************/ - -/*! ZSTD_getDictID_fromDict() : Requires v1.4.0+ - * Provides the dictID stored within dictionary. - * if @return == 0, the dictionary is not conformant with Zstandard specification. - * It can still be loaded, but as a content-only dictionary. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); - -/*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+ - * Provides the dictID of the dictionary loaded into `cdict`. - * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict( const ZSTD_CDict * cdict ); - -/*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+ - * Provides the dictID of the dictionary loaded into `ddict`. - * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); - -/*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+ - * Provides the dictID required to decompressed the frame stored within `src`. - * If @return == 0, the dictID could not be decoded. - * This could for one of the following reasons : - * - The frame does not require a dictionary to be decoded (most common case). - * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information. - * Note : this use case also happens when using a non-conformant dictionary. - * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). - * - This is not a Zstandard frame. - * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); - - -/******************************************************************************* - * Advanced dictionary and prefix API (Requires v1.4.0+) - * - * This API allows dictionaries to be used with ZSTD_compress2(), - * ZSTD_compressStream2(), and ZSTD_decompressDCtx(). - * Dictionaries are sticky, they remain valid when same context is re-used, - * they only reset when the context is reset - * with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters. - * In contrast, Prefixes are single-use. - ******************************************************************************/ - - -/*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+ - * Create an internal CDict from `dict` buffer. - * Decompression will have to use same dictionary. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary, - * meaning "return to no-dictionary mode". - * Note 1 : Dictionary is sticky, it will be used for all future compressed frames, - * until parameters are reset, a new dictionary is loaded, or the dictionary - * is explicitly invalidated by loading a NULL dictionary. - * Note 2 : Loading a dictionary involves building tables. - * It's also a CPU consuming operation, with non-negligible impact on latency. - * Tables are dependent on compression parameters, and for this reason, - * compression parameters can no longer be changed after loading a dictionary. - * Note 3 :`dict` content will be copied internally. - * Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead. - * In such a case, dictionary buffer must outlive its users. - * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() - * to precisely select how dictionary content must be interpreted. - * Note 5 : This method does not benefit from LDM (long distance mode). - * If you want to employ LDM on some large dictionary content, - * prefer employing ZSTD_CCtx_refPrefix() described below. - */ -ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); - -/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+ - * Reference a prepared dictionary, to be used for all future compressed frames. - * Note that compression parameters are enforced from within CDict, - * and supersede any compression parameter previously set within CCtx. - * The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs. - * The ignored parameters will be used again if the CCtx is returned to no-dictionary mode. - * The dictionary will remain valid for future compressed frames using same CCtx. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special : Referencing a NULL CDict means "return to no-dictionary mode". - * Note 1 : Currently, only one dictionary can be managed. - * Referencing a new dictionary effectively "discards" any previous one. - * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */ -ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); - -/*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+ - * Reference a prefix (single-usage dictionary) for next compressed frame. - * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end). - * Decompression will need same prefix to properly regenerate data. - * Compressing with a prefix is similar in outcome as performing a diff and compressing it, - * but performs much faster, especially during decompression (compression speed is tunable with compression level). - * This method is compatible with LDM (long distance mode). - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary - * Note 1 : Prefix buffer is referenced. It **must** outlive compression. - * Its content must remain unmodified during compression. - * Note 2 : If the intention is to diff some large src data blob with some prior version of itself, - * ensure that the window size is large enough to contain the entire source. - * See ZSTD_c_windowLog. - * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. - * It's a CPU consuming operation, with non-negligible impact on latency. - * If there is a need to use the same prefix multiple times, consider loadDictionary instead. - * Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent). - * Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. */ -ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, - const void* prefix, size_t prefixSize); - -/*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+ - * Create an internal DDict from dict buffer, to be used to decompress all future frames. - * The dictionary remains valid for all future frames, until explicitly invalidated, or - * a new dictionary is loaded. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, - * meaning "return to no-dictionary mode". - * Note 1 : Loading a dictionary involves building tables, - * which has a non-negligible impact on CPU usage and latency. - * It's recommended to "load once, use many times", to amortize the cost - * Note 2 :`dict` content will be copied internally, so `dict` can be released after loading. - * Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead. - * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of - * how dictionary content is loaded and interpreted. - */ -ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); - -/*! ZSTD_DCtx_refDDict() : Requires v1.4.0+ - * Reference a prepared dictionary, to be used to decompress next frames. - * The dictionary remains active for decompression of future frames using same DCtx. - * - * If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function - * will store the DDict references in a table, and the DDict used for decompression - * will be determined at decompression time, as per the dict ID in the frame. - * The memory for the table is allocated on the first call to refDDict, and can be - * freed with ZSTD_freeDCtx(). - * - * If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary - * will be managed, and referencing a dictionary effectively "discards" any previous one. - * - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special: referencing a NULL DDict means "return to no-dictionary mode". - * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx. - */ -ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); - -/*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+ - * Reference a prefix (single-usage dictionary) to decompress next frame. - * This is the reverse operation of ZSTD_CCtx_refPrefix(), - * and must use the same prefix as the one used during compression. - * Prefix is **only used once**. Reference is discarded at end of frame. - * End of frame is reached when ZSTD_decompressStream() returns 0. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary - * Note 2 : Prefix buffer is referenced. It **must** outlive decompression. - * Prefix buffer must remain unmodified up to the end of frame, - * reached when ZSTD_decompressStream() returns 0. - * Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent). - * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section) - * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. - * A full dictionary is more costly, as it requires building tables. - */ -ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, - const void* prefix, size_t prefixSize); - -/* === Memory management === */ - -/*! ZSTD_sizeof_*() : Requires v1.4.0+ - * These functions give the _current_ memory usage of selected object. - * Note that object memory usage can evolve (increase or decrease) over time. */ -ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); -ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); -ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); -ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); -ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); -ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); - -#endif /* ZSTD_H_235446 */ - - -/* ************************************************************************************** - * ADVANCED AND EXPERIMENTAL FUNCTIONS - **************************************************************************************** - * The definitions in the following section are considered experimental. - * They are provided for advanced scenarios. - * They should never be used with a dynamic library, as prototypes may change in the future. - * Use them only in association with static linking. - * ***************************************************************************************/ - -#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) -#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY - - /* This can be overridden externally to hide static symbols. */ - #ifndef ZSTDLIB_STATIC_API - #if defined( ZSTD_DLL_EXPORT ) && ( ZSTD_DLL_EXPORT == 1 ) - #define ZSTDLIB_STATIC_API __declspec( dllexport ) ZSTDLIB_VISIBLE - #elif 1 - #define ZSTDLIB_STATIC_API __declspec( dllimport ) ZSTDLIB_VISIBLE - #else - #define ZSTDLIB_STATIC_API ZSTDLIB_VISIBLE - #endif - #endif - -/**************************************************************************************** - * experimental API (static linking only) - **************************************************************************************** - * The following symbols and constants - * are not planned to join "stable API" status in the near future. - * They can still change in future versions. - * Some of them are planned to remain in the static_only section indefinitely. - * Some of them might be removed in the future (especially when redundant with existing stable functions) - * ***************************************************************************************/ - -#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1) /* minimum input size required to query frame header size */ -#define ZSTD_FRAMEHEADERSIZE_MIN(format) ((format) == ZSTD_f_zstd1 ? 6 : 2) -#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */ -#define ZSTD_SKIPPABLEHEADERSIZE 8 - -/* compression parameter bounds */ -#define ZSTD_WINDOWLOG_MAX_32 30 -#define ZSTD_WINDOWLOG_MAX_64 31 -#define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64)) -#define ZSTD_WINDOWLOG_MIN 10 -#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30) -#define ZSTD_HASHLOG_MIN 6 -#define ZSTD_CHAINLOG_MAX_32 29 -#define ZSTD_CHAINLOG_MAX_64 30 -#define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64)) -#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN -#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1) -#define ZSTD_SEARCHLOG_MIN 1 -#define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */ -#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */ -#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX -#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */ -#define ZSTD_STRATEGY_MIN ZSTD_fast -#define ZSTD_STRATEGY_MAX ZSTD_btultra2 - #define ZSTD_BLOCKSIZE_MAX_MIN \ - ( 1 \ - << 10 ) /* The minimum valid max blocksize. Maximum blocksizes smaller than this make compressBound() inaccurate. */ - - - #define ZSTD_OVERLAPLOG_MIN 0 - #define ZSTD_OVERLAPLOG_MAX 9 - - #define ZSTD_WINDOWLOG_LIMIT_DEFAULT \ - 27 /* by default, the streaming decoder will refuse any frame - * requiring larger than (1< 0: - * If litLength != 0: - * rep == 1 --> offset == repeat_offset_1 - * rep == 2 --> offset == repeat_offset_2 - * rep == 3 --> offset == repeat_offset_3 - * If litLength == 0: - * rep == 1 --> offset == repeat_offset_2 - * rep == 2 --> offset == repeat_offset_3 - * rep == 3 --> offset == repeat_offset_1 - 1 - * - * Note: This field is optional. ZSTD_generateSequences() will calculate the value of - * 'rep', but repeat offsets do not necessarily need to be calculated from an external - * sequence provider's perspective. For example, ZSTD_compressSequences() does not - * use this 'rep' field at all (as of now). - */ -} ZSTD_Sequence; - -typedef struct { - unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */ - unsigned chainLog; /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */ - unsigned hashLog; /**< dispatch table : larger == faster, more memory */ - unsigned searchLog; /**< nb of searches : larger == more compression, slower */ - unsigned minMatch; /**< match length searched : larger == faster decompression, sometimes less compression */ - unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */ - ZSTD_strategy strategy; /**< see ZSTD_strategy definition above */ -} ZSTD_compressionParameters; - -typedef struct { - int contentSizeFlag; /**< 1: content size will be in frame header (when known) */ - int checksumFlag; /**< 1: generate a 32-bits checksum using XXH64 algorithm at end of frame, for error detection */ - int noDictIDFlag; /**< 1: no dictID will be saved into frame header (dictID is only useful for dictionary compression) */ -} ZSTD_frameParameters; - -typedef struct { - ZSTD_compressionParameters cParams; - ZSTD_frameParameters fParams; -} ZSTD_parameters; - -typedef enum { - ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */ - ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */ - ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */ -} ZSTD_dictContentType_e; - -typedef enum { - ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */ - ZSTD_dlm_byRef = 1 /**< Reference dictionary content -- the dictionary buffer must outlive its users. */ -} ZSTD_dictLoadMethod_e; - -typedef enum { - ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */ - ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number. - * Useful to save 4 bytes per generated frame. - * Decoder cannot recognise automatically this format, requiring this instruction. */ -} ZSTD_format_e; - -typedef enum { - /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */ - ZSTD_d_validateChecksum = 0, - ZSTD_d_ignoreChecksum = 1 -} ZSTD_forceIgnoreChecksum_e; - -typedef enum { - /* Note: this enum controls ZSTD_d_refMultipleDDicts */ - ZSTD_rmd_refSingleDDict = 0, - ZSTD_rmd_refMultipleDDicts = 1 -} ZSTD_refMultipleDDicts_e; - -typedef enum { - /* Note: this enum and the behavior it controls are effectively internal - * implementation details of the compressor. They are expected to continue - * to evolve and should be considered only in the context of extremely - * advanced performance tuning. - * - * Zstd currently supports the use of a CDict in three ways: - * - * - The contents of the CDict can be copied into the working context. This - * means that the compression can search both the dictionary and input - * while operating on a single set of internal tables. This makes - * the compression faster per-byte of input. However, the initial copy of - * the CDict's tables incurs a fixed cost at the beginning of the - * compression. For small compressions (< 8 KB), that copy can dominate - * the cost of the compression. - * - * - The CDict's tables can be used in-place. In this model, compression is - * slower per input byte, because the compressor has to search two sets of - * tables. However, this model incurs no start-up cost (as long as the - * working context's tables can be reused). For small inputs, this can be - * faster than copying the CDict's tables. - * - * - The CDict's tables are not used at all, and instead we use the working - * context alone to reload the dictionary and use params based on the source - * size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict(). - * This method is effective when the dictionary sizes are very small relative - * to the input size, and the input size is fairly large to begin with. - * - * Zstd has a simple internal heuristic that selects which strategy to use - * at the beginning of a compression. However, if experimentation shows that - * Zstd is making poor choices, it is possible to override that choice with - * this enum. - */ - ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */ - ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */ - ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */ - ZSTD_dictForceLoad = 3 /* Always reload the dictionary */ -} ZSTD_dictAttachPref_e; - -typedef enum { - ZSTD_lcm_auto = 0, /**< Automatically determine the compression mode based on the compression level. - * Negative compression levels will be uncompressed, and positive compression - * levels will be compressed. */ - ZSTD_lcm_huffman = 1, /**< Always attempt Huffman compression. Uncompressed literals will still be - * emitted if Huffman compression is not profitable. */ - ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */ -} ZSTD_literalCompressionMode_e; - -typedef enum { - /* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final - * decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable - * or ZSTD_ps_disable allow for a force enable/disable the feature. - */ - ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */ - ZSTD_ps_enable = 1, /* Force-enable the feature */ - ZSTD_ps_disable = 2 /* Do not use the feature */ -} ZSTD_paramSwitch_e; - -/*************************************** -* Frame header and size functions -***************************************/ - -/*! ZSTD_findDecompressedSize() : - * `src` should point to the start of a series of ZSTD encoded and/or skippable frames - * `srcSize` must be the _exact_ size of this series - * (i.e. there should be a frame boundary at `src + srcSize`) - * @return : - decompressed size of all data in all successive frames - * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN - * - if an error occurred: ZSTD_CONTENTSIZE_ERROR - * - * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. - * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - * In which case, it's necessary to use streaming mode to decompress data. - * note 2 : decompressed size is always present when compression is done with ZSTD_compress() - * note 3 : decompressed size can be very large (64-bits value), - * potentially larger than what local system can handle as a single memory segment. - * In which case, it's necessary to use streaming mode to decompress data. - * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. - * Always ensure result fits within application's authorized limits. - * Each application can set its own limits. - * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to - * read each contained frame header. This is fast as most of the data is skipped, - * however it does mean that all frame data must be present and valid. */ -ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize( const void * src, size_t srcSize ); - -/*! ZSTD_decompressBound() : - * `src` should point to the start of a series of ZSTD encoded and/or skippable frames - * `srcSize` must be the _exact_ size of this series - * (i.e. there should be a frame boundary at `src + srcSize`) - * @return : - upper-bound for the decompressed size of all data in all successive frames - * - if an error occurred: ZSTD_CONTENTSIZE_ERROR - * - * note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame. - * note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`. - * in this case, `ZSTD_findDecompressedSize` and `ZSTD_decompressBound` return the same value. - * note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by: - * upper-bound = # blocks * min(128 KB, Window_Size) - */ -ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound( const void * src, size_t srcSize ); - -/*! ZSTD_frameHeaderSize() : - * srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX. - * @return : size of the Frame Header, - * or an error code (if srcSize is too small) */ -ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize( const void * src, size_t srcSize ); - -typedef enum { - ZSTD_frame, - ZSTD_skippableFrame -} ZSTD_frameType_e; -typedef struct -{ - unsigned long long - frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */ - unsigned long long windowSize; /* can be very large, up to <= frameContentSize */ - unsigned blockSizeMax; - ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */ - unsigned headerSize; - unsigned dictID; - unsigned checksumFlag; - unsigned _reserved1; - unsigned _reserved2; -} ZSTD_frameHeader; - -/*! ZSTD_getFrameHeader() : - * decode Frame Header, or requires larger `srcSize`. - * @return : 0, `zfhPtr` is correctly filled, - * >0, `srcSize` is too small, value is wanted `srcSize` amount, - * or an error code, which can be tested using ZSTD_isError() */ -ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader( ZSTD_frameHeader * zfhPtr, - const void * src, - size_t srcSize ); /**< doesn't consume input */ -/*! ZSTD_getFrameHeader_advanced() : - * same as ZSTD_getFrameHeader(), - * with added capability to select a format (like ZSTD_f_zstd1_magicless) */ -ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced( ZSTD_frameHeader * zfhPtr, - const void * src, - size_t srcSize, - ZSTD_format_e format ); - -/*! ZSTD_decompressionMargin() : - * Zstd supports in-place decompression, where the input and output buffers overlap. - * In this case, the output buffer must be at least (Margin + Output_Size) bytes large, - * and the input buffer must be at the end of the output buffer. - * - * _______________________ Output Buffer ________________________ - * | | - * | ____ Input Buffer ____| - * | | | - * v v v - * |---------------------------------------|-----------|----------| - * ^ ^ ^ - * |___________________ Output_Size ___________________|_ Margin _| - * - * NOTE: See also ZSTD_DECOMPRESSION_MARGIN(). - * NOTE: This applies only to single-pass decompression through ZSTD_decompress() or - * ZSTD_decompressDCtx(). - * NOTE: This function supports multi-frame input. - * - * @param src The compressed frame(s) - * @param srcSize The size of the compressed frame(s) - * @returns The decompression margin or an error that can be checked with ZSTD_isError(). - */ -ZSTDLIB_STATIC_API size_t ZSTD_decompressionMargin( const void * src, size_t srcSize ); - - /*! ZSTD_DECOMPRESS_MARGIN() : - * Similar to ZSTD_decompressionMargin(), but instead of computing the margin from - * the compressed frame, compute it from the original size and the blockSizeLog. - * See ZSTD_decompressionMargin() for details. - * - * WARNING: This macro does not support multi-frame input, the input must be a single - * zstd frame. If you need that support use the function, or implement it yourself. - * - * @param originalSize The original uncompressed size of the data. - * @param blockSize The block size == MIN(windowSize, ZSTD_BLOCKSIZE_MAX). - * Unless you explicitly set the windowLog smaller than - * ZSTD_BLOCKSIZELOG_MAX you can just use ZSTD_BLOCKSIZE_MAX. - */ - #define ZSTD_DECOMPRESSION_MARGIN( originalSize, blockSize ) \ - ( (size_t)( ZSTD_FRAMEHEADERSIZE_MAX /* Frame header */ + 4 /* checksum */ \ - + ( ( originalSize ) == 0 ? \ - 0 : \ - 3 * ( ( ( originalSize ) + (blockSize)-1 ) / blockSize ) ) /* 3 bytes per block */ \ - + ( blockSize ) /* One block of margin */ \ - ) ) - -typedef enum { - ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */ - ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */ -} ZSTD_sequenceFormat_e; - -/*! ZSTD_sequenceBound() : - * `srcSize` : size of the input buffer - * @return : upper-bound for the number of sequences that can be generated - * from a buffer of srcSize bytes - * - * note : returns number of sequences - to get bytes, multiply by sizeof(ZSTD_Sequence). - */ -ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound( size_t srcSize ); - -/*! ZSTD_generateSequences() : - * Generate sequences using ZSTD_compress2(), given a source buffer. - * - * Each block will end with a dummy sequence - * with offset == 0, matchLength == 0, and litLength == length of last literals. - * litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0) - * simply acts as a block delimiter. - * - * @zc can be used to insert custom compression params. - * This function invokes ZSTD_compress2(). - * - * The output of this function can be fed into ZSTD_compressSequences() with CCtx - * setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters - * @return : number of sequences generated - */ - -ZSTDLIB_STATIC_API size_t -ZSTD_generateSequences( ZSTD_CCtx * zc, ZSTD_Sequence * outSeqs, size_t outSeqsSize, const void * src, size_t srcSize ); - -/*! ZSTD_mergeBlockDelimiters() : - * Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals - * by merging them into the literals of the next sequence. - * - * As such, the final generated result has no explicit representation of block boundaries, - * and the final last literals segment is not represented in the sequences. - * - * The output of this function can be fed into ZSTD_compressSequences() with CCtx - * setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters - * @return : number of sequences left after merging - */ -ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters( ZSTD_Sequence * sequences, size_t seqsSize ); - -/*! ZSTD_compressSequences() : - * Compress an array of ZSTD_Sequence, associated with @src buffer, into dst. - * @src contains the entire input (not just the literals). - * If @srcSize > sum(sequence.length), the remaining bytes are considered all literals - * If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.) - * The entire source is compressed into a single frame. - * - * The compression behavior changes based on cctx params. In particular: - * If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain - * no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on - * the block size derived from the cctx, and sequences may be split. This is the default setting. - * - * If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain - * block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided. - * - * If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined - * behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for - * specifics regarding offset/matchlength requirements) then the function will bail out and return an error. - * - * In addition to the two adjustable experimental params, there are other important cctx params. - * - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN. - * - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression. - * - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset - * is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md - * - * Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused. - * Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly, - * and cannot emit an RLE block that disagrees with the repcode history - * @return : final compressed size, or a ZSTD error code. - */ -ZSTDLIB_STATIC_API size_t ZSTD_compressSequences( ZSTD_CCtx * cctx, - void * dst, - size_t dstSize, - const ZSTD_Sequence * inSeqs, - size_t inSeqsSize, - const void * src, - size_t srcSize ); - - -/*! ZSTD_writeSkippableFrame() : - * Generates a zstd skippable frame containing data given by src, and writes it to dst buffer. - * - * Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number, - * ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15. - * As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so - * the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant. - * - * Returns an error if destination buffer is not large enough, if the source size is not representable - * with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid). - * - * @return : number of bytes written or a ZSTD error. - */ -ZSTDLIB_STATIC_API size_t -ZSTD_writeSkippableFrame( void * dst, size_t dstCapacity, const void * src, size_t srcSize, unsigned magicVariant ); - -/*! ZSTD_readSkippableFrame() : - * Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer. - * - * The parameter magicVariant will receive the magicVariant that was supplied when the frame was written, - * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested - * in the magicVariant. - * - * Returns an error if destination buffer is not large enough, or if the frame is not skippable. - * - * @return : number of bytes written or a ZSTD error. - */ -ZSTDLIB_API size_t -ZSTD_readSkippableFrame( void * dst, size_t dstCapacity, unsigned * magicVariant, const void * src, size_t srcSize ); - -/*! ZSTD_isSkippableFrame() : - * Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame. - */ -ZSTDLIB_API unsigned ZSTD_isSkippableFrame( const void * buffer, size_t size ); - - -/*************************************** -* Memory management -***************************************/ - -/*! ZSTD_estimate*() : - * These functions make it possible to estimate memory usage - * of a future {D,C}Ctx, before its creation. - * - * ZSTD_estimateCCtxSize() will provide a memory budget large enough - * for any compression level up to selected one. - * Note : Unlike ZSTD_estimateCStreamSize*(), this estimate - * does not include space for a window buffer. - * Therefore, the estimation is only guaranteed for single-shot compressions, not streaming. - * The estimate will assume the input may be arbitrarily large, - * which is the worst case. - * - * When srcSize can be bound by a known and rather "small" value, - * this fact can be used to provide a tighter estimation - * because the CCtx compression context will need less memory. - * This tighter estimation can be provided by more advanced functions - * ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(), - * and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter(). - * Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits. - * - * Note : only single-threaded compression is supported. - * ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. - * - * Note 2 : ZSTD_estimateCCtxSize* functions are not compatible with the Block-Level Sequence Producer API at this time. - * Size estimates assume that no external sequence producer is registered. - */ -ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize( int compressionLevel ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams( ZSTD_compressionParameters cParams ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams( const ZSTD_CCtx_params * params ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize( void ); - -/*! ZSTD_estimateCStreamSize() : - * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one. - * It will also consider src size to be arbitrarily "large", which is worst case. - * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation. - * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. - * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParams_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1. - * Note : CStream size estimation is only correct for single-threaded compression. - * ZSTD_DStream memory budget depends on window Size. - * This information can be passed manually, using ZSTD_estimateDStreamSize, - * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame(); - * Note : if streaming is init with function ZSTD_init?Stream_usingDict(), - * an internal ?Dict will be created, which additional size is not estimated here. - * In this case, get total size by adding ZSTD_estimate?DictSize - * Note 2 : only single-threaded compression is supported. - * ZSTD_estimateCStreamSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. - * Note 3 : ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time. - * Size estimates assume that no external sequence producer is registered. - */ -ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize( int compressionLevel ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams( ZSTD_compressionParameters cParams ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams( const ZSTD_CCtx_params * params ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize( size_t windowSize ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame( const void * src, size_t srcSize ); - -/*! ZSTD_estimate?DictSize() : - * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). - * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced(). - * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller. - */ -ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize( size_t dictSize, int compressionLevel ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced( size_t dictSize, - ZSTD_compressionParameters cParams, - ZSTD_dictLoadMethod_e dictLoadMethod ); -ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize( size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod ); - -/*! ZSTD_initStatic*() : - * Initialize an object using a pre-allocated fixed-size buffer. - * workspace: The memory area to emplace the object into. - * Provided pointer *must be 8-bytes aligned*. - * Buffer must outlive object. - * workspaceSize: Use ZSTD_estimate*Size() to determine - * how large workspace must be to support target scenario. - * @return : pointer to object (same address as workspace, just different type), - * or NULL if error (size too small, incorrect alignment, etc.) - * Note : zstd will never resize nor malloc() when using a static buffer. - * If the object requires more memory than available, - * zstd will just error out (typically ZSTD_error_memory_allocation). - * Note 2 : there is no corresponding "free" function. - * Since workspace is allocated externally, it must be freed externally too. - * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level - * into its associated cParams. - * Limitation 1 : currently not compatible with internal dictionary creation, triggered by - * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict(). - * Limitation 2 : static cctx currently not compatible with multi-threading. - * Limitation 3 : static dctx is incompatible with legacy support. - */ -ZSTDLIB_STATIC_API ZSTD_CCtx * ZSTD_initStaticCCtx( void * workspace, size_t workspaceSize ); -ZSTDLIB_STATIC_API ZSTD_CStream * ZSTD_initStaticCStream( void * workspace, - size_t workspaceSize ); /**< same as ZSTD_initStaticCCtx() */ - -ZSTDLIB_STATIC_API ZSTD_DCtx * ZSTD_initStaticDCtx( void * workspace, size_t workspaceSize ); -ZSTDLIB_STATIC_API ZSTD_DStream * ZSTD_initStaticDStream( void * workspace, - size_t workspaceSize ); /**< same as ZSTD_initStaticDCtx() */ - -ZSTDLIB_STATIC_API const ZSTD_CDict * ZSTD_initStaticCDict( void * workspace, - size_t workspaceSize, - const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_compressionParameters cParams ); - -ZSTDLIB_STATIC_API const ZSTD_DDict * ZSTD_initStaticDDict( void * workspace, - size_t workspaceSize, - const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType ); - - -/*! Custom memory allocation : - * These prototypes make it possible to pass your own allocation/free functions. - * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below. - * All allocation/free operations will be completed using these custom variants instead of regular ones. - */ -typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); -typedef void (*ZSTD_freeFunction) (void* opaque, void* address); -typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem; -static - #ifdef __GNUC__ - __attribute__( ( __unused__ ) ) - #endif - ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */ - -ZSTDLIB_STATIC_API ZSTD_CCtx * ZSTD_createCCtx_advanced( ZSTD_customMem customMem ); -ZSTDLIB_STATIC_API ZSTD_CStream * ZSTD_createCStream_advanced( ZSTD_customMem customMem ); -ZSTDLIB_STATIC_API ZSTD_DCtx * ZSTD_createDCtx_advanced( ZSTD_customMem customMem ); -ZSTDLIB_STATIC_API ZSTD_DStream * ZSTD_createDStream_advanced( ZSTD_customMem customMem ); - -ZSTDLIB_STATIC_API ZSTD_CDict * ZSTD_createCDict_advanced( const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_compressionParameters cParams, - ZSTD_customMem customMem ); - -/*! Thread pool : - * These prototypes make it possible to share a thread pool among multiple compression contexts. - * This can limit resources for applications with multiple threads where each one uses - * a threaded compression mode (via ZSTD_c_nbWorkers parameter). - * ZSTD_createThreadPool creates a new thread pool with a given number of threads. - * Note that the lifetime of such pool must exist while being used. - * ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value - * to use an internal thread pool). - * ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer. - */ -typedef struct POOL_ctx_s ZSTD_threadPool; -ZSTDLIB_STATIC_API ZSTD_threadPool * ZSTD_createThreadPool( size_t numThreads ); -ZSTDLIB_STATIC_API void ZSTD_freeThreadPool( ZSTD_threadPool * pool ); /* accept NULL pointer */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool( ZSTD_CCtx * cctx, ZSTD_threadPool * pool ); - - -/* - * This API is temporary and is expected to change or disappear in the future! - */ -ZSTDLIB_STATIC_API ZSTD_CDict * ZSTD_createCDict_advanced2( const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - const ZSTD_CCtx_params * cctxParams, - ZSTD_customMem customMem ); - -ZSTDLIB_STATIC_API ZSTD_DDict * ZSTD_createDDict_advanced( const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_customMem customMem ); - - -/*************************************** -* Advanced compression functions -***************************************/ - -/*! ZSTD_createCDict_byReference() : - * Create a digested dictionary for compression - * Dictionary content is just referenced, not duplicated. - * As a consequence, `dictBuffer` **must** outlive CDict, - * and its content must remain unmodified throughout the lifetime of CDict. - * note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */ -ZSTDLIB_STATIC_API ZSTD_CDict * -ZSTD_createCDict_byReference( const void * dictBuffer, size_t dictSize, int compressionLevel ); - -/*! ZSTD_getCParams() : - * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. - * `estimatedSrcSize` value is optional, select 0 if not known */ -ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams( int compressionLevel, - unsigned long long estimatedSrcSize, - size_t dictSize ); - -/*! ZSTD_getParams() : - * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. - * All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */ -ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams( int compressionLevel, - unsigned long long estimatedSrcSize, - size_t dictSize ); - -/*! ZSTD_checkCParams() : - * Ensure param values remain within authorized range. - * @return 0 on success, or an error code (can be checked with ZSTD_isError()) */ -ZSTDLIB_STATIC_API size_t ZSTD_checkCParams( ZSTD_compressionParameters params ); - -/*! ZSTD_adjustCParams() : - * optimize params for a given `srcSize` and `dictSize`. - * `srcSize` can be unknown, in which case use ZSTD_CONTENTSIZE_UNKNOWN. - * `dictSize` must be `0` when there is no dictionary. - * cPar can be invalid : all parameters will be clamped within valid range in the @return struct. - * This function never fails (wide contract) */ -ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams( ZSTD_compressionParameters cPar, - unsigned long long srcSize, - size_t dictSize ); - -/*! ZSTD_CCtx_setCParams() : - * Set all parameters provided within @p cparams into the working @p cctx. - * Note : if modifying parameters during compression (MT mode only), - * note that changes to the .windowLog parameter will be ignored. - * @return 0 on success, or an error code (can be checked with ZSTD_isError()). - * On failure, no parameters are updated. - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setCParams( ZSTD_CCtx * cctx, ZSTD_compressionParameters cparams ); - -/*! ZSTD_CCtx_setFParams() : - * Set all parameters provided within @p fparams into the working @p cctx. - * @return 0 on success, or an error code (can be checked with ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setFParams( ZSTD_CCtx * cctx, ZSTD_frameParameters fparams ); - -/*! ZSTD_CCtx_setParams() : - * Set all parameters provided within @p params into the working @p cctx. - * @return 0 on success, or an error code (can be checked with ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParams( ZSTD_CCtx * cctx, ZSTD_parameters params ); - -/*! ZSTD_compress_advanced() : - * Note : this function is now DEPRECATED. - * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters. - * This prototype will generate compilation warnings. */ -ZSTD_DEPRECATED( "use ZSTD_compress2" ) -ZSTDLIB_STATIC_API -size_t ZSTD_compress_advanced( ZSTD_CCtx * cctx, - void * dst, - size_t dstCapacity, - const void * src, - size_t srcSize, - const void * dict, - size_t dictSize, - ZSTD_parameters params ); - -/*! ZSTD_compress_usingCDict_advanced() : - * Note : this function is now DEPRECATED. - * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters. - * This prototype will generate compilation warnings. */ -ZSTD_DEPRECATED( "use ZSTD_compress2 with ZSTD_CCtx_loadDictionary" ) -ZSTDLIB_STATIC_API -size_t ZSTD_compress_usingCDict_advanced( ZSTD_CCtx * cctx, - void * dst, - size_t dstCapacity, - const void * src, - size_t srcSize, - const ZSTD_CDict * cdict, - ZSTD_frameParameters fParams ); - - -/*! ZSTD_CCtx_loadDictionary_byReference() : - * Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx. - * It saves some memory, but also requires that `dict` outlives its usage within `cctx` */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference( ZSTD_CCtx * cctx, const void * dict, size_t dictSize ); - -/*! ZSTD_CCtx_loadDictionary_advanced() : - * Same as ZSTD_CCtx_loadDictionary(), but gives finer control over - * how to load the dictionary (by copy ? by reference ?) - * and how to interpret it (automatic ? force raw mode ? full mode only ?) */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced( ZSTD_CCtx * cctx, - const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType ); - -/*! ZSTD_CCtx_refPrefix_advanced() : - * Same as ZSTD_CCtx_refPrefix(), but gives finer control over - * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced( ZSTD_CCtx * cctx, - const void * prefix, - size_t prefixSize, - ZSTD_dictContentType_e dictContentType ); - -/* === experimental parameters === */ -/* these parameters can be used with ZSTD_setParameter() - * they are not guaranteed to remain supported in the future */ - - /* Enables rsyncable mode, - * which makes compressed files more rsync friendly - * by adding periodic synchronization points to the compressed data. - * The target average block size is ZSTD_c_jobSize / 2. - * It's possible to modify the job size to increase or decrease - * the granularity of the synchronization point. - * Once the jobSize is smaller than the window size, - * it will result in compression ratio degradation. - * NOTE 1: rsyncable mode only works when multithreading is enabled. - * NOTE 2: rsyncable performs poorly in combination with long range mode, - * since it will decrease the effectiveness of synchronization points, - * though mileage may vary. - * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s. - * If the selected compression level is already running significantly slower, - * the overall speed won't be significantly impacted. - */ - #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1 - -/* Select a compression format. - * The value must be of type ZSTD_format_e. - * See ZSTD_format_e enum definition for details */ -#define ZSTD_c_format ZSTD_c_experimentalParam2 - -/* Force back-reference distances to remain < windowSize, - * even when referencing into Dictionary content (default:0) */ -#define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3 - -/* Controls whether the contents of a CDict - * are used in place, or copied into the working context. - * Accepts values from the ZSTD_dictAttachPref_e enum. - * See the comments on that enum for an explanation of the feature. */ -#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4 - - /* Controlled with ZSTD_paramSwitch_e enum. - * Default is ZSTD_ps_auto. - * Set to ZSTD_ps_disable to never compress literals. - * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals - * may still be emitted if huffman is not beneficial to use.) - * - * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use - * literals compression based on the compression parameters - specifically, - * negative compression levels do not use literal compression. - */ - #define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5 - - /* Tries to fit compressed block size to be around targetCBlockSize. - * No target when targetCBlockSize == 0. - * There is no guarantee on compressed block size (default:0) */ - #define ZSTD_c_targetCBlockSize ZSTD_c_experimentalParam6 - - /* User's best guess of source size. - * Hint is not valid when srcSizeHint == 0. - * There is no guarantee that hint is close to actual source size, - * but compression ratio may regress significantly if guess considerably underestimates */ - #define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7 - - /* Controls whether the new and experimental "dedicated dictionary search - * structure" can be used. This feature is still rough around the edges, be - * prepared for surprising behavior! - * - * How to use it: - * - * When using a CDict, whether to use this feature or not is controlled at - * CDict creation, and it must be set in a CCtxParams set passed into that - * construction (via ZSTD_createCDict_advanced2()). A compression will then - * use the feature or not based on how the CDict was constructed; the value of - * this param, set in the CCtx, will have no effect. - * - * However, when a dictionary buffer is passed into a CCtx, such as via - * ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control - * whether the CDict that is created internally can use the feature or not. - * - * What it does: - * - * Normally, the internal data structures of the CDict are analogous to what - * would be stored in a CCtx after compressing the contents of a dictionary. - * To an approximation, a compression using a dictionary can then use those - * data structures to simply continue what is effectively a streaming - * compression where the simulated compression of the dictionary left off. - * Which is to say, the search structures in the CDict are normally the same - * format as in the CCtx. - * - * It is possible to do better, since the CDict is not like a CCtx: the search - * structures are written once during CDict creation, and then are only read - * after that, while the search structures in the CCtx are both read and - * written as the compression goes along. This means we can choose a search - * structure for the dictionary that is read-optimized. - * - * This feature enables the use of that different structure. - * - * Note that some of the members of the ZSTD_compressionParameters struct have - * different semantics and constraints in the dedicated search structure. It is - * highly recommended that you simply set a compression level in the CCtxParams - * you pass into the CDict creation call, and avoid messing with the cParams - * directly. - * - * Effects: - * - * This will only have any effect when the selected ZSTD_strategy - * implementation supports this feature. Currently, that's limited to - * ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2. - * - * Note that this means that the CDict tables can no longer be copied into the - * CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be - * usable. The dictionary can only be attached or reloaded. - * - * In general, you should expect compression to be faster--sometimes very much - * so--and CDict creation to be slightly slower. Eventually, we will probably - * make this mode the default. - */ - #define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8 - - /* ZSTD_c_stableInBuffer - * Experimental parameter. - * Default is 0 == disabled. Set to 1 to enable. - * - * Tells the compressor that input data presented with ZSTD_inBuffer - * will ALWAYS be the same between calls. - * Technically, the @src pointer must never be changed, - * and the @pos field can only be updated by zstd. - * However, it's possible to increase the @size field, - * allowing scenarios where more data can be appended after compressions starts. - * These conditions are checked by the compressor, - * and compression will fail if they are not respected. - * Also, data in the ZSTD_inBuffer within the range [src, src + pos) - * MUST not be modified during compression or it will result in data corruption. - * - * When this flag is enabled zstd won't allocate an input window buffer, - * because the user guarantees it can reference the ZSTD_inBuffer until - * the frame is complete. But, it will still allocate an output buffer - * large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also - * avoid the memcpy() from the input buffer to the input window buffer. - * - * NOTE: So long as the ZSTD_inBuffer always points to valid memory, using - * this flag is ALWAYS memory safe, and will never access out-of-bounds - * memory. However, compression WILL fail if conditions are not respected. - * - * WARNING: The data in the ZSTD_inBuffer in the range [src, src + pos) MUST - * not be modified during compression or it will result in data corruption. - * This is because zstd needs to reference data in the ZSTD_inBuffer to find - * matches. Normally zstd maintains its own window buffer for this purpose, - * but passing this flag tells zstd to rely on user provided buffer instead. - */ - #define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9 - - /* ZSTD_c_stableOutBuffer - * Experimental parameter. - * Default is 0 == disabled. Set to 1 to enable. - * - * Tells he compressor that the ZSTD_outBuffer will not be resized between - * calls. Specifically: (out.size - out.pos) will never grow. This gives the - * compressor the freedom to say: If the compressed data doesn't fit in the - * output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to - * always decompress directly into the output buffer, instead of decompressing - * into an internal buffer and copying to the output buffer. - * - * When this flag is enabled zstd won't allocate an output buffer, because - * it can write directly to the ZSTD_outBuffer. It will still allocate the - * input window buffer (see ZSTD_c_stableInBuffer). - * - * Zstd will check that (out.size - out.pos) never grows and return an error - * if it does. While not strictly necessary, this should prevent surprises. - */ - #define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10 - - /* ZSTD_c_blockDelimiters - * Default is 0 == ZSTD_sf_noBlockDelimiters. - * - * For use with sequence compression API: ZSTD_compressSequences(). - * - * Designates whether or not the given array of ZSTD_Sequence contains block delimiters - * and last literals, which are defined as sequences with offset == 0 and matchLength == 0. - * See the definition of ZSTD_Sequence for more specifics. - */ - #define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11 - - /* ZSTD_c_validateSequences - * Default is 0 == disabled. Set to 1 to enable sequence validation. - * - * For use with sequence compression API: ZSTD_compressSequences(). - * Designates whether or not we validate sequences provided to ZSTD_compressSequences() - * during function execution. - * - * Without validation, providing a sequence that does not conform to the zstd spec will cause - * undefined behavior, and may produce a corrupted block. - * - * With validation enabled, if sequence is invalid (see doc/zstd_compression_format.md for - * specifics regarding offset/matchlength requirements) then the function will bail out and - * return an error. - * - */ - #define ZSTD_c_validateSequences ZSTD_c_experimentalParam12 - - /* ZSTD_c_useBlockSplitter - * Controlled with ZSTD_paramSwitch_e enum. - * Default is ZSTD_ps_auto. - * Set to ZSTD_ps_disable to never use block splitter. - * Set to ZSTD_ps_enable to always use block splitter. - * - * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use - * block splitting based on the compression parameters. - */ - #define ZSTD_c_useBlockSplitter ZSTD_c_experimentalParam13 - - /* ZSTD_c_useRowMatchFinder - * Controlled with ZSTD_paramSwitch_e enum. - * Default is ZSTD_ps_auto. - * Set to ZSTD_ps_disable to never use row-based matchfinder. - * Set to ZSTD_ps_enable to force usage of row-based matchfinder. - * - * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use - * the row-based matchfinder based on support for SIMD instructions and the window log. - * Note that this only pertains to compression strategies: greedy, lazy, and lazy2 - */ - #define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14 - - /* ZSTD_c_deterministicRefPrefix - * Default is 0 == disabled. Set to 1 to enable. - * - * Zstd produces different results for prefix compression when the prefix is - * directly adjacent to the data about to be compressed vs. when it isn't. - * This is because zstd detects that the two buffers are contiguous and it can - * use a more efficient match finding algorithm. However, this produces different - * results than when the two buffers are non-contiguous. This flag forces zstd - * to always load the prefix in non-contiguous mode, even if it happens to be - * adjacent to the data, to guarantee determinism. - * - * If you really care about determinism when using a dictionary or prefix, - * like when doing delta compression, you should select this option. It comes - * at a speed penalty of about ~2.5% if the dictionary and data happened to be - * contiguous, and is free if they weren't contiguous. We don't expect that - * intentionally making the dictionary and data contiguous will be worth the - * cost to memcpy() the data. - */ - #define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15 - - /* ZSTD_c_prefetchCDictTables - * Controlled with ZSTD_paramSwitch_e enum. Default is ZSTD_ps_auto. - * - * In some situations, zstd uses CDict tables in-place rather than copying them - * into the working context. (See docs on ZSTD_dictAttachPref_e above for details). - * In such situations, compression speed is seriously impacted when CDict tables are - * "cold" (outside CPU cache). This parameter instructs zstd to prefetch CDict tables - * when they are used in-place. - * - * For sufficiently small inputs, the cost of the prefetch will outweigh the benefit. - * For sufficiently large inputs, zstd will by default memcpy() CDict tables - * into the working context, so there is no need to prefetch. This parameter is - * targeted at a middle range of input sizes, where a prefetch is cheap enough to be - * useful but memcpy() is too expensive. The exact range of input sizes where this - * makes sense is best determined by careful experimentation. - * - * Note: for this parameter, ZSTD_ps_auto is currently equivalent to ZSTD_ps_disable, - * but in the future zstd may conditionally enable this feature via an auto-detection - * heuristic for cold CDicts. - * Use ZSTD_ps_disable to opt out of prefetching under any circumstances. - */ - #define ZSTD_c_prefetchCDictTables ZSTD_c_experimentalParam16 - - /* ZSTD_c_enableSeqProducerFallback - * Allowed values are 0 (disable) and 1 (enable). The default setting is 0. - * - * Controls whether zstd will fall back to an internal sequence producer if an - * external sequence producer is registered and returns an error code. This fallback - * is block-by-block: the internal sequence producer will only be called for blocks - * where the external sequence producer returns an error code. Fallback parsing will - * follow any other cParam settings, such as compression level, the same as in a - * normal (fully-internal) compression operation. - * - * The user is strongly encouraged to read the full Block-Level Sequence Producer API - * documentation (below) before setting this parameter. */ - #define ZSTD_c_enableSeqProducerFallback ZSTD_c_experimentalParam17 - - /* ZSTD_c_maxBlockSize - * Allowed values are between 1KB and ZSTD_BLOCKSIZE_MAX (128KB). - * The default is ZSTD_BLOCKSIZE_MAX, and setting to 0 will set to the default. - * - * This parameter can be used to set an upper bound on the blocksize - * that overrides the default ZSTD_BLOCKSIZE_MAX. It cannot be used to set upper - * bounds greater than ZSTD_BLOCKSIZE_MAX or bounds lower than 1KB (will make - * compressBound() inaccurate). Only currently meant to be used for testing. - * - */ - #define ZSTD_c_maxBlockSize ZSTD_c_experimentalParam18 - - /* ZSTD_c_searchForExternalRepcodes - * This parameter affects how zstd parses external sequences, such as sequences - * provided through the compressSequences() API or from an external block-level - * sequence producer. - * - * If set to ZSTD_ps_enable, the library will check for repeated offsets in - * external sequences, even if those repcodes are not explicitly indicated in - * the "rep" field. Note that this is the only way to exploit repcode matches - * while using compressSequences() or an external sequence producer, since zstd - * currently ignores the "rep" field of external sequences. - * - * If set to ZSTD_ps_disable, the library will not exploit repeated offsets in - * external sequences, regardless of whether the "rep" field has been set. This - * reduces sequence compression overhead by about 25% while sacrificing some - * compression ratio. - * - * The default value is ZSTD_ps_auto, for which the library will enable/disable - * based on compression level. - * - * Note: for now, this param only has an effect if ZSTD_c_blockDelimiters is - * set to ZSTD_sf_explicitBlockDelimiters. That may change in the future. - */ - #define ZSTD_c_searchForExternalRepcodes ZSTD_c_experimentalParam19 - -/*! ZSTD_CCtx_getParameter() : - * Get the requested compression parameter value, selected by enum ZSTD_cParameter, - * and store it into int* value. - * @return : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter( const ZSTD_CCtx * cctx, ZSTD_cParameter param, int * value ); - - -/*! ZSTD_CCtx_params : - * Quick howto : - * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure - * - ZSTD_CCtxParams_setParameter() : Push parameters one by one into - * an existing ZSTD_CCtx_params structure. - * This is similar to - * ZSTD_CCtx_setParameter(). - * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to - * an existing CCtx. - * These parameters will be applied to - * all subsequent frames. - * - ZSTD_compressStream2() : Do compression using the CCtx. - * - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer. - * - * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() - * for static allocation of CCtx for single-threaded compression. - */ -ZSTDLIB_STATIC_API ZSTD_CCtx_params * ZSTD_createCCtxParams( void ); -ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams( ZSTD_CCtx_params * params ); /* accept NULL pointer */ - -/*! ZSTD_CCtxParams_reset() : - * Reset params to default values. - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset( ZSTD_CCtx_params * params ); - -/*! ZSTD_CCtxParams_init() : - * Initializes the compression parameters of cctxParams according to - * compression level. All other parameters are reset to their default values. - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init( ZSTD_CCtx_params * cctxParams, int compressionLevel ); - -/*! ZSTD_CCtxParams_init_advanced() : - * Initializes the compression and frame parameters of cctxParams according to - * params. All other parameters are reset to their default values. - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced( ZSTD_CCtx_params * cctxParams, ZSTD_parameters params ); - -/*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+ - * Similar to ZSTD_CCtx_setParameter. - * Set one compression parameter, selected by enum ZSTD_cParameter. - * Parameters must be applied to a ZSTD_CCtx using - * ZSTD_CCtx_setParametersUsingCCtxParams(). - * @result : a code representing success or failure (which can be tested with - * ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter( ZSTD_CCtx_params * params, ZSTD_cParameter param, int value ); - -/*! ZSTD_CCtxParams_getParameter() : - * Similar to ZSTD_CCtx_getParameter. - * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter( const ZSTD_CCtx_params * params, - ZSTD_cParameter param, - int * value ); - -/*! ZSTD_CCtx_setParametersUsingCCtxParams() : - * Apply a set of ZSTD_CCtx_params to the compression context. - * This can be done even after compression is started, - * if nbWorkers==0, this will have no impact until a new compression is started. - * if nbWorkers>=1, new parameters will be picked up at next job, - * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated). - */ -ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams( ZSTD_CCtx * cctx, const ZSTD_CCtx_params * params ); - -/*! ZSTD_compressStream2_simpleArgs() : - * Same as ZSTD_compressStream2(), - * but using only integral types as arguments. - * This variant might be helpful for binders from dynamic languages - * which have troubles handling structures containing memory pointers. - */ -ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs( ZSTD_CCtx * cctx, - void * dst, - size_t dstCapacity, - size_t * dstPos, - const void * src, - size_t srcSize, - size_t * srcPos, - ZSTD_EndDirective endOp ); - - -/*************************************** -* Advanced decompression functions -***************************************/ - -/*! ZSTD_isFrame() : - * Tells if the content of `buffer` starts with a valid Frame Identifier. - * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. - * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. - * Note 3 : Skippable Frame Identifiers are considered valid. */ -ZSTDLIB_STATIC_API unsigned ZSTD_isFrame( const void * buffer, size_t size ); - -/*! ZSTD_createDDict_byReference() : - * Create a digested dictionary, ready to start decompression operation without startup delay. - * Dictionary content is referenced, and therefore stays in dictBuffer. - * It is important that dictBuffer outlives DDict, - * it must remain read accessible throughout the lifetime of DDict */ -ZSTDLIB_STATIC_API ZSTD_DDict * ZSTD_createDDict_byReference( const void * dictBuffer, size_t dictSize ); - -/*! ZSTD_DCtx_loadDictionary_byReference() : - * Same as ZSTD_DCtx_loadDictionary(), - * but references `dict` content instead of copying it into `dctx`. - * This saves memory if `dict` remains around., - * However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */ -ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference( ZSTD_DCtx * dctx, const void * dict, size_t dictSize ); - -/*! ZSTD_DCtx_loadDictionary_advanced() : - * Same as ZSTD_DCtx_loadDictionary(), - * but gives direct control over - * how to load the dictionary (by copy ? by reference ?) - * and how to interpret it (automatic ? force raw mode ? full mode only ?). */ -ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced( ZSTD_DCtx * dctx, - const void * dict, - size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType ); - -/*! ZSTD_DCtx_refPrefix_advanced() : - * Same as ZSTD_DCtx_refPrefix(), but gives finer control over - * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ -ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced( ZSTD_DCtx * dctx, - const void * prefix, - size_t prefixSize, - ZSTD_dictContentType_e dictContentType ); - -/*! ZSTD_DCtx_setMaxWindowSize() : - * Refuses allocating internal buffers for frames requiring a window size larger than provided limit. - * This protects a decoder context from reserving too much memory for itself (potential attack scenario). - * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. - * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) - * @return : 0, or an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize( ZSTD_DCtx * dctx, size_t maxWindowSize ); - -/*! ZSTD_DCtx_getParameter() : - * Get the requested decompression parameter value, selected by enum ZSTD_dParameter, - * and store it into int* value. - * @return : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter( ZSTD_DCtx * dctx, ZSTD_dParameter param, int * value ); - - /* ZSTD_d_format - * experimental parameter, - * allowing selection between ZSTD_format_e input compression formats - */ - #define ZSTD_d_format ZSTD_d_experimentalParam1 - /* ZSTD_d_stableOutBuffer - * Experimental parameter. - * Default is 0 == disabled. Set to 1 to enable. - * - * Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same - * between calls, except for the modifications that zstd makes to pos (the - * caller must not modify pos). This is checked by the decompressor, and - * decompression will fail if it ever changes. Therefore the ZSTD_outBuffer - * MUST be large enough to fit the entire decompressed frame. This will be - * checked when the frame content size is known. The data in the ZSTD_outBuffer - * in the range [dst, dst + pos) MUST not be modified during decompression - * or you will get data corruption. - * - * When this flag is enabled zstd won't allocate an output buffer, because - * it can write directly to the ZSTD_outBuffer, but it will still allocate - * an input buffer large enough to fit any compressed block. This will also - * avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer. - * If you need to avoid the input buffer allocation use the buffer-less - * streaming API. - * - * NOTE: So long as the ZSTD_outBuffer always points to valid memory, using - * this flag is ALWAYS memory safe, and will never access out-of-bounds - * memory. However, decompression WILL fail if you violate the preconditions. - * - * WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST - * not be modified during decompression or you will get data corruption. This - * is because zstd needs to reference data in the ZSTD_outBuffer to regenerate - * matches. Normally zstd maintains its own buffer for this purpose, but passing - * this flag tells zstd to use the user provided buffer. - */ - #define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2 - - /* ZSTD_d_forceIgnoreChecksum - * Experimental parameter. - * Default is 0 == disabled. Set to 1 to enable - * - * Tells the decompressor to skip checksum validation during decompression, regardless - * of whether checksumming was specified during compression. This offers some - * slight performance benefits, and may be useful for debugging. - * Param has values of type ZSTD_forceIgnoreChecksum_e - */ - #define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3 - - /* ZSTD_d_refMultipleDDicts - * Experimental parameter. - * Default is 0 == disabled. Set to 1 to enable - * - * If enabled and dctx is allocated on the heap, then additional memory will be allocated - * to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict() - * using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead - * store all references. At decompression time, the appropriate dictID is selected - * from the set of DDicts based on the dictID in the frame. - * - * Usage is simply calling ZSTD_refDDict() on multiple dict buffers. - * - * Param has values of byte ZSTD_refMultipleDDicts_e - * - * WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory - * allocation for the hash table. ZSTD_freeDCtx() also frees this memory. - * Memory is allocated as per ZSTD_DCtx::customMem. - * - * Although this function allocates memory for the table, the user is still responsible for - * memory management of the underlying ZSTD_DDict* themselves. - */ - #define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4 - - /* ZSTD_d_disableHuffmanAssembly - * Set to 1 to disable the Huffman assembly implementation. - * The default value is 0, which allows zstd to use the Huffman assembly - * implementation if available. - * - * This parameter can be used to disable Huffman assembly at runtime. - * If you want to disable it at compile time you can define the macro - * ZSTD_DISABLE_ASM. - */ - #define ZSTD_d_disableHuffmanAssembly ZSTD_d_experimentalParam5 - - -/*! ZSTD_DCtx_setFormat() : - * This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter(). - * Instruct the decoder context about what kind of data to decode next. - * This instruction is mandatory to decode data without a fully-formed header, - * such ZSTD_f_zstd1_magicless for example. - * @return : 0, or an error code (which can be tested using ZSTD_isError()). */ -ZSTD_DEPRECATED( "use ZSTD_DCtx_setParameter() instead" ) -ZSTDLIB_STATIC_API -size_t ZSTD_DCtx_setFormat( ZSTD_DCtx * dctx, ZSTD_format_e format ); - -/*! ZSTD_decompressStream_simpleArgs() : - * Same as ZSTD_decompressStream(), - * but using only integral types as arguments. - * This can be helpful for binders from dynamic languages - * which have troubles handling structures containing memory pointers. - */ -ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs( ZSTD_DCtx * dctx, - void * dst, - size_t dstCapacity, - size_t * dstPos, - const void * src, - size_t srcSize, - size_t * srcPos ); - - -/******************************************************************** -* Advanced streaming functions -* Warning : most of these functions are now redundant with the Advanced API. -* Once Advanced API reaches "stable" status, -* redundant functions will be deprecated, and then at some point removed. -********************************************************************/ - -/*===== Advanced Streaming compression functions =====*/ - -/*! ZSTD_initCStream_srcSize() : - * This function is DEPRECATED, and equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * - * pledgedSrcSize must be correct. If it is not known at init time, use - * ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, - * "0" also disables frame content size field. It may be enabled in the future. - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_initCStream_srcSize( ZSTD_CStream * zcs, int compressionLevel, unsigned long long pledgedSrcSize ); - -/*! ZSTD_initCStream_usingDict() : - * This function is DEPRECATED, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - * - * Creates of an internal CDict (incompatible with static CCtx), except if - * dict == NULL or dictSize < 8, in which case no dict is used. - * Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if - * it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy. - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_initCStream_usingDict( ZSTD_CStream * zcs, const void * dict, size_t dictSize, int compressionLevel ); - -/*! ZSTD_initCStream_advanced() : - * This function is DEPRECATED, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setParams(zcs, params); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - * - * dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy. - * pledgedSrcSize must be correct. - * If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_initCStream_advanced( - ZSTD_CStream * zcs, const void * dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize ); - -/*! ZSTD_initCStream_usingCDict() : - * This function is DEPRECATED, and equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, cdict); - * - * note : cdict will just be referenced, and must outlive compression session - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_initCStream_usingCDict( ZSTD_CStream * zcs, const ZSTD_CDict * cdict ); - -/*! ZSTD_initCStream_usingCDict_advanced() : - * This function is DEPRECATED, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setFParams(zcs, fParams); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * ZSTD_CCtx_refCDict(zcs, cdict); - * - * same as ZSTD_initCStream_usingCDict(), with control over frame parameters. - * pledgedSrcSize must be correct. If srcSize is not known at init time, use - * value ZSTD_CONTENTSIZE_UNKNOWN. - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_initCStream_usingCDict_advanced( ZSTD_CStream * zcs, - const ZSTD_CDict * cdict, - ZSTD_frameParameters fParams, - unsigned long long pledgedSrcSize ); - -/*! ZSTD_resetCStream() : - * This function is DEPRECATED, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but - * ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be - * explicitly specified. - * - * start a new frame, using same parameters from previous frame. - * This is typically useful to skip dictionary loading stage, since it will re-use it in-place. - * Note that zcs must be init at least once before using ZSTD_resetCStream(). - * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN. - * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end. - * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, - * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. - * @return : 0, or an error code (which can be tested using ZSTD_isError()) - * This prototype will generate compilation warnings. - */ -ZSTD_DEPRECATED( "use ZSTD_CCtx_reset, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API -size_t ZSTD_resetCStream( ZSTD_CStream * zcs, unsigned long long pledgedSrcSize ); - - -typedef struct { - unsigned long long ingested; /* nb input bytes read and buffered */ - unsigned long long consumed; /* nb input bytes actually compressed */ - unsigned long long produced; /* nb of compressed bytes generated and buffered */ - unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */ - unsigned currentJobID; /* MT only : latest started job nb */ - unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */ -} ZSTD_frameProgression; - -/* ZSTD_getFrameProgression() : - * tells how much data has been ingested (read from input) - * consumed (input actually compressed) and produced (output) for current frame. - * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed. - * Aggregates progression inside active worker threads. - */ -ZSTDLIB_STATIC_API ZSTD_frameProgression ZSTD_getFrameProgression( const ZSTD_CCtx * cctx ); - -/*! ZSTD_toFlushNow() : - * Tell how many bytes are ready to be flushed immediately. - * Useful for multithreading scenarios (nbWorkers >= 1). - * Probe the oldest active job, defined as oldest job not yet entirely flushed, - * and check its output buffer. - * @return : amount of data stored in oldest job and ready to be flushed immediately. - * if @return == 0, it means either : - * + there is no active job (could be checked with ZSTD_frameProgression()), or - * + oldest job is still actively compressing data, - * but everything it has produced has also been flushed so far, - * therefore flush speed is limited by production speed of oldest job - * irrespective of the speed of concurrent (and newer) jobs. - */ -ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow( ZSTD_CCtx * cctx ); - - -/*===== Advanced Streaming decompression functions =====*/ - -/*! - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * ZSTD_DCtx_loadDictionary(zds, dict, dictSize); - * - * note: no dictionary will be used if dict == NULL or dictSize < 8 - */ -ZSTD_DEPRECATED( "use ZSTD_DCtx_reset + ZSTD_DCtx_loadDictionary, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict( ZSTD_DStream * zds, const void * dict, size_t dictSize ); - -/*! - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * ZSTD_DCtx_refDDict(zds, ddict); - * - * note : ddict is referenced, it must outlive decompression session - */ -ZSTD_DEPRECATED( "use ZSTD_DCtx_reset + ZSTD_DCtx_refDDict, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict( ZSTD_DStream * zds, const ZSTD_DDict * ddict ); - -/*! - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * - * re-use decompression parameters from previous init; saves dictionary loading - */ -ZSTD_DEPRECATED( "use ZSTD_DCtx_reset, see zstd.h for detailed instructions" ) -ZSTDLIB_STATIC_API size_t ZSTD_resetDStream( ZSTD_DStream * zds ); - - -/* ********************* BLOCK-LEVEL SEQUENCE PRODUCER API ********************* - * - * *** OVERVIEW *** - * The Block-Level Sequence Producer API allows users to provide their own custom - * sequence producer which libzstd invokes to process each block. The produced list - * of sequences (literals and matches) is then post-processed by libzstd to produce - * valid compressed blocks. - * - * This block-level offload API is a more granular complement of the existing - * frame-level offload API compressSequences() (introduced in v1.5.1). It offers - * an easier migration story for applications already integrated with libzstd: the - * user application continues to invoke the same compression functions - * ZSTD_compress2() or ZSTD_compressStream2() as usual, and transparently benefits - * from the specific advantages of the external sequence producer. For example, - * the sequence producer could be tuned to take advantage of known characteristics - * of the input, to offer better speed / ratio, or could leverage hardware - * acceleration not available within libzstd itself. - * - * See contrib/externalSequenceProducer for an example program employing the - * Block-Level Sequence Producer API. - * - * *** USAGE *** - * The user is responsible for implementing a function of type - * ZSTD_sequenceProducer_F. For each block, zstd will pass the following - * arguments to the user-provided function: - * - * - sequenceProducerState: a pointer to a user-managed state for the sequence - * producer. - * - * - outSeqs, outSeqsCapacity: an output buffer for the sequence producer. - * outSeqsCapacity is guaranteed >= ZSTD_sequenceBound(srcSize). The memory - * backing outSeqs is managed by the CCtx. - * - * - src, srcSize: an input buffer for the sequence producer to parse. - * srcSize is guaranteed to be <= ZSTD_BLOCKSIZE_MAX. - * - * - dict, dictSize: a history buffer, which may be empty, which the sequence - * producer may reference as it parses the src buffer. Currently, zstd will - * always pass dictSize == 0 into external sequence producers, but this will - * change in the future. - * - * - compressionLevel: a signed integer representing the zstd compression level - * set by the user for the current operation. The sequence producer may choose - * to use this information to change its compression strategy and speed/ratio - * tradeoff. Note: the compression level does not reflect zstd parameters set - * through the advanced API. - * - * - windowSize: a size_t representing the maximum allowed offset for external - * sequences. Note that sequence offsets are sometimes allowed to exceed the - * windowSize if a dictionary is present, see doc/zstd_compression_format.md - * for details. - * - * The user-provided function shall return a size_t representing the number of - * sequences written to outSeqs. This return value will be treated as an error - * code if it is greater than outSeqsCapacity. The return value must be non-zero - * if srcSize is non-zero. The ZSTD_SEQUENCE_PRODUCER_ERROR macro is provided - * for convenience, but any value greater than outSeqsCapacity will be treated as - * an error code. - * - * If the user-provided function does not return an error code, the sequences - * written to outSeqs must be a valid parse of the src buffer. Data corruption may - * occur if the parse is not valid. A parse is defined to be valid if the - * following conditions hold: - * - The sum of matchLengths and literalLengths must equal srcSize. - * - All sequences in the parse, except for the final sequence, must have - * matchLength >= ZSTD_MINMATCH_MIN. The final sequence must have - * matchLength >= ZSTD_MINMATCH_MIN or matchLength == 0. - * - All offsets must respect the windowSize parameter as specified in - * doc/zstd_compression_format.md. - * - If the final sequence has matchLength == 0, it must also have offset == 0. - * - * zstd will only validate these conditions (and fail compression if they do not - * hold) if the ZSTD_c_validateSequences cParam is enabled. Note that sequence - * validation has a performance cost. - * - * If the user-provided function returns an error, zstd will either fall back - * to an internal sequence producer or fail the compression operation. The user can - * choose between the two behaviors by setting the ZSTD_c_enableSeqProducerFallback - * cParam. Fallback compression will follow any other cParam settings, such as - * compression level, the same as in a normal compression operation. - * - * The user shall instruct zstd to use a particular ZSTD_sequenceProducer_F - * function by calling - * ZSTD_registerSequenceProducer(cctx, - * sequenceProducerState, - * sequenceProducer) - * This setting will persist until the next parameter reset of the CCtx. - * - * The sequenceProducerState must be initialized by the user before calling - * ZSTD_registerSequenceProducer(). The user is responsible for destroying the - * sequenceProducerState. - * - * *** LIMITATIONS *** - * This API is compatible with all zstd compression APIs which respect advanced parameters. - * However, there are three limitations: - * - * First, the ZSTD_c_enableLongDistanceMatching cParam is not currently supported. - * COMPRESSION WILL FAIL if it is enabled and the user tries to compress with a block-level - * external sequence producer. - * - Note that ZSTD_c_enableLongDistanceMatching is auto-enabled by default in some - * cases (see its documentation for details). Users must explicitly set - * ZSTD_c_enableLongDistanceMatching to ZSTD_ps_disable in such cases if an external - * sequence producer is registered. - * - As of this writing, ZSTD_c_enableLongDistanceMatching is disabled by default - * whenever ZSTD_c_windowLog < 128MB, but that's subject to change. Users should - * check the docs on ZSTD_c_enableLongDistanceMatching whenever the Block-Level Sequence - * Producer API is used in conjunction with advanced settings (like ZSTD_c_windowLog). - * - * Second, history buffers are not currently supported. Concretely, zstd will always pass - * dictSize == 0 to the external sequence producer (for now). This has two implications: - * - Dictionaries are not currently supported. Compression will *not* fail if the user - * references a dictionary, but the dictionary won't have any effect. - * - Stream history is not currently supported. All advanced compression APIs, including - * streaming APIs, work with external sequence producers, but each block is treated as - * an independent chunk without history from previous blocks. - * - * Third, multi-threading within a single compression is not currently supported. In other words, - * COMPRESSION WILL FAIL if ZSTD_c_nbWorkers > 0 and an external sequence producer is registered. - * Multi-threading across compressions is fine: simply create one CCtx per thread. - * - * Long-term, we plan to overcome all three limitations. There is no technical blocker to - * overcoming them. It is purely a question of engineering effort. - */ - - #define ZSTD_SEQUENCE_PRODUCER_ERROR ( (size_t)( -1 ) ) - -typedef size_t ZSTD_sequenceProducer_F( void * sequenceProducerState, - ZSTD_Sequence * outSeqs, - size_t outSeqsCapacity, - const void * src, - size_t srcSize, - const void * dict, - size_t dictSize, - int compressionLevel, - size_t windowSize ); - -/*! ZSTD_registerSequenceProducer() : - * Instruct zstd to use a block-level external sequence producer function. - * - * The sequenceProducerState must be initialized by the caller, and the caller is - * responsible for managing its lifetime. This parameter is sticky across - * compressions. It will remain set until the user explicitly resets compression - * parameters. - * - * Sequence producer registration is considered to be an "advanced parameter", - * part of the "advanced API". This means it will only have an effect on compression - * APIs which respect advanced parameters, such as compress2() and compressStream2(). - * Older compression APIs such as compressCCtx(), which predate the introduction of - * "advanced parameters", will ignore any external sequence producer setting. - * - * The sequence producer can be "cleared" by registering a NULL function pointer. This - * removes all limitations described above in the "LIMITATIONS" section of the API docs. - * - * The user is strongly encouraged to read the full API documentation (above) before - * calling this function. */ -ZSTDLIB_STATIC_API void ZSTD_registerSequenceProducer( ZSTD_CCtx * cctx, - void * sequenceProducerState, - ZSTD_sequenceProducer_F * sequenceProducer ); - - -/********************************************************************* -* Buffer-less and synchronous inner streaming functions (DEPRECATED) -* -* This API is deprecated, and will be removed in a future version. -* It allows streaming (de)compression with user allocated buffers. -* However, it is hard to use, and not as well tested as the rest of -* our API. -* -* Please use the normal streaming API instead: ZSTD_compressStream2, -* and ZSTD_decompressStream. -* If there is functionality that you need, but it doesn't provide, -* please open an issue on our GitHub. -********************************************************************* */ - -/** - Buffer-less streaming compression (synchronous mode) - - A ZSTD_CCtx object is required to track streaming operations. - Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource. - ZSTD_CCtx object can be re-used multiple times within successive compression operations. - - Start by initializing a context. - Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression. - - Then, consume your input using ZSTD_compressContinue(). - There are some important considerations to keep in mind when using this advanced function : - - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only. - - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks. - - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario. - Worst case evaluation is provided by ZSTD_compressBound(). - ZSTD_compressContinue() doesn't guarantee recover after a failed compression. - - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog). - It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) - - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. - In which case, it will "discard" the relevant memory section from its history. - - Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. - It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame. - Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders. - - `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again. -*/ - -/*===== Buffer-less streaming compression functions =====*/ -ZSTD_DEPRECATED( "The buffer-less API is deprecated in favor of the normal streaming API. See docs." ) -ZSTDLIB_STATIC_API size_t ZSTD_compressBegin( ZSTD_CCtx * cctx, int compressionLevel ); -ZSTD_DEPRECATED( "The buffer-less API is deprecated in favor of the normal streaming API. See docs." ) -ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict( ZSTD_CCtx * cctx, - const void * dict, - size_t dictSize, - int compressionLevel ); -ZSTD_DEPRECATED( "The buffer-less API is deprecated in favor of the normal streaming API. See docs." ) -ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict( ZSTD_CCtx * cctx, - const ZSTD_CDict * cdict ); /**< note: fails if cdict==NULL */ - -ZSTD_DEPRECATED( - "This function will likely be removed in a future release. It is misleading and has very limited utility." ) -ZSTDLIB_STATIC_API -size_t ZSTD_copyCCtx( - ZSTD_CCtx * cctx, - const ZSTD_CCtx * preparedCCtx, - unsigned long long pledgedSrcSize ); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */ - -ZSTD_DEPRECATED( "The buffer-less API is deprecated in favor of the normal streaming API. See docs." ) -ZSTDLIB_STATIC_API size_t -ZSTD_compressContinue( ZSTD_CCtx * cctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize ); -ZSTD_DEPRECATED( "The buffer-less API is deprecated in favor of the normal streaming API. See docs." ) -ZSTDLIB_STATIC_API size_t -ZSTD_compressEnd( ZSTD_CCtx * cctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize ); - -/* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */ -ZSTD_DEPRECATED( "use advanced API to access custom parameters" ) -ZSTDLIB_STATIC_API -size_t ZSTD_compressBegin_advanced( - ZSTD_CCtx * cctx, - const void * dict, - size_t dictSize, - ZSTD_parameters params, - unsigned long long - pledgedSrcSize ); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ -ZSTD_DEPRECATED( "use advanced API to access custom parameters" ) -ZSTDLIB_STATIC_API -size_t ZSTD_compressBegin_usingCDict_advanced( - ZSTD_CCtx * const cctx, - const ZSTD_CDict * const cdict, - ZSTD_frameParameters const fParams, - unsigned long long const - pledgedSrcSize ); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */ -/** - Buffer-less streaming decompression (synchronous mode) - - A ZSTD_DCtx object is required to track streaming operations. - Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it. - A ZSTD_DCtx object can be re-used multiple times. - - First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader(). - Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough. - Data fragment must be large enough to ensure successful decoding. - `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough. - result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled. - >0 : `srcSize` is too small, please provide at least result bytes on next attempt. - errorCode, which can be tested using ZSTD_isError(). - - It fills a ZSTD_frameHeader structure with important information to correctly decode the frame, - such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`). - Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information. - As a consequence, check that values remain within valid application range. - For example, do not allocate memory blindly, check that `windowSize` is within expectation. - Each application can set its own limits, depending on local restrictions. - For extended interoperability, it is recommended to support `windowSize` of at least 8 MB. - - ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes. - ZSTD_decompressContinue() is very sensitive to contiguity, - if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place, - or that previous contiguous segment is large enough to properly handle maximum back-reference distance. - There are multiple ways to guarantee this condition. - - The most memory efficient way is to use a round buffer of sufficient size. - Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(), - which can return an error code if required value is too large for current system (in 32-bits mode). - In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one, - up to the moment there is not enough room left in the buffer to guarantee decoding another full block, - which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`. - At which point, decoding can resume from the beginning of the buffer. - Note that already decoded data stored in the buffer should be flushed before being overwritten. - - There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory. - - Finally, if you control the compression process, you can also ignore all buffer size rules, - as long as the encoder and decoder progress in "lock-step", - aka use exactly the same buffer sizes, break contiguity at the same place, etc. - - Once buffers are setup, start decompression, with ZSTD_decompressBegin(). - If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict(). - - Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively. - ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue(). - ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail. - - result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity). - It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item. - It can also be an error code, which can be tested with ZSTD_isError(). - - A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero. - Context can then be reset to start a new decompression. - - Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType(). - This information is not required to properly decode a frame. - - == Special case : skippable frames == - - Skippable frames allow integration of user-defined data into a flow of concatenated frames. - Skippable frames will be ignored (skipped) by decompressor. - The format of skippable frames is as follows : - a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F - b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits - c) Frame Content - any content (User Data) of length equal to Frame Size - For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame. - For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content. -*/ - -/*===== Buffer-less streaming decompression functions =====*/ - -ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min( - unsigned long long windowSize, - unsigned long long - frameContentSize ); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */ - -ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin( ZSTD_DCtx * dctx ); -ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict( ZSTD_DCtx * dctx, const void * dict, size_t dictSize ); -ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict( ZSTD_DCtx * dctx, const ZSTD_DDict * ddict ); - -ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress( ZSTD_DCtx * dctx ); -ZSTDLIB_STATIC_API size_t -ZSTD_decompressContinue( ZSTD_DCtx * dctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize ); - -/* misc */ -ZSTD_DEPRECATED( - "This function will likely be removed in the next minor release. It is misleading and has very limited utility." ) -ZSTDLIB_STATIC_API void ZSTD_copyDCtx( ZSTD_DCtx * dctx, const ZSTD_DCtx * preparedDCtx ); -typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e; -ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType( ZSTD_DCtx * dctx ); - - -/* ========================================= */ -/** Block level API (DEPRECATED) */ -/* ========================================= */ - -/*! - - This API is deprecated in favor of the regular compression API. - You can get the frame header down to 2 bytes by setting: - - ZSTD_c_format = ZSTD_f_zstd1_magicless - - ZSTD_c_contentSizeFlag = 0 - - ZSTD_c_checksumFlag = 0 - - ZSTD_c_dictIDFlag = 0 - - This API is not as well tested as our normal API, so we recommend not using it. - We will be removing it in a future version. If the normal API doesn't provide - the functionality you need, please open a GitHub issue. - - Block functions produce and decode raw zstd blocks, without frame metadata. - Frame metadata cost is typically ~12 bytes, which can be non-negligible for very small blocks (< 100 bytes). - But users will have to take in charge needed metadata to regenerate data, such as compressed and content sizes. - - A few rules to respect : - - Compressing and decompressing require a context structure - + Use ZSTD_createCCtx() and ZSTD_createDCtx() - - It is necessary to init context before starting - + compression : any ZSTD_compressBegin*() variant, including with dictionary - + decompression : any ZSTD_decompressBegin*() variant, including with dictionary - - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB - + If input is larger than a block size, it's necessary to split input data into multiple blocks - + For inputs larger than a single block, consider using regular ZSTD_compress() instead. - Frame metadata is not that costly, and quickly becomes negligible as source size grows larger than a block. - - When a block is considered not compressible enough, ZSTD_compressBlock() result will be 0 (zero) ! - ===> In which case, nothing is produced into `dst` ! - + User __must__ test for such outcome and deal directly with uncompressed data - + A block cannot be declared incompressible if ZSTD_compressBlock() return value was != 0. - Doing so would mess up with statistics history, leading to potential data corruption. - + ZSTD_decompressBlock() _doesn't accept uncompressed data as input_ !! - + In case of multiple successive blocks, should some of them be uncompressed, - decoder must be informed of their existence in order to follow proper history. - Use ZSTD_insertBlock() for such a case. -*/ - -/*===== Raw zstd block functions =====*/ -ZSTD_DEPRECATED( "The block API is deprecated in favor of the normal compression API. See docs." ) -ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize( const ZSTD_CCtx * cctx ); -ZSTD_DEPRECATED( "The block API is deprecated in favor of the normal compression API. See docs." ) -ZSTDLIB_STATIC_API size_t -ZSTD_compressBlock( ZSTD_CCtx * cctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize ); -ZSTD_DEPRECATED( "The block API is deprecated in favor of the normal compression API. See docs." ) -ZSTDLIB_STATIC_API size_t -ZSTD_decompressBlock( ZSTD_DCtx * dctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize ); -ZSTD_DEPRECATED( "The block API is deprecated in favor of the normal compression API. See docs." ) -ZSTDLIB_STATIC_API size_t ZSTD_insertBlock( - ZSTD_DCtx * dctx, - const void * blockStart, - size_t blockSize ); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */ - -#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ - -#if defined (__cplusplus) -} -#endif diff --git a/winlibs/include/zstd_errors.h b/winlibs/include/zstd_errors.h deleted file mode 100644 index fe8f145ec..000000000 --- a/winlibs/include/zstd_errors.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#ifndef ZSTD_ERRORS_H_398273423 -#define ZSTD_ERRORS_H_398273423 - -#if defined( __cplusplus ) -extern "C" { -#endif - -/*===== dependency =====*/ -#include /* size_t */ - - -/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */ -#ifndef ZSTDERRORLIB_VISIBLE - /* Backwards compatibility with old macro name */ - #ifdef ZSTDERRORLIB_VISIBILITY - #define ZSTDERRORLIB_VISIBLE ZSTDERRORLIB_VISIBILITY - #elif defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && !defined( __MINGW32__ ) - #define ZSTDERRORLIB_VISIBLE __attribute__( ( visibility( "default" ) ) ) - #else - #define ZSTDERRORLIB_VISIBLE - #endif -#endif - -#ifndef ZSTDERRORLIB_HIDDEN - #if defined( __GNUC__ ) && ( __GNUC__ >= 4 ) && !defined( __MINGW32__ ) - #define ZSTDERRORLIB_HIDDEN __attribute__( ( visibility( "hidden" ) ) ) - #else - #define ZSTDERRORLIB_HIDDEN - #endif -#endif - -#if defined( ZSTD_DLL_EXPORT ) && ( ZSTD_DLL_EXPORT == 1 ) - #define ZSTDERRORLIB_API __declspec( dllexport ) ZSTDERRORLIB_VISIBLE -#elif 1 - #define ZSTDERRORLIB_API \ - __declspec( dllimport ) \ - ZSTDERRORLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ -#else - #define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBLE -#endif - -/*-********************************************* - * Error codes list - *-********************************************* - * Error codes _values_ are pinned down since v1.3.1 only. - * Therefore, don't rely on values if you may link to any version < v1.3.1. - * - * Only values < 100 are considered stable. - * - * note 1 : this API shall be used with static linking only. - * dynamic linking is not yet officially supported. - * note 2 : Prefer relying on the enum than on its value whenever possible - * This is the only supported way to use the error list < v1.3.1 - * note 3 : ZSTD_isError() is always correct, whatever the library version. - **********************************************/ -typedef enum { - ZSTD_error_no_error = 0, - ZSTD_error_GENERIC = 1, - ZSTD_error_prefix_unknown = 10, - ZSTD_error_version_unsupported = 12, - ZSTD_error_frameParameter_unsupported = 14, - ZSTD_error_frameParameter_windowTooLarge = 16, - ZSTD_error_corruption_detected = 20, - ZSTD_error_checksum_wrong = 22, - ZSTD_error_literals_headerWrong = 24, - ZSTD_error_dictionary_corrupted = 30, - ZSTD_error_dictionary_wrong = 32, - ZSTD_error_dictionaryCreation_failed = 34, - ZSTD_error_parameter_unsupported = 40, - ZSTD_error_parameter_combination_unsupported = 41, - ZSTD_error_parameter_outOfBound = 42, - ZSTD_error_tableLog_tooLarge = 44, - ZSTD_error_maxSymbolValue_tooLarge = 46, - ZSTD_error_maxSymbolValue_tooSmall = 48, - ZSTD_error_stabilityCondition_notRespected = 50, - ZSTD_error_stage_wrong = 60, - ZSTD_error_init_missing = 62, - ZSTD_error_memory_allocation = 64, - ZSTD_error_workSpace_tooSmall = 66, - ZSTD_error_dstSize_tooSmall = 70, - ZSTD_error_srcSize_wrong = 72, - ZSTD_error_dstBuffer_null = 74, - ZSTD_error_noForwardProgress_destFull = 80, - ZSTD_error_noForwardProgress_inputEmpty = 82, - /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */ - ZSTD_error_frameIndex_tooLarge = 100, - ZSTD_error_seekableIO = 102, - ZSTD_error_dstBuffer_wrong = 104, - ZSTD_error_srcBuffer_wrong = 105, - ZSTD_error_sequenceProducer_failed = 106, - ZSTD_error_externalSequences_invalid = 107, - ZSTD_error_maxCode = - 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */ -} ZSTD_ErrorCode; - -/*! ZSTD_getErrorCode() : - convert a `size_t` function result into a `ZSTD_ErrorCode` enum type, - which can be used to compare with enum list published above */ -ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode( size_t functionResult ); -ZSTDERRORLIB_API const char * ZSTD_getErrorString( - ZSTD_ErrorCode code ); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ - - -#if defined( __cplusplus ) -} -#endif - -#endif /* ZSTD_ERRORS_H_398273423 */ diff --git a/winlibs/lib/dbg/charset-1.dll b/winlibs/lib/dbg/charset-1.dll deleted file mode 100644 index f7287c6f2..000000000 Binary files a/winlibs/lib/dbg/charset-1.dll and /dev/null differ diff --git a/winlibs/lib/dbg/hunspell-1.7-0.dll b/winlibs/lib/dbg/hunspell-1.7-0.dll deleted file mode 100644 index bd76251de..000000000 Binary files a/winlibs/lib/dbg/hunspell-1.7-0.dll and /dev/null differ diff --git a/winlibs/lib/dbg/hunspell-1.7.lib b/winlibs/lib/dbg/hunspell-1.7.lib deleted file mode 100644 index 263cff895..000000000 Binary files a/winlibs/lib/dbg/hunspell-1.7.lib and /dev/null differ diff --git a/winlibs/lib/dbg/iconv-2.dll b/winlibs/lib/dbg/iconv-2.dll deleted file mode 100644 index 5ad5d468c..000000000 Binary files a/winlibs/lib/dbg/iconv-2.dll and /dev/null differ diff --git a/winlibs/lib/dbg/liblzma.dll b/winlibs/lib/dbg/liblzma.dll deleted file mode 100644 index 4a8c4c6af..000000000 Binary files a/winlibs/lib/dbg/liblzma.dll and /dev/null differ diff --git a/winlibs/lib/dbg/lzma.lib b/winlibs/lib/dbg/lzma.lib deleted file mode 100644 index bcc18f625..000000000 Binary files a/winlibs/lib/dbg/lzma.lib and /dev/null differ diff --git a/winlibs/lib/dbg/opencc.dll b/winlibs/lib/dbg/opencc.dll deleted file mode 100644 index 1c3a1aab9..000000000 Binary files a/winlibs/lib/dbg/opencc.dll and /dev/null differ diff --git a/winlibs/lib/dbg/opencc.lib b/winlibs/lib/dbg/opencc.lib deleted file mode 100644 index d61569a65..000000000 Binary files a/winlibs/lib/dbg/opencc.lib and /dev/null differ diff --git a/winlibs/lib/dbg/xapian-30.dll b/winlibs/lib/dbg/xapian-30.dll deleted file mode 100644 index c9c135e5c..000000000 Binary files a/winlibs/lib/dbg/xapian-30.dll and /dev/null differ diff --git a/winlibs/lib/dbg/xapian.lib b/winlibs/lib/dbg/xapian.lib deleted file mode 100644 index ee218c198..000000000 Binary files a/winlibs/lib/dbg/xapian.lib and /dev/null differ diff --git a/winlibs/lib/dbg/zim-9.dll b/winlibs/lib/dbg/zim-9.dll deleted file mode 100644 index 9b56d992b..000000000 Binary files a/winlibs/lib/dbg/zim-9.dll and /dev/null differ diff --git a/winlibs/lib/dbg/zim.lib b/winlibs/lib/dbg/zim.lib deleted file mode 100644 index ba170a668..000000000 Binary files a/winlibs/lib/dbg/zim.lib and /dev/null differ diff --git a/winlibs/lib/dbg/zlibd.lib b/winlibs/lib/dbg/zlibd.lib deleted file mode 100644 index 04e0758eb..000000000 Binary files a/winlibs/lib/dbg/zlibd.lib and /dev/null differ diff --git a/winlibs/lib/dbg/zlibd1.dll b/winlibs/lib/dbg/zlibd1.dll deleted file mode 100644 index 2dafa561a..000000000 Binary files a/winlibs/lib/dbg/zlibd1.dll and /dev/null differ diff --git a/winlibs/lib/dbg/zstd.dll b/winlibs/lib/dbg/zstd.dll deleted file mode 100644 index 91f30e325..000000000 Binary files a/winlibs/lib/dbg/zstd.dll and /dev/null differ diff --git a/winlibs/lib/dbg/zstd.lib b/winlibs/lib/dbg/zstd.lib deleted file mode 100644 index 9f024e261..000000000 Binary files a/winlibs/lib/dbg/zstd.lib and /dev/null differ diff --git a/winlibs/lib/hunspell-1.7-0.dll b/winlibs/lib/hunspell-1.7-0.dll deleted file mode 100644 index 8cec7b7d7..000000000 Binary files a/winlibs/lib/hunspell-1.7-0.dll and /dev/null differ diff --git a/winlibs/lib/hunspell-1.7.lib b/winlibs/lib/hunspell-1.7.lib deleted file mode 100644 index 263cff895..000000000 Binary files a/winlibs/lib/hunspell-1.7.lib and /dev/null differ diff --git a/winlibs/lib/liblzma.dll b/winlibs/lib/liblzma.dll deleted file mode 100644 index b2ed62ca9..000000000 Binary files a/winlibs/lib/liblzma.dll and /dev/null differ diff --git a/winlibs/lib/lzma.lib b/winlibs/lib/lzma.lib deleted file mode 100644 index bcc18f625..000000000 Binary files a/winlibs/lib/lzma.lib and /dev/null differ diff --git a/winlibs/lib/msvc/README.md b/winlibs/lib/msvc/README.md deleted file mode 100644 index 6b3e359ca..000000000 --- a/winlibs/lib/msvc/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Prebuilt Libs for GoldenDict's - -almost all of these are found in the vcpkg - -use vcpkg install [lib] and copy the packages into this directory. \ No newline at end of file diff --git a/winlibs/lib/msvc/bz2.lib b/winlibs/lib/msvc/bz2.lib deleted file mode 100644 index 180170ab2..000000000 Binary files a/winlibs/lib/msvc/bz2.lib and /dev/null differ diff --git a/winlibs/lib/msvc/iconv.lib b/winlibs/lib/msvc/iconv.lib deleted file mode 100644 index d6c1735df..000000000 Binary files a/winlibs/lib/msvc/iconv.lib and /dev/null differ diff --git a/winlibs/lib/msvc/libcrypto-3-x64.dll b/winlibs/lib/msvc/libcrypto-3-x64.dll deleted file mode 100644 index 928739307..000000000 Binary files a/winlibs/lib/msvc/libcrypto-3-x64.dll and /dev/null differ diff --git a/winlibs/lib/msvc/libiconv.dll b/winlibs/lib/msvc/libiconv.dll deleted file mode 100644 index 4b08f73e8..000000000 Binary files a/winlibs/lib/msvc/libiconv.dll and /dev/null differ diff --git a/winlibs/lib/msvc/libssl-3-x64.dll b/winlibs/lib/msvc/libssl-3-x64.dll deleted file mode 100644 index 81ec4947a..000000000 Binary files a/winlibs/lib/msvc/libssl-3-x64.dll and /dev/null differ diff --git a/winlibs/lib/msvc/lzo2.lib b/winlibs/lib/msvc/lzo2.lib deleted file mode 100644 index b52fbb839..000000000 Binary files a/winlibs/lib/msvc/lzo2.lib and /dev/null differ diff --git a/winlibs/lib/msvc/ogg.lib b/winlibs/lib/msvc/ogg.lib deleted file mode 100644 index 5a9b88dcc..000000000 Binary files a/winlibs/lib/msvc/ogg.lib and /dev/null differ diff --git a/winlibs/lib/msvc/vorbis.lib b/winlibs/lib/msvc/vorbis.lib deleted file mode 100644 index d7c14b7aa..000000000 Binary files a/winlibs/lib/msvc/vorbis.lib and /dev/null differ diff --git a/winlibs/lib/msvc/vorbisenc.lib b/winlibs/lib/msvc/vorbisenc.lib deleted file mode 100644 index 221cc61af..000000000 Binary files a/winlibs/lib/msvc/vorbisenc.lib and /dev/null differ diff --git a/winlibs/lib/msvc/vorbisfile.lib b/winlibs/lib/msvc/vorbisfile.lib deleted file mode 100644 index f1a7b657f..000000000 Binary files a/winlibs/lib/msvc/vorbisfile.lib and /dev/null differ diff --git a/winlibs/lib/opencc.dll b/winlibs/lib/opencc.dll deleted file mode 100644 index 0fc85b544..000000000 Binary files a/winlibs/lib/opencc.dll and /dev/null differ diff --git a/winlibs/lib/opencc.lib b/winlibs/lib/opencc.lib deleted file mode 100644 index d61569a65..000000000 Binary files a/winlibs/lib/opencc.lib and /dev/null differ diff --git a/winlibs/lib/xapian-30.dll b/winlibs/lib/xapian-30.dll deleted file mode 100644 index 29ff2ef54..000000000 Binary files a/winlibs/lib/xapian-30.dll and /dev/null differ diff --git a/winlibs/lib/xapian.lib b/winlibs/lib/xapian.lib deleted file mode 100644 index ede96683f..000000000 Binary files a/winlibs/lib/xapian.lib and /dev/null differ diff --git a/winlibs/lib/zim-9.dll b/winlibs/lib/zim-9.dll deleted file mode 100644 index ae81fd787..000000000 Binary files a/winlibs/lib/zim-9.dll and /dev/null differ diff --git a/winlibs/lib/zim.lib b/winlibs/lib/zim.lib deleted file mode 100644 index ba170a668..000000000 Binary files a/winlibs/lib/zim.lib and /dev/null differ diff --git a/winlibs/lib/zlib.lib b/winlibs/lib/zlib.lib deleted file mode 100644 index d5af61a36..000000000 Binary files a/winlibs/lib/zlib.lib and /dev/null differ diff --git a/winlibs/lib/zlib1.dll b/winlibs/lib/zlib1.dll deleted file mode 100644 index fb071f0c4..000000000 Binary files a/winlibs/lib/zlib1.dll and /dev/null differ diff --git a/winlibs/lib/zstd.dll b/winlibs/lib/zstd.dll deleted file mode 100644 index cabce6559..000000000 Binary files a/winlibs/lib/zstd.dll and /dev/null differ diff --git a/winlibs/lib/zstd.lib b/winlibs/lib/zstd.lib deleted file mode 100644 index 9f024e261..000000000 Binary files a/winlibs/lib/zstd.lib and /dev/null differ diff --git a/winlibs/readme.txt b/winlibs/readme.txt deleted file mode 100644 index 73a9022c6..000000000 --- a/winlibs/readme.txt +++ /dev/null @@ -1,10 +0,0 @@ -This directory holds precompiled third-party libraries and their header files -used to build GoldenDict under Windows. Those are supplied merely to ease -the build process. No other platform except Windows uses those files, so they -can safely be removed for Linux builds etc. -Due credit goes to those created those libraries. The libraries are -copyrighted by their responsive copyright holders and distributed in -compliance to their respective licenses. No modifications were made except -those needed in order to build the libraries correctly. The source codes -aren't shipped here merely to shrink the size of the distribution, and can -be downloaded from the original libraries' websites separately. diff --git a/winlibs/scripts/00README.txt b/winlibs/scripts/00README.txt deleted file mode 100644 index 9cd6fec55..000000000 --- a/winlibs/scripts/00README.txt +++ /dev/null @@ -1,11 +0,0 @@ -FFmpeg, libao, speex, zLib build instructions ------------------------------------ - -Build -===== - -vcpkg install libao,libspeex,ffmpeg[core,avcodec,avformat,mp3lame,opus,speex,swresample,vorbis,fdk-aac,gpl],zlib:x64-windows-release - -binaries (dlls): ${vcpkg}/installed/bin -C headers: ${vcpkg}/installed/include -Linker files: ${vcpkg}/installed/lib