From c181c45ac184f5f49b4046c3177304e3c5dfba7d Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 12 Mar 2020 04:20:38 +0200 Subject: [PATCH] * Add presets for Hyperscan 5.2.1 (pull #849) --- .appveyor.yml | 2 + .travis.yml | 9 + CHANGELOG.md | 2 +- README.md | 1 + ci/build.cmd | 2 +- ci/install-travis.sh | 7 +- cppbuild.sh | 2 +- hyperscan/LICENSE | 116 + hyperscan/README.md | 135 + hyperscan/cppbuild.sh | 54 + hyperscan/platform/pom.xml | 115 + hyperscan/pom.xml | 54 + hyperscan/samples/HyperscanTest.java | 74 + hyperscan/samples/pom.xml | 21 + .../bytedeco/hyperscan/global/hyperscan.java | 2368 +++++++++++++++++ .../org/bytedeco/hyperscan/hs_alloc_t.java | 34 + .../hyperscan/hs_compile_error_t.java | 102 + .../org/bytedeco/hyperscan/hs_database.java | 19 + .../org/bytedeco/hyperscan/hs_database_t.java | 26 + .../org/bytedeco/hyperscan/hs_expr_ext_t.java | 76 + .../bytedeco/hyperscan/hs_expr_info_t.java | 77 + .../org/bytedeco/hyperscan/hs_free_t.java | 27 + .../hyperscan/hs_platform_info_t.java | 63 + .../org/bytedeco/hyperscan/hs_scratch.java | 18 + .../org/bytedeco/hyperscan/hs_scratch_t.java | 21 + .../org/bytedeco/hyperscan/hs_stream.java | 22 + .../org/bytedeco/hyperscan/hs_stream_t.java | 21 + .../hyperscan/match_event_handler.java | 81 + .../bytedeco/hyperscan/presets/hyperscan.java | 50 + hyperscan/src/main/java9/module-info.java | 6 + platform/pom.xml | 6 + pom.xml | 4 + 32 files changed, 3609 insertions(+), 6 deletions(-) create mode 100644 hyperscan/LICENSE create mode 100644 hyperscan/README.md create mode 100755 hyperscan/cppbuild.sh create mode 100644 hyperscan/platform/pom.xml create mode 100644 hyperscan/pom.xml create mode 100644 hyperscan/samples/HyperscanTest.java create mode 100644 hyperscan/samples/pom.xml create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/global/hyperscan.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_alloc_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_compile_error_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_ext_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_info_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_free_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_platform_info_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream_t.java create mode 100644 hyperscan/src/gen/java/org/bytedeco/hyperscan/match_event_handler.java create mode 100644 hyperscan/src/main/java/org/bytedeco/hyperscan/presets/hyperscan.java create mode 100644 hyperscan/src/main/java9/module-info.java diff --git a/.appveyor.yml b/.appveyor.yml index 456b52e481d..9a46527ef3d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -45,6 +45,8 @@ environment: OS: windows-x86_64 - PROJ: "hdf5" OS: windows-x86_64 + - PROJ: "hyperscan" + OS: windows-x86_64 - PROJ: "mkl" OS: windows-x86_64 - PROJ: "mkl-dnn,dnnl" diff --git a/.travis.yml b/.travis.yml index d268130d2d3..c783ad02778 100644 --- a/.travis.yml +++ b/.travis.yml @@ -376,6 +376,10 @@ matrix: env: PROJ=hdf5 OS=linux-x86_64 install: true script: ./ci/install-travis.sh + - os: linux + env: PROJ=hyperscan OS=linux-x86_64 + install: true + script: ./ci/install-travis.sh - os: linux env: PROJ=mkl OS=linux-x86_64 install: true @@ -486,6 +490,11 @@ matrix: env: PROJ=hdf5 OS=macosx-x86_64 install: true script: ./ci/install-travis.sh + - os: osx + osx_image: xcode9.3 + env: PROJ=hyperscan OS=macosx-x86_64 + install: true + script: ./ci/install-travis.sh - os: osx osx_image: xcode9.3 env: PROJ=mkl OS=macosx-x86_64 diff --git a/CHANGELOG.md b/CHANGELOG.md index 55826290d89..5fdf47d0471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ * Make sure `clone()` actually returns new `PIX`, `FPIX`, or `DPIX` objects with presets for Leptonica * Add `opencv_python3` module and corresponding loader class with sample code to the presets for OpenCV * Bundle OpenSSL in the presets for CPython for consistency across platforms ([issue #796](https://github.com/bytedeco/javacpp-presets/issues/796)) - * Add presets for Arrow 0.16.0, SciPy 1.4.1 ([issue #747](https://github.com/bytedeco/javacpp-presets/issues/747)), Gym 0.17.1 + * Add presets for Arrow 0.16.0, SciPy 1.4.1 ([issue #747](https://github.com/bytedeco/javacpp-presets/issues/747)), Gym 0.17.1, Hyperscan 5.2.1 ([pull #849](https://github.com/bytedeco/javacpp-presets/pull/849)) * Upgrade presets for OpenCV 4.2.0, FFmpeg 4.2.2, Spinnaker 1.27.0.48, HDF5 1.12.0, MKL 2020.0, MKL-DNN 0.21.4, DNNL 1.2.1, OpenBLAS 0.3.9, CPython 3.7.6, NumPy 1.18.1, LLVM 9.0.1, CUDA 10.2, cuDNN 7.6.5, NCCL 2.5.6, MXNet 1.6.0, TensorFlow 1.15.2, TensorRT 7.0, ALE 0.6.1, Leptonica 1.79.0, Tesseract 4.1.1, ONNX Runtime 1.1.2, Qt 5.14.1, Skia 1.68.1, and their dependencies ### November 5, 2019 version 1.5.2 diff --git a/README.md b/README.md index eeca619c03a..9275ff3f6a8 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip * flandmark 1.07 http://cmp.felk.cvut.cz/~uricamic/flandmark/#download * Arrow 0.16.x https://arrow.apache.org/install/ * HDF5 1.12.0 https://www.hdfgroup.org/downloads/ + * Hyperscan 5.2.x https://github.com/intel/hyperscan * MKL 2020.0 https://software.intel.com/intel-mkl * MKL-DNN 0.21.x https://github.com/intel/mkl-dnn * DNNL 1.2.x https://github.com/intel/mkl-dnn diff --git a/ci/build.cmd b/ci/build.cmd index 8c09f985152..d6d5a3aa07c 100644 --- a/ci/build.cmd +++ b/ci/build.cmd @@ -33,7 +33,7 @@ if "%APPVEYOR_PULL_REQUEST_NUMBER%" == "" if "%APPVEYOR_REPO_BRANCH%" == "releas rem C:\msys64\usr\bin\bash -lc "pacman -Syu --noconfirm" rem C:\msys64\usr\bin\bash -lc "pacman -Su --noconfirm" C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm base-devel git tar nasm yasm pkg-config unzip p7zip zip autoconf autoconf-archive automake libtool make patch gnupg" -C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-toolchain mingw-w64-x86_64-libtool mingw-w64-x86_64-gcc mingw-w64-i686-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-i686-gcc-fortran mingw-w64-x86_64-libwinpthread-git mingw-w64-i686-libwinpthread-git mingw-w64-x86_64-SDL mingw-w64-i686-SDL" +C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-toolchain mingw-w64-x86_64-libtool mingw-w64-x86_64-gcc mingw-w64-i686-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-i686-gcc-fortran mingw-w64-x86_64-libwinpthread-git mingw-w64-i686-libwinpthread-git mingw-w64-x86_64-SDL mingw-w64-i686-SDL mingw-w64-x86_64-ragel" SET "PATH=C:\Program Files\Python37;C:\Program Files (x86)\CMake\bin;C:\msys64\usr\bin\core_perl;C:\msys64\%MSYSTEM%\bin;C:\msys64\usr\bin;%PATH%" C:\msys64\usr\bin\bash -c "ci/install-windows.sh %PROJ%" diff --git a/ci/install-travis.sh b/ci/install-travis.sh index a175d8c5e4a..949bb2d5f87 100755 --- a/ci/install-travis.sh +++ b/ci/install-travis.sh @@ -49,7 +49,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then export JAVA_HOME=$(/usr/libexec/java_hom if [[ "$OS" == "linux-x86" ]] || [[ "$OS" == "linux-x86_64" ]] || [[ "$OS" =~ android ]]; then CENTOS_VERSION=6 SCL_ENABLE="devtoolset-7 python27 rh-git29" - if [[ "mxnet tensorflow onnx ngraph onnxruntime qt skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then + if [[ "mxnet hyperscan tensorflow onnx ngraph onnxruntime qt skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then CENTOS_VERSION=7 SCL_ENABLE="devtoolset-7 rh-git218" fi @@ -58,7 +58,8 @@ if [[ "$OS" == "linux-x86" ]] || [[ "$OS" == "linux-x86_64" ]] || [[ "$OS" =~ an DOCKER_CONTAINER_ID=$(docker ps | grep centos | awk '{print $1}') echo "Container id is $DOCKER_CONTAINER_ID please wait while updates applied" docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install centos-release-scl-rh epel-release" - docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install rh-java-common-ant $SCL_ENABLE ccache clang gcc-c++ gcc-gfortran java-1.8.0-openjdk-devel ant python python36-devel python36-pip swig git file which wget unzip tar bzip2 gzip xz patch make cmake3 autoconf-archive libtool bison flex perl nasm yasm alsa-lib-devel freeglut-devel gtk2-devel libusb-devel libusb1-devel zlib-devel SDL-devel libva-devel libxkbcommon-devel fontconfig-devel libffi-devel" + docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -y repolist" + docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install rh-java-common-ant $SCL_ENABLE ccache clang gcc-c++ gcc-gfortran java-1.8.0-openjdk-devel ant python python36-devel python36-pip swig git file which wget unzip tar bzip2 gzip xz patch make cmake3 autoconf-archive libtool bison flex perl nasm yasm alsa-lib-devel freeglut-devel gtk2-devel libusb-devel libusb1-devel zlib-devel SDL-devel libva-devel libxkbcommon-devel fontconfig-devel libffi-devel ragel" docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -y --disablerepo=cuda update" if [ "$OS" == "linux-x86" ]; then docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "rpm -qa | sed s/.x86_64$/.i686/ | xargs yum -q -y --disablerepo=cuda install" @@ -203,7 +204,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then echo "performing brew update and install of dependencies, please wait.." brew update brew upgrade cmake maven - brew install ccache swig autoconf-archive libtool libusb xz sdl gpg1 bison flex perl nasm yasm + brew install ccache swig autoconf-archive libtool libusb xz sdl gpg1 bison flex perl nasm yasm ragel # Try to use ccache to speed up the build export PATH=/usr/local/opt/ccache/libexec/:/usr/local/opt/gpg1/libexec/gpgbin/:/usr/local/opt/bison/bin/:/usr/local/opt/flex/bin/:$PATH diff --git a/cppbuild.sh b/cppbuild.sh index fd360daa26e..74f14b775f9 100755 --- a/cppbuild.sh +++ b/cppbuild.sh @@ -164,7 +164,7 @@ function sedinplace { } if [[ -z ${PROJECTS:-} ]]; then - PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems) + PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems) fi for PROJECT in ${PROJECTS[@]}; do diff --git a/hyperscan/LICENSE b/hyperscan/LICENSE new file mode 100644 index 00000000000..cddef0c6188 --- /dev/null +++ b/hyperscan/LICENSE @@ -0,0 +1,116 @@ +Hyperscan is licensed under the BSD License. + +Copyright (c) 2015, Intel Corporation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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. + + +-------------------------------------------------------------------------------- + +This product also contains code from third parties, under the following +licenses: + +Intel's Slicing-by-8 CRC32 implementation +----------------------------------------- + +Copyright (c) 2004-2006, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + + +Boost C++ Headers Library +------------------------- + +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. + + +The Google C++ Testing Framework (Google Test) +---------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER 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. \ No newline at end of file diff --git a/hyperscan/README.md b/hyperscan/README.md new file mode 100644 index 00000000000..0bf53d45d6e --- /dev/null +++ b/hyperscan/README.md @@ -0,0 +1,135 @@ +JavaCPP Presets for Hyperscan +============================= + +Introduction +------------ +This directory contains the JavaCPP Presets module for: + + * Hyperscan 5.2.1 https://www.hyperscan.io + +Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. + + +Documentation +------------- +Java API documentation is available here: + + * http://bytedeco.org/javacpp-presets/hyperscan/apidocs/ + + +Sample Usage +------------ +Here is a simple example of Hyperscan + +We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `HyperscanTest.java` source files below, simply execute on the command line: +```bash + $ mvn compile exec:java +``` + +Be aware that flag `-Djavacpp.platform` can be used to specify the target platform when running the maven command above, for example: +```bash + $ mvn compile exec:java -Djavacpp.platform=linux-x86_64 +``` + +### The `pom.xml` build file +```xml + + 4.0.0 + org.bytedeco.hyperscan + HyperscanTest + 1.5.3-SNAPSHOT + + HyperscanTest + 1.7 + 1.7 + + + + org.bytedeco + hyperscan-platform + 5.2.1-1.5.3-SNAPSHOT + + + + . + + +``` + +### The `HyperscanTest.java` source file +```java +import org.bytedeco.hyperscan.global.hyperscan; +import org.bytedeco.hyperscan.hs_compile_error_t; +import org.bytedeco.hyperscan.hs_database_t; +import org.bytedeco.hyperscan.hs_scratch_t; +import org.bytedeco.hyperscan.match_event_handler; +import org.bytedeco.javacpp.BytePointer; +import org.bytedeco.javacpp.IntPointer; +import org.bytedeco.javacpp.Loader; +import org.bytedeco.javacpp.Pointer; +import org.bytedeco.javacpp.PointerPointer; +import org.bytedeco.javacpp.annotation.Cast; + +import static org.bytedeco.hyperscan.global.hyperscan.HS_FLAG_SINGLEMATCH; +import static org.bytedeco.hyperscan.global.hyperscan.HS_MODE_BLOCK; + +public class HyperscanTest { + + public static void main(String[] args) { + Loader.load(hyperscan.class); + + String[] patterns = { "abc1", "asa", "dab" }; + hs_database_t database_t = null; + match_event_handler matchEventHandler = null; + hs_scratch_t scratchSpace = new hs_scratch_t(); + hs_compile_error_t compile_error_t; + + try(PointerPointer database_t_p = new PointerPointer(1); + PointerPointer compile_error_t_p = new PointerPointer(1); + IntPointer compileFlags = new IntPointer(HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH); + IntPointer patternIds = new IntPointer(1, 1, 1); + PointerPointer expressionsPointer = new PointerPointer(patterns) + ) { + + matchEventHandler = new match_event_handler() { + @Override + public int call(@Cast("unsigned int") int id, + @Cast("unsigned long long") long from, + @Cast("unsigned long long") long to, + @Cast("unsigned int") int flags, Pointer context) { + System.out.println(from + "-" + to); + System.out.println(id); + return 0; + } + }; + + int result = hyperscan.hs_compile_multi(expressionsPointer, compileFlags, patternIds, 3, HS_MODE_BLOCK, + null, database_t_p, compile_error_t_p); + + database_t = new hs_database_t(database_t_p.get(0)); + compile_error_t = new hs_compile_error_t(compile_error_t_p.get(0)); + if (result != 0) { + System.out.println(compile_error_t.message().getString()); + System.exit(1); + } + result = hyperscan.hs_alloc_scratch(database_t, scratchSpace); + if (result != 0) { + System.out.println("Error during scratch space allocation"); + System.exit(1); + } + + String textToSearch = "-21dasaaadabcaaa"; + hyperscan.hs_scan(database_t, textToSearch, textToSearch.length(), 0, scratchSpace, matchEventHandler, expressionsPointer); + + } finally { + hyperscan.hs_free_scratch(scratchSpace); + if (database_t != null) { + hyperscan.hs_free_database(database_t); + } + if (matchEventHandler != null) { + matchEventHandler.close(); + } + } + } +} +``` diff --git a/hyperscan/cppbuild.sh b/hyperscan/cppbuild.sh new file mode 100755 index 00000000000..93bbc02df82 --- /dev/null +++ b/hyperscan/cppbuild.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# This file is meant to be included by the parent cppbuild.sh script +if [[ -z "$PLATFORM" ]]; then + pushd .. + bash cppbuild.sh "$@" hyperscan + popd + exit +fi + +HYPERSCAN_VERSION=5.2.1 +BOOST=1_70_0 +download "https://github.com/intel/hyperscan/archive/v$HYPERSCAN_VERSION.tar.gz" hyperscan-$HYPERSCAN_VERSION.tar.gz +download http://downloads.sourceforge.net/project/boost/boost/${BOOST//_/.}/boost_$BOOST.tar.gz boost_$BOOST.tar.gz +mkdir -p $PLATFORM +cd $PLATFORM +INSTALL_PATH=`pwd` +mkdir -p include lib +mkdir -p include/hs +echo "Decompressing archives..." +tar -xzvf ../hyperscan-$HYPERSCAN_VERSION.tar.gz +tar --totals -xf ../boost_$BOOST.tar.gz + +cd boost_$BOOST +./bootstrap.sh --with-libraries=headers +./b2 headers +cd .. + +ln -sf $INSTALL_PATH/boost_$BOOST/boost $INSTALL_PATH/hyperscan-$HYPERSCAN_VERSION/include/boost + +cd hyperscan-$HYPERSCAN_VERSION + +case $PLATFORM in + linux-x86_64) + CFLAGS='-O -fPIC' CC="gcc" CXX="g++ -std=c++11 -m64 -fPIC" "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" . + make -j $MAKEJ + make install/strip + ;; + macosx-x86_64) + "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='-Wno-error' . + make -j $MAKEJ + make install/strip + ;; + windows-x86_64) + CXXFLAGS="/Wv:17" "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' . + MSBuild.exe hyperscan.sln //p:Configuration=Release //p:Platform=x64 + cp -r src/* $INSTALL_PATH/include/hs/ + cp lib/*.lib $INSTALL_PATH/lib + ;; + *) + echo "Error: Platform \"$PLATFORM\" is not supported" + ;; +esac + +cd ../.. \ No newline at end of file diff --git a/hyperscan/platform/pom.xml b/hyperscan/platform/pom.xml new file mode 100644 index 00000000000..fbabc053ea8 --- /dev/null +++ b/hyperscan/platform/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + + + org.bytedeco + javacpp-presets + 1.5.3-SNAPSHOT + ../../ + + + hyperscan-platform + 5.2.1-${project.parent.version} + JavaCPP Presets Platform for hyperscan + + + hyperscan + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.linux-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.macosx-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.windows-x86_64} + + + + + + + maven-jar-plugin + + + default-jar + + + + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar + + + + + + empty-javadoc-jar + + jar + + + javadoc + + + + empty-sources-jar + + jar + + + sources + + + + + + org.moditect + moditect-maven-plugin + + + add-module-infos + none + + + add-platform-module-info + package + + add-module-info + + + + + ${project.build.directory}/${project.artifactId}.jar + + module org.bytedeco.${javacpp.moduleId}.platform { + requires org.bytedeco.${javacpp.moduleId}.linux.x86_64; + requires org.bytedeco.${javacpp.moduleId}.macosx.x86_64; + requires org.bytedeco.${javacpp.moduleId}.windows.x86_64; + } + + + + + + + + + + \ No newline at end of file diff --git a/hyperscan/pom.xml b/hyperscan/pom.xml new file mode 100644 index 00000000000..ea83f4ec6e8 --- /dev/null +++ b/hyperscan/pom.xml @@ -0,0 +1,54 @@ + + + + javacpp-presets + org.bytedeco + 1.5.3-SNAPSHOT + + 4.0.0 + + hyperscan + 5.2.1-${project.parent.version} + JavaCPP Presets for Hyperscan + + + + org.bytedeco + javacpp + + + + + + + maven-resources-plugin + + + maven-compiler-plugin + + + org.bytedeco + javacpp + + + maven-jar-plugin + + + org.moditect + moditect-maven-plugin + + + maven-dependency-plugin + + + maven-source-plugin + + + maven-javadoc-plugin + + + + + \ No newline at end of file diff --git a/hyperscan/samples/HyperscanTest.java b/hyperscan/samples/HyperscanTest.java new file mode 100644 index 00000000000..633e44d27ca --- /dev/null +++ b/hyperscan/samples/HyperscanTest.java @@ -0,0 +1,74 @@ +import org.bytedeco.hyperscan.global.hyperscan; +import org.bytedeco.hyperscan.hs_compile_error_t; +import org.bytedeco.hyperscan.hs_database_t; +import org.bytedeco.hyperscan.hs_scratch_t; +import org.bytedeco.hyperscan.match_event_handler; +import org.bytedeco.javacpp.BytePointer; +import org.bytedeco.javacpp.IntPointer; +import org.bytedeco.javacpp.Loader; +import org.bytedeco.javacpp.Pointer; +import org.bytedeco.javacpp.PointerPointer; +import org.bytedeco.javacpp.annotation.Cast; + +import static org.bytedeco.hyperscan.global.hyperscan.HS_FLAG_SINGLEMATCH; +import static org.bytedeco.hyperscan.global.hyperscan.HS_MODE_BLOCK; + +public class HyperscanTest { + + public static void main(String[] args) { + Loader.load(hyperscan.class); + + String[] patterns = { "abc1", "asa", "dab" }; + hs_database_t database_t = null; + match_event_handler matchEventHandler = null; + hs_scratch_t scratchSpace = new hs_scratch_t(); + hs_compile_error_t compile_error_t; + + try(PointerPointer database_t_p = new PointerPointer(1); + PointerPointer compile_error_t_p = new PointerPointer(1); + IntPointer compileFlags = new IntPointer(HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH); + IntPointer patternIds = new IntPointer(1, 1, 1); + PointerPointer expressionsPointer = new PointerPointer(patterns) + ) { + + matchEventHandler = new match_event_handler() { + @Override + public int call(@Cast("unsigned int") int id, + @Cast("unsigned long long") long from, + @Cast("unsigned long long") long to, + @Cast("unsigned int") int flags, Pointer context) { + System.out.println(from + "-" + to); + System.out.println(id); + return 0; + } + }; + + int result = hyperscan.hs_compile_multi(expressionsPointer, compileFlags, patternIds, 3, HS_MODE_BLOCK, + null, database_t_p, compile_error_t_p); + + database_t = new hs_database_t(database_t_p.get(0)); + compile_error_t = new hs_compile_error_t(compile_error_t_p.get(0)); + if (result != 0) { + System.out.println(compile_error_t.message().getString()); + System.exit(1); + } + result = hyperscan.hs_alloc_scratch(database_t, scratchSpace); + if (result != 0) { + System.out.println("Error during scratch space allocation"); + System.exit(1); + } + + String textToSearch = "-21dasaaadabcaaa"; + hyperscan.hs_scan(database_t, textToSearch, textToSearch.length(), 0, scratchSpace, matchEventHandler, expressionsPointer); + + } finally { + hyperscan.hs_free_scratch(scratchSpace); + if (database_t != null) { + hyperscan.hs_free_database(database_t); + } + if (matchEventHandler != null) { + matchEventHandler.close(); + } + } + } +} diff --git a/hyperscan/samples/pom.xml b/hyperscan/samples/pom.xml new file mode 100644 index 00000000000..f218fcb3f59 --- /dev/null +++ b/hyperscan/samples/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + org.bytedeco.hyperscan + HyperscanTest + 1.5.3-SNAPSHOT + + HyperscanTest + 1.7 + 1.7 + + + + org.bytedeco + hyperscan-platform + 5.2.1-1.5.3-SNAPSHOT + + + + . + + diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/global/hyperscan.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/global/hyperscan.java new file mode 100644 index 00000000000..a704934ed42 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/global/hyperscan.java @@ -0,0 +1,2368 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan.global; + +import org.bytedeco.hyperscan.*; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +public class hyperscan extends org.bytedeco.hyperscan.presets.hyperscan { + static { Loader.load(); } + +// Parsed from hs/hs_common.h + +/* + * Copyright (c) 2015-2019, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 HS_COMMON_H_ +// #define HS_COMMON_H_ + +// #if defined(_WIN32) +// #define HS_CDECL __cdecl +// #else +// #define HS_CDECL +// #endif +// #include + +/** + * \file + * \brief The Hyperscan common API definition. + * + * Hyperscan is a high speed regular expression engine. + * + * This header contains functions available to both the Hyperscan compiler and + * runtime. + */ + +// #ifdef __cplusplus +// Targeting ../hs_database.java + + +// Targeting ../hs_database_t.java + + + +/** + * A type for errors returned by Hyperscan functions. + */ + +/** + * Free a compiled pattern database. + * + * The free callback set by \ref hs_set_database_allocator() (or \ref + * hs_set_allocator()) will be used by this function. + * + * @param db + * A compiled pattern database. NULL may also be safely provided, in which + * case the function does nothing. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_free_database(hs_database_t db); + +/** + * Serialize a pattern database to a stream of bytes. + * + * The allocator callback set by \ref hs_set_misc_allocator() (or \ref + * hs_set_allocator()) will be used by this function. + * + * @param db + * A compiled pattern database. + * + * @param bytes + * On success, a pointer to an array of bytes will be returned here. + * These bytes can be subsequently relocated or written to disk. The + * caller is responsible for freeing this block. + * + * @param length + * On success, the number of bytes in the generated byte array will be + * returned here. + * + * @return + * \ref HS_SUCCESS on success, \ref HS_NOMEM if the byte array cannot be + * allocated, other values may be returned if errors are detected. + */ +public static native @Cast("hs_error_t") int hs_serialize_database(@Const hs_database_t db, @Cast("char**") PointerPointer bytes, + @Cast("size_t*") SizeTPointer length); +public static native @Cast("hs_error_t") int hs_serialize_database(@Const hs_database_t db, @Cast("char**") @ByPtrPtr BytePointer bytes, + @Cast("size_t*") SizeTPointer length); +public static native @Cast("hs_error_t") int hs_serialize_database(@Const hs_database_t db, @Cast("char**") @ByPtrPtr ByteBuffer bytes, + @Cast("size_t*") SizeTPointer length); +public static native @Cast("hs_error_t") int hs_serialize_database(@Const hs_database_t db, @Cast("char**") @ByPtrPtr byte[] bytes, + @Cast("size_t*") SizeTPointer length); + +/** + * Reconstruct a pattern database from a stream of bytes previously generated + * by \ref hs_serialize_database(). + * + * This function will allocate sufficient space for the database using the + * allocator set with \ref hs_set_database_allocator() (or \ref + * hs_set_allocator()); to use a pre-allocated region of memory, use the \ref + * hs_deserialize_database_at() function. + * + * @param bytes + * A byte array generated by \ref hs_serialize_database() representing a + * compiled pattern database. + * + * @param length + * The length of the byte array generated by \ref hs_serialize_database(). + * This should be the same value as that returned by \ref + * hs_serialize_database(). + * + * @param db + * On success, a pointer to a newly allocated \ref hs_database_t will be + * returned here. This database can then be used for scanning, and + * eventually freed by the caller using \ref hs_free_database(). + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_deserialize_database(@Cast("const char*") BytePointer bytes, + @Cast("const size_t") long length, + @Cast("hs_database_t**") PointerPointer db); +public static native @Cast("hs_error_t") int hs_deserialize_database(@Cast("const char*") BytePointer bytes, + @Cast("const size_t") long length, + @ByPtrPtr hs_database_t db); +public static native @Cast("hs_error_t") int hs_deserialize_database(String bytes, + @Cast("const size_t") long length, + @ByPtrPtr hs_database_t db); + +/** + * Reconstruct a pattern database from a stream of bytes previously generated + * by \ref hs_serialize_database() at a given memory location. + * + * This function (unlike \ref hs_deserialize_database()) will write the + * reconstructed database to the memory location given in the \p db parameter. + * The amount of space required at this location can be determined with the + * \ref hs_serialized_database_size() function. + * + * @param bytes + * A byte array generated by \ref hs_serialize_database() representing a + * compiled pattern database. + * + * @param length + * The length of the byte array generated by \ref hs_serialize_database(). + * This should be the same value as that returned by \ref + * hs_serialize_database(). + * + * @param db + * Pointer to an 8-byte aligned block of memory of sufficient size to hold + * the deserialized database. On success, the reconstructed database will + * be written to this location. This database can then be used for pattern + * matching. The user is responsible for freeing this memory; the \ref + * hs_free_database() call should not be used. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_deserialize_database_at(@Cast("const char*") BytePointer bytes, + @Cast("const size_t") long length, + hs_database_t db); +public static native @Cast("hs_error_t") int hs_deserialize_database_at(String bytes, + @Cast("const size_t") long length, + hs_database_t db); + +/** + * Provides the size of the stream state allocated by a single stream opened + * against the given database. + * + * @param database + * Pointer to a compiled (streaming mode) pattern database. + * + * @param stream_size + * On success, the size in bytes of an individual stream opened against the + * given database is placed in this parameter. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_stream_size(@Const hs_database_t database, + @Cast("size_t*") SizeTPointer stream_size); + +/** + * Provides the size of the given database in bytes. + * + * @param database + * Pointer to compiled pattern database. + * + * @param database_size + * On success, the size of the compiled database in bytes is placed in this + * parameter. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_database_size(@Const hs_database_t database, + @Cast("size_t*") SizeTPointer database_size); + +/** + * Utility function for reporting the size that would be required by a + * database if it were deserialized. + * + * This can be used to allocate a shared memory region or other "special" + * allocation prior to deserializing with the \ref hs_deserialize_database_at() + * function. + * + * @param bytes + * Pointer to a byte array generated by \ref hs_serialize_database() + * representing a compiled pattern database. + * + * @param length + * The length of the byte array generated by \ref hs_serialize_database(). + * This should be the same value as that returned by \ref + * hs_serialize_database(). + * + * @param deserialized_size + * On success, the size of the compiled database that would be generated + * by \ref hs_deserialize_database_at() is returned here. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_serialized_database_size(@Cast("const char*") BytePointer bytes, + @Cast("const size_t") long length, + @Cast("size_t*") SizeTPointer deserialized_size); +public static native @Cast("hs_error_t") int hs_serialized_database_size(String bytes, + @Cast("const size_t") long length, + @Cast("size_t*") SizeTPointer deserialized_size); + +/** + * Utility function providing information about a database. + * + * @param database + * Pointer to a compiled database. + * + * @param info + * On success, a string containing the version and platform information for + * the supplied database is placed in the parameter. The string is + * allocated using the allocator supplied in \ref hs_set_misc_allocator() + * (or malloc() if no allocator was set) and should be freed by the caller. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_database_info(@Const hs_database_t database, + @Cast("char**") PointerPointer info); +public static native @Cast("hs_error_t") int hs_database_info(@Const hs_database_t database, + @Cast("char**") @ByPtrPtr BytePointer info); +public static native @Cast("hs_error_t") int hs_database_info(@Const hs_database_t database, + @Cast("char**") @ByPtrPtr ByteBuffer info); +public static native @Cast("hs_error_t") int hs_database_info(@Const hs_database_t database, + @Cast("char**") @ByPtrPtr byte[] info); + +/** + * Utility function providing information about a serialized database. + * + * @param bytes + * Pointer to a serialized database. + * + * @param length + * Length in bytes of the serialized database. + * + * @param info + * On success, a string containing the version and platform information + * for the supplied serialized database is placed in the parameter. The + * string is allocated using the allocator supplied in \ref + * hs_set_misc_allocator() (or malloc() if no allocator was set) and + * should be freed by the caller. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_serialized_database_info(@Cast("const char*") BytePointer bytes, + @Cast("size_t") long length, @Cast("char**") PointerPointer info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(@Cast("const char*") BytePointer bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr BytePointer info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(String bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr ByteBuffer info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(@Cast("const char*") BytePointer bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr byte[] info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(String bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr BytePointer info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(@Cast("const char*") BytePointer bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr ByteBuffer info); +public static native @Cast("hs_error_t") int hs_serialized_database_info(String bytes, + @Cast("size_t") long length, @Cast("char**") @ByPtrPtr byte[] info); +// Targeting ../hs_alloc_t.java + + +// Targeting ../hs_free_t.java + + + +/** + * Set the allocate and free functions used by Hyperscan for allocating + * memory at runtime for stream state, scratch space, database bytecode, + * and various other data structure returned by the Hyperscan API. + * + * The function is equivalent to calling \ref hs_set_stream_allocator(), + * \ref hs_set_scratch_allocator(), \ref hs_set_database_allocator() and + * \ref hs_set_misc_allocator() with the provided parameters. + * + * This call will override any previous allocators that have been set. + * + * Note: there is no way to change the allocator used for temporary objects + * created during the various compile calls (\ref hs_compile(), \ref + * hs_compile_multi(), \ref hs_compile_ext_multi()). + * + * @param alloc_func + * A callback function pointer that allocates memory. This function must + * return memory suitably aligned for the largest representable data type + * on this platform. + * + * @param free_func + * A callback function pointer that frees allocated memory. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_set_allocator(hs_alloc_t alloc_func, + hs_free_t free_func); + +/** + * Set the allocate and free functions used by Hyperscan for allocating memory + * for database bytecode produced by the compile calls (\ref hs_compile(), \ref + * hs_compile_multi(), \ref hs_compile_ext_multi()) and by database + * deserialization (\ref hs_deserialize_database()). + * + * If no database allocation functions are set, or if NULL is used in place of + * both parameters, then memory allocation will default to standard methods + * (such as the system malloc() and free() calls). + * + * This call will override any previous database allocators that have been set. + * + * Note: the database allocator may also be set by calling \ref + * hs_set_allocator(). + * + * Note: there is no way to change how temporary objects created during the + * various compile calls (\ref hs_compile(), \ref hs_compile_multi(), \ref + * hs_compile_ext_multi()) are allocated. + * + * @param alloc_func + * A callback function pointer that allocates memory. This function must + * return memory suitably aligned for the largest representable data type + * on this platform. + * + * @param free_func + * A callback function pointer that frees allocated memory. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_set_database_allocator(hs_alloc_t alloc_func, + hs_free_t free_func); + +/** + * Set the allocate and free functions used by Hyperscan for allocating memory + * for items returned by the Hyperscan API such as \ref hs_compile_error_t, \ref + * hs_expr_info_t and serialized databases. + * + * If no misc allocation functions are set, or if NULL is used in place of both + * parameters, then memory allocation will default to standard methods (such as + * the system malloc() and free() calls). + * + * This call will override any previous misc allocators that have been set. + * + * Note: the misc allocator may also be set by calling \ref hs_set_allocator(). + * + * @param alloc_func + * A callback function pointer that allocates memory. This function must + * return memory suitably aligned for the largest representable data type + * on this platform. + * + * @param free_func + * A callback function pointer that frees allocated memory. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_set_misc_allocator(hs_alloc_t alloc_func, + hs_free_t free_func); + +/** + * Set the allocate and free functions used by Hyperscan for allocating memory + * for scratch space by \ref hs_alloc_scratch() and \ref hs_clone_scratch(). + * + * If no scratch allocation functions are set, or if NULL is used in place of + * both parameters, then memory allocation will default to standard methods + * (such as the system malloc() and free() calls). + * + * This call will override any previous scratch allocators that have been set. + * + * Note: the scratch allocator may also be set by calling \ref + * hs_set_allocator(). + * + * @param alloc_func + * A callback function pointer that allocates memory. This function must + * return memory suitably aligned for the largest representable data type + * on this platform. + * + * @param free_func + * A callback function pointer that frees allocated memory. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_set_scratch_allocator(hs_alloc_t alloc_func, + hs_free_t free_func); + +/** + * Set the allocate and free functions used by Hyperscan for allocating memory + * for stream state by \ref hs_open_stream(). + * + * If no stream allocation functions are set, or if NULL is used in place of + * both parameters, then memory allocation will default to standard methods + * (such as the system malloc() and free() calls). + * + * This call will override any previous stream allocators that have been set. + * + * Note: the stream allocator may also be set by calling \ref + * hs_set_allocator(). + * + * @param alloc_func + * A callback function pointer that allocates memory. This function must + * return memory suitably aligned for the largest representable data type + * on this platform. + * + * @param free_func + * A callback function pointer that frees allocated memory. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_set_stream_allocator(hs_alloc_t alloc_func, + hs_free_t free_func); + +/** + * Utility function for identifying this release version. + * + * @return + * A string containing the version number of this release build and the + * date of the build. It is allocated statically, so it does not need to + * be freed by the caller. + */ +public static native @Cast("const char*") BytePointer hs_version(); + +/** + * Utility function to test the current system architecture. + * + * Hyperscan requires the Supplemental Streaming SIMD Extensions 3 instruction + * set. This function can be called on any x86 platform to determine if the + * system provides the required instruction set. + * + * This function does not test for more advanced features if Hyperscan has + * been built for a more specific architecture, for example the AVX2 + * instruction set. + * + * @return + * \ref HS_SUCCESS on success, \ref HS_ARCH_ERROR if system does not + * support Hyperscan. + */ +public static native @Cast("hs_error_t") int hs_valid_platform(); + +/** + * \defgroup HS_ERROR hs_error_t values + * + * \{ + */ + +/** + * The engine completed normally. + */ +public static final int HS_SUCCESS = 0; + +/** + * A parameter passed to this function was invalid. + * + * This error is only returned in cases where the function can detect an + * invalid parameter -- it cannot be relied upon to detect (for example) + * pointers to freed memory or other invalid data. + */ +public static final int HS_INVALID = (-1); + +/** + * A memory allocation failed. + */ +public static final int HS_NOMEM = (-2); + +/** + * The engine was terminated by callback. + * + * This return value indicates that the target buffer was partially scanned, + * but that the callback function requested that scanning cease after a match + * was located. + */ +public static final int HS_SCAN_TERMINATED = (-3); + +/** + * The pattern compiler failed, and the \ref hs_compile_error_t should be + * inspected for more detail. + */ +public static final int HS_COMPILER_ERROR = (-4); + +/** + * The given database was built for a different version of Hyperscan. + */ +public static final int HS_DB_VERSION_ERROR = (-5); + +/** + * The given database was built for a different platform (i.e., CPU type). + */ +public static final int HS_DB_PLATFORM_ERROR = (-6); + +/** + * The given database was built for a different mode of operation. This error + * is returned when streaming calls are used with a block or vectored database + * and vice versa. + */ +public static final int HS_DB_MODE_ERROR = (-7); + +/** + * A parameter passed to this function was not correctly aligned. + */ +public static final int HS_BAD_ALIGN = (-8); + +/** + * The memory allocator (either malloc() or the allocator set with \ref + * hs_set_allocator()) did not correctly return memory suitably aligned for the + * largest representable data type on this platform. + */ +public static final int HS_BAD_ALLOC = (-9); + +/** + * The scratch region was already in use. + * + * This error is returned when Hyperscan is able to detect that the scratch + * region given is already in use by another Hyperscan API call. + * + * A separate scratch region, allocated with \ref hs_alloc_scratch() or \ref + * hs_clone_scratch(), is required for every concurrent caller of the Hyperscan + * API. + * + * For example, this error might be returned when \ref hs_scan() has been + * called inside a callback delivered by a currently-executing \ref hs_scan() + * call using the same scratch region. + * + * Note: Not all concurrent uses of scratch regions may be detected. This error + * is intended as a best-effort debugging tool, not a guarantee. + */ +public static final int HS_SCRATCH_IN_USE = (-10); + +/** + * Unsupported CPU architecture. + * + * This error is returned when Hyperscan is able to detect that the current + * system does not support the required instruction set. + * + * At a minimum, Hyperscan requires Supplemental Streaming SIMD Extensions 3 + * (SSSE3). + */ +public static final int HS_ARCH_ERROR = (-11); + +/** + * Provided buffer was too small. + * + * This error indicates that there was insufficient space in the buffer. The + * call should be repeated with a larger provided buffer. + * + * Note: in this situation, it is normal for the amount of space required to be + * returned in the same manner as the used space would have been returned if the + * call was successful. + */ +public static final int HS_INSUFFICIENT_SPACE = (-12); + +/** + * Unexpected internal error. + * + * This error indicates that there was unexpected matching behaviors. This + * could be related to invalid usage of stream and scratch space or invalid memory + * operations by users. + * + */ +public static final int HS_UNKNOWN_ERROR = (-13); + +/** \} */ + +// #ifdef __cplusplus /* extern "C" */ +// #endif + +// #endif /* HS_COMMON_H_ */ + + +// Parsed from hs/hs_compile.h + +/* + * Copyright (c) 2015-2019, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 HS_COMPILE_H_ +// #define HS_COMPILE_H_ + +/** + * \file + * \brief The Hyperscan compiler API definition. + * + * Hyperscan is a high speed regular expression engine. + * + * This header contains functions for compiling regular expressions into + * Hyperscan databases that can be used by the Hyperscan runtime. + */ + +// #include "hs_common.h" + +// #ifdef __cplusplus +// Targeting ../hs_compile_error_t.java + + +// Targeting ../hs_platform_info_t.java + + +// Targeting ../hs_expr_info_t.java + + +// Targeting ../hs_expr_ext_t.java + + + +/** + * \defgroup HS_EXT_FLAG hs_expr_ext_t flags + * + * These flags are used in \ref hs_expr_ext_t::flags to indicate which fields + * are used. + * + * \{ + */ + +/** Flag indicating that the hs_expr_ext::min_offset field is used. */ +public static final long HS_EXT_FLAG_MIN_OFFSET = 1L; + +/** Flag indicating that the hs_expr_ext::max_offset field is used. */ +public static final long HS_EXT_FLAG_MAX_OFFSET = 2L; + +/** Flag indicating that the hs_expr_ext::min_length field is used. */ +public static final long HS_EXT_FLAG_MIN_LENGTH = 4L; + +/** Flag indicating that the hs_expr_ext::edit_distance field is used. */ +public static final long HS_EXT_FLAG_EDIT_DISTANCE = 8L; + +/** Flag indicating that the hs_expr_ext::hamming_distance field is used. */ +public static final long HS_EXT_FLAG_HAMMING_DISTANCE = 16L; + +/** \} */ + +/** + * The basic regular expression compiler. + * + * This is the function call with which an expression is compiled into a + * Hyperscan database which can be passed to the runtime functions (such as + * \ref hs_scan(), \ref hs_open_stream(), etc.) + * + * @param expression + * The NULL-terminated expression to parse. Note that this string must + * represent ONLY the pattern to be matched, with no delimiters or flags; + * any global flags should be specified with the \p flags argument. For + * example, the expression {@code /abc?def/i} should be compiled by providing + * {@code abc?def} as the \p expression, and \ref HS_FLAG_CASELESS as the \a + * flags. + * + * @param flags + * Flags which modify the behaviour of the expression. Multiple flags may + * be used by ORing them together. Valid values are: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_DOTALL - Matching a {@code .} will not exclude newlines. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated for the + * expression per stream. + * - HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an + * empty string, such as {@code .*}. + * - HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters. + * - HS_FLAG_UCP - Use Unicode properties for character classes. + * - HS_FLAG_PREFILTER - Compile pattern in prefiltering mode. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * - HS_FLAG_COMBINATION - Parse the expression in logical combination + * syntax. + * - HS_FLAG_QUIET - Ignore match reporting for this expression. Used for + * the sub-expressions in logical combinations. + * + * @param mode + * Compiler mode flags that affect the database as a whole. One of \ref + * HS_MODE_STREAM or \ref HS_MODE_BLOCK or \ref HS_MODE_VECTORED must be + * supplied, to select between the generation of a streaming, block or + * vectored database. In addition, other flags (beginning with HS_MODE_) + * may be supplied to enable specific features. See \ref HS_MODE_FLAG for + * more details. + * + * @param platform + * If not NULL, the platform structure is used to determine the target + * platform for the database. If NULL, a database suitable for running + * on the current host platform is produced. + * + * @param db + * On success, a pointer to the generated database will be returned in + * this parameter, or NULL on failure. The caller is responsible for + * deallocating the buffer using the \ref hs_free_database() function. + * + * @param error + * If the compile fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the error + * parameter. + */ +public static native @Cast("hs_error_t") int hs_compile(@Cast("const char*") BytePointer expression, @Cast("unsigned int") int flags, + @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @Cast("hs_database_t**") PointerPointer db, @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_compile(@Cast("const char*") BytePointer expression, @Cast("unsigned int") int flags, + @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile(String expression, @Cast("unsigned int") int flags, + @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, @ByPtrPtr hs_compile_error_t error); + +/** + * The multiple regular expression compiler. + * + * This is the function call with which a set of expressions is compiled into a + * database which can be passed to the runtime functions (such as \ref + * hs_scan(), \ref hs_open_stream(), etc.) Each expression can be labelled with + * a unique integer which is passed into the match callback to identify the + * pattern that has matched. + * + * @param expressions + * Array of NULL-terminated expressions to compile. Note that (as for \ref + * hs_compile()) these strings must contain only the pattern to be + * matched, with no delimiters or flags. For example, the expression + * {@code /abc?def/i} should be compiled by providing {@code abc?def} as the first + * string in the \p expressions array, and \ref HS_FLAG_CASELESS as the + * first value in the \p flags array. + * + * @param flags + * Array of flags which modify the behaviour of each expression. Multiple + * flags may be used by ORing them together. Specifying the NULL pointer + * in place of an array will set the flags value for all patterns to zero. + * Valid values are: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_DOTALL - Matching a {@code .} will not exclude newlines. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated by patterns + * with this match id per stream. + * - HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an + * empty string, such as {@code .*}. + * - HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters. + * - HS_FLAG_UCP - Use Unicode properties for character classes. + * - HS_FLAG_PREFILTER - Compile pattern in prefiltering mode. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * - HS_FLAG_COMBINATION - Parse the expression in logical combination + * syntax. + * - HS_FLAG_QUIET - Ignore match reporting for this expression. Used for + * the sub-expressions in logical combinations. + * + * @param ids + * An array of integers specifying the ID number to be associated with the + * corresponding pattern in the expressions array. Specifying the NULL + * pointer in place of an array will set the ID value for all patterns to + * zero. + * + * @param elements + * The number of elements in the input arrays. + * + * @param mode + * Compiler mode flags that affect the database as a whole. One of \ref + * HS_MODE_STREAM or \ref HS_MODE_BLOCK or \ref HS_MODE_VECTORED must be + * supplied, to select between the generation of a streaming, block or + * vectored database. In addition, other flags (beginning with HS_MODE_) + * may be supplied to enable specific features. See \ref HS_MODE_FLAG for + * more details. + * + * @param platform + * If not NULL, the platform structure is used to determine the target + * platform for the database. If NULL, a database suitable for running + * on the current host platform is produced. + * + * @param db + * On success, a pointer to the generated database will be returned in + * this parameter, or NULL on failure. The caller is responsible for + * deallocating the buffer using the \ref hs_free_database() function. + * + * @param error + * If the compile fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the \p error + * parameter. + * + */ +public static native @Cast("hs_error_t") int hs_compile_multi(@Cast("const char*const*") PointerPointer expressions, + @Cast("const unsigned int*") IntPointer flags, + @Cast("const unsigned int*") IntPointer ids, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @Cast("hs_database_t**") PointerPointer db, + @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_compile_multi(@Cast("const char*const*") @ByPtrPtr BytePointer expressions, + @Cast("const unsigned int*") IntPointer flags, + @Cast("const unsigned int*") IntPointer ids, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_multi(@Cast("const char*const*") @ByPtrPtr ByteBuffer expressions, + @Cast("const unsigned int*") IntBuffer flags, + @Cast("const unsigned int*") IntBuffer ids, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_multi(@Cast("const char*const*") @ByPtrPtr byte[] expressions, + @Cast("const unsigned int*") int[] flags, + @Cast("const unsigned int*") int[] ids, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); + +/** + * The multiple regular expression compiler with extended parameter support. + * + * This function call compiles a group of expressions into a database in the + * same way as \ref hs_compile_multi(), but allows additional parameters to be + * specified via an \ref hs_expr_ext_t structure per expression. + * + * @param expressions + * Array of NULL-terminated expressions to compile. Note that (as for \ref + * hs_compile()) these strings must contain only the pattern to be + * matched, with no delimiters or flags. For example, the expression + * {@code /abc?def/i} should be compiled by providing {@code abc?def} as the first + * string in the \p expressions array, and \ref HS_FLAG_CASELESS as the + * first value in the \p flags array. + * + * @param flags + * Array of flags which modify the behaviour of each expression. Multiple + * flags may be used by ORing them together. Specifying the NULL pointer + * in place of an array will set the flags value for all patterns to zero. + * Valid values are: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_DOTALL - Matching a {@code .} will not exclude newlines. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated by patterns + * with this match id per stream. + * - HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an + * empty string, such as {@code .*}. + * - HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters. + * - HS_FLAG_UCP - Use Unicode properties for character classes. + * - HS_FLAG_PREFILTER - Compile pattern in prefiltering mode. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * - HS_FLAG_COMBINATION - Parse the expression in logical combination + * syntax. + * - HS_FLAG_QUIET - Ignore match reporting for this expression. Used for + * the sub-expressions in logical combinations. + * + * @param ids + * An array of integers specifying the ID number to be associated with the + * corresponding pattern in the expressions array. Specifying the NULL + * pointer in place of an array will set the ID value for all patterns to + * zero. + * + * @param ext + * An array of pointers to filled \ref hs_expr_ext_t structures that + * define extended behaviour for each pattern. NULL may be specified if no + * extended behaviour is needed for an individual pattern, or in place of + * the whole array if it is not needed for any expressions. Memory used by + * these structures must be both allocated and freed by the caller. + * + * @param elements + * The number of elements in the input arrays. + * + * @param mode + * Compiler mode flags that affect the database as a whole. One of \ref + * HS_MODE_STREAM, \ref HS_MODE_BLOCK or \ref HS_MODE_VECTORED must be + * supplied, to select between the generation of a streaming, block or + * vectored database. In addition, other flags (beginning with HS_MODE_) + * may be supplied to enable specific features. See \ref HS_MODE_FLAG for + * more details. + * + * @param platform + * If not NULL, the platform structure is used to determine the target + * platform for the database. If NULL, a database suitable for running + * on the current host platform is produced. + * + * @param db + * On success, a pointer to the generated database will be returned in + * this parameter, or NULL on failure. The caller is responsible for + * deallocating the buffer using the \ref hs_free_database() function. + * + * @param error + * If the compile fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the \p error + * parameter. + * + */ +public static native @Cast("hs_error_t") int hs_compile_ext_multi(@Cast("const char*const*") PointerPointer expressions, + @Cast("const unsigned int*") IntPointer flags, + @Cast("const unsigned int*") IntPointer ids, + @Cast("const hs_expr_ext_t*const*") PointerPointer ext, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @Cast("hs_database_t**") PointerPointer db, @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_compile_ext_multi(@Cast("const char*const*") @ByPtrPtr BytePointer expressions, + @Cast("const unsigned int*") IntPointer flags, + @Cast("const unsigned int*") IntPointer ids, + @Const @ByPtrPtr hs_expr_ext_t ext, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_ext_multi(@Cast("const char*const*") @ByPtrPtr ByteBuffer expressions, + @Cast("const unsigned int*") IntBuffer flags, + @Cast("const unsigned int*") IntBuffer ids, + @Const @ByPtrPtr hs_expr_ext_t ext, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_ext_multi(@Cast("const char*const*") @ByPtrPtr byte[] expressions, + @Cast("const unsigned int*") int[] flags, + @Cast("const unsigned int*") int[] ids, + @Const @ByPtrPtr hs_expr_ext_t ext, + @Cast("unsigned int") int elements, @Cast("unsigned int") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, @ByPtrPtr hs_compile_error_t error); + +/** + * The basic pure literal expression compiler. + * + * This is the function call with which a pure literal expression (not a + * common regular expression) is compiled into a Hyperscan database which + * can be passed to the runtime functions (such as \ref hs_scan(), + * \ref hs_open_stream(), etc.) + * + * @param expression + * The NULL-terminated expression to parse. Note that this string must + * represent ONLY the pattern to be matched, with no delimiters or flags; + * any global flags should be specified with the \p flags argument. For + * example, the expression {@code /abc?def/i} should be compiled by providing + * {@code abc?def} as the \p expression, and \ref HS_FLAG_CASELESS as the \a + * flags. Meanwhile, the string content shall be fully parsed in a literal + * sense without any regular grammars. For example, the \p expression + * {@code abc?} simply means a char sequence of {@code a}, {@code b}, {@code c}, and {@code ?}. The {@code ?} + * here doesn't mean 0 or 1 quantifier under regular semantics. + * + * @param flags + * Flags which modify the behaviour of the expression. Multiple flags may + * be used by ORing them together. Compared to \ref hs_compile(), fewer + * valid values are provided: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated for the + * expression per stream. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * + * @param len + * The length of the text content of the pure literal expression. As the + * text content indicated by \p expression is treated as single character + * one by one, the special terminating character {@code \0} should be allowed + * to appear in expression, and not treated as a terminator for a string. + * Thus, the end of a pure literal expression cannot be indicated by + * identifying {@code \0}, but by counting to the expression length. + * + * @param mode + * Compiler mode flags that affect the database as a whole. One of \ref + * HS_MODE_STREAM or \ref HS_MODE_BLOCK or \ref HS_MODE_VECTORED must be + * supplied, to select between the generation of a streaming, block or + * vectored database. In addition, other flags (beginning with HS_MODE_) + * may be supplied to enable specific features. See \ref HS_MODE_FLAG for + * more details. + * + * @param platform + * If not NULL, the platform structure is used to determine the target + * platform for the database. If NULL, a database suitable for running + * on the current host platform is produced. + * + * @param db + * On success, a pointer to the generated database will be returned in + * this parameter, or NULL on failure. The caller is responsible for + * deallocating the buffer using the \ref hs_free_database() function. + * + * @param error + * If the compile fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the error + * parameter. + */ +public static native @Cast("hs_error_t") int hs_compile_lit(@Cast("const char*") BytePointer expression, @Cast("unsigned") int flags, + @Cast("const size_t") long len, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @Cast("hs_database_t**") PointerPointer db, + @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_compile_lit(@Cast("const char*") BytePointer expression, @Cast("unsigned") int flags, + @Cast("const size_t") long len, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_lit(String expression, @Cast("unsigned") int flags, + @Cast("const size_t") long len, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +/** + * The multiple pure literal expression compiler. + * + * This is the function call with which a set of pure literal expressions is + * compiled into a database which can be passed to the runtime functions (such + * as \ref hs_scan(), \ref hs_open_stream(), etc.) Each expression can be + * labelled with a unique integer which is passed into the match callback to + * identify the pattern that has matched. + * + * @param expressions + * The NULL-terminated expression to parse. Note that this string must + * represent ONLY the pattern to be matched, with no delimiters or flags; + * any global flags should be specified with the \p flags argument. For + * example, the expression {@code /abc?def/i} should be compiled by providing + * {@code abc?def} as the \p expression, and \ref HS_FLAG_CASELESS as the \a + * flags. Meanwhile, the string content shall be fully parsed in a literal + * sense without any regular grammars. For example, the \p expression + * {@code abc?} simply means a char sequence of {@code a}, {@code b}, {@code c}, and {@code ?}. The {@code ?} + * here doesn't mean 0 or 1 quantifier under regular semantics. + * + * @param flags + * Array of flags which modify the behaviour of each expression. Multiple + * flags may be used by ORing them together. Specifying the NULL pointer + * in place of an array will set the flags value for all patterns to zero. + * Compared to \ref hs_compile_multi(), fewer valid values are provided: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated for the + * expression per stream. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * + * @param ids + * An array of integers specifying the ID number to be associated with the + * corresponding pattern in the expressions array. Specifying the NULL + * pointer in place of an array will set the ID value for all patterns to + * zero. + * + * @param lens + * Array of lengths of the text content of each pure literal expression. + * As the text content indicated by \p expression is treated as single + * character one by one, the special terminating character {@code \0} should be + * allowed to appear in expression, and not treated as a terminator for a + * string. Thus, the end of a pure literal expression cannot be indicated + * by identifying {@code \0}, but by counting to the expression length. + * + * @param elements + * The number of elements in the input arrays. + * + * @param mode + * Compiler mode flags that affect the database as a whole. One of \ref + * HS_MODE_STREAM or \ref HS_MODE_BLOCK or \ref HS_MODE_VECTORED must be + * supplied, to select between the generation of a streaming, block or + * vectored database. In addition, other flags (beginning with HS_MODE_) + * may be supplied to enable specific features. See \ref HS_MODE_FLAG for + * more details. + * + * @param platform + * If not NULL, the platform structure is used to determine the target + * platform for the database. If NULL, a database suitable for running + * on the current host platform is produced. + * + * @param db + * On success, a pointer to the generated database will be returned in + * this parameter, or NULL on failure. The caller is responsible for + * deallocating the buffer using the \ref hs_free_database() function. + * + * @param error + * If the compile fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the error + * parameter. + */ +public static native @Cast("hs_error_t") int hs_compile_lit_multi(@Cast("const char*const*") PointerPointer expressions, + @Cast("const unsigned*") IntPointer flags, + @Cast("const unsigned*") IntPointer ids, + @Cast("const size_t*") SizeTPointer lens, + @Cast("unsigned") int elements, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @Cast("hs_database_t**") PointerPointer db, + @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_compile_lit_multi(@Cast("const char*const*") @ByPtrPtr BytePointer expressions, + @Cast("const unsigned*") IntPointer flags, + @Cast("const unsigned*") IntPointer ids, + @Cast("const size_t*") SizeTPointer lens, + @Cast("unsigned") int elements, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_lit_multi(@Cast("const char*const*") @ByPtrPtr ByteBuffer expressions, + @Cast("const unsigned*") IntBuffer flags, + @Cast("const unsigned*") IntBuffer ids, + @Cast("const size_t*") SizeTPointer lens, + @Cast("unsigned") int elements, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_compile_lit_multi(@Cast("const char*const*") @ByPtrPtr byte[] expressions, + @Cast("const unsigned*") int[] flags, + @Cast("const unsigned*") int[] ids, + @Cast("const size_t*") SizeTPointer lens, + @Cast("unsigned") int elements, @Cast("unsigned") int mode, + @Const hs_platform_info_t platform, + @ByPtrPtr hs_database_t db, + @ByPtrPtr hs_compile_error_t error); + +/** + * Free an error structure generated by \ref hs_compile(), \ref + * hs_compile_multi() or \ref hs_compile_ext_multi(). + * + * @param error + * The \ref hs_compile_error_t to be freed. NULL may also be safely + * provided. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_free_compile_error(hs_compile_error_t error); + +/** + * Utility function providing information about a regular expression. The + * information provided in \ref hs_expr_info_t includes the minimum and maximum + * width of a pattern match. + * + * Note: successful analysis of an expression with this function does not imply + * that compilation of the same expression (via \ref hs_compile(), \ref + * hs_compile_multi() or \ref hs_compile_ext_multi()) would succeed. This + * function may return \ref HS_SUCCESS for regular expressions that Hyperscan + * cannot compile. + * + * Note: some per-pattern flags (such as \ref HS_FLAG_ALLOWEMPTY, \ref + * HS_FLAG_SOM_LEFTMOST) are accepted by this call, but as they do not affect + * the properties returned in the \ref hs_expr_info_t structure, they will not + * affect the outcome of this function. + * + * @param expression + * The NULL-terminated expression to parse. Note that this string must + * represent ONLY the pattern to be matched, with no delimiters or flags; + * any global flags should be specified with the \p flags argument. For + * example, the expression {@code /abc?def/i} should be compiled by providing + * {@code abc?def} as the \p expression, and \ref HS_FLAG_CASELESS as the \a + * flags. + * + * @param flags + * Flags which modify the behaviour of the expression. Multiple flags may + * be used by ORing them together. Valid values are: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_DOTALL - Matching a {@code .} will not exclude newlines. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated by the + * expression per stream. + * - HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an + * empty string, such as {@code .*}. + * - HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters. + * - HS_FLAG_UCP - Use Unicode properties for character classes. + * - HS_FLAG_PREFILTER - Compile pattern in prefiltering mode. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * - HS_FLAG_COMBINATION - Parse the expression in logical combination + * syntax. + * - HS_FLAG_QUIET - Ignore match reporting for this expression. Used for + * the sub-expressions in logical combinations. + * + * @param info + * On success, a pointer to the pattern information will be returned in + * this parameter, or NULL on failure. This structure is allocated using + * the allocator supplied in \ref hs_set_allocator() (or malloc() if no + * allocator was set) and should be freed by the caller. + * + * @param error + * If the call fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the error + * parameter. + */ +public static native @Cast("hs_error_t") int hs_expression_info(@Cast("const char*") BytePointer expression, + @Cast("unsigned int") int flags, + @Cast("hs_expr_info_t**") PointerPointer info, + @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_expression_info(@Cast("const char*") BytePointer expression, + @Cast("unsigned int") int flags, + @ByPtrPtr hs_expr_info_t info, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_expression_info(String expression, + @Cast("unsigned int") int flags, + @ByPtrPtr hs_expr_info_t info, + @ByPtrPtr hs_compile_error_t error); + +/** + * Utility function providing information about a regular expression, with + * extended parameter support. The information provided in \ref hs_expr_info_t + * includes the minimum and maximum width of a pattern match. + * + * Note: successful analysis of an expression with this function does not imply + * that compilation of the same expression (via \ref hs_compile(), \ref + * hs_compile_multi() or \ref hs_compile_ext_multi()) would succeed. This + * function may return \ref HS_SUCCESS for regular expressions that Hyperscan + * cannot compile. + * + * Note: some per-pattern flags (such as \ref HS_FLAG_ALLOWEMPTY, \ref + * HS_FLAG_SOM_LEFTMOST) are accepted by this call, but as they do not affect + * the properties returned in the \ref hs_expr_info_t structure, they will not + * affect the outcome of this function. + * + * @param expression + * The NULL-terminated expression to parse. Note that this string must + * represent ONLY the pattern to be matched, with no delimiters or flags; + * any global flags should be specified with the \p flags argument. For + * example, the expression {@code /abc?def/i} should be compiled by providing + * {@code abc?def} as the \p expression, and \ref HS_FLAG_CASELESS as the \a + * flags. + * + * @param flags + * Flags which modify the behaviour of the expression. Multiple flags may + * be used by ORing them together. Valid values are: + * - HS_FLAG_CASELESS - Matching will be performed case-insensitively. + * - HS_FLAG_DOTALL - Matching a {@code .} will not exclude newlines. + * - HS_FLAG_MULTILINE - {@code ^} and {@code $} anchors match any newlines in data. + * - HS_FLAG_SINGLEMATCH - Only one match will be generated by the + * expression per stream. + * - HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an + * empty string, such as {@code .*}. + * - HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters. + * - HS_FLAG_UCP - Use Unicode properties for character classes. + * - HS_FLAG_PREFILTER - Compile pattern in prefiltering mode. + * - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset + * when a match is found. + * - HS_FLAG_COMBINATION - Parse the expression in logical combination + * syntax. + * - HS_FLAG_QUIET - Ignore match reporting for this expression. Used for + * the sub-expressions in logical combinations. + * + * @param ext + * A pointer to a filled \ref hs_expr_ext_t structure that defines + * extended behaviour for this pattern. NULL may be specified if no + * extended parameters are needed. + * + * @param info + * On success, a pointer to the pattern information will be returned in + * this parameter, or NULL on failure. This structure is allocated using + * the allocator supplied in \ref hs_set_allocator() (or malloc() if no + * allocator was set) and should be freed by the caller. + * + * @param error + * If the call fails, a pointer to a \ref hs_compile_error_t will be + * returned, providing details of the error condition. The caller is + * responsible for deallocating the buffer using the \ref + * hs_free_compile_error() function. + * + * @return + * \ref HS_SUCCESS is returned on successful compilation; \ref + * HS_COMPILER_ERROR on failure, with details provided in the error + * parameter. + */ +public static native @Cast("hs_error_t") int hs_expression_ext_info(@Cast("const char*") BytePointer expression, + @Cast("unsigned int") int flags, + @Const hs_expr_ext_t ext, + @Cast("hs_expr_info_t**") PointerPointer info, + @Cast("hs_compile_error_t**") PointerPointer error); +public static native @Cast("hs_error_t") int hs_expression_ext_info(@Cast("const char*") BytePointer expression, + @Cast("unsigned int") int flags, + @Const hs_expr_ext_t ext, + @ByPtrPtr hs_expr_info_t info, + @ByPtrPtr hs_compile_error_t error); +public static native @Cast("hs_error_t") int hs_expression_ext_info(String expression, + @Cast("unsigned int") int flags, + @Const hs_expr_ext_t ext, + @ByPtrPtr hs_expr_info_t info, + @ByPtrPtr hs_compile_error_t error); + +/** + * Populates the platform information based on the current host. + * + * @param platform + * On success, the pointed to structure is populated based on the current + * host. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_populate_platform(hs_platform_info_t platform); + +/** + * \defgroup HS_PATTERN_FLAG Pattern flags + * + * \{ + */ + +/** + * Compile flag: Set case-insensitive matching. + * + * This flag sets the expression to be matched case-insensitively by default. + * The expression may still use PCRE tokens (notably {@code (?i)} and + * {@code (?-i)}) to switch case-insensitive matching on and off. + */ +public static final int HS_FLAG_CASELESS = 1; + +/** + * Compile flag: Matching a {@code .} will not exclude newlines. + * + * This flag sets any instances of the {@code .} token to match newline characters as + * well as all other characters. The PCRE specification states that the {@code .} + * token does not match newline characters by default, so without this flag the + * {@code .} token will not cross line boundaries. + */ +public static final int HS_FLAG_DOTALL = 2; + +/** + * Compile flag: Set multi-line anchoring. + * + * This flag instructs the expression to make the {@code ^} and {@code $} tokens match + * newline characters as well as the start and end of the stream. If this flag + * is not specified, the {@code ^} token will only ever match at the start of a + * stream, and the {@code $} token will only ever match at the end of a stream within + * the guidelines of the PCRE specification. + */ +public static final int HS_FLAG_MULTILINE = 4; + +/** + * Compile flag: Set single-match only mode. + * + * This flag sets the expression's match ID to match at most once. In streaming + * mode, this means that the expression will return only a single match over + * the lifetime of the stream, rather than reporting every match as per + * standard Hyperscan semantics. In block mode or vectored mode, only the first + * match for each invocation of \ref hs_scan() or \ref hs_scan_vector() will be + * returned. + * + * If multiple expressions in the database share the same match ID, then they + * either must all specify \ref HS_FLAG_SINGLEMATCH or none of them specify + * \ref HS_FLAG_SINGLEMATCH. If a group of expressions sharing a match ID + * specify the flag, then at most one match with the match ID will be generated + * per stream. + * + * Note: The use of this flag in combination with \ref HS_FLAG_SOM_LEFTMOST + * is not currently supported. + */ +public static final int HS_FLAG_SINGLEMATCH = 8; + +/** + * Compile flag: Allow expressions that can match against empty buffers. + * + * This flag instructs the compiler to allow expressions that can match against + * empty buffers, such as {@code .?}, {@code .*}, {@code (a|)}. Since Hyperscan can return every + * possible match for an expression, such expressions generally execute very + * slowly; the default behaviour is to return an error when an attempt to + * compile one is made. Using this flag will force the compiler to allow such + * an expression. + */ +public static final int HS_FLAG_ALLOWEMPTY = 16; + +/** + * Compile flag: Enable UTF-8 mode for this expression. + * + * This flag instructs Hyperscan to treat the pattern as a sequence of UTF-8 + * characters. The results of scanning invalid UTF-8 sequences with a Hyperscan + * library that has been compiled with one or more patterns using this flag are + * undefined. + */ +public static final int HS_FLAG_UTF8 = 32; + +/** + * Compile flag: Enable Unicode property support for this expression. + * + * This flag instructs Hyperscan to use Unicode properties, rather than the + * default ASCII interpretations, for character mnemonics like {@code \w} and {@code \s} as + * well as the POSIX character classes. It is only meaningful in conjunction + * with \ref HS_FLAG_UTF8. + */ +public static final int HS_FLAG_UCP = 64; + +/** + * Compile flag: Enable prefiltering mode for this expression. + * + * This flag instructs Hyperscan to compile an "approximate" version of this + * pattern for use in a prefiltering application, even if Hyperscan does not + * support the pattern in normal operation. + * + * The set of matches returned when this flag is used is guaranteed to be a + * superset of the matches specified by the non-prefiltering expression. + * + * If the pattern contains pattern constructs not supported by Hyperscan (such + * as zero-width assertions, back-references or conditional references) these + * constructs will be replaced internally with broader constructs that may + * match more often. + * + * Furthermore, in prefiltering mode Hyperscan may simplify a pattern that + * would otherwise return a "Pattern too large" error at compile time, or for + * performance reasons (subject to the matching guarantee above). + * + * It is generally expected that the application will subsequently confirm + * prefilter matches with another regular expression matcher that can provide + * exact matches for the pattern. + * + * Note: The use of this flag in combination with \ref HS_FLAG_SOM_LEFTMOST + * is not currently supported. + */ +public static final int HS_FLAG_PREFILTER = 128; + +/** + * Compile flag: Enable leftmost start of match reporting. + * + * This flag instructs Hyperscan to report the leftmost possible start of match + * offset when a match is reported for this expression. (By default, no start + * of match is returned.) + * + * Enabling this behaviour may reduce performance and increase stream state + * requirements in streaming mode. + */ +public static final int HS_FLAG_SOM_LEFTMOST = 256; + +/** + * Compile flag: Logical combination. + * + * This flag instructs Hyperscan to parse this expression as logical + * combination syntax. + * Logical constraints consist of operands, operators and parentheses. + * The operands are expression indices, and operators can be + * '!'(NOT), '&'(AND) or '|'(OR). + * For example: + * (101&102&103)|(104&!105) + * ((301|302)&303)&(304|305) + */ +public static final int HS_FLAG_COMBINATION = 512; + +/** + * Compile flag: Don't do any match reporting. + * + * This flag instructs Hyperscan to ignore match reporting for this expression. + * It is designed to be used on the sub-expressions in logical combinations. + */ +public static final int HS_FLAG_QUIET = 1024; + +/** \} */ + +/** + * \defgroup HS_CPU_FEATURES_FLAG CPU feature support flags + * + * \{ + */ + +/** + * CPU features flag - Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) + * + * Setting this flag indicates that the target platform supports AVX2 + * instructions. + */ +public static final long HS_CPU_FEATURES_AVX2 = (1L << 2); + +/** + * CPU features flag - Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX512) + * + * Setting this flag indicates that the target platform supports AVX512 + * instructions, specifically AVX-512BW. Using AVX512 implies the use of AVX2. + */ +public static final long HS_CPU_FEATURES_AVX512 = (1L << 3); + +/** \} */ + +/** + * \defgroup HS_TUNE_FLAG Tuning flags + * + * \{ + */ + +/** + * Tuning Parameter - Generic + * + * This indicates that the compiled database should not be tuned for any + * particular target platform. + */ +public static final int HS_TUNE_FAMILY_GENERIC = 0; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Sandy Bridge + * + * This indicates that the compiled database should be tuned for the + * Sandy Bridge microarchitecture. + */ +public static final int HS_TUNE_FAMILY_SNB = 1; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Ivy Bridge + * + * This indicates that the compiled database should be tuned for the + * Ivy Bridge microarchitecture. + */ +public static final int HS_TUNE_FAMILY_IVB = 2; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Haswell + * + * This indicates that the compiled database should be tuned for the + * Haswell microarchitecture. + */ +public static final int HS_TUNE_FAMILY_HSW = 3; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Silvermont + * + * This indicates that the compiled database should be tuned for the + * Silvermont microarchitecture. + */ +public static final int HS_TUNE_FAMILY_SLM = 4; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Broadwell + * + * This indicates that the compiled database should be tuned for the + * Broadwell microarchitecture. + */ +public static final int HS_TUNE_FAMILY_BDW = 5; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Skylake + * + * This indicates that the compiled database should be tuned for the + * Skylake microarchitecture. + */ +public static final int HS_TUNE_FAMILY_SKL = 6; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Skylake Server + * + * This indicates that the compiled database should be tuned for the + * Skylake Server microarchitecture. + */ +public static final int HS_TUNE_FAMILY_SKX = 7; + +/** + * Tuning Parameter - Intel(R) microarchitecture code name Goldmont + * + * This indicates that the compiled database should be tuned for the + * Goldmont microarchitecture. + */ +public static final int HS_TUNE_FAMILY_GLM = 8; + +/** \} */ + +/** + * \defgroup HS_MODE_FLAG Compile mode flags + * + * The mode flags are used as values for the mode parameter of the various + * compile calls (\ref hs_compile(), \ref hs_compile_multi() and \ref + * hs_compile_ext_multi()). + * + * A mode value can be built by ORing these flag values together; the only + * required flag is one of \ref HS_MODE_BLOCK, \ref HS_MODE_STREAM or \ref + * HS_MODE_VECTORED. Other flags may be added to enable support for additional + * features. + * + * \{ + */ + +/** + * Compiler mode flag: Block scan (non-streaming) database. + */ +public static final int HS_MODE_BLOCK = 1; + +/** + * Compiler mode flag: Alias for \ref HS_MODE_BLOCK. + */ +public static final int HS_MODE_NOSTREAM = 1; + +/** + * Compiler mode flag: Streaming database. + */ +public static final int HS_MODE_STREAM = 2; + +/** + * Compiler mode flag: Vectored scanning database. + */ +public static final int HS_MODE_VECTORED = 4; + +/** + * Compiler mode flag: use full precision to track start of match offsets in + * stream state. + * + * This mode will use the most stream state per pattern, but will always return + * an accurate start of match offset regardless of how far back in the past it + * was found. + * + * One of the SOM_HORIZON modes must be selected to use the \ref + * HS_FLAG_SOM_LEFTMOST expression flag. + */ +public static final long HS_MODE_SOM_HORIZON_LARGE = (1L << 24); + +/** + * Compiler mode flag: use medium precision to track start of match offsets in + * stream state. + * + * This mode will use less stream state than \ref HS_MODE_SOM_HORIZON_LARGE and + * will limit start of match accuracy to offsets within 2^32 bytes of the + * end of match offset reported. + * + * One of the SOM_HORIZON modes must be selected to use the \ref + * HS_FLAG_SOM_LEFTMOST expression flag. + */ +public static final long HS_MODE_SOM_HORIZON_MEDIUM = (1L << 25); + +/** + * Compiler mode flag: use limited precision to track start of match offsets in + * stream state. + * + * This mode will use less stream state than \ref HS_MODE_SOM_HORIZON_LARGE and + * will limit start of match accuracy to offsets within 2^16 bytes of the + * end of match offset reported. + * + * One of the SOM_HORIZON modes must be selected to use the \ref + * HS_FLAG_SOM_LEFTMOST expression flag. + */ +public static final long HS_MODE_SOM_HORIZON_SMALL = (1L << 26); + +/** \} */ + +// #ifdef __cplusplus /* extern "C" */ +// #endif + +// #endif /* HS_COMPILE_H_ */ + + +// Parsed from hs/hs_runtime.h + +/* + * Copyright (c) 2015-2018, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 HS_RUNTIME_H_ +// #define HS_RUNTIME_H_ + +// #include + +/** + * \file + * \brief The Hyperscan runtime API definition. + * + * Hyperscan is a high speed regular expression engine. + * + * This header contains functions for using compiled Hyperscan databases for + * scanning data at runtime. + */ + +// #include "hs_common.h" + +// #ifdef __cplusplus +// Targeting ../hs_stream.java + + +// Targeting ../hs_stream_t.java + + +// Targeting ../hs_scratch.java + + +// Targeting ../hs_scratch_t.java + + +// Targeting ../match_event_handler.java + + + +/** + * Open and initialise a stream. + * + * @param db + * A compiled pattern database. + * + * @param flags + * Flags modifying the behaviour of the stream. This parameter is provided + * for future use and is unused at present. + * + * @param stream + * On success, a pointer to the generated \ref hs_stream_t will be + * returned; NULL on failure. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_open_stream(@Const hs_database_t db, @Cast("unsigned int") int flags, + @Cast("hs_stream_t**") PointerPointer stream); +public static native @Cast("hs_error_t") int hs_open_stream(@Const hs_database_t db, @Cast("unsigned int") int flags, + @ByPtrPtr hs_stream_t stream); + +/** + * Write data to be scanned to the opened stream. + * + * This is the function call in which the actual pattern matching takes place + * as data is written to the stream. Matches will be returned via the \ref + * match_event_handler callback supplied. + * + * @param id + * The stream ID (returned by \ref hs_open_stream()) to which the data + * will be written. + * + * @param data + * Pointer to the data to be scanned. + * + * @param length + * The number of bytes to scan. + * + * @param flags + * Flags modifying the behaviour of the stream. This parameter is provided + * for future use and is unused at present. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch(). + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param ctxt + * The user defined pointer which will be passed to the callback function + * when a match occurs. + * + * @return + * Returns \ref HS_SUCCESS on success; \ref HS_SCAN_TERMINATED if the + * match callback indicated that scanning should stop; other values on + * error. + */ +public static native @Cast("hs_error_t") int hs_scan_stream(hs_stream_t id, @Cast("const char*") BytePointer data, + @Cast("unsigned int") int length, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer ctxt); +public static native @Cast("hs_error_t") int hs_scan_stream(hs_stream_t id, String data, + @Cast("unsigned int") int length, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer ctxt); + +/** + * Close a stream. + * + * This function completes matching on the given stream and frees the memory + * associated with the stream state. After this call, the stream pointed to by + * \p id is invalid and can no longer be used. To reuse the stream state after + * completion, rather than closing it, the \ref hs_reset_stream function can be + * used. + * + * This function must be called for any stream created with \ref + * hs_open_stream(), even if scanning has been terminated by a non-zero return + * from the match callback function. + * + * Note: This operation may result in matches being returned (via calls to the + * match event callback) for expressions anchored to the end of the data stream + * (for example, via the use of the {@code $} meta-character). If these matches are + * not desired, NULL may be provided as the \ref match_event_handler callback. + * + * If NULL is provided as the \ref match_event_handler callback, it is + * permissible to provide a NULL scratch. + * + * @param id + * The stream ID returned by \ref hs_open_stream(). + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch(). This is + * allowed to be NULL only if the \p onEvent callback is also NULL. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param ctxt + * The user defined pointer which will be passed to the callback function + * when a match occurs. + * + * @return + * Returns \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_close_stream(hs_stream_t id, hs_scratch_t scratch, + match_event_handler onEvent, Pointer ctxt); + +/** + * Reset a stream to an initial state. + * + * Conceptually, this is equivalent to performing \ref hs_close_stream() on the + * given stream, followed by a \ref hs_open_stream(). This new stream replaces + * the original stream in memory, avoiding the overhead of freeing the old + * stream and allocating the new one. + * + * Note: This operation may result in matches being returned (via calls to the + * match event callback) for expressions anchored to the end of the original + * data stream (for example, via the use of the {@code $} meta-character). If these + * matches are not desired, NULL may be provided as the \ref match_event_handler + * callback. + * + * Note: the stream will also be tied to the same database. + * + * @param id + * The stream (as created by \ref hs_open_stream()) to be replaced. + * + * @param flags + * Flags modifying the behaviour of the stream. This parameter is provided + * for future use and is unused at present. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch(). This is + * allowed to be NULL only if the \p onEvent callback is also NULL. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param context + * The user defined pointer which will be passed to the callback function + * when a match occurs. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_reset_stream(hs_stream_t id, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer context); + +/** + * Duplicate the given stream. The new stream will have the same state as the + * original including the current stream offset. + * + * @param to_id + * On success, a pointer to the new, copied \ref hs_stream_t will be + * returned; NULL on failure. + * + * @param from_id + * The stream (as created by \ref hs_open_stream()) to be copied. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_copy_stream(@Cast("hs_stream_t**") PointerPointer to_id, + @Const hs_stream_t from_id); +public static native @Cast("hs_error_t") int hs_copy_stream(@ByPtrPtr hs_stream_t to_id, + @Const hs_stream_t from_id); + +/** + * Duplicate the given 'from' stream state onto the 'to' stream. The 'to' stream + * will first be reset (reporting any EOD matches if a non-NULL \p onEvent + * callback handler is provided). + * + * Note: the 'to' stream and the 'from' stream must be open against the same + * database. + * + * @param to_id + * On success, a pointer to the new, copied \ref hs_stream_t will be + * returned; NULL on failure. + * + * @param from_id + * The stream (as created by \ref hs_open_stream()) to be copied. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch(). This is + * allowed to be NULL only if the \p onEvent callback is also NULL. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param context + * The user defined pointer which will be passed to the callback function + * when a match occurs. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_reset_and_copy_stream(hs_stream_t to_id, + @Const hs_stream_t from_id, + hs_scratch_t scratch, + match_event_handler onEvent, + Pointer context); + +/** + * Creates a compressed representation of the provided stream in the buffer + * provided. This compressed representation can be converted back into a stream + * state by using \ref hs_expand_stream() or \ref hs_reset_and_expand_stream(). + * The size of the compressed representation will be placed into \p used_space. + * + * If there is not sufficient space in the buffer to hold the compressed + * representation, \ref HS_INSUFFICIENT_SPACE will be returned and \p used_space + * will be populated with the amount of space required. + * + * Note: this function does not close the provided stream, you may continue to + * use the stream or to free it with \ref hs_close_stream(). + * + * @param stream + * The stream (as created by \ref hs_open_stream()) to be compressed. + * + * @param buf + * Buffer to write the compressed representation into. Note: if the call is + * just being used to determine the amount of space required, it is allowed + * to pass NULL here and \p buf_space as 0. + * + * @param buf_space + * The number of bytes in \p buf. If buf_space is too small, the call will + * fail with \ref HS_INSUFFICIENT_SPACE. + * + * @param used_space + * Pointer to where the amount of used space will be written to. The used + * buffer space is always less than or equal to \p buf_space. If the call + * fails with \ref HS_INSUFFICIENT_SPACE, this pointer will be used to + * write out the amount of buffer space required. + * + * @return + * \ref HS_SUCCESS on success, \ref HS_INSUFFICIENT_SPACE if the provided + * buffer is too small. + */ +public static native @Cast("hs_error_t") int hs_compress_stream(@Const hs_stream_t stream, @Cast("char*") BytePointer buf, + @Cast("size_t") long buf_space, @Cast("size_t*") SizeTPointer used_space); +public static native @Cast("hs_error_t") int hs_compress_stream(@Const hs_stream_t stream, @Cast("char*") ByteBuffer buf, + @Cast("size_t") long buf_space, @Cast("size_t*") SizeTPointer used_space); +public static native @Cast("hs_error_t") int hs_compress_stream(@Const hs_stream_t stream, @Cast("char*") byte[] buf, + @Cast("size_t") long buf_space, @Cast("size_t*") SizeTPointer used_space); + +/** + * Decompresses a compressed representation created by \ref hs_compress_stream() + * into a new stream. + * + * Note: \p buf must correspond to a complete compressed representation created + * by \ref hs_compress_stream() of a stream that was opened against \p db. It is + * not always possible to detect misuse of this API and behaviour is undefined + * if these properties are not satisfied. + * + * @param db + * The compiled pattern database that the compressed stream was opened + * against. + * + * @param stream + * On success, a pointer to the expanded \ref hs_stream_t will be + * returned; NULL on failure. + * + * @param buf + * A compressed representation of a stream. These compressed forms are + * created by \ref hs_compress_stream(). + * + * @param buf_size + * The size in bytes of the compressed representation. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_expand_stream(@Const hs_database_t db, + @Cast("hs_stream_t**") PointerPointer stream, @Cast("const char*") BytePointer buf, + @Cast("size_t") long buf_size); +public static native @Cast("hs_error_t") int hs_expand_stream(@Const hs_database_t db, + @ByPtrPtr hs_stream_t stream, @Cast("const char*") BytePointer buf, + @Cast("size_t") long buf_size); +public static native @Cast("hs_error_t") int hs_expand_stream(@Const hs_database_t db, + @ByPtrPtr hs_stream_t stream, String buf, + @Cast("size_t") long buf_size); + +/** + * Decompresses a compressed representation created by \ref hs_compress_stream() + * on top of the 'to' stream. The 'to' stream will first be reset (reporting + * any EOD matches if a non-NULL \p onEvent callback handler is provided). + * + * Note: the 'to' stream must be opened against the same database as the + * compressed stream. + * + * Note: \p buf must correspond to a complete compressed representation created + * by \ref hs_compress_stream() of a stream that was opened against \p db. It is + * not always possible to detect misuse of this API and behaviour is undefined + * if these properties are not satisfied. + * + * @param to_stream + * A pointer to a valid stream state. A pointer to the expanded \ref + * hs_stream_t will be returned; NULL on failure. + * + * @param buf + * A compressed representation of a stream. These compressed forms are + * created by \ref hs_compress_stream(). + * + * @param buf_size + * The size in bytes of the compressed representation. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch(). This is + * allowed to be NULL only if the \p onEvent callback is also NULL. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param context + * The user defined pointer which will be passed to the callback function + * when a match occurs. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_reset_and_expand_stream(hs_stream_t to_stream, + @Cast("const char*") BytePointer buf, @Cast("size_t") long buf_size, + hs_scratch_t scratch, + match_event_handler onEvent, + Pointer context); +public static native @Cast("hs_error_t") int hs_reset_and_expand_stream(hs_stream_t to_stream, + String buf, @Cast("size_t") long buf_size, + hs_scratch_t scratch, + match_event_handler onEvent, + Pointer context); + +/** + * The block (non-streaming) regular expression scanner. + * + * This is the function call in which the actual pattern matching takes place + * for block-mode pattern databases. + * + * @param db + * A compiled pattern database. + * + * @param data + * Pointer to the data to be scanned. + * + * @param length + * The number of bytes to scan. + * + * @param flags + * Flags modifying the behaviour of this function. This parameter is + * provided for future use and is unused at present. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch() for this + * database. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param context + * The user defined pointer which will be passed to the callback function. + * + * @return + * Returns \ref HS_SUCCESS on success; \ref HS_SCAN_TERMINATED if the + * match callback indicated that scanning should stop; other values on + * error. + */ +public static native @Cast("hs_error_t") int hs_scan(@Const hs_database_t db, @Cast("const char*") BytePointer data, + @Cast("unsigned int") int length, @Cast("unsigned int") int flags, + hs_scratch_t scratch, match_event_handler onEvent, + Pointer context); +public static native @Cast("hs_error_t") int hs_scan(@Const hs_database_t db, String data, + @Cast("unsigned int") int length, @Cast("unsigned int") int flags, + hs_scratch_t scratch, match_event_handler onEvent, + Pointer context); + +/** + * The vectored regular expression scanner. + * + * This is the function call in which the actual pattern matching takes place + * for vectoring-mode pattern databases. + * + * @param db + * A compiled pattern database. + * + * @param data + * An array of pointers to the data blocks to be scanned. + * + * @param length + * An array of lengths (in bytes) of each data block to scan. + * + * @param count + * Number of data blocks to scan. This should correspond to the size of + * of the \p data and \p length arrays. + * + * @param flags + * Flags modifying the behaviour of this function. This parameter is + * provided for future use and is unused at present. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch() for + * this database. + * + * @param onEvent + * Pointer to a match event callback function. If a NULL pointer is given, + * no matches will be returned. + * + * @param context + * The user defined pointer which will be passed to the callback function. + * + * @return + * Returns \ref HS_SUCCESS on success; \ref HS_SCAN_TERMINATED if the match + * callback indicated that scanning should stop; other values on error. + */ +public static native @Cast("hs_error_t") int hs_scan_vector(@Const hs_database_t db, + @Cast("const char*const*") PointerPointer data, + @Cast("const unsigned int*") IntPointer length, + @Cast("unsigned int") int count, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer context); +public static native @Cast("hs_error_t") int hs_scan_vector(@Const hs_database_t db, + @Cast("const char*const*") @ByPtrPtr BytePointer data, + @Cast("const unsigned int*") IntPointer length, + @Cast("unsigned int") int count, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer context); +public static native @Cast("hs_error_t") int hs_scan_vector(@Const hs_database_t db, + @Cast("const char*const*") @ByPtrPtr ByteBuffer data, + @Cast("const unsigned int*") IntBuffer length, + @Cast("unsigned int") int count, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer context); +public static native @Cast("hs_error_t") int hs_scan_vector(@Const hs_database_t db, + @Cast("const char*const*") @ByPtrPtr byte[] data, + @Cast("const unsigned int*") int[] length, + @Cast("unsigned int") int count, @Cast("unsigned int") int flags, + hs_scratch_t scratch, + match_event_handler onEvent, Pointer context); + +/** + * Allocate a "scratch" space for use by Hyperscan. + * + * This is required for runtime use, and one scratch space per thread, or + * concurrent caller, is required. Any allocator callback set by \ref + * hs_set_scratch_allocator() or \ref hs_set_allocator() will be used by this + * function. + * + * @param db + * The database, as produced by \ref hs_compile(). + * + * @param scratch + * On first allocation, a pointer to NULL should be provided so a new + * scratch can be allocated. If a scratch block has been previously + * allocated, then a pointer to it should be passed back in to see if it + * is valid for this database block. If a new scratch block is required, + * the original will be freed and the new one returned, otherwise the + * previous scratch block will be returned. On success, the scratch block + * will be suitable for use with the provided database in addition to any + * databases that original scratch space was suitable for. + * + * @return + * \ref HS_SUCCESS on successful allocation; \ref HS_NOMEM if the + * allocation fails. Other errors may be returned if invalid parameters + * are specified. + */ +public static native @Cast("hs_error_t") int hs_alloc_scratch(@Const hs_database_t db, + @Cast("hs_scratch_t**") PointerPointer scratch); +public static native @Cast("hs_error_t") int hs_alloc_scratch(@Const hs_database_t db, + @ByPtrPtr hs_scratch_t scratch); + +/** + * Allocate a scratch space that is a clone of an existing scratch space. + * + * This is useful when multiple concurrent threads will be using the same set + * of compiled databases, and another scratch space is required. Any allocator + * callback set by \ref hs_set_scratch_allocator() or \ref hs_set_allocator() + * will be used by this function. + * + * @param src + * The existing \ref hs_scratch_t to be cloned. + * + * @param dest + * A pointer to the new scratch space will be returned here. + * + * @return + * \ref HS_SUCCESS on success; \ref HS_NOMEM if the allocation fails. + * Other errors may be returned if invalid parameters are specified. + */ +public static native @Cast("hs_error_t") int hs_clone_scratch(@Const hs_scratch_t src, + @Cast("hs_scratch_t**") PointerPointer dest); +public static native @Cast("hs_error_t") int hs_clone_scratch(@Const hs_scratch_t src, + @ByPtrPtr hs_scratch_t dest); + +/** + * Provides the size of the given scratch space. + * + * @param scratch + * A per-thread scratch space allocated by \ref hs_alloc_scratch() or \ref + * hs_clone_scratch(). + * + * @param scratch_size + * On success, the size of the scratch space in bytes is placed in this + * parameter. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_scratch_size(@Const hs_scratch_t scratch, + @Cast("size_t*") SizeTPointer scratch_size); + +/** + * Free a scratch block previously allocated by \ref hs_alloc_scratch() or \ref + * hs_clone_scratch(). + * + * The free callback set by \ref hs_set_scratch_allocator() or \ref + * hs_set_allocator() will be used by this function. + * + * @param scratch + * The scratch block to be freed. NULL may also be safely provided. + * + * @return + * \ref HS_SUCCESS on success, other values on failure. + */ +public static native @Cast("hs_error_t") int hs_free_scratch(hs_scratch_t scratch); + +/** + * Callback 'from' return value, indicating that the start of this match was + * too early to be tracked with the requested SOM_HORIZON precision. + */ +public static final long HS_OFFSET_PAST_HORIZON = (~0L); + +// #ifdef __cplusplus /* extern "C" */ +// #endif + +// #endif /* HS_RUNTIME_H_ */ + + +// Parsed from hs/hs.h + +/* + * Copyright (c) 2015, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 HS_H_ +// #define HS_H_ + +/** + * \file + * \brief The complete Hyperscan API definition. + * + * Hyperscan is a high speed regular expression engine. + * + * This header includes both the Hyperscan compiler and runtime components. See + * the individual component headers for documentation. + */ + +// #include "hs_compile.h" +// #include "hs_runtime.h" + +// #endif /* HS_H_ */ + + +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_alloc_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_alloc_t.java new file mode 100644 index 00000000000..9688d3a9067 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_alloc_t.java @@ -0,0 +1,34 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * The type of the callback function that will be used by Hyperscan to allocate + * more memory at runtime as required, for example in \ref hs_open_stream() to + * allocate stream state. + * + * If Hyperscan is to be used in a multi-threaded, or similarly concurrent + * environment, the allocation function will need to be re-entrant, or + * similarly safe for concurrent use. + * + * @param size + * The number of bytes to allocate. + * @return + * A pointer to the region of memory allocated, or NULL on error. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_alloc_t extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_alloc_t(Pointer p) { super(p); } + protected hs_alloc_t() { allocate(); } + private native void allocate(); + public native Pointer call(@Cast("size_t") long size); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_compile_error_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_compile_error_t.java new file mode 100644 index 00000000000..b9c37a05aa1 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_compile_error_t.java @@ -0,0 +1,102 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + +// #endif + +/** + * A type containing error details that is returned by the compile calls (\ref + * hs_compile(), \ref hs_compile_multi() and \ref hs_compile_ext_multi()) on + * failure. The caller may inspect the values returned in this type to + * determine the cause of failure. + * + * Common errors generated during the compile process include: + * + * - *Invalid parameter* + * + * An invalid argument was specified in the compile call. + * + * - *Unrecognised flag* + * + * An unrecognised value was passed in the flags argument. + * + * - *Pattern matches empty buffer* + * + * By default, Hyperscan only supports patterns that will *always* + * consume at least one byte of input. Patterns that do not have this + * property (such as {@code /(abc)?/}) will produce this error unless + * the \ref HS_FLAG_ALLOWEMPTY flag is supplied. Note that such + * patterns will produce a match for *every* byte when scanned. + * + * - *Embedded anchors not supported* + * + * Hyperscan only supports the use of anchor meta-characters (such as + * {@code ^} and {@code $}) in patterns where they could *only* match + * at the start or end of a buffer. A pattern containing an embedded + * anchor, such as {@code /abc^def/}, can never match, as there is no + * way for {@code abc} to precede the start of the data stream. + * + * - *Bounded repeat is too large* + * + * The pattern contains a repeated construct with very large finite + * bounds. + * + * - *Unsupported component type* + * + * An unsupported PCRE construct was used in the pattern. + * + * - *Unable to generate bytecode* + * + * This error indicates that Hyperscan was unable to compile a pattern + * that is syntactically valid. The most common cause is a pattern that is + * very long and complex or contains a large repeated subpattern. + * + * - *Unable to allocate memory* + * + * The library was unable to allocate temporary storage used during + * compilation time. + * + * - *Allocator returned misaligned memory* + * + * The memory allocator (either malloc() or the allocator set with \ref + * hs_set_allocator()) did not correctly return memory suitably aligned + * for the largest representable data type on this platform. + * + * - *Internal error* + * + * An unexpected error occurred: if this error is reported, please contact + * the Hyperscan team with a description of the situation. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_compile_error_t extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public hs_compile_error_t() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public hs_compile_error_t(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_compile_error_t(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public hs_compile_error_t position(long position) { + return (hs_compile_error_t)super.position(position); + } + + /** + * A human-readable error message describing the error. + */ + public native @Cast("char*") BytePointer message(); public native hs_compile_error_t message(BytePointer setter); + + /** + * The zero-based number of the expression that caused the error (if this + * can be determined). If the error is not specific to an expression, then + * this value will be less than zero. + */ + public native int expression(); public native hs_compile_error_t expression(int setter); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database.java new file mode 100644 index 00000000000..8a9a3d5b7f5 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + +// #endif + +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_database extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_database() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_database(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database_t.java new file mode 100644 index 00000000000..cdf7bbad37e --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_database_t.java @@ -0,0 +1,26 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * A Hyperscan pattern database. + * + * Generated by one of the Hyperscan compiler functions: + * - \ref hs_compile() + * - \ref hs_compile_multi() + * - \ref hs_compile_ext_multi() + */ +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_database_t extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_database_t() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_database_t(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_ext_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_ext_t.java new file mode 100644 index 00000000000..20ca04007ce --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_ext_t.java @@ -0,0 +1,76 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * A structure containing additional parameters related to an expression, + * passed in at build time to \ref hs_compile_ext_multi() or \ref + * hs_expression_ext_info. + * + * These parameters allow the set of matches produced by a pattern to be + * constrained at compile time, rather than relying on the application to + * process unwanted matches at runtime. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_expr_ext_t extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public hs_expr_ext_t() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public hs_expr_ext_t(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_expr_ext_t(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public hs_expr_ext_t position(long position) { + return (hs_expr_ext_t)super.position(position); + } + + /** + * Flags governing which parts of this structure are to be used by the + * compiler. See \ref HS_EXT_FLAG. + */ + public native @Cast("unsigned long long") long flags(); public native hs_expr_ext_t flags(long setter); + + /** + * The minimum end offset in the data stream at which this expression + * should match successfully. To use this parameter, set the + * \ref HS_EXT_FLAG_MIN_OFFSET flag in the hs_expr_ext::flags field. + */ + public native @Cast("unsigned long long") long min_offset(); public native hs_expr_ext_t min_offset(long setter); + + /** + * The maximum end offset in the data stream at which this expression + * should match successfully. To use this parameter, set the + * \ref HS_EXT_FLAG_MAX_OFFSET flag in the hs_expr_ext::flags field. + */ + public native @Cast("unsigned long long") long max_offset(); public native hs_expr_ext_t max_offset(long setter); + + /** + * The minimum match length (from start to end) required to successfully + * match this expression. To use this parameter, set the + * \ref HS_EXT_FLAG_MIN_LENGTH flag in the hs_expr_ext::flags field. + */ + public native @Cast("unsigned long long") long min_length(); public native hs_expr_ext_t min_length(long setter); + + /** + * Allow patterns to approximately match within this edit distance. To use + * this parameter, set the \ref HS_EXT_FLAG_EDIT_DISTANCE flag in the + * hs_expr_ext::flags field. + */ + public native @Cast("unsigned") int edit_distance(); public native hs_expr_ext_t edit_distance(int setter); + + /** + * Allow patterns to approximately match within this Hamming distance. To + * use this parameter, set the \ref HS_EXT_FLAG_HAMMING_DISTANCE flag in the + * hs_expr_ext::flags field. + */ + public native @Cast("unsigned") int hamming_distance(); public native hs_expr_ext_t hamming_distance(int setter); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_info_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_info_t.java new file mode 100644 index 00000000000..a58b77bd518 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_expr_info_t.java @@ -0,0 +1,77 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * A type containing information related to an expression that is returned by + * \ref hs_expression_info() or \ref hs_expression_ext_info. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_expr_info_t extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public hs_expr_info_t() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public hs_expr_info_t(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_expr_info_t(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public hs_expr_info_t position(long position) { + return (hs_expr_info_t)super.position(position); + } + + /** + * The minimum length in bytes of a match for the pattern. + * + * Note: in some cases when using advanced features to suppress matches + * (such as extended parameters or the \ref HS_FLAG_SINGLEMATCH flag) this + * may represent a conservative lower bound for the true minimum length of + * a match. + */ + public native @Cast("unsigned int") int min_width(); public native hs_expr_info_t min_width(int setter); + + /** + * The maximum length in bytes of a match for the pattern. If the pattern + * has an unbounded maximum length, this will be set to the maximum value + * of an unsigned int (UINT_MAX). + * + * Note: in some cases when using advanced features to suppress matches + * (such as extended parameters or the \ref HS_FLAG_SINGLEMATCH flag) this + * may represent a conservative upper bound for the true maximum length of + * a match. + */ + public native @Cast("unsigned int") int max_width(); public native hs_expr_info_t max_width(int setter); + + /** + * Whether this expression can produce matches that are not returned in + * order, such as those produced by assertions. Zero if false, non-zero if + * true. + */ + public native @Cast("char") byte unordered_matches(); public native hs_expr_info_t unordered_matches(byte setter); + + /** + * Whether this expression can produce matches at end of data (EOD). In + * streaming mode, EOD matches are raised during \ref hs_close_stream(), + * since it is only when \ref hs_close_stream() is called that the EOD + * location is known. Zero if false, non-zero if true. + * + * Note: trailing {@code \b} word boundary assertions may also result in EOD + * matches as end-of-data can act as a word boundary. + */ + public native @Cast("char") byte matches_at_eod(); public native hs_expr_info_t matches_at_eod(byte setter); + + /** + * Whether this expression can *only* produce matches at end of data (EOD). + * In streaming mode, all matches for this expression are raised during + * \ref hs_close_stream(). Zero if false, non-zero if true. + */ + public native @Cast("char") byte matches_only_at_eod(); public native hs_expr_info_t matches_only_at_eod(byte setter); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_free_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_free_t.java new file mode 100644 index 00000000000..7559572640e --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_free_t.java @@ -0,0 +1,27 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * The type of the callback function that will be used by Hyperscan to free + * memory regions previously allocated using the \ref hs_alloc_t function. + * + * @param ptr + * The region of memory to be freed. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_free_t extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_free_t(Pointer p) { super(p); } + protected hs_free_t() { allocate(); } + private native void allocate(); + public native void call(Pointer ptr); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_platform_info_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_platform_info_t.java new file mode 100644 index 00000000000..cb79f6a0dfa --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_platform_info_t.java @@ -0,0 +1,63 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * A type containing information on the target platform which may optionally be + * provided to the compile calls (\ref hs_compile(), \ref hs_compile_multi(), + * \ref hs_compile_ext_multi()). + * + * A hs_platform_info structure may be populated for the current platform by + * using the \ref hs_populate_platform() call. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_platform_info_t extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public hs_platform_info_t() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public hs_platform_info_t(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_platform_info_t(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public hs_platform_info_t position(long position) { + return (hs_platform_info_t)super.position(position); + } + + /** + * Information about the target platform which may be used to guide the + * optimisation process of the compile. + * + * Use of this field does not limit the processors that the resulting + * database can run on, but may impact the performance of the resulting + * database. + */ + public native @Cast("unsigned int") int tune(); public native hs_platform_info_t tune(int setter); + + /** + * Relevant CPU features available on the target platform + * + * This value may be produced by combining HS_CPU_FEATURE_* flags (such as + * \ref HS_CPU_FEATURES_AVX2). Multiple CPU features may be or'ed together + * to produce the value. + */ + public native @Cast("unsigned long long") long cpu_features(); public native hs_platform_info_t cpu_features(long setter); + + /** + * Reserved for future use. + */ + public native @Cast("unsigned long long") long reserved1(); public native hs_platform_info_t reserved1(long setter); + + /** + * Reserved for future use. + */ + public native @Cast("unsigned long long") long reserved2(); public native hs_platform_info_t reserved2(long setter); +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch.java new file mode 100644 index 00000000000..693ccb48ca5 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch.java @@ -0,0 +1,18 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_scratch extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_scratch() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_scratch(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch_t.java new file mode 100644 index 00000000000..04003cb3ba5 --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_scratch_t.java @@ -0,0 +1,21 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * A Hyperscan scratch space. + */ +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_scratch_t extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_scratch_t() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_scratch_t(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream.java new file mode 100644 index 00000000000..e943f783c7b --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + +// #endif + +/** + * Definition of the stream identifier type. + */ +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_stream extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_stream() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_stream(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream_t.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream_t.java new file mode 100644 index 00000000000..7343de0a27b --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/hs_stream_t.java @@ -0,0 +1,21 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * The stream identifier returned by \ref hs_open_stream(). + */ +@Opaque @Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class hs_stream_t extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public hs_stream_t() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public hs_stream_t(Pointer p) { super(p); } +} diff --git a/hyperscan/src/gen/java/org/bytedeco/hyperscan/match_event_handler.java b/hyperscan/src/gen/java/org/bytedeco/hyperscan/match_event_handler.java new file mode 100644 index 00000000000..5a11862c6dd --- /dev/null +++ b/hyperscan/src/gen/java/org/bytedeco/hyperscan/match_event_handler.java @@ -0,0 +1,81 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.hyperscan; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.hyperscan.global.hyperscan.*; + + +/** + * Definition of the match event callback function type. + * + * A callback function matching the defined type must be provided by the + * application calling the \ref hs_scan(), \ref hs_scan_vector() or \ref + * hs_scan_stream() functions (or other streaming calls which can produce + * matches). + * + * This callback function will be invoked whenever a match is located in the + * target data during the execution of a scan. The details of the match are + * passed in as parameters to the callback function, and the callback function + * should return a value indicating whether or not matching should continue on + * the target data. If no callbacks are desired from a scan call, NULL may be + * provided in order to suppress match production. + * + * This callback function should not attempt to call Hyperscan API functions on + * the same stream nor should it attempt to reuse the scratch space allocated + * for the API calls that caused it to be triggered. Making another call to the + * Hyperscan library with completely independent parameters should work (for + * example, scanning a different database in a new stream and with new scratch + * space), but reusing data structures like stream state and/or scratch space + * will produce undefined behavior. + * + * @param id + * The ID number of the expression that matched. If the expression was a + * single expression compiled with \ref hs_compile(), this value will be + * zero. + * + * @param from + * - If a start of match flag is enabled for the current pattern, this + * argument will be set to the start of match for the pattern assuming + * that that start of match value lies within the current 'start of match + * horizon' chosen by one of the SOM_HORIZON mode flags. +

+ * - If the start of match value lies outside this horizon (possible only + * when the SOM_HORIZON value is not \ref HS_MODE_SOM_HORIZON_LARGE), + * the \p from value will be set to \ref HS_OFFSET_PAST_HORIZON. +

+ * - This argument will be set to zero if the Start of Match flag is not + * enabled for the given pattern. + * + * @param to + * The offset after the last byte that matches the expression. + * + * @param flags + * This is provided for future use and is unused at present. + * + * @param context + * The pointer supplied by the user to the \ref hs_scan(), \ref + * hs_scan_vector() or \ref hs_scan_stream() function. + * + * @return + * Non-zero if the matching should cease, else zero. If scanning is + * performed in streaming mode and a non-zero value is returned, any + * subsequent calls to \ref hs_scan_stream() for that stream will + * immediately return with \ref HS_SCAN_TERMINATED. + */ +@Properties(inherit = org.bytedeco.hyperscan.presets.hyperscan.class) +public class match_event_handler extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public match_event_handler(Pointer p) { super(p); } + protected match_event_handler() { allocate(); } + private native void allocate(); + public native int call(@Cast("unsigned int") int id, + @Cast("unsigned long long") long from, + @Cast("unsigned long long") long to, + @Cast("unsigned int") int flags, + Pointer context); +} diff --git a/hyperscan/src/main/java/org/bytedeco/hyperscan/presets/hyperscan.java b/hyperscan/src/main/java/org/bytedeco/hyperscan/presets/hyperscan.java new file mode 100644 index 00000000000..840ddee0f72 --- /dev/null +++ b/hyperscan/src/main/java/org/bytedeco/hyperscan/presets/hyperscan.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2020 Dmytro Maksutov + * + * Licensed either under the Apache License, Version 2.0, or (at your option) + * under the terms of the GNU General Public License as published by + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, 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 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * 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. + */ + +package org.bytedeco.hyperscan.presets; + +import org.bytedeco.javacpp.Loader; +import org.bytedeco.javacpp.annotation.Platform; +import org.bytedeco.javacpp.annotation.Properties; +import org.bytedeco.javacpp.tools.Info; +import org.bytedeco.javacpp.tools.InfoMap; +import org.bytedeco.javacpp.tools.InfoMapper; + +@Properties( + value = { + @Platform( + value = {"linux-x86_64", "macosx-x86_64", "windows-x86_64"}, + compiler = "cpp11", + include = {"hs/hs_common.h", "hs/hs_compile.h", "hs/hs_runtime.h", "hs/hs.h"}, + link = {"hs@.5", "hs_runtime@.5"} + ) + }, + target = "org.bytedeco.hyperscan", + global = "org.bytedeco.hyperscan.global.hyperscan" +) +public class hyperscan implements InfoMapper { + static { Loader.checkVersion("org.bytedeco", "hyperscan"); } + + public void map(InfoMap infoMap) { + infoMap.put(new Info("HS_CDECL").cppTypes().annotations()); + } +} diff --git a/hyperscan/src/main/java9/module-info.java b/hyperscan/src/main/java9/module-info.java new file mode 100644 index 00000000000..44ce432964a --- /dev/null +++ b/hyperscan/src/main/java9/module-info.java @@ -0,0 +1,6 @@ +module org.bytedeco.hyperscan { + requires transitive org.bytedeco.javacpp; + exports org.bytedeco.hyperscan; + exports org.bytedeco.hyperscan.global; + exports org.bytedeco.hyperscan.presets; +} \ No newline at end of file diff --git a/platform/pom.xml b/platform/pom.xml index f5f438f32fa..33eaa7cf8b2 100644 --- a/platform/pom.xml +++ b/platform/pom.xml @@ -30,6 +30,7 @@ ../flandmark/platform ../arrow/platform ../hdf5/platform + ../hyperscan/platform ../mkl/platform ../mkl-dnn/platform ../dnnl/platform @@ -144,6 +145,11 @@ hdf5-platform 1.12.0-${project.version} + + org.bytedeco + hyperscan-platform + 5.2.1-${project.version} + org.bytedeco mkl-platform diff --git a/pom.xml b/pom.xml index 0fb5c873fe5..24e2c28812a 100644 --- a/pom.xml +++ b/pom.xml @@ -590,6 +590,7 @@ flandmark arrow hdf5 + hyperscan mkl mkl-dnn dnnl @@ -1307,6 +1308,7 @@ flandmark arrow hdf5 + hyperscan mkl mkl-dnn dnnl @@ -1379,6 +1381,7 @@ flandmark arrow hdf5 + hyperscan mkl mkl-dnn dnnl @@ -1514,6 +1517,7 @@ flandmark arrow hdf5 + hyperscan mkl mkl-dnn dnnl