diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..8ce9b51c3 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,24 @@ +--- +Checks: > + bugprone-*, + clang-analyzer-*, + google-*, + misc-*, + modernize-*, + performance-*, + portability-*, + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -bugprone-narrowing-conversions, + -bugprone-not-null-terminated-result, + -bugprone-reserved-identifier, + -bugprone-sizeof-expression, + -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + -clang-analyzer-security.insecureAPI.strcpy, + -google-readability-todo, + -misc-unused-parameters, + -performance-no-int-to-ptr, + -bugprone-assignment-in-if-condition, + +... diff --git a/.gdbinit b/.gdbinit index cbf79cb5b..75716ac1b 100644 --- a/.gdbinit +++ b/.gdbinit @@ -1,11 +1,13 @@ -cd ./build/src/tests +cd ./build/src/jbs +file ./jbs +#set args --ssl +set confirm off set follow-fork-mode parent set detach-on-fork on set print elements 4096 - define lb set breakpoint pending on source ~/.breakpoints diff --git a/.gitignore b/.gitignore index 3adb4dd62..995aba3d3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ cmake-build* .cmake_dirty Makefile Testing/ -compile_commands.json *.dat *.db *-wal diff --git a/.gitmodules b/.gitmodules index 47e9deb5b..29bb605be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "mxe"] - path = mxe - url = https://github.com/mxe/mxe.git [submodule "src/bindings/ejdb2_swift/EJDB2Swift"] path = src/bindings/ejdb2_swift/EJDB2Swift url = https://github.com/Softmotions/EJDB2Swift.git diff --git a/.lvimrc b/.lvimrc index ad5a33bab..76fd7c7c3 100644 --- a/.lvimrc +++ b/.lvimrc @@ -1,26 +1,30 @@ " Local vim rc -let g:build_type = 'Debug' -let g:build_tests = 'ON' -let g:cc = 'clang' -let g:cxx = 'clang++' +if exists('g:build_dir') + finish +endif + +let g:build_type = get(g:, 'build_type', 'Debug') +let g:build_tests = get(g:, 'build_tests', 'ON') +let g:cc = get(g:, 'cc', 'clang') +let g:cxx = get(g:, 'cxx', 'clang++') let g:root_dir = g:localvimrc_script_dir_unresolved let $ROOT_DIR = g:root_dir let $UNCRUSTIFY_CONFIG = g:root_dir.'/uncrustify.cfg' let g:build_dir = g:root_dir.'/build' -let &l:makeprg = 'cd '.g:build_dir.' && make -j4' +let &g:makeprg = 'cd '.g:build_dir.' && make -j1' packadd termdebug let g:termdebug_wide=1 nnoremap c :call asyncrun#run('', - \ {'mode':'terminal','cwd':g:build_dir,'save':2}, - \ 'cmake .. -DCMAKE_BUILD_TYPE='.g:build_type.' -DBUILD_TESTS='.g:build_tests + \ {'mode':'terminal','save':2}, + \ 'cmake -B '.g:build_dir.' -DCMAKE_BUILD_TYPE='.g:build_type.' -DBUILD_TESTS='.g:build_tests \ .' -DCMAKE_CXX_COMPILER='.g:cxx.' -DCMAKE_C_COMPILER='.g:cc \ .' -DCMAKE_EXPORT_COMPILE_COMMANDS=ON' \ .' -DBUILD_JNI_BINDING=ON' \ .' -DBUILD_NODEJS_BINDING=ON' \ .' -DBUILD_DART_BINDING=OFF') - \ + \ \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index bc00c95b9..000000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "configurations": [ - { - "name": "Mac", - "includePath": [ - "/usr/include", - "/usr/local/include", - "/usr/lib/jvm/java-11-openjdk-amd64/include", - "${workspaceRoot}", - "${workspaceRoot}/build/include", - "${workspaceRoot}/build/src/extern_facil/lib/facil", - "${workspaceRoot}/build/src/extern_facil/lib/facil/cli", - "${workspaceRoot}/build/src/extern_facil/lib/facil/http", - "${workspaceRoot}/build/src/extern_facil/lib/facil/fiobj", - "${workspaceRoot}/build/src/generated", - "${workspaceRoot}/src", - "${workspaceRoot}/src/jbl", - "${workspaceRoot}/src/jql", - "${workspaceRoot}/src/util" - ], - "defines": [], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ - "/usr/include", - "/usr/local/include", - "/usr/lib/jvm/java-11-openjdk-amd64/include", - "${workspaceRoot}", - "${workspaceRoot}/build/include", - "${workspaceRoot}/build/src/extern_facil/lib/facil", - "${workspaceRoot}/build/src/extern_facil/lib/facil/cli", - "${workspaceRoot}/build/src/extern_facil/lib/facil/http", - "${workspaceRoot}/build/src/extern_facil/lib/facil/fiobj", - "${workspaceRoot}/build/src/generated", - "${workspaceRoot}/src", - "${workspaceRoot}/src/jbl", - "${workspaceRoot}/src/jql", - "${workspaceRoot}/src/util" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - }, - "macFrameworkPath": [ - "/System/Library/Frameworks", - "/Library/Frameworks" - ] - }, - { - "name": "Linux", - "includePath": [ - "/usr/include", - "/usr/include/linux", - "/usr/local/include", - "/usr/include/x86_64-linux-gnu", - "/usr/lib/gcc/x86_64-linux-gnu/7/include", - "/usr/lib/gcc/x86_64-linux-gnu/6/include", - "/usr/lib/gcc/x86_64-linux-gnu/5/include", - "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed", - "/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed", - "/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", - "/usr/include/x86_64-linux-gnu/c++/7", - "/usr/include/x86_64-linux-gnu/c++/6", - "/usr/include/x86_64-linux-gnu/c++/5", - "/usr/include/c++/7", - "/usr/include/c++/6", - "/usr/include/c++/5", - "/usr/include/c++/7/backward", - "/usr/include/c++/6/backward", - "/usr/include/c++/5/backward", - "/usr/lib/jvm/java-11-openjdk-amd64/include", - "${workspaceRoot}", - "${workspaceRoot}/build/include", - "${workspaceRoot}/build/src/extern_facil/lib/facil", - "${workspaceRoot}/build/src/extern_facil/lib/facil/cli", - "${workspaceRoot}/build/src/extern_facil/lib/facil/http", - "${workspaceRoot}/build/src/extern_facil/lib/facil/fiobj", - "${workspaceRoot}/build/src/generated", - "${workspaceRoot}/src", - "${workspaceRoot}/src/jbl", - "${workspaceRoot}/src/jql", - "${workspaceRoot}/src/util" - ], - "defines": [ - "_GNU_SOURCE", - "IW_64" - ], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ - "/usr/include", - "/usr/include/linux", - "/usr/local/include", - "/usr/include/x86_64-linux-gnu", - "/usr/lib/gcc/x86_64-linux-gnu/7/include", - "/usr/lib/gcc/x86_64-linux-gnu/6/include", - "/usr/lib/gcc/x86_64-linux-gnu/5/include", - "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed", - "/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed", - "/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", - "/usr/include/x86_64-linux-gnu/c++/7", - "/usr/include/x86_64-linux-gnu/c++/6", - "/usr/include/x86_64-linux-gnu/c++/5", - "/usr/include/c++/7", - "/usr/include/c++/6", - "/usr/include/c++/5", - "/usr/include/c++/7/backward", - "/usr/include/c++/6/backward", - "/usr/include/c++/5/backward", - "/usr/lib/jvm/java-11-openjdk-amd64/include", - "${workspaceRoot}", - "${workspaceRoot}/build/include", - "${workspaceRoot}/build/src/extern_facil/lib/facil", - "${workspaceRoot}/build/src/extern_facil/lib/facil/cli", - "${workspaceRoot}/build/src/extern_facil/lib/facil/http", - "${workspaceRoot}/build/src/extern_facil/lib/facil/fiobj", - "${workspaceRoot}/build/src/generated", - "${workspaceRoot}/src", - "${workspaceRoot}/src/jbl", - "${workspaceRoot}/src/jql", - "${workspaceRoot}/src/util" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - }, - "compilerPath": "/usr/bin/clang", - "cStandard": "c11", - "cppStandard": "c++17", - "configurationProvider": "vector-of-bool.cmake-tools" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/eclipse-formatter.xml b/.vscode/eclipse-formatter.xml deleted file mode 100644 index dc5a0027e..000000000 --- a/.vscode/eclipse-formatter.xml +++ /dev/null @@ -1,362 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index e91bc60f6..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "EJDB", - "type": "cppdbg", - "request": "launch", - "program": "${command:cmake.launchTargetPath}", - "stopAtEntry": false, - "cwd": "${command:cmake.launchTargetDirectory}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - }, - { - "text": "set print elements 4096" - } - ] - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7a03e4427..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "files.insertFinalNewline": false, - //"cmake.generator": "Unix Makefiles", - "cmake.generator": "Ninja", - "cmake.configureArgs": [ - "-DCMAKE_VERBOSE_MAKEFILE=OFF", - "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", - "-DENABLE_HTTP=ON", - "-DBUILD_BENCHMARKS=OFF", - "-DBUILD_SHARED_LIBS=ON", - "-DBUILD_TESTS=ON", - "-DBUILD_EXAMPLES=OFF", - "-DBUILD_JNI_BINDING=ON", - "-DBUILD_DART_BINDING=ON", - "-DBUILD_NODEJS_BINDING=ON", - "-DBUILD_SWIFT_BINDING=ON", - "-DBUILD_REACT_NATIVE_BINDING=OFF", - "-DBUILD_FLUTTER_BINDING=OFF", - "-DANDROID_ABIS=x86", - "-DASAN=OFF", - //"-DFACIL_URL=file:///home/adam/Projects/contrib/facil.io" - //"-DIOWOW_URL=file:///home/adam/Projects/softmotions/iowow", - ], - "cmake.configureOnEdit": false, - "cmake.ctestArgs": [], - "cmake.debugConfig": { - "cwd": "${workspaceRoot}/build/src/tests" - }, - "C_Cpp.formatting": "Disabled", - "C_Cpp.configurationWarnings": "Disabled", - "C_Cpp.intelliSenseEngineFallback": "Enabled", - - "astyle.astylerc": "${workspaceRoot}/.astylerc", - "astyle.c.enable": false, - "astyle.cpp.enable": false, - "python.pythonPath": "/usr/bin/python3", - "python.linting.pylintEnabled": false, - "python.linting.enabled": true, - "python.linting.pycodestyleEnabled": false, - "python.linting.flake8Enabled": true, - "search.exclude": { - "**/build": true - }, - "files.exclude": { - "**/.git": true, - "**/build": true, - "**/mxe": true - }, - "cSpell.enabled": true, - "files.watcherExclude": { - "**/.git/objects/**": true, - "**/.git/subtree-cache/**": true, - "**/node_modules/**": true, - "**/mxe/**": true, - "**/build/**": true - }, - - "files.associations": { - "*.arb": "json", - "*.gyp": "jsonc", - "*.conf": "plaintext", - "*.h": "c", - "*.c": "c" - }, - - "dart.runPubGetOnPubspecChanges": false, - "dart.analysisExcludedFolders": ["mxe", "build"], - - "java.configuration.updateBuildConfiguration": "automatic", - "java.import.gradle.version": "5.4.1", - "java.import.gradle.wrapper.enabled": true, - "java.format.settings.url": ".vscode/eclipse-formatter.xml", - - "clang-tidy.compilerArgs": [ - "-I", - "src", - "-I", - "src/jbi", - "-I", - "src/jbl", - "-I", - "src/jbr", - "-I", - "src/jql", - "-I", - "src/util", - "-I", - "build/include", - "-I", - "build/src/generated", - "-I", - "build/src/extern_facil/lib/facil", - "-I", - "build/src/extern_facil/lib/facil/fiobj", - "-I", - "/usr/lib/jvm/adoptopenjdk-15-hotspot-amd64/include" - ] -} diff --git a/BASE.md b/BASE.md index fd27fb97a..5860ed0ce 100644 --- a/BASE.md +++ b/BASE.md @@ -1,8 +1,9 @@ # EJDB 2.0 -[![Join Telegram](https://img.shields.io/badge/join-ejdb2%20telegram-0088cc.svg)](https://tlg.name/ejdb2) +**NOTE: Issues tracker is disabled. You are welcome to contribute, pull requests accepted.** + [![license](https://img.shields.io/github/license/Softmotions/ejdb.svg)](https://github.com/Softmotions/ejdb/blob/master/LICENSE) -![maintained](https://img.shields.io/maintenance/yes/2021.svg) +![maintained](https://img.shields.io/maintenance/yes/2024.svg) EJDB2 is an embeddable JSON database engine published under MIT license. @@ -18,14 +19,14 @@ EJDB2 is an embeddable JSON database engine published under MIT license. * [rfc7386](https://tools.ietf.org/html/rfc7386) JSON Merge patch * [rfc6901](https://tools.ietf.org/html/rfc6901) JSON Path * [Support of collection joins](#jql-collection-joins) -* Powered by [iowow.io](http://iowow.io) - The persistent key/value storage engine -* Provides HTTP REST/Websockets network endpoints with help of [facil.io](http://facil.io) +* Powered by [IOWOW](http://iowow.softmotions.com) - The persistent key/value storage engine +* HTTP REST/Websockets endpoints powered by [IWNET](https://github.com/Softmotions/iwnet) and [BearSSL](https://github.com/Softmotions/BearSSL). * JSON documents are stored in using fast and compact [binn](https://github.com/liteserver/binn) binary format --- * [Native language bindings](#native-language-bindings) * Supported platforms - * [OSX](#osx) + * [macOS](#osx) * [iOS](https://github.com/Softmotions/EJDB2Swift) * [Linux](#linux) * [Android](#android) @@ -46,25 +47,26 @@ EJDB2 is an embeddable JSON database engine published under MIT license. * [License](#license) --- -## EJDB2 platforms matrix - -| | Linux | macOS | iOS | Android | Windows | -| --- | --- | --- | --- | --- | --- | -| C library | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:1 | -| NodeJS | :heavy_check_mark: | :heavy_check_mark: | | | :x:3 | -| DartVM | :heavy_check_mark: | :heavy_check_mark:2 | | | :x:3 | -| Flutter | | | :heavy_check_mark: | :heavy_check_mark: | | -| React Native | | | :x:4 | :heavy_check_mark: | | -| Swift | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | -| Java | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark:2 | +[![EJDB2 Presentation](https://iowow.softmotions.com/articles/ejdb-presentation-cover.png)](https://iowow.softmotions.com/articles/ejdb/) +## EJDB2 platforms matrix +| | Linux | macOS | iOS | Android | Windows | +| --- | --- | --- | --- | --- | --- | +| C library | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:1 | +| NodeJS | :heavy_check_mark: | :heavy_check_mark: | | | :x:3 | +| Java | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark:2 | +| DartVM5 | :heavy_check_mark: | :heavy_check_mark:2 | | | :x:3 | +| Flutter5 | | | :heavy_check_mark: | :heavy_check_mark: | | +| React Native5 | | | :x:4 | :heavy_check_mark: | | +| Swift5 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | + +
`[5]` **Bindings are unmaintained** Contributors needed.
`[1]` No HTTP/Websocket support [#257](https://github.com/Softmotions/ejdb/issues/257)
`[2]` Binaries are not distributed with dart `pub.` You can build it [manually](https://github.com/Softmotions/ejdb/tree/master/src/bindings/ejdb2_node#how-build-it-manually)
`[3]` Can be build, but needed a linkage with windows node/dart `libs`.
`[4]` Porting in progress [#273](https://github.com/Softmotions/ejdb/issues/273) - ## Native language bindings * [NodeJS](https://www.npmjs.com/package/ejdb2_node) @@ -77,6 +79,10 @@ EJDB2 is an embeddable JSON database engine published under MIT license. ### Unofficial EJDB2 language bindings +* Go + * https://github.com/memmaker/go-ejdb2 +* Rust + * https://crates.io/crates/ejdb2 * .Net * https://github.com/kmvi/ejdb2-csharp * Haskell @@ -90,49 +96,43 @@ EJDB2 is an embeddable JSON database engine published under MIT license. ## Status * **EJDB 2.0 core engine is well tested and used in various heavily loaded deployments** -* Tested on `Linux` and `OSX` platforms. [Limited Windows support](./WINDOWS.md) +* Tested on `Linux`, `macOS` and `FreeBSD`. [Has limited Windows support](./WINDOWS.md) * Old EJDB 1.x version can be found in separate [ejdb_1.x](https://github.com/Softmotions/ejdb/tree/ejdb_1.x) branch. We are not maintaining ejdb 1.x. -## Use cases +## Used by -* Softmotions trading robots platform -* [Gimme - a social toy tokens exchange mobile application.](https://play.google.com/store/apps/details?id=com.softmotions.gimme) EJDB2 is used both on mobile and server sides. +* [Wirow video conferencing platform](https://github.com/wirow-io/wirow-server/) Are you using EJDB? [Let me know!](mailto:info@softmotions.com) -## macOS / OSX +## macOS EJDB2 code ported and tested on `High Sierra` / `Mojave` / `Catalina` -See also [EJDB2 Swift binding](https://github.com/Softmotions/EJDB2Swift) for OSX, iOS and Linux +[EJDB2 Swift binding](https://github.com/Softmotions/EJDB2Swift) for MacOS, iOS and Linux. +Swift binding is outdated at now. Looking for contributors. ``` brew install ejdb ``` -or +## Building from sources + +cmake v3.24 or higher required ``` +git clone --recurse-submodules git@github.com:Softmotions/ejdb.git + mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make install ``` ## Linux -### Ubuntu/Debian -#### PPA repository - -```sh -sudo add-apt-repository ppa:adamansky/ejdb2 -sudo apt-get update -sudo apt-get install ejdb2 -``` #### Building debian packages -cmake v3.15 or higher required - ```sh mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DPACKAGE_DEB=ON @@ -149,9 +149,15 @@ make package ## Windows EJDB2 can be cross-compiled for windows -**Note:** HTTP/Websocket network API is disabled and not supported -on Windows until port of http://facil.io library (#257) +**Note:** HTTP/Websocket network API is disabled and not yet supported Nodejs/Dart bindings not yet ported to Windows. **[Cross-compilation Guide for Windows](./WINDOWS.md)** + + +## IWSTART + +IWSTART is an automatic CMake initial project generator for C projects based on [iowow](https://github.com/Softmotions/iowow) / [iwnet](https://github.com/Softmotions/iwnet) / [ejdb2](https://github.com/Softmotions/ejdb) libs. + +https://github.com/Softmotions/iwstart \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 263658f2f..d0656e3a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +cmake_policy(SET CMP0135 NEW) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") @@ -15,10 +17,8 @@ project(${PROJECT_NAME} C) set(PROJECT_VENDOR "Softmotions (https://softmotions.com)") set(PROJECT_WEBSITE "http://ejdb.org") set(PROJECT_MAINTAINER "Anton Adamansky ") -set(PROJECT_DESCRIPTION_SUMMARY - "Embeddable JSON database engine with network support (EJDB2).") -set(PROJECT_DESCRIPTION - "Embeddable JSON database engine with network support (EJDB2).") +set(PROJECT_DESCRIPTION_SUMMARY "Embeddable JSON database engine (EJDB2).") +set(PROJECT_DESCRIPTION "Embeddable JSON database engine (EJDB2).") set(CHANGELOG_MESSAGE ${CHANGELOG_LAST_MESSAGE}) set(PROJECT_PPA "ppa:adamansky/ejdb2") set(PROJECT_PPA_USER "adamansky") @@ -36,7 +36,11 @@ set(${PROJECT_NAME}_VERSION_PATCH 0) option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(ENABLE_HTTP "Enable HTTP endpoint and standalone server (jbs)" ON) +option(INSTALL_FLAT_SUBPROJECT_INCLUDES + "Install iowow/iwnet headers into CMAKE_INSTALL_PREFIX/{iowow,iwnet} dir" + OFF) option(BUILD_TESTS "Build test cases" OFF) +option(NOBLOCKS "Turn off Clang Blocks support" OFF) option(ASAN "Turn on address sanitizer" OFF) option(BUILD_EXAMPLES "Build example projects" ON) option(BUILD_BENCHMARKS "Build benchmarks" OFF) @@ -59,7 +63,7 @@ set(PPA_DEBIAN_VERSION CACHE STRING "PPA version suffix for debian packages") set(PROJECT_PPA_DISTRIB_TARGET - "focal" + "jammy" CACHE STRING "Ubuntu PPA distribution names") set(ANDROID_ABIS @@ -127,13 +131,7 @@ if(PACKAGE_RPM) list(APPEND CPACK_GENERATORS "RPM") endif() -if(NOT - (CPACK_GENERATORS - AND (BUILD_JNI_BINDING - OR BUILD_DART_BINDING - OR BUILD_NODEJS_BINDING))) - set(DO_INSTALL_CORE ON) -endif() +set(DO_INSTALL_CORE ON) add_subdirectory(man) @@ -153,27 +151,20 @@ if(CPACK_GENERATORS) "/mxe/" "/build/" "/target/" - "/tools/" "/docker/" + "/benchmark/" "/node_modules/" "/cmake-.*/" "/Makefile$" "hints\\\\.txt$" "/\\\\.clang/" - "/\\\\.codelite/" + "/\\\\.cache/" "/\\\\.git/" - "/\\\\.idea/" "/\\\\.settings/" - "/\\\\.vscode/" "\\\\.classpath$" "\\\\.editorconfig$" - "\\\\.iml$" - "\\\\.ipr$" "\\\\.log$" "\\\\.mk$" - "\\\\.project$" - "\\\\.workspace$" - "\\\\.astylerc$" "uncrustify\\\\.cfg") set(PROJECT_ARCH "${CMAKE_SYSTEM_PROCESSOR}") add_subdirectory(installer) @@ -200,4 +191,4 @@ message("${PROJECT_NAME} PROJECT: ${CHANGELOG_LAST_LINE}") if(CHANGELOG_MESSAGE) message("${PROJECT_NAME} CHANGELOG_MESSAGE:\n ${CHANGELOG_MESSAGE}") -endif() +endif() \ No newline at end of file diff --git a/Changelog b/Changelog index 8ae3e03b8..a83af4802 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,55 @@ +ejdb2 (2.74) UNRELEASED; urgency=medium + + * Naming refactoring. + * ejdb_swift, ejdb_react_native, ejdb_android, ejdb_dart, ejdb_flutter + marked as unmaintained. + * Updated to the current iowow API. Naming refactoring. + * Fix:JQL Incorrect floating point match against integers (#380) + * Fix: Incorrect parsing of JQL JSON with floats in scientific format (#378) + * Fix: windows build errors + * Fix: Updated iwnet fixed wrong handling of fs error events (iwn_poller) + * Chore: BearSSL updated to the latest version. + * Fix: Delete ejdb crash as realloc(): invalid next size #366 + + -- Anton Adamansky Thu, 17 Nov 2022 19:42:23 +0200 + +ejdb2 (2.73) testing; urgency=medium + + * Fixed ERR_STREAM_PREMATURE_CLOSE on Node 18 (#346) + * Resolved security issuies with nodejs packages + * ejdb2 json module migrated to iowow + * Upgraded to the stable verion of iwnet lib. + * Updated EJDB2Swift submodule + * Replaced old iowow regexp engine with new (iwre.h) based on https://github.com/jserv/cregex + + -- Anton Adamansky Mon, 14 Nov 2022 18:42:52 +0200 + +ejdb2 (2.72) testing; urgency=medium + + * Upgraded to the stable verion of iwnet lib. + + -- Anton Adamansky Wed, 23 Feb 2022 17:00:23 +0700 + +ejdb2 (2.71) testing; urgency=medium + + * Fixed wrong format of printf like function calls. + * Query placeholders with the same name can be specified multiply times. + * Query placeholders API is supported in projections. + * Removed potential memory leaks in `jql_set_xx` query API (jql.h) + * Added BearSSL include files as part of ejdb2 distribution + + -- Anton Adamansky Fri, 18 Feb 2022 21:57:08 +0700 + +ejdb2 (2.70) testing; urgency=medium + + * Network API is now powered by IWNET https://github.com/Softmotions/iwnet + * Correct handling of `vsnprintf` return value. (jbl.c) + * Moved `lwre` regexp library into `iowow` project. + * Java: Added JSON.clone() method. + * Java: Added JSON ObjectBuilder.move() method. + + -- Anton Adamansky Mon, 14 Feb 2022 18:18:10 +0700 + ejdb2 (2.62) testing; urgency=medium * Fixed incorrect query results on array values (#331) @@ -481,4 +533,4 @@ ejdb2 (2.0.0) testing; urgency=medium * Initial beta release - -- Anton Adamansky Mon, 01 Apr 2019 20:21:27 +0700 + -- Anton Adamansky Mon, 01 Apr 2019 20:21:27 +0700 \ No newline at end of file diff --git a/LICENSE b/LICENSE index 5319d1e8e..9f84967fb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2021 Softmotions Ltd +Copyright (c) 2012-2024 Softmotions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index dff074ca4..e20253f76 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # EJDB 2.0 -[![Join Telegram](https://img.shields.io/badge/join-ejdb2%20telegram-0088cc.svg)](https://tlg.name/ejdb2) +**NOTE: Issues tracker is disabled. You are welcome to contribute, pull requests accepted.** + [![license](https://img.shields.io/github/license/Softmotions/ejdb.svg)](https://github.com/Softmotions/ejdb/blob/master/LICENSE) -![maintained](https://img.shields.io/maintenance/yes/2021.svg) +![maintained](https://img.shields.io/maintenance/yes/2024.svg) EJDB2 is an embeddable JSON database engine published under MIT license. @@ -18,14 +19,14 @@ EJDB2 is an embeddable JSON database engine published under MIT license. * [rfc7386](https://tools.ietf.org/html/rfc7386) JSON Merge patch * [rfc6901](https://tools.ietf.org/html/rfc6901) JSON Path * [Support of collection joins](#jql-collection-joins) -* Powered by [iowow.io](http://iowow.io) - The persistent key/value storage engine -* Provides HTTP REST/Websockets network endpoints with help of [facil.io](http://facil.io) +* Powered by [IOWOW](http://iowow.softmotions.com) - The persistent key/value storage engine +* HTTP REST/Websockets endpoints powered by [IWNET](https://github.com/Softmotions/iwnet) and [BearSSL](https://github.com/Softmotions/BearSSL). * JSON documents are stored in using fast and compact [binn](https://github.com/liteserver/binn) binary format --- * [Native language bindings](#native-language-bindings) * Supported platforms - * [OSX](#osx) + * [macOS](#osx) * [iOS](https://github.com/Softmotions/EJDB2Swift) * [Linux](#linux) * [Android](#android) @@ -46,25 +47,26 @@ EJDB2 is an embeddable JSON database engine published under MIT license. * [License](#license) --- -## EJDB2 platforms matrix - -| | Linux | macOS | iOS | Android | Windows | -| --- | --- | --- | --- | --- | --- | -| C library | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:1 | -| NodeJS | :heavy_check_mark: | :heavy_check_mark: | | | :x:3 | -| DartVM | :heavy_check_mark: | :heavy_check_mark:2 | | | :x:3 | -| Flutter | | | :heavy_check_mark: | :heavy_check_mark: | | -| React Native | | | :x:4 | :heavy_check_mark: | | -| Swift | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | -| Java | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark:2 | +[![EJDB2 Presentation](https://iowow.softmotions.com/articles/ejdb-presentation-cover.png)](https://iowow.softmotions.com/articles/ejdb/) +## EJDB2 platforms matrix +| | Linux | macOS | iOS | Android | Windows | +| --- | --- | --- | --- | --- | --- | +| C library | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:1 | +| NodeJS | :heavy_check_mark: | :heavy_check_mark: | | | :x:3 | +| Java | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark:2 | +| DartVM5 | :heavy_check_mark: | :heavy_check_mark:2 | | | :x:3 | +| Flutter5 | | | :heavy_check_mark: | :heavy_check_mark: | | +| React Native5 | | | :x:4 | :heavy_check_mark: | | +| Swift5 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | + +
`[5]` **Bindings are unmaintained** Contributors needed.
`[1]` No HTTP/Websocket support [#257](https://github.com/Softmotions/ejdb/issues/257)
`[2]` Binaries are not distributed with dart `pub.` You can build it [manually](https://github.com/Softmotions/ejdb/tree/master/src/bindings/ejdb2_node#how-build-it-manually)
`[3]` Can be build, but needed a linkage with windows node/dart `libs`.
`[4]` Porting in progress [#273](https://github.com/Softmotions/ejdb/issues/273) - ## Native language bindings * [NodeJS](https://www.npmjs.com/package/ejdb2_node) @@ -77,6 +79,10 @@ EJDB2 is an embeddable JSON database engine published under MIT license. ### Unofficial EJDB2 language bindings +* Go + * https://github.com/memmaker/go-ejdb2 +* Rust + * https://crates.io/crates/ejdb2 * .Net * https://github.com/kmvi/ejdb2-csharp * Haskell @@ -90,49 +96,43 @@ EJDB2 is an embeddable JSON database engine published under MIT license. ## Status * **EJDB 2.0 core engine is well tested and used in various heavily loaded deployments** -* Tested on `Linux` and `OSX` platforms. [Limited Windows support](./WINDOWS.md) +* Tested on `Linux`, `macOS` and `FreeBSD`. [Has limited Windows support](./WINDOWS.md) * Old EJDB 1.x version can be found in separate [ejdb_1.x](https://github.com/Softmotions/ejdb/tree/ejdb_1.x) branch. We are not maintaining ejdb 1.x. -## Use cases +## Used by -* Softmotions trading robots platform -* [Gimme - a social toy tokens exchange mobile application.](https://play.google.com/store/apps/details?id=com.softmotions.gimme) EJDB2 is used both on mobile and server sides. +* [Wirow video conferencing platform](https://github.com/wirow-io/wirow-server/) Are you using EJDB? [Let me know!](mailto:info@softmotions.com) -## macOS / OSX +## macOS EJDB2 code ported and tested on `High Sierra` / `Mojave` / `Catalina` -See also [EJDB2 Swift binding](https://github.com/Softmotions/EJDB2Swift) for OSX, iOS and Linux +[EJDB2 Swift binding](https://github.com/Softmotions/EJDB2Swift) for MacOS, iOS and Linux. +Swift binding is outdated at now. Looking for contributors. ``` brew install ejdb ``` -or +## Building from sources + +cmake v3.24 or higher required ``` +git clone --recurse-submodules git@github.com:Softmotions/ejdb.git + mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make install ``` ## Linux -### Ubuntu/Debian -#### PPA repository - -```sh -sudo add-apt-repository ppa:adamansky/ejdb2 -sudo apt-get update -sudo apt-get install ejdb2 -``` #### Building debian packages -cmake v3.15 or higher required - ```sh mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DPACKAGE_DEB=ON @@ -149,14 +149,21 @@ make package ## Windows EJDB2 can be cross-compiled for windows -**Note:** HTTP/Websocket network API is disabled and not supported -on Windows until port of http://facil.io library (#257) +**Note:** HTTP/Websocket network API is disabled and not yet supported Nodejs/Dart bindings not yet ported to Windows. **[Cross-compilation Guide for Windows](./WINDOWS.md)** +## IWSTART + +IWSTART is an automatic CMake initial project generator for C projects based on [iowow](https://github.com/Softmotions/iowow) / [iwnet](https://github.com/Softmotions/iwnet) / [ejdb2](https://github.com/Softmotions/ejdb) libs. + +https://github.com/Softmotions/iwstart + + +# WARNING: Unsupported now. Maintainer needed. # Android @@ -614,6 +621,8 @@ PROJECTIONS = PROJECTION [ {'+' | '-'} PROJECTION ] Projection allows to get only subset of JSON document excluding not needed data. +**Query placeholders API is supported in projections.** + Lets add one more document to our collection: ```sh @@ -903,45 +912,45 @@ modifier to the query to get rid of unnecessary data transferring and json data # HTTP REST/Websocket API endpoint EJDB engine provides the ability to start a separate HTTP/Websocket endpoint worker exposing network API for quering and data modifications. +SSL (TLS 1.2) is supported by `jbs` server. -The easiest way to expose database over the network is using the standalone `jbs` server. (Of course if you plan to avoid `C API` integration). +The easiest way to expose database over the network is use the standalone `jbs` server. (Of course if you want to avoid `C API` integration). ## jbs server ``` -jbs -h - -EJDB 2.0.0 standalone REST/Websocket server. http://ejdb.org +Usage: - --file <> Database file path. Default: db.jb - -f <> (same as --file) - --port ## HTTP port number listen to. Default: 9191 - -p ## (same as --port) - --bind <> Address server listen. Default: localhost - -b <> (same as --bind) - --access <> Server access token matched to 'X-Access-Token' HTTP header value - -a <> (same as --access) - --trunc Cleanup existing database file on open - -t (same as --trunc) - --wal Use write ahead logging (WAL). Must be set for data durability. - -w (same as --wal) + ./jbs [options] -Advanced options - --sbz ## Max sorting buffer size. If exceeded, an overflow temp file for data will be created. Default: 16777216, min: 1048576 - --dsz ## Initial size of buffer to process/store document on queries. Preferable average size of document. Default: 65536, min: 16384 - --bsz ## Max HTTP/WS API document body size. Default: 67108864, min: 524288 + -v, --version Print program version. + -f, --file=<> Database file path. Default: ejdb2.db + -p, --port=NUM HTTP server port numer. Default: 9191 + -l, --listen=<> Network address server will listen. Default: localhost + -k, --key=<> PEM private key file for TLS 1.2 HTTP server. + -c, --certs=<> PEM certificates file for TLS 1.2 HTTP server. + -a, --access=TOKEN|@FILE Access token to match 'X-Access-Token' HTTP header value. + -r, --access-read Allows unrestricted read-only data access. + -C, --cors Enable COSR response headers for HTTP server + -t, --trunc Cleanup/reset database file on open. + -w, --wal use the write ahead log (WAL). Used to provide data durability. -Use any of the following input formats: - -arg -arg= -arg +Advanced options: + -S, --sbz=NUM Max sorting buffer size. If exceeded, an overflow temp file for data will be created. + Default: 16777216, min: 1048576 + -D, --dsz=NUM Initial size of buffer to process/store document on queries. Preferable average size of document. + Default: 65536, min: 16384 + -T, --trylock Exit with error if database is locked by another process. + If not set, current process will wait for lock release. -Use the -h, -help or -? to get this information again. ``` ## HTTP API -Access to HTTP endpoint can be protected by a token specified with `--access` -command flag or by C API `EJDB_HTTP` options. If access token specified on server, client must provide `X-Access-Token` HTTP header value. If token is required and not provided by client the `401` HTTP code will be reported. If access token is not matched to the token provided the `403` HTTP code will be returned. -For any other errors server will respond with `500` error code. +HTTP endpoint may be protected by a token specified with `--access` flag or C API `EJDB_HTTP` struct. +If access token was set, client should provide `X-Access-Token` HTTP header. +If token is required but not provided by client `401` HTTP code will be reported. +If access token is not matched to the token provided by client server will respond with `403` HTTP code. ## REST API @@ -956,7 +965,7 @@ Replaces/store document under specific numeric `id` ### DELETE /{collection}/{id} Removes document identified by `id` from a `collection` * `200` on success. Empty body -* `404` if document not found +* `404` document not found ### PATCH /{collection}/{id} Patch a document identified by `id` by [rfc7396](https://tools.ietf.org/html/rfc7396), @@ -968,7 +977,7 @@ Retrieve document identified by `id` from a `collection`. * `200` on success. Body: JSON document text. * `content-type:application/json` * `content-length:` -* `404` if document not found +* `404` document not found ### POST / Query a collection by provided query as POST body. @@ -1322,7 +1331,7 @@ gcc -o example1 example1.o -lejdb2 MIT License -Copyright (c) 2012-2021 Softmotions Ltd +Copyright (c) 2012-2024 Softmotions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/WINDOWS.md b/WINDOWS.md index 9e5ffb599..aef26fb58 100644 --- a/WINDOWS.md +++ b/WINDOWS.md @@ -1,14 +1,14 @@ # Windows cross compilation -**Note:** HTTP/Websocket network API is disabled and not supported -on Windows until porting of http://facil.io library +**Note:** HTTP/Websocket network API is disabled and not yet supported. Nodejs/Dart bindings not yet ported to Windows. ## Prerequisites ```sh -sudo apt-get install bison flex libtool ruby scons intltool libtool-bin p7zip-full wine +sudo apt-get install bison flex libtool ruby scons intltool libtool-bin p7zip-full wine wine32 \ + python-is-python3 python3-mako gperf ``` ## Build @@ -16,7 +16,7 @@ sudo apt-get install bison flex libtool ruby scons intltool libtool-bin p7zip-fu ### Prepare MXE ```sh -git submodule update --init +git clone https://github.com/mxe/mxe.git ``` `nano ./mxe/settings.mk`: diff --git a/cmake/Modules/AddFacil.cmake b/cmake/Modules/AddFacil.cmake deleted file mode 100644 index 15ceb234e..000000000 --- a/cmake/Modules/AddFacil.cmake +++ /dev/null @@ -1,86 +0,0 @@ -include(ExternalProject) - -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - set(_UPDATE_DISCONNECTED 0) -else() - set(_UPDATE_DISCONNECTED 1) -endif() - -set(FACIL_SOURCE_DIR "${CMAKE_BINARY_DIR}/src/extern_facil") -set(FACIL_BINARY_DIR "${CMAKE_BINARY_DIR}/src/extern_facil") -set(FACIL_INCLUDE_DIR "${FACIL_BINARY_DIR}/lib/facil") -set(FACIL_LIBRARY_DIR "${FACIL_BINARY_DIR}") - -if("${FACIL_URL}" STREQUAL "") - if(EXISTS ${CMAKE_SOURCE_DIR}/facil.zip) - set(FACIL_URL ${CMAKE_SOURCE_DIR}/facil.zip) - else() - set(FACIL_URL https://github.com/Softmotions/facil.io/archive/master.zip) - endif() -endif() - -message("FACIL_URL: ${FACIL_URL}") - -set(CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_FLAGS=-fPIC) - -foreach(extra - CMAKE_C_COMPILER - CMAKE_TOOLCHAIN_FILE - ANDROID_PLATFORM - ANDROID_ABI - TEST_TOOL_CMD - PLATFORM - ENABLE_BITCODE - ENABLE_ARC - ENABLE_VISIBILITY - ENABLE_STRICT_TRY_COMPILE - ARCHS) - if(DEFINED ${extra}) - list(APPEND CMAKE_ARGS "-D${extra}=${${extra}}") - endif() -endforeach() -message("FACIL CMAKE_ARGS: ${CMAKE_ARGS}") - -ExternalProject_Add( - extern_facil - URL ${FACIL_URL} - DOWNLOAD_NAME facil.zip - TIMEOUT 360 - # Remove in-source makefile to avoid clashing - PATCH_COMMAND rm -f ./makefile - PREFIX ${CMAKE_BINARY_DIR} - BUILD_IN_SOURCE ON - GIT_PROGRESS ON - UPDATE_COMMAND "" - INSTALL_COMMAND "" - UPDATE_DISCONNECTED ${_UPDATE_DISCONNECTED} - LOG_DOWNLOAD OFF - LOG_UPDATE OFF - LOG_BUILD OFF - LOG_CONFIGURE OFF - LOG_INSTALL OFF - CMAKE_ARGS ${CMAKE_ARGS} - BUILD_BYPRODUCTS "${FACIL_LIBRARY_DIR}/libfacil.io.a" -) - -add_library(facil_s STATIC IMPORTED GLOBAL) -set_target_properties( - facil_s - PROPERTIES - IMPORTED_LOCATION "${FACIL_LIBRARY_DIR}/libfacil.io.a" -) -add_dependencies(facil_s extern_facil) - -if (DO_INSTALL_CORE) - install(FILES "${FACIL_LIBRARY_DIR}/libfacil.io.a" - RENAME "libfacilio-1.a" - DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -list(APPEND PROJECT_LLIBRARIES facil_s) -list(APPEND PROJECT_INCLUDE_DIRS "${FACIL_INCLUDE_DIR}" - "${FACIL_INCLUDE_DIR}/fiobj" - "${FACIL_INCLUDE_DIR}/http" - "${FACIL_INCLUDE_DIR}/cli" - "${FACIL_INCLUDE_DIR}/tls") diff --git a/cmake/Modules/AddIOWOW.cmake b/cmake/Modules/AddIOWOW.cmake index eb6c76769..e99aad8a1 100644 --- a/cmake/Modules/AddIOWOW.cmake +++ b/cmake/Modules/AddIOWOW.cmake @@ -1,57 +1,52 @@ -include(ExternalProject) - -if(${CMAKE_VERSION} VERSION_LESS "3.8.0") - set(_UPDATE_DISCONNECTED 0) -else() - set(_UPDATE_DISCONNECTED 1) +if(TARGET IOWOW::static) + return() endif() -set(IOWOW_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include") +find_package(IOWOW) -if("${IOWOW_URL}" STREQUAL "") - if(EXISTS ${CMAKE_SOURCE_DIR}/iowow.zip) - set(IOWOW_URL ${CMAKE_SOURCE_DIR}/iowow.zip) - else() - set(IOWOW_URL https://github.com/Softmotions/iowow/archive/master.zip) - endif() +if(TARGET IOWOW::static) + return() endif() -message("IOWOW_URL: ${IOWOW_URL}") +set(IOWOW_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) -if(APPLE) - set(BYPRODUCT "${CMAKE_BINARY_DIR}/lib/libiowow-1.a") -else() - set(BYPRODUCT "${CMAKE_BINARY_DIR}/src/extern_iowow-build/src/libiowow-1.a") +include(ExternalProject) + +if(NOT DEFINED IOWOW_URL) + set(IOWOW_URL + https://github.com/Softmotions/iowow/archive/refs/heads/master.zip) endif() +set(BYPRODUCT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libiowow-1.a") + set(CMAKE_ARGS - -DOWNER_PROJECT_NAME=${PROJECT_NAME} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DASAN=${ASAN} - -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF) + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DBUILD_SHARED_LIBS=OFF + -DBUILD_EXAMPLES=OFF) -# In order to properly pass owner project CMAKE variables than contains semicolons, -# we used a specific separator for 'ExternalProject_Add', using the LIST_SEPARATOR parameter. -# This allows building fat binaries on macOS, etc. (ie: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64") -# Otherwise, semicolons get replaced with spaces and CMake isn't aware of a multi-arch setup. -set(semicolon_sub "^^") +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_INSTALL_PREFIX} + ${CMAKE_BINARY_DIR}) +list(REMOVE_DUPLICATES CMAKE_FIND_ROOT_PATH) + +set(SSUB "|") foreach( extra - CMAKE_OSX_ARCHITECTURES + ANDROID_ABI + ANDROID_PLATFORM + ARCHS CMAKE_C_COMPILER + CMAKE_FIND_ROOT_PATH + CMAKE_OSX_ARCHITECTURES CMAKE_TOOLCHAIN_FILE - ANDROID_PLATFORM - ANDROID_ABI - TEST_TOOL_CMD - PLATFORM - ENABLE_BITCODE ENABLE_ARC - ENABLE_VISIBILITY + ENABLE_BITCODE ENABLE_STRICT_TRY_COMPILE - ARCHS) + ENABLE_VISIBILITY + PLATFORM + TEST_TOOL_CMD) if(DEFINED ${extra}) - # Replace occurences of ";" with our custom separator and append to CMAKE_ARGS - string(REPLACE ";" "${semicolon_sub}" extra_sub "${${extra}}") + string(REPLACE ";" "${SSUB}" extra_sub "${${extra}}") list(APPEND CMAKE_ARGS "-D${extra}=${extra_sub}") endif() endforeach() @@ -65,24 +60,17 @@ ExternalProject_Add( TIMEOUT 360 PREFIX ${CMAKE_BINARY_DIR} BUILD_IN_SOURCE OFF + # DOWNLOAD_EXTRACT_TIMESTAMP ON UPDATE_COMMAND "" - UPDATE_DISCONNECTED ${_UPDATE_DISCONNECTED} - LOG_DOWNLOAD OFF - LOG_UPDATE OFF - LOG_BUILD OFF - LOG_CONFIGURE OFF - LOG_INSTALL OFF - LIST_SEPARATOR "${semicolon_sub}" CMAKE_ARGS ${CMAKE_ARGS} + LIST_SEPARATOR "${SSUB}" BUILD_BYPRODUCTS ${BYPRODUCT}) -add_library(iowow_s STATIC IMPORTED GLOBAL) -set_target_properties(iowow_s PROPERTIES IMPORTED_LOCATION ${BYPRODUCT}) -add_dependencies(iowow_s extern_iowow) - -if(DO_INSTALL_CORE) - install(FILES "${BYPRODUCT}" DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() +add_library(IOWOW::static STATIC IMPORTED GLOBAL) +set_target_properties( + IOWOW::static + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${BYPRODUCT} + IMPORTED_LINK_INTERFACE_LIBRARIES "Threads::Threads;m") -list(APPEND PROJECT_LLIBRARIES iowow_s m) -list(APPEND PROJECT_INCLUDE_DIRS "${IOWOW_INCLUDE_DIR}") +add_dependencies(IOWOW::static extern_iowow) diff --git a/cmake/Modules/AddIWNET.cmake b/cmake/Modules/AddIWNET.cmake new file mode 100644 index 000000000..cda121a54 --- /dev/null +++ b/cmake/Modules/AddIWNET.cmake @@ -0,0 +1,75 @@ +if(TARGET IWNET::static) + return() +endif() + +include(AddIOWOW) +find_package(IWNET) + +if(TARGET IWNET::static) + return() +endif() + +set(IWNET_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) + +include(ExternalProject) +if(NOT DEFINED IWNET_URL) + set(IWNET_URL + https://github.com/Softmotions/iwnet/archive/refs/heads/master.zip) +endif() + +set(BYPRODUCT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libiwnet-1.a") + +set(CMAKE_ARGS + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DBUILD_SHARED_LIBS=OFF + -DBUILD_EXAMPLES=OFF) + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_INSTALL_PREFIX} + ${CMAKE_BINARY_DIR}) + +list(REMOVE_DUPLICATES CMAKE_FIND_ROOT_PATH) + +set(SSUB "|") +foreach( + extra + ANDROID_ABI + ANDROID_PLATFORM + ARCHS + CMAKE_C_COMPILER + CMAKE_FIND_ROOT_PATH + CMAKE_OSX_ARCHITECTURES + CMAKE_TOOLCHAIN_FILE + ENABLE_ARC + ENABLE_BITCODE + ENABLE_STRICT_TRY_COMPILE + ENABLE_VISIBILITY + PLATFORM + TEST_TOOL_CMD) + if(DEFINED ${extra}) + string(REPLACE ";" "${SSUB}" extra_sub "${${extra}}") + list(APPEND CMAKE_ARGS "-D${extra}=${extra_sub}") + endif() +endforeach() + +message("IWNET CMAKE_ARGS: ${CMAKE_ARGS}") + +ExternalProject_Add( + extern_iwnet + URL ${IWNET_URL} + DOWNLOAD_NAME iwnet.zip + TIMEOUT 360 + PREFIX ${CMAKE_BINARY_DIR} + BUILD_IN_SOURCE OFF + UPDATE_COMMAND "" + CMAKE_ARGS ${CMAKE_ARGS} + LIST_SEPARATOR "${SSUB}" + BUILD_BYPRODUCTS ${BYPRODUCT}) + +add_library(IWNET::static STATIC IMPORTED GLOBAL) +set_target_properties( + IWNET::static + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${BYPRODUCT} + IMPORTED_LINK_INTERFACE_LIBRARIES "IOWOW::static") + +add_dependencies(IWNET::static extern_iwnet) diff --git a/cmake/Modules/DebChangelog.cmake b/cmake/Modules/DebChangelog.cmake index e42796efe..571a627f7 100644 --- a/cmake/Modules/DebChangelog.cmake +++ b/cmake/Modules/DebChangelog.cmake @@ -26,21 +26,16 @@ file(STRINGS "${DEB_CHANGELOG}" _DEBCHANGELOGN) foreach(CLINE IN LISTS _DEBCHANGELOGN) if (NOT CHANGELOG_LAST_VERSION) #ejdb (1.2.6) testing; urgency=low - #ejdb (1.2) testing; urgency=low - string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)(\\.([0-9]+))?)\\)[ \t]+[A-Za-z]+;[ \t].*" _MATCHED "${CLINE}") + string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)\\.([0-9]+))\\)[ \t]+[A-Za-z]+;.*" _MATCHED "${CLINE}") if (_MATCHED) set(CHANGELOG_LAST_LINE "${_MATCHED}") set(CHANGELOG_LAST_VERSION "${CMAKE_MATCH_1}") set(CHANGELOG_LAST_VERSION_MAJOR "${CMAKE_MATCH_2}") - set(CHANGELOG_LAST_VERSION_MINOR "${CMAKE_MATCH_3}") - if (NOT CMAKE_MATCH5) - set(CHANGELOG_LAST_VERSION_PATCH "0") - else() - set(CHANGELOG_LAST_VERSION_PATCH "${CMAKE_MATCH_5}") - endif() + set(CHANGELOG_LAST_VERSION_MINOR "${CMAKE_MATCH_3}") + set(CHANGELOG_LAST_VERSION_PATCH "${CMAKE_MATCH_4}") endif() elseif(NOT CHANGELOG_LAST_MESSAGE) - string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)(\\.([0-9]+))?)\\)[ \t]+[A-Za-z]+;[ \t].*" _MATCHED "${CLINE}") + string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)\\.([0-9]+))\\)[ \t]+[A-Za-z]+;.*" _MATCHED "${CLINE}") if (_MATCHED) string(STRIP "${_CDESC}" CHANGELOG_LAST_MESSAGE) return() diff --git a/cmake/Modules/FindIOWOW.cmake b/cmake/Modules/FindIOWOW.cmake index d93dfd0e1..b96e2cf89 100644 --- a/cmake/Modules/FindIOWOW.cmake +++ b/cmake/Modules/FindIOWOW.cmake @@ -1,39 +1,20 @@ -# Find the IOWOW headers and libraries, attemting to import IOWOW exported targets, -# -# IOWOW_INCLUDE_DIRS - The IOWOW include directory -# IOWOW_LIBRARIES - The libraries needed to use IOWOW -# IOWOW_FOUND - True if IOWOW found in system +mark_as_advanced(IOWOW_INCLUDE_DIRS IOWOW_STATIC_LIB) -find_path(IOWOW_INCLUDE_DIR NAMES iowow/iowow.h) -mark_as_advanced(IOWOW_INCLUDE_DIR) -find_library(IOWOW_LIBRARY NAMES - iowow - libiowow - iowowlib -) -mark_as_advanced(IOWOW_LIBRARY) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(IOWOW DEFAULT_MSG IOWOW_LIBRARY IOWOW_INCLUDE_DIR) - -if(IOWOW_FOUND) - set(IOWOW_LIBRARIES ${IOWOW_LIBRARY}) - set(IOWOW_INCLUDE_DIRS ${IOWOW_INCLUDE_DIR}) - find_path(IOWOW_EXPORTS_DIR - NAMES "iowow/iowow-exports.cmake" - PATHS /usr/share /usr/local/share) - mark_as_advanced(IOWOW_EXPORTS_DIR) - if(IOWOW_EXPORTS_DIR) - if(EXISTS ${IOWOW_EXPORTS_DIR}/iowow/iowow-exports.cmake) - include(${IOWOW_EXPORTS_DIR}/iowow/iowow-exports.cmake) - message("-- Imported ${IOWOW_EXPORTS_DIR}/iowow/iowow-exports.cmake") - endif() - if(EXISTS ${IOWOW_EXPORTS_DIR}/iowow/iowow-static-exports.cmake) - include(${IOWOW_EXPORTS_DIR}/iowow/iowow-static-exports.cmake) - message("-- Imported ${IOWOW_EXPORTS_DIR}/iowow/iowow-static-exports.cmake") - endif() - endif(IOWOW_EXPORTS_DIR) -elseif(IOWOW_FIND_REQUIRED) - message(FATAL_ERROR "Could not find libiowow.") -endif(IOWOW_FOUND) +find_path( + IOWOW_INCLUDE_DIRS + NAMES iowow/iowow.h + PATH_SUFFIXES ejdb2) +find_library(IOWOW_STATIC_LIB NAMES libiowow-1.a) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(IOWOW DEFAULT_MSG IOWOW_INCLUDE_DIRS + IOWOW_STATIC_LIB) +if(IOWOW_FOUND) + add_library(IOWOW::static STATIC IMPORTED GLOBAL) + set_target_properties( + IOWOW::static + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${IOWOW_STATIC_LIB} + IMPORTED_LINK_INTERFACE_LIBRARIES "Threads::Threads;m") +endif() diff --git a/cmake/Modules/FindIWNET.cmake b/cmake/Modules/FindIWNET.cmake new file mode 100644 index 000000000..c0e873d2d --- /dev/null +++ b/cmake/Modules/FindIWNET.cmake @@ -0,0 +1,20 @@ +mark_as_advanced(IWNET_INCLUDE_DIRS IWNET_STATIC_LIB) + +find_path( + IWNET_INCLUDE_DIRS + NAMES iwnet/iwnet.h + PATH_SUFFIXES ejdb2) + +find_library(IWNET_STATIC_LIB NAMES libiwnet-1.a) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(IWNET DEFAULT_MSG IWNET_INCLUDE_DIRS + IWNET_STATIC_LIB) +if(IWNET_FOUND) + add_library(IWNET::static STATIC IMPORTED GLOBAL) + set_target_properties( + IWNET::static + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${IWNET_STATIC_LIB} + IMPORTED_LINK_INTERFACE_LIBRARIES "IOWOW::static") +endif() diff --git a/cmake/Modules/GitRevision.cmake b/cmake/Modules/GitRevision.cmake index c18f986f7..c898d8f1f 100644 --- a/cmake/Modules/GitRevision.cmake +++ b/cmake/Modules/GitRevision.cmake @@ -14,5 +14,10 @@ else() message(STATUS "GIT not found") endif() +if(NOT GIT_REVISION AND EXISTS ${CMAKE_SOURCE_DIR}/.revision) + file(READ ${CMAKE_SOURCE_DIR}/.revision _GIT_REVISION) + string(STRIP "${_GIT_REVISION}" GIT_REVISION) +endif() + diff --git a/cmake/Modules/UploadPPA.cmake b/cmake/Modules/UploadPPA.cmake index 2bed3624a..cd534d794 100644 --- a/cmake/Modules/UploadPPA.cmake +++ b/cmake/Modules/UploadPPA.cmake @@ -207,7 +207,7 @@ execute_process(COMMAND chmod +x ${debian_rules}) ############################################################################## # debian/compat -file(WRITE ${DEBIAN_SOURCE_DIR}/debian/compat "7") +file(WRITE ${DEBIAN_SOURCE_DIR}/debian/compat "13") ############################################################################## # debian/source/format @@ -282,14 +282,11 @@ set(CPACK_SOURCE_IGNORE_FILES ${CPACK_SOURCE_IGNORE_FILES} "/build.*/" "/Testing/" - "/test/" "/tmp/" "/packaging/" "/debian/" "/node_modules/" "/\\\\.git.*" - "/\\\\.idea/" - "/\\\\.codelite/" "*~$") #set(package_file_name "${CPACK_DEBIAN_PACKAGE_NAME}_${DEBIAN_PACKAGE_VERSION}") diff --git a/cmake/Modules/Win32LIBTools.cmake b/cmake/Modules/Win32LIBTools.cmake index 24448de41..42dbf2f1c 100644 --- a/cmake/Modules/Win32LIBTools.cmake +++ b/cmake/Modules/Win32LIBTools.cmake @@ -15,7 +15,7 @@ if (NOT WINTOOLS_WGET_EXEC) endif() set(WINTOOLS_DIR ${CMAKE_BINARY_DIR}/WINTOOLS) -set(WINTOOLS_DL_ROOT "http://softmotions.com/windev") +set(WINTOOLS_DL_ROOT "https://assets.softmotions.com/windev") if (NOT EXISTS ${WINTOOLS_DIR}) file(MAKE_DIRECTORY ${WINTOOLS_DIR}) diff --git a/compile_commands.json b/compile_commands.json new file mode 120000 index 000000000..affbd32ab --- /dev/null +++ b/compile_commands.json @@ -0,0 +1 @@ +./build/compile_commands.json \ No newline at end of file diff --git a/docker/testbed/llvm-update-alternatives.sh b/docker/testbed/llvm-update-alternatives.sh index 9ae477495..15aa52e57 100755 --- a/docker/testbed/llvm-update-alternatives.sh +++ b/docker/testbed/llvm-update-alternatives.sh @@ -64,6 +64,7 @@ function register_clang_version { --slave /usr/bin/clangd clangd /usr/bin/clangd-${version} \ --slave /usr/bin/lld lld /usr/bin/lld-${version} \ --slave /usr/bin/lld-link lld-link /usr/bin/lld-link-${version} \ + --slave /usr/bin/llc llc /usr/bin/llc-${version} \ --slave /usr/bin/lldb lldb /usr/bin/lldb-${version} \ --slave /usr/bin/lldb-argdumper lldb-argdumper /usr/bin/lldb-argdumper-${version} \ --slave /usr/bin/lldb-instr lldb-instr /usr/bin/lldb-instr-${version} \ @@ -73,4 +74,4 @@ function register_clang_version { --slave /usr/bin/lli-child-target lli-child-target /usr/bin/lli-child-target-${version} } -register_clang_version $1 $2 +register_clang_version $1 $2 \ No newline at end of file diff --git a/docker/testbed/llvm.sh b/docker/testbed/llvm.sh index 1fb8c1261..750fa3b7b 100755 --- a/docker/testbed/llvm.sh +++ b/docker/testbed/llvm.sh @@ -29,6 +29,8 @@ declare -A LLVM_VERSION_PATTERNS LLVM_VERSION_PATTERNS[9]="-9" LLVM_VERSION_PATTERNS[10]="-10" LLVM_VERSION_PATTERNS[11]="-11" +LLVM_VERSION_PATTERNS[15]="-15" +LLVM_VERSION_PATTERNS[16]="-16" if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then echo "This script does not support LLVM version $LLVM_VERSION" @@ -48,7 +50,8 @@ case "$DIST_VERSION" in Ubuntu_18.10 ) REPO_NAME="deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic$LLVM_VERSION_STRING main" ;; Ubuntu_19.04 ) REPO_NAME="deb http://apt.llvm.org/disco/ llvm-toolchain-disco$LLVM_VERSION_STRING main" ;; Ubuntu_19.10 ) REPO_NAME="deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan$LLVM_VERSION_STRING main" ;; - Ubuntu_20.04 ) REPO_NAME="deb http://apt.llvm.org/focal/ llvm-toolchain-focal$LLVM_VERSION_STRING main" ;; + Ubuntu_20.04 ) REPO_NAME="deb http://apt.llvm.org/focal/ llvm-toolchain-focal$LLVM_VERSION_STRING main" ;; + Ubuntu_22.04 ) REPO_NAME="deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy$LLVM_VERSION_STRING main" ;; * ) echo "Distribution '$DISTRO' in version '$VERSION' is not supported by this script (${DIST_VERSION})." exit 2 diff --git a/installer/core/CMakeLists.txt b/installer/core/CMakeLists.txt index 867bd0c69..fd2b29e13 100644 --- a/installer/core/CMakeLists.txt +++ b/installer/core/CMakeLists.txt @@ -33,15 +33,14 @@ if (PACKAGE_DEB) set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PROJECT_WEBSITE}) set(CPACK_DEBIAN_PACKAGE_SECTION libs) set(CPACK_DEBIAN_PACKAGE_PRIORITY optional) - #set(CPACK_DEBIAN_PACKAGE_DEPENDS zlib1g) - set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS pkg-config git devscripts dh-make) + #set(CPACK_DEBIAN_PACKAGE_DEPENDS libcurl4) + set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS pkg-config git devscripts dh-make libcurl4-openssl-dev) if (NOT PPA_DEBIAN_VERSION) set(PPA_DEBIAN_VERSION ppa1) endif () if (PROJECT_PPA) set(DPUT_HOST ${PROJECT_PPA}) endif () - #set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "any") set(CPACK_DEBIAN_RESOURCE_FILE_CHANGELOG ${CMAKE_SOURCE_DIR}/Changelog) set(CPACK_DEBIAN_UPDATE_CHANGELOG ON) endif (PACKAGE_DEB) @@ -53,9 +52,8 @@ endif (PACKAGE_TGZ) include(CPack) if (ENABLE_PPA) - set(CPACK_SOURCE_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../fetch_libs.cmake") if (NOT PROJECT_PPA_DISTRIB_TARGET) - set(PROJECT_PPA_DISTRIB_TARGET focal) + set(PROJECT_PPA_DISTRIB_TARGET jammy) endif () set(DPUT_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/../debian/dput.cf.in) include(UploadPPA) diff --git a/installer/fetch_libs.cmake b/installer/fetch_libs.cmake deleted file mode 100644 index 6f563ab88..000000000 --- a/installer/fetch_libs.cmake +++ /dev/null @@ -1,5 +0,0 @@ -message("DOWNLOAD https://github.com/Softmotions/facil.io/archive/master.zip") -file(DOWNLOAD https://github.com/Softmotions/facil.io/archive/master.zip ${CMAKE_CURRENT_BINARY_DIR}/facil.zip) - -message("DOWNLOAD https://github.com/Softmotions/iowow/archive/master.zip") -file(DOWNLOAD https://github.com/Softmotions/iowow/archive/master.zip ${CMAKE_CURRENT_BINARY_DIR}/iowow.zip) diff --git a/installer/jni/CMakeLists.txt b/installer/jni/CMakeLists.txt index c6e408ef9..105bf9c20 100644 --- a/installer/jni/CMakeLists.txt +++ b/installer/jni/CMakeLists.txt @@ -44,7 +44,7 @@ if(PACKAGE_DEB) set(CPACK_DEBIAN_PACKAGE_PRIORITY optional) # set(CPACK_DEBIAN_PACKAGE_DEPENDS zlib1g) set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS pkg-config git devscripts dh-make - openjdk-11-jdk) + openjdk-11-jdk libcurl4-openssl-dev) if(NOT PPA_DEBIAN_VERSION) set(PPA_DEBIAN_VERSION ppa1) endif() @@ -63,10 +63,8 @@ endif(PACKAGE_TGZ) include(CPack) if(ENABLE_PPA) - set(CPACK_SOURCE_INSTALL_SCRIPT - "${CMAKE_CURRENT_SOURCE_DIR}/../fetch_libs.cmake") if(NOT PROJECT_PPA_DISTRIB_TARGET) - set(PROJECT_PPA_DISTRIB_TARGET focal) + set(PROJECT_PPA_DISTRIB_TARGET jammy) endif() set(DPUT_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/../debian/dput.cf.in) include(UploadPPA) diff --git a/ios-tc.cmake b/ios-tc.cmake index 682b7bb5b..d580b2f0d 100644 --- a/ios-tc.cmake +++ b/ios-tc.cmake @@ -129,7 +129,7 @@ # command. # -cmake_minimum_required(VERSION 3.8.0) +cmake_minimum_required(VERSION 3.10) # CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. if(IOS_TOOLCHAIN_HAS_RUN) diff --git a/musl-linux-x86-64-tc.cmake b/musl-linux-x86-64-tc.cmake new file mode 100644 index 000000000..151fd271f --- /dev/null +++ b/musl-linux-x86-64-tc.cmake @@ -0,0 +1,24 @@ +# See https://github.com/richfelker/musl-cross-make + +if(NOT MUSL_HOME) + set(MUSL_HOME $ENV{MUSL_HOME}) +endif() +if(NOT MUSL_HOME) + message(FATAL_ERROR "Please setup MUSL_HOME environment variable") +endif() + +set(MUSL_CFG x86_64-linux-musl) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(CROSS_HOST x86_64-unknown-linux) + +set(CMAKE_FIND_ROOT_PATH "${MUSL_HOME}/${MUSL_CFG};${FIND_ROOT};${CMAKE_BINARY_DIR}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +set(CMAKE_C_COMPILER ${MUSL_HOME}/bin/${MUSL_CFG}-gcc) +set(CMAKE_CXX_COMPILER ${MUSL_HOME}/bin/${MUSL_CFG}-g++) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") diff --git a/mxe b/mxe deleted file mode 160000 index 91e21fc4b..000000000 --- a/mxe +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 91e21fc4bc0775790b0a7cc3f7da4aef89637a0f diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5831f6b63..6271e73fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,15 +5,16 @@ if(NOT CMAKE_BUILD_TYPE) ) endif() -set(MODULES util jbl jql jbi) +set(MODULES util jql jbi) set(PROJECT_LLIBRARIES) set(PROJECT_INCLUDE_DIRS) set(ALL_SRC) set(ALL_HDRS) set(PUB_HDRS) set(PROJECT_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated) + list(APPEND PROJECT_INCLUDE_DIRS "${PROJECT_GENERATED_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}") + "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/include") if(APPLE) option(BUILD_FRAMEWORK "Build an OS X framework" OFF) @@ -33,13 +34,36 @@ include(CheckIncludeFiles) include(CheckLibraryExists) include(TestBigEndian) +find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD) +if(CMAKE_USE_WIN32_THREADS_INIT) + add_definitions(-DJB_WIN32_THREADS) +elseif(CMAKE_USE_PTHREADS_INIT) + add_definitions(-DJB_PTHREADS) +else() + mesage(FATAL_ERROR "Unable to find suitable threading library") +endif(CMAKE_USE_WIN32_THREADS_INIT) + +check_include_file("Block.h" HAVE_BLOCK_H) +if(NOT NOBLOCKS + AND CMAKE_C_COMPILER_ID MATCHES "Clang" + AND HAVE_BLOCK_H) + set(IW_BLOCKS ON) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks") + list(PREPEND PROJECT_LLIBRARIES "-lBlocksRuntime") + add_definitions(-DIW_BLOCKS) +endif() + include(AddIOWOW) +list(APPEND PROJECT_LLIBRARIES "IOWOW::static") +list(APPEND PROJECT_INCLUDE_DIRS ${IOWOW_INCLUDE_DIRS}) if(ENABLE_HTTP) if(WIN32) message(FATAL_ERROR "ENABLE_HTTP option cannot be used in Windows build") endif() - include(AddFacil) + include(AddIWNET) + list(APPEND PROJECT_LLIBRARIES "IWNET::static") + list(APPEND PROJECT_INCLUDE_DIRS ${IWNET_INCLUDE_DIRS}) add_definitions(-DJB_HTTP) list(APPEND MODULES jbr) endif() @@ -68,15 +92,6 @@ if(BUILD_TESTS) add_definitions(-DIW_TESTS) endif() -find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD) -if(CMAKE_USE_WIN32_THREADS_INIT) - add_definitions(-DJB_WIN32_THREADS) -elseif(CMAKE_USE_PTHREADS_INIT) - add_definitions(-DJB_PTHREADS) -else() - mesage(FATAL_ERROR "Unable to find suitable threading library") -endif(CMAKE_USE_WIN32_THREADS_INIT) - if(ANDROID) find_library(LOG_LIB log) if(NOT LOG_LIB) @@ -106,15 +121,11 @@ else() add_definitions(-D_POSIX_THREAD_SAFE_FUNCTIONS) endif() -foreach(HF IN ITEMS stdlib stddef stdint stdbool) - string(TOUPPER "${HF}" UHF) - check_include_file(${HF}.h "JB_HAVE_${UHF}") - if(NOT JB_HAVE_${UHF}) - message(FATAL_ERROR "Include file '${HF}.h' not FOUND") - endif() -endforeach() - -add_definitions(-D_XOPEN_SOURCE=600) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Needed by Linux in order to use nftw() but fail to build on FreeBSD due to + # __BSD_VISIBLE define state. + add_definitions(-D_XOPEN_SOURCE=700) +endif() add_definitions(-D_DEFAULT_SOURCE) add_definitions(-D_LARGEFILE_SOURCE) add_definitions(-D_FILE_OFFSET_BITS=64) @@ -133,17 +144,12 @@ foreach(MODULE IN LISTS MODULES) list(APPEND PROJECT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}) endforeach(MODULE) -list( - APPEND - PUB_HDRS - ${CMAKE_CURRENT_SOURCE_DIR}/ejdb2.h - ${CMAKE_CURRENT_SOURCE_DIR}/jbl/jbl.h - ${CMAKE_CURRENT_SOURCE_DIR}/jbr/jbr.h - ${CMAKE_CURRENT_SOURCE_DIR}/jql/jql.h - ${CMAKE_CURRENT_SOURCE_DIR}/util/lwre.h) +list(APPEND PUB_HDRS ${PROJECT_GENERATED_DIR}/ejdb2.h + ${CMAKE_CURRENT_SOURCE_DIR}/jbr/jbr.h + ${CMAKE_CURRENT_SOURCE_DIR}/jql/jql.h) set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -std=gnu11 -fsigned-char -pedantic -Wfatal-errors -Wall -Wextra \ + "${CMAKE_C_FLAGS} -std=gnu11 -fsigned-char -Wfatal-errors -Wall -Wextra \ -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-function \ -Wno-missing-field-initializers -Wno-missing-braces") @@ -178,9 +184,18 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tmpl/ejdb2cfg.h ${PROJECT_GENERATED_DIR}/ejdb2cfg.h) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ejdb2.h.in + ${PROJECT_GENERATED_DIR}/ejdb2.h @ONLY) + file(GLOB PROJECT_GENERATED_HDRS ${PROJECT_GENERATED_DIR}/*.h) list(APPEND ALL_HDRS ${PROJECT_GENERATED_HDRS}) +set(PCLIBS "-liowow -lm") +if(DEFINED IWNET_INCLUDE_DIR) + set(PCLIBS "-liwnet ${PCLIBS}") +endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tmpl/libejdb2.pc.in ${PROJECT_GENERATED_DIR}/libejdb2.pc @ONLY) @@ -263,9 +278,9 @@ else() add_library(ejdb2_s STATIC ${ALL_SRC}) endif() -target_link_libraries(ejdb2 ${PROJECT_LLIBRARIES}) +target_link_libraries(ejdb2 PUBLIC ${PROJECT_LLIBRARIES}) if(BUILD_SHARED_LIBS) - target_link_libraries(ejdb2_s ${PROJECT_LLIBRARIES}) + target_link_libraries(ejdb2_s PUBLIC ${PROJECT_LLIBRARIES}) endif() if(BUILD_SHARED_LIBS) @@ -282,8 +297,8 @@ if(BUILD_SHARED_LIBS) ${CMAKE_CURRENT_BINARY_DIR}/libejdb2.exp DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() - endif() + set_target_properties( ejdb2 PROPERTIES VERSION ${PROJECT_VERSION} @@ -299,19 +314,23 @@ if(BUILD_SHARED_LIBS) endif() set_target_properties( - ejdb2_s PROPERTIES VERSION ${PROJECT_VERSION} COMPILE_FLAGS "-DIW_NODLL" - OUTPUT_NAME ejdb2-${PROJECT_VERSION_MAJOR}) + ejdb2_s + PROPERTIES VERSION ${PROJECT_VERSION} + COMPILE_FLAGS "-DIW_STATIC" + OUTPUT_NAME ejdb2-${PROJECT_VERSION_MAJOR}) else() + set_target_properties( ejdb2 PROPERTIES VERSION ${PROJECT_VERSION} PUBLIC_HEADER "${PUB_HDRS}" - COMPILE_FLAGS "-DIW_NODLL" + COMPILE_FLAGS "-DIW_STATIC" LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -s" OUTPUT_NAME ejdb2-${PROJECT_VERSION_MAJOR}) endif() if(DO_INSTALL_CORE) + include(InstallRequiredSystemLibraries) install( TARGETS ejdb2 EXPORT ejdb2-exports @@ -338,13 +357,28 @@ if(BUILD_SHARED_LIBS AND DO_INSTALL_CORE) endif() if(DO_INSTALL_CORE) - # Install iowow headers included into ejdb2 + if(INSTALL_FLAT_SUBPROJECT_INCLUDES) + set(INCLUDES_DEST ${CMAKE_INSTALL_INCLUDEDIR}) + else() + set(INCLUDES_DEST ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + + if(DEFINED IWNET_INCLUDE_DIR) + install( + DIRECTORY ${IWNET_INCLUDE_DIR}/iwnet + DESTINATION ${INCLUDES_DEST} + COMPONENT headers + FILES_MATCHING + PATTERN "*.h") + endif() + install( - DIRECTORY ${IOWOW_INCLUDE_DIR}/${PROJECT_NAME}/iowow - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} + DIRECTORY ${IOWOW_INCLUDE_DIR}/iowow + DESTINATION ${INCLUDES_DEST} COMPONENT headers FILES_MATCHING PATTERN "*.h") + install(FILES ${CMAKE_SOURCE_DIR}/LICENSE ${CMAKE_SOURCE_DIR}/Changelog DESTINATION ${CMAKE_INSTALL_DOCDIR}) install( @@ -359,8 +393,6 @@ if(DO_INSTALL_CORE) endif() -include(InstallRequiredSystemLibraries) - set(${PROJECT_NAME}_PUB_HDRS ${PUB_HDRS} CACHE INTERNAL "${PROJECT_NAME}: Public headers" FORCE) diff --git a/src/bindings/ejdb2_android/README.md b/src/bindings/ejdb2_android/README.md index 33ed49371..32cda7a1d 100644 --- a/src/bindings/ejdb2_android/README.md +++ b/src/bindings/ejdb2_android/README.md @@ -1,3 +1,5 @@ +# WARNING: Unsupported now. Maintainer needed. + # Android * [Flutter binding](https://github.com/Softmotions/ejdb/tree/master/src/bindings/ejdb2_flutter) diff --git a/src/bindings/ejdb2_android/test/ejdb2/src/androidTest/java/com/softmotions/ejdb2/Ejdb2AndroidTest.java b/src/bindings/ejdb2_android/test/ejdb2/src/androidTest/java/com/softmotions/ejdb2/Ejdb2AndroidTest.java index 3c6329878..93aea6ad7 100644 --- a/src/bindings/ejdb2_android/test/ejdb2/src/androidTest/java/com/softmotions/ejdb2/Ejdb2AndroidTest.java +++ b/src/bindings/ejdb2_android/test/ejdb2/src/androidTest/java/com/softmotions/ejdb2/Ejdb2AndroidTest.java @@ -83,7 +83,7 @@ public void ejdb2tests() { exception = e; } assertTrue(exception != null && exception.getMessage() != null); - assertEquals(86005, exception.getCode()); + assertEquals(76005, exception.getCode()); assertTrue(exception.getMessage().contains("JBL_ERROR_PARSE_UNQUOTED_STRING")); db.put("mycoll", "{'foo':'baz'}".replace('\'', '"')); diff --git a/src/bindings/ejdb2_dart/LICENSE b/src/bindings/ejdb2_dart/LICENSE index 5319d1e8e..1247a0f02 100644 --- a/src/bindings/ejdb2_dart/LICENSE +++ b/src/bindings/ejdb2_dart/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2021 Softmotions Ltd +Copyright (c) 2012-2022 Softmotions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/src/bindings/ejdb2_dart/README.md b/src/bindings/ejdb2_dart/README.md index 0a79fe34e..593467aa5 100644 --- a/src/bindings/ejdb2_dart/README.md +++ b/src/bindings/ejdb2_dart/README.md @@ -1,3 +1,5 @@ +# WARNING: Unsupported now. Maintainer needed. + # EJDB2 Dart VM native binding Embeddable JSON Database engine http://ejdb.org Dart binding. @@ -46,4 +48,3 @@ make cd src/bindings/ejdb2_dart/ejdb2_dart pub get ``` - diff --git a/src/bindings/ejdb2_dart/lib/ejdb2_dart.c b/src/bindings/ejdb2_dart/lib/ejdb2_dart.c index 8834abbca..7d03c7fcf 100644 --- a/src/bindings/ejdb2_dart/lib/ejdb2_dart.c +++ b/src/bindings/ejdb2_dart/lib/ejdb2_dart.c @@ -2,7 +2,7 @@ #include "dart_api.h" #include "dart_native_api.h" #include -#include +#include #include #include #include @@ -85,51 +85,51 @@ static void ejd_rename_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_P static void ejd_bkp_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_Port reply_port); static struct NativeFunctionLookup k_scoped_functions[] = { - { "port", ejd_port }, - { "exec", ejd_exec }, - { "check_exec", ejd_exec_check }, - { "jql_set", ejd_jql_set }, + { "port", ejd_port }, + { "exec", ejd_exec }, + { "check_exec", ejd_exec_check }, + { "jql_set", ejd_jql_set }, { "jql_get_limit", ejd_jql_get_limit }, - { "create_query", ejd_create_query }, - { "set_handle", ejd_set_handle }, - { "get_handle", ejd_get_handle }, - { "explain_rc", ejd_explain_rc }, - { 0, 0 } + { "create_query", ejd_create_query }, + { "set_handle", ejd_set_handle }, + { "get_handle", ejd_get_handle }, + { "explain_rc", ejd_explain_rc }, + { 0, 0 } }; static struct WrapperFunctionLookup k_wrapped_functions[] = { - { "get", ejd_get_wrapped }, - { "put", ejd_put_wrapped }, - { "del", ejd_del_wrapped }, + { "get", ejd_get_wrapped }, + { "put", ejd_put_wrapped }, + { "del", ejd_del_wrapped }, { "rename", ejd_rename_wrapped }, - { "patch", ejd_patch_wrapped }, - { "idx", ejd_idx_wrapped }, - { "rmi", ejd_rmi_wrapped }, - { "rmc", ejd_rmc_wrapped }, - { "info", ejd_info_wrapped }, - { "open", ejd_open_wrapped }, - { "close", ejd_close_wrapped }, - { "bkp", ejd_bkp_wrapped }, - { 0, 0 } + { "patch", ejd_patch_wrapped }, + { "idx", ejd_idx_wrapped }, + { "rmi", ejd_rmi_wrapped }, + { "rmc", ejd_rmc_wrapped }, + { "info", ejd_info_wrapped }, + { "open", ejd_open_wrapped }, + { "close", ejd_close_wrapped }, + { "bkp", ejd_bkp_wrapped }, + { 0, 0 } }; #define EJTH(h_) ejd_error_check_propagate(h_) -#define EJGO(h_, rh_, label_) \ - if (Dart_IsError(h_)) { \ - rh_ = (h_); \ - goto label_; \ - } +#define EJGO(h_, rh_, label_) \ + if (Dart_IsError(h_)) { \ + rh_ = (h_); \ + goto label_; \ + } #define EJLIB() EJTH(Dart_LookupLibrary(Dart_NewStringFromCString("package:ejdb2_dart/ejdb2_dart.dart"))) -#define EJPORT_RC(co_, rc_) \ - if (rc_) { \ - (co_)->type = Dart_CObject_kInt64; \ - (co_)->value.as_int64 = (rc_); \ - } +#define EJPORT_RC(co_, rc_) \ + if (rc_) { \ + (co_)->type = Dart_CObject_kInt64; \ + (co_)->value.as_int64 = (rc_); \ + } -IW_INLINE char *cobject_str(Dart_CObject *co, bool nulls, iwrc *rcp) { +IW_INLINE char* cobject_str(Dart_CObject *co, bool nulls, iwrc *rcp) { *rcp = 0; if (co) { if (co->type == Dart_CObject_kString) { @@ -418,7 +418,7 @@ static iwrc ejd_exec_pause_guard(QCTX qctx) { return rc; } -static iwrc ejd_exec_visitor(struct _EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { +static iwrc ejd_exec_visitor(struct ejdb_exec *ux, EJDB_DOC doc, int64_t *step) { iwrc rc = 0; QCTX qctx = ux->opaque; @@ -1452,7 +1452,7 @@ static void ejd_get_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_Port // /////////////////////////////////////////////////////////////////////////// -static const char *ejd_ecodefn(locale_t locale, uint32_t ecode) { +static const char* ejd_ecodefn(locale_t locale, uint32_t ecode) { if (!((ecode > _EJD_ERROR_START) && (ecode < _EJD_ERROR_END))) { return 0; } diff --git a/src/bindings/ejdb2_dart/test/ejdb2_dart_test.dart b/src/bindings/ejdb2_dart/test/ejdb2_dart_test.dart index 980d8f5e2..b0da5b7d7 100644 --- a/src/bindings/ejdb2_dart/test/ejdb2_dart_test.dart +++ b/src/bindings/ejdb2_dart/test/ejdb2_dart_test.dart @@ -14,7 +14,7 @@ void main() async { await db.put('mycoll', '{"'); } on EJDB2Error catch (e) { error = e; - assert(e.code == 86005); + assert(e.code == 76005); assert(e.message == 'Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)'); } assert(error != null); diff --git a/src/bindings/ejdb2_dart/version.txt b/src/bindings/ejdb2_dart/version.txt index e440e5c84..7813681f5 100644 --- a/src/bindings/ejdb2_dart/version.txt +++ b/src/bindings/ejdb2_dart/version.txt @@ -1 +1 @@ -3 \ No newline at end of file +5 \ No newline at end of file diff --git a/src/bindings/ejdb2_flutter/LICENSE b/src/bindings/ejdb2_flutter/LICENSE index 90d6fd380..1247a0f02 100644 --- a/src/bindings/ejdb2_flutter/LICENSE +++ b/src/bindings/ejdb2_flutter/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2021 Softmotions Ltd +Copyright (c) 2012-2022 Softmotions Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/bindings/ejdb2_flutter/README.md b/src/bindings/ejdb2_flutter/README.md index d34860446..b2618e22f 100644 --- a/src/bindings/ejdb2_flutter/README.md +++ b/src/bindings/ejdb2_flutter/README.md @@ -1,3 +1,5 @@ +# WARNING: Unsupported now. Maintainer needed. + # EJDB2 Flutter integration Embeddable JSON Database engine http://ejdb.org Dart binding. @@ -98,4 +100,4 @@ cd ./example # Start Android emulator flutter run -``` +``` \ No newline at end of file diff --git a/src/bindings/ejdb2_flutter/example/lib/main.dart b/src/bindings/ejdb2_flutter/example/lib/main.dart index f79083801..0b82bb207 100644 --- a/src/bindings/ejdb2_flutter/example/lib/main.dart +++ b/src/bindings/ejdb2_flutter/example/lib/main.dart @@ -49,7 +49,7 @@ class _MyAppState extends State { } assertNotNull(error); assertTrue(error is EJDB2Error); - assertEqual(error.code, '@ejdb IWRC:86005'); + assertEqual(error.code, '@ejdb IWRC:76005'); assertTrue('${error.message}'.contains('Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)')); diff --git a/src/bindings/ejdb2_flutter/version.txt b/src/bindings/ejdb2_flutter/version.txt index d8263ee98..62f945751 100644 --- a/src/bindings/ejdb2_flutter/version.txt +++ b/src/bindings/ejdb2_flutter/version.txt @@ -1 +1 @@ -2 \ No newline at end of file +6 \ No newline at end of file diff --git a/src/bindings/ejdb2_jni/src/CMakeLists.txt b/src/bindings/ejdb2_jni/src/CMakeLists.txt index 6a94a7693..c73f87a0b 100644 --- a/src/bindings/ejdb2_jni/src/CMakeLists.txt +++ b/src/bindings/ejdb2_jni/src/CMakeLists.txt @@ -62,7 +62,8 @@ else() com/softmotions/ejdb2/JQL.java com/softmotions/ejdb2/JQLCallback.java com/softmotions/ejdb2/JSON.java - com/softmotions/ejdb2/JSONException.java) + com/softmotions/ejdb2/JSONException.java + com/softmotions/ejdb2/JSONMissingException.java) utils_list_prepend(EJDB2_JAVA_SOURCES_JAR "main/java/" ${EJDB2_JAVA_SOURCES}) diff --git a/src/bindings/ejdb2_jni/src/ejdb2jni.c b/src/bindings/ejdb2_jni/src/ejdb2jni.c index e3183e07b..a8145f381 100644 --- a/src/bindings/ejdb2_jni/src/ejdb2jni.c +++ b/src/bindings/ejdb2_jni/src/ejdb2jni.c @@ -41,12 +41,12 @@ static jfieldID k_JQL_collection_fid; static jfieldID k_JQL_skip_fid; static jfieldID k_JQL_limit_fid; -#define JBNFIELD(fid_, env_, clazz_, name_, type_) \ - fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); +#define JBNFIELD(fid_, env_, clazz_, name_, type_) \ + fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); -#define JBNFIELD2(fid_, env_, clazz_, name_, type_, label_) \ - fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); \ - if (!fid_) goto label_; +#define JBNFIELD2(fid_, env_, clazz_, name_, type_, label_) \ + fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); \ + if (!fid_) goto label_; typedef struct JBN_JSPRINT_CTX { int flush_buffer_sz; @@ -582,7 +582,6 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_EJDB2__1ensure_1index( jstring coll_, jstring path_, jint mode) { - iwrc rc; EJDB db; const char *coll = (*env)->GetStringUTFChars(env, coll_, 0); @@ -720,7 +719,7 @@ typedef struct JBN_EXEC_CTX { jmethodID cbMid; } JBN_EXEC_CTX; -static iwrc jbn_exec_visitor(struct _EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { +static iwrc jbn_exec_visitor(struct ejdb_exec *ux, EJDB_DOC doc, int64_t *step) { iwrc rc = 0; jstring json = 0; JBN_EXEC_CTX *ectx = ux->opaque; @@ -782,7 +781,7 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1execute( RCGO(rc, finish); JBN_EXEC_CTX ectx = { - .env = env, + .env = env, .cbObj = cbObj }; @@ -805,13 +804,13 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1execute( } EJDB_EXEC ux = { - .db = db, - .q = q, - .skip = skip > 0 ? skip : 0, - .limit = limit > 0 ? limit : 0, - .opaque = &ectx, + .db = db, + .q = q, + .skip = skip > 0 ? skip : 0, + .limit = limit > 0 ? limit : 0, + .opaque = &ectx, .visitor = cbObj ? jbn_exec_visitor : 0, - .log = log + .log = log }; rc = ejdb_exec(&ux); @@ -875,11 +874,11 @@ JNIEXPORT jlong JNICALL Java_com_softmotions_ejdb2_JQL__1execute_1scalar_1long( } EJDB_EXEC ux = { - .db = db, - .q = q, - .skip = skip > 0 ? skip : 0, + .db = db, + .q = q, + .skip = skip > 0 ? skip : 0, .limit = limit > 0 ? limit : 0, - .log = log + .log = log }; rc = ejdb_exec(&ux); @@ -1005,7 +1004,6 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1set_1long( jint pos, jstring placeholder_, jlong val) { - JQL q; iwrc rc; const char *placeholder = 0; @@ -1139,7 +1137,7 @@ JNIEXPORT jlong JNICALL Java_com_softmotions_ejdb2_JQL__1get_1skip(JNIEnv *env, return (jlong) skip; } -static const char *jbn_ecodefn(locale_t locale, uint32_t ecode) { +static const char* jbn_ecodefn(locale_t locale, uint32_t ecode) { if (!((ecode > _JBN_ERROR_START) && (ecode < _JBN_ERROR_END))) { return 0; } diff --git a/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSON.java b/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSON.java index 57174e0f7..940194712 100644 --- a/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSON.java +++ b/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSON.java @@ -13,8 +13,10 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Consumer; import java.util.Objects; import java.util.Set; +import java.util.UUID; /** * JSON parser/container. @@ -25,13 +27,24 @@ * * - https://github.com/ralfstx/minimal-json (MIT) */ -public final class JSON implements Comparable { +public final class JSON implements Comparable, Cloneable { - public static ObjectBuilder buildObject() { - return new ObjectBuilder(); + private static final Object UNIQ = new Object(); + + @Override + public Object clone() { + if (isContainer()) { + return JSON.fromString(toString()); + } else { + return new JSON(type, value); + } + } + + public static ObjectBuilder object(Object... props) { + return new ObjectBuilder().put(props); } - public static ArrayBuilder buildArray() { + public static ArrayBuilder array() { return new ArrayBuilder(); } @@ -55,9 +68,17 @@ public static JSON fromList(List list) { return new JSON(ValueType.ARRAY, list); } + public static JSON fromObject(Object obj) { + if (obj instanceof JSON) { + return (JSON) obj; + } else { + return new JSON(ValueType.getTypeOf(obj), obj); + } + } + private static final ValueType[] valueTypes = new ValueType[256]; - private static final int[] hexDigits = new int['f' + 1]; - private static JSON UNKNOWN = new JSON(ValueType.UNKNOWN, null); + private static final int[] hexDigits = new int['f' + 1]; + private static JSON UNKNOWN = new JSON(ValueType.UNKNOWN, null); static { for (int i = 0; i < valueTypes.length; ++i) { @@ -97,13 +118,13 @@ public static JSON fromList(List list) { } } - public final Object value; + public final Object value; public final ValueType type; private char[] reusableChars = new char[32]; - private byte[] buf = new byte[0]; - private int head; - private int tail; + private byte[] buf = new byte[0]; + private int head; + private int tail; JSON(byte[] buf) { this.buf = buf; @@ -155,6 +176,10 @@ public boolean isUnknown() { return type == ValueType.UNKNOWN; } + public boolean isNullOrUnknown() { + return type == ValueType.NULL || type == ValueType.UNKNOWN; + } + public boolean isNull() { return type == ValueType.NULL; } @@ -179,6 +204,20 @@ public boolean isArray() { return type == ValueType.ARRAY; } + public boolean isContainer() { + return type == ValueType.OBJECT || type == ValueType.ARRAY; + } + + public int length() { + if (type == ValueType.ARRAY) { + return ((List) value).size(); + } else if (type == ValueType.OBJECT) { + return ((Map) value).size(); + } else { + return 0; + } + } + public Builder modify() { return new Builder(this); } @@ -187,7 +226,15 @@ public Set keys() { if (type != ValueType.OBJECT) { return Collections.EMPTY_SET; } - return ((Map) value).keySet(); + return ((Map) value).keySet(); + } + + public String gets(String key) { + return get(key).asString(); + } + + public String gets(int index) { + return get(index).asString(); } public JSON get(String key) { @@ -220,6 +267,22 @@ public JSON get(int index) { return new JSON(ValueType.getTypeOf(v), v); } + public JSON getOrThrow(String key) { + JSON json = get(key); + if (json.isUnknown()) { + throw new JSONMissingException(key); + } + return json; + } + + public JSON getOrThrow(int index) { + JSON json = get(index); + if (json.isUnknown()) { + throw new JSONMissingException(index); + } + return json; + } + public T cast() { return (T) value; } @@ -240,6 +303,20 @@ public String asString() { return asStringOr(null); } + public String[] asStringArray() { + if (type != ValueType.ARRAY) { + return new String[0]; + } else { + List list = (List) value; + String[] res = new String[list.size()]; + for (int i = 0; i < list.size(); ++i) { + var v = list.get(i); + res[i] = v != null ? String.valueOf(v) : null; + } + return res; + } + } + public String asTextOr(String fallbackValue) { if (type == ValueType.UNKNOWN) { return fallbackValue; @@ -249,7 +326,7 @@ public String asTextOr(String fallbackValue) { } public String asText() { - return asTextOr(null); + return asTextOr(""); } public Boolean asBooleanOr(Boolean fallbackValue) { @@ -311,6 +388,14 @@ public JSON at(String pointer) { return traverse(this, createPointer(pointer)); } + public JSON atOrThrow(String pointer) { + JSON json = at(pointer); + if (json.isUnknown()) { + throw new JSONMissingException(pointer); + } + return json; + } + private JSON traverse(JSON obj, List pp) { if (pp.isEmpty() || obj.isUnknown()) { return obj; @@ -817,25 +902,25 @@ public static ValueType getTypeOf(Object v) { } private static final class NumberChars { - char[] chars; - int charsLength; + char[] chars; + int charsLength; boolean dotFound; } private static final class JsonWriter { private static final char[] QUOT_CHARS = { '\\', '"' }; - private static final char[] BS_CHARS = { '\\', '\\' }; - private static final char[] LF_CHARS = { '\\', 'n' }; - private static final char[] CR_CHARS = { '\\', 'r' }; - private static final char[] TAB_CHARS = { '\\', 't' }; + private static final char[] BS_CHARS = { '\\', '\\' }; + private static final char[] LF_CHARS = { '\\', 'n' }; + private static final char[] CR_CHARS = { '\\', 'r' }; + private static final char[] TAB_CHARS = { '\\', 't' }; // In JavaScript, U+2028 and U+2029 characters count as line endings and must be // encoded. // http://stackoverflow.com/questions/2965293/javascript-parse-error-on-u2028-unicode-character private static final char[] UNICODE_2028_CHARS = { '\\', 'u', '2', '0', '2', '8' }; private static final char[] UNICODE_2029_CHARS = { '\\', 'u', '2', '0', '2', '9' }; - private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', - 'e', 'f' }; + private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', + 'd', 'e', 'f' }; private final Writer writer; @@ -949,9 +1034,9 @@ static char[] getReplacementChars(char ch) { } public static final class Builder { - final JSON json; + final JSON json; final ObjectBuilder o; - final ArrayBuilder a; + final ArrayBuilder a; Builder(JSON json) { this.json = json; @@ -1030,6 +1115,10 @@ public ObjectBuilder put(String key, String val) { return getO().put(key, val); } + public ObjectBuilder put(String key, JSON val) { + return getO().put(key, val); + } + public ObjectBuilder put(String key, Number val) { return getO().put(key, val); } @@ -1046,6 +1135,10 @@ public ObjectBuilder delete(String key) { return getO().delete(key); } + public ObjectBuilder move(String oldKey, String newKey) { + return getO().move(oldKey, newKey); + } + public Iterable keys() { return getO().keys(); } @@ -1088,6 +1181,33 @@ public static final class ArrayBuilder { this(new ArrayList<>()); } + public ArrayBuilder addAll(String[] all) { + if (all != null) { + for (var v : all) { + add(v); + } + } + return this; + } + + public ArrayBuilder addAll(Number[] all) { + if (all != null) { + for (var v : all) { + add(v); + } + } + return this; + } + + public ArrayBuilder addAll(Boolean[] all) { + if (all != null) { + for (var v : all) { + add(v); + } + } + return this; + } + public ObjectBuilder addObject() { ObjectBuilder b = new ObjectBuilder(); value.add(b.value); @@ -1120,6 +1240,15 @@ public ArrayBuilder addArray(JSON val) { return this; } + public ArrayBuilder add(JSON val) { + if (val != null) { + value.add(val.value); + } else { + addNull(); + } + return this; + } + public ArrayBuilder add(String val) { value.add(val); return this; @@ -1189,7 +1318,7 @@ public ObjectBuilder putObject(String key) { } public ObjectBuilder putObject(String key, JSON val) { - if (val.type == ValueType.NULL) { + if (val == null || val.type == ValueType.NULL) { return putNull(key); } if (val.type != ValueType.OBJECT) { @@ -1205,6 +1334,12 @@ public ArrayBuilder putArray(String key) { return b; } + public ObjectBuilder putArray(String key, Consumer c) { + ArrayBuilder b = new ArrayBuilder(); + c.accept(b); + return this; + } + public ObjectBuilder putArray(String key, JSON val) { if (val.type == ValueType.NULL) { return putNull(key); @@ -1216,6 +1351,15 @@ public ObjectBuilder putArray(String key, JSON val) { return this; } + public ObjectBuilder put(String key, JSON val) { + if (val != null) { + value.put(key, val.value); + } else { + value.put(key, null); + } + return this; + } + public ObjectBuilder put(String key, String val) { value.put(key, val); return this; @@ -1231,11 +1375,52 @@ public ObjectBuilder put(String key, Boolean val) { return this; } + public ObjectBuilder put(String key, UUID val) { + if (val == null) { + putNull(key); + } else { + put(key, val.toString()); + } + return this; + } + + public ObjectBuilder put(String key, Object o) { + if (o instanceof JSON) { + put(key, (JSON) o); + } else if (o instanceof UUID) { + value.put(key, o.toString()); + } else { + value.put(key, o); + } + return this; + } + + public ObjectBuilder put(Object... a) { + Object key = UNIQ; + for (var v : a) { + if (key != UNIQ) { + put(String.valueOf(key), v); + key = UNIQ; + } else { + key = v; + } + } + return this; + } + public ObjectBuilder putNull(String key) { value.put(key, null); return this; } + public ObjectBuilder move(String oldKey, String newKey) { + if (value.containsKey(oldKey)) { + value.put(newKey, value.get(oldKey)); + value.remove(oldKey); + } + return this; + } + public ObjectBuilder delete(String key) { value.remove(key); return this; diff --git a/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSONMissingException.java b/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSONMissingException.java new file mode 100644 index 000000000..45301ad11 --- /dev/null +++ b/src/bindings/ejdb2_jni/src/main/java/com/softmotions/ejdb2/JSONMissingException.java @@ -0,0 +1,17 @@ +package com.softmotions.ejdb2; + +/** + * Missing JSON value at key exception. + */ +public class JSONMissingException extends RuntimeException { + + private static final long serialVersionUID = -1180177018517230756L; + + public JSONMissingException(String key) { + super("Missing JSON value at: '" + key + '\''); + } + + public JSONMissingException(int index) { + super("Missing JSON value at: '" + index + '\''); + } +} diff --git a/src/bindings/ejdb2_jni/src/test/java/com/softmotions/ejdb2/TestEJDB2.java b/src/bindings/ejdb2_jni/src/test/java/com/softmotions/ejdb2/TestEJDB2.java index 456f5da74..464bfe61a 100644 --- a/src/bindings/ejdb2_jni/src/test/java/com/softmotions/ejdb2/TestEJDB2.java +++ b/src/bindings/ejdb2_jni/src/test/java/com/softmotions/ejdb2/TestEJDB2.java @@ -24,7 +24,7 @@ private static void jsonBasicTest() throws Exception { Map map = (Map) json.value; assert map.get("foo").equals("bar"); - ObjectBuilder b = JSON.buildObject(); + ObjectBuilder b = JSON.object(); b.put("foo", "bar").putArray("baz").add(1).add("one").toJSON(); json = b.toJSON().at("/baz/1"); @@ -77,7 +77,7 @@ private static void dbTest() throws Exception { exception = e; } assert (exception != null && exception.getMessage() != null); - assert (exception.getCode() == 86005); + assert (exception.getCode() == 76005); assert (exception.getMessage().contains("JBL_ERROR_PARSE_UNQUOTED_STRING")); db.put("mycoll", "{'foo':'baz'}".replace('\'', '"')); diff --git a/src/bindings/ejdb2_jni/version.txt b/src/bindings/ejdb2_jni/version.txt index 25bf17fc5..a5c750fea 100644 --- a/src/bindings/ejdb2_jni/version.txt +++ b/src/bindings/ejdb2_jni/version.txt @@ -1 +1 @@ -18 \ No newline at end of file +27 \ No newline at end of file diff --git a/src/bindings/ejdb2_node/binary.js b/src/bindings/ejdb2_node/binary.js index 62000163f..81020b204 100644 --- a/src/bindings/ejdb2_node/binary.js +++ b/src/bindings/ejdb2_node/binary.js @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,4 +33,4 @@ const utils = require('./utils'); module.exports = function (name) { const file = path.join(__dirname, utils.binariesDir, name); return require(file); -}; \ No newline at end of file +}; diff --git a/src/bindings/ejdb2_node/ejdb2_node.c b/src/bindings/ejdb2_node/ejdb2_node.c index 99cc4573f..6bb3e6c11 100644 --- a/src/bindings/ejdb2_node/ejdb2_node.c +++ b/src/bindings/ejdb2_node/ejdb2_node.c @@ -26,44 +26,44 @@ IW_INLINE bool jn_is_exception_pending(napi_env env) { } #define JNTHROW(env, rc, message) \ - jn_throw_error(env, rc, "ejdb2_node.c" ":" STR(__LINE__), message) + jn_throw_error(env, rc, "ejdb2_node.c" ":" STR(__LINE__), message) -#define JNTHROW_LAST(env) do { \ - const napi_extended_error_info *info = 0; \ - napi_get_last_error_info((env), &info); \ - if (info) JNTHROW((env), 0, info->error_message); \ +#define JNTHROW_LAST(env) do { \ + const napi_extended_error_info *info = 0; \ + napi_get_last_error_info((env), &info); \ + if (info) JNTHROW((env), 0, info->error_message); \ } while (0) -#define JNCHECK(ns, env) do { \ - if (ns && ns != napi_pending_exception) { \ - JNTHROW_LAST(env); \ - } \ +#define JNCHECK(ns, env) do { \ + if (ns && ns != napi_pending_exception) { \ + JNTHROW_LAST(env); \ + } \ } while (0) -#define JNRC(env, rc) do { \ - if (rc && !jn_is_exception_pending(env)) { \ - JNTHROW(env, rc, 0); \ - } \ +#define JNRC(env, rc) do { \ + if (rc && !jn_is_exception_pending(env)) { \ + JNTHROW(env, rc, 0); \ + } \ } while (0) #define JNRET(ns, env, call, res) do { \ - ns = (call); \ - if (ns) { \ - if (ns != napi_pending_exception) { \ - JNTHROW_LAST(env); \ - } \ - return (res); \ - } \ + ns = (call); \ + if (ns) { \ + if (ns != napi_pending_exception) { \ + JNTHROW_LAST(env); \ + } \ + return (res); \ + } \ } while (0) #define JNGO(ns, env, call, label) do { \ - ns = (call); \ - if (ns) { \ - if (ns != napi_pending_exception) { \ - JNTHROW_LAST(env); \ - } \ - goto label; \ - } \ + ns = (call); \ + if (ns) { \ + if (ns != napi_pending_exception) { \ + JNTHROW_LAST(env); \ + } \ + goto label; \ + } \ } while (0) static napi_value jn_create_error(napi_env env, iwrc rc, const char *location, const char *msg) { @@ -203,7 +203,7 @@ IW_INLINE napi_value jn_create_int64(napi_env env, int64_t val) { return ret; } -static char *jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls, bool coerce, iwrc *rcp) { +static char* jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls, bool coerce, iwrc *rcp) { *rcp = 0; size_t len = 0; napi_status ns = 0; @@ -242,7 +242,7 @@ static char *jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls, return buf; } -static char *jn_string_at( +static char* jn_string_at( napi_env env, IWPOOL *pool, napi_value arr, bool nulls, bool coerce, uint32_t idx, iwrc *rcp) { *rcp = 0; @@ -410,7 +410,7 @@ static JNWORK jn_work_create(iwrc *rcp) { return w; } -static void *jn_work_alloc_data(size_t siz, JNWORK work, iwrc *rcp) { +static void* jn_work_alloc_data(size_t siz, JNWORK work, iwrc *rcp) { *rcp = 0; work->data = iwpool_calloc(siz, work->pool); if (!work->data) { @@ -1445,7 +1445,6 @@ static void jn_resultset_tsf( napi_value js_add_stream, void *context, void *data) { - if (!env) { // shutdown pending JNCS cs = data; jn_cs_destroy(&cs); @@ -2008,7 +2007,7 @@ static napi_value jn_jql_limit(napi_env env, napi_callback_info info) { // ---------------- -static const char *jn_ecodefn(locale_t locale, uint32_t ecode) { +static const char* jn_ecodefn(locale_t locale, uint32_t ecode) { if (!((ecode > _JN_ERROR_START) && (ecode < _JN_ERROR_END))) { return 0; } diff --git a/src/bindings/ejdb2_node/index.d.ts b/src/bindings/ejdb2_node/index.d.ts index d74ac732b..ecd60b3d4 100644 --- a/src/bindings/ejdb2_node/index.d.ts +++ b/src/bindings/ejdb2_node/index.d.ts @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/bindings/ejdb2_node/index.js b/src/bindings/ejdb2_node/index.js index b0d172b11..b65d95899 100644 --- a/src/bindings/ejdb2_node/index.js +++ b/src/bindings/ejdb2_node/index.js @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,8 +24,8 @@ * SOFTWARE. *************************************************************************************************/ -const semver = require('semver'); -const {engines} = require('./package'); +const semver = require("semver"); +const { engines } = require("./package"); if (!semver.satisfies(process.version, engines.node)) { console.log(`Required node version ${engines.node} not satisfied with current version ${process.version}.`); @@ -33,23 +33,22 @@ if (!semver.satisfies(process.version, engines.node)) { } global.__ejdb_add_stream_result__ = addStreamResult; // Passing it to ejdb2_node init -const {EJDB2Impl} = require('./binary')('ejdb2_node'); -const {Readable} = require('stream'); +const { EJDB2Impl } = require("./binary")("ejdb2_node"); +const { Readable } = require("stream"); delete global.__ejdb_add_stream_result__; /** * EJDB2 Error helpers. */ class JBE { - /** * Returns `true` if given error [err] is `IWKV_ERROR_NOTFOUND` * @param {Error} err * @returns {boolean} */ static isNotFound(err) { - const code = (err.code || '').toString(); - return code.indexOf('@ejdb IWRC:75001') == 0; + const code = (err.code || "").toString(); + return code.indexOf("@ejdb IWRC:75001") == 0; } /** @@ -58,8 +57,8 @@ class JBE { * @return {boolean} */ static isInvalidQuery(err) { - const code = (err.code || '').toString(); - return code.indexOf('@ejdb IWRC:87001') == 0; + const code = (err.code || "").toString(); + return code.indexOf("@ejdb IWRC:87001") == 0; } } @@ -67,7 +66,6 @@ class JBE { * EJDB document. */ class JBDOC { - /** * Get document JSON object */ @@ -99,7 +97,6 @@ class JBDOC { * EJDB Query resultset stream. */ class JBDOCStream extends Readable { - get _impl() { return this.jql._impl; } @@ -115,7 +112,7 @@ class JBDOCStream extends Readable { constructor(jql, opts) { super({ objectMode: true, - highWaterMark: 64 + highWaterMark: 64, }); this._pending = []; this._paused = true; @@ -123,8 +120,13 @@ class JBDOCStream extends Readable { this._aborted = false; this.jql = jql; this.opts = opts; - this.promise = this._impl.jql_stream_attach(jql, this, [opts.limit, opts.explainCallback]) - .catch((err) => this.destroy(err)); + this.promise = this._impl + .jql_stream_attach(jql, this, [opts.limit, opts.explainCallback]) + .catch((err) => this.destroy(err)); + } + + finish() { + this.push(null); } abort() { @@ -159,9 +161,10 @@ class JBDOCStream extends Readable { // may be not empty at the time of `jql_stream_pause` call let pv = this._pending.shift(); while (this.writable && pv) { - if (pv.length == 0) { // Got pending EOF + if (pv.length == 0) { + // Got pending EOF this._pending.length = 0; - this.destroy(); + this.finish(); break; } addStreamResult(this, pv[0], pv[1]); @@ -195,17 +198,18 @@ function addStreamResult(stream, id, jsondoc, log) { delete stream.opts.explainCallback; } - const count = (typeof jsondoc === 'number'); + const count = typeof jsondoc === "number"; if (id >= 0 || count) { if (!stream._aborted) { if (stream._paused) { // Maintaining pending list since `napi_threadsafe_function` queue // may be not empty at the time of `jql_stream_pause` call - stream.pending.push([id, jsondoc]); + stream._pending.push([id, jsondoc]); return; } let doc; - if (count) { // count int response + if (count) { + // count int response doc = new JBDOC(jsondoc, jsondoc); } else if (jsondoc != null) { doc = new JBDOC(id, jsondoc); @@ -216,11 +220,12 @@ function addStreamResult(stream, id, jsondoc, log) { } } - if (id < 0) { // last record + if (id < 0) { + // last record if (!stream._aborted && stream._paused) { - stream.pending.push([]); + stream._pending.push([]); } else { - stream.destroy(); + stream.finish(); } } } @@ -229,7 +234,6 @@ function addStreamResult(stream, id, jsondoc, log) { * EJDB Query. */ class JQL { - get _impl() { return this.db._impl; } @@ -272,9 +276,9 @@ class JQL { completionPromise(opts) { const stream = this.stream(opts || {}); return new Promise((resolve, reject) => { - stream.on('data', () => stream.destroy()); - stream.on('close', () => resolve()); - stream.on('error', (err) => reject(err)); + stream.on("data", () => stream.finish()); + stream.on("close", () => resolve()); + stream.on("error", (err) => reject(err)); }); } @@ -287,11 +291,11 @@ class JQL { scalarInt(opts) { const stream = this.stream(opts); return new Promise((resolve, reject) => { - stream.on('data', (doc) => { + stream.on("data", (doc) => { resolve(doc.id); - stream.destroy(); + stream.finish(); }); - stream.on('error', (err) => reject(err)); + stream.on("error", (err) => reject(err)); }); } @@ -306,9 +310,9 @@ class JQL { const ret = []; const stream = this.stream(opts); return new Promise((resolve, reject) => { - stream.on('data', (doc) => ret.push(doc)); - stream.on('close', () => resolve(ret)); - stream.on('error', (err) => reject(err)); + stream.on("data", (doc) => ret.push(doc)); + stream.on("close", () => resolve(ret)); + stream.on("error", (err) => reject(err)); }); } @@ -324,14 +328,14 @@ class JQL { const ret = []; const stream = this.stream(opts); return new Promise((resolve, reject) => { - stream.on('data', (doc) => { + stream.on("data", (doc) => { ret.push(doc); if (ret.length >= n) { - stream.destroy(); + stream.finish(); } }); - stream.on('close', () => resolve(ret)); - stream.on('error', (err) => reject(err)); + stream.on("close", () => resolve(ret)); + stream.on("error", (err) => reject(err)); }); } @@ -355,7 +359,7 @@ class JQL { */ setJSON(placeholder, val) { this._checkPlaceholder(placeholder); - if (typeof val !== 'string') { + if (typeof val !== "string") { val = JSON.stringify(val); } this._impl.jql_set(this, placeholder, val, 1); @@ -372,9 +376,9 @@ class JQL { this._checkPlaceholder(placeholder); if (val instanceof RegExp) { const sval = val.toString(); - val = sval.substring(1, sval.lastIndexOf('/')); - } else if (typeof val !== 'string') { - throw new Error('Regexp argument must be a string or RegExp object'); + val = sval.substring(1, sval.lastIndexOf("/")); + } else if (typeof val !== "string") { + throw new Error("Regexp argument must be a string or RegExp object"); } this._impl.jql_set(this, placeholder, val, 2); return this; @@ -388,8 +392,8 @@ class JQL { */ setNumber(placeholder, val) { this._checkPlaceholder(placeholder); - if (typeof val !== 'number') { - throw new Error('Value must be a number'); + if (typeof val !== "number") { + throw new Error("Value must be a number"); } this._impl.jql_set(this, placeholder, val, this._isInteger(val) ? 3 : 4); return this; @@ -415,7 +419,7 @@ class JQL { */ setString(placeholder, val) { this._checkPlaceholder(placeholder); - if (val != null && typeof val !== 'string') { + if (val != null && typeof val !== "string") { val = val.toString(); } this._impl.jql_set(this, placeholder, val, 6); @@ -439,8 +443,8 @@ class JQL { _checkPlaceholder(placeholder) { const t = typeof placeholder; - if (t !== 'number' && t !== 'string') { - throw new Error('Invalid placeholder specified, must be either string or number'); + if (t !== "number" && t !== "string") { + throw new Error("Invalid placeholder specified, must be either string or number"); } } } @@ -449,7 +453,6 @@ class JQL { * EJDB2 Nodejs wrapper. */ class EJDB2 { - /** * Open database instance. * @@ -463,27 +466,27 @@ class EJDB2 { function toArgs() { let oflags = 0; const ret = [path]; - if (opts['readonly']) { + if (opts["readonly"]) { oflags |= 0x02; } - if (opts['truncate']) { + if (opts["truncate"]) { oflags |= 0x04; } ret.push(oflags); - ret.push(opts['wal_enabled'] != null ? !!opts['wal_enabled'] : true); - ret.push(opts['wal_check_crc_on_checkpoint']); - ret.push(opts['wal_checkpoint_buffer_sz']); - ret.push(opts['wal_checkpoint_timeout_sec']); - ret.push(opts['wal_savepoint_timeout_sec']); - ret.push(opts['wal_wal_buffer_sz']); - ret.push(opts['document_buffer_sz']); - ret.push(opts['sort_buffer_sz']); - ret.push(opts['http_enabled']); - ret.push(opts['http_access_token']); - ret.push(opts['http_bind']); - ret.push(opts['http_max_body_size']); - ret.push(opts['http_port']); - ret.push(opts['http_read_anon']); + ret.push(opts["wal_enabled"] != null ? !!opts["wal_enabled"] : true); + ret.push(opts["wal_check_crc_on_checkpoint"]); + ret.push(opts["wal_checkpoint_buffer_sz"]); + ret.push(opts["wal_checkpoint_timeout_sec"]); + ret.push(opts["wal_savepoint_timeout_sec"]); + ret.push(opts["wal_wal_buffer_sz"]); + ret.push(opts["document_buffer_sz"]); + ret.push(opts["sort_buffer_sz"]); + ret.push(opts["http_enabled"]); + ret.push(opts["http_access_token"]); + ret.push(opts["http_bind"]); + ret.push(opts["http_max_body_size"]); + ret.push(opts["http_port"]); + ret.push(opts["http_read_anon"]); return ret; } @@ -513,7 +516,7 @@ class EJDB2 { * @returns {Promise} */ put(collection, json, id) { - if (typeof json !== 'string') { + if (typeof json !== "string") { json = JSON.stringify(json); } return this._impl.put(collection, json, id); @@ -715,7 +718,5 @@ class EJDB2 { module.exports = { EJDB2, - JBE + JBE, }; - - diff --git a/src/bindings/ejdb2_node/install.js b/src/bindings/ejdb2_node/install.js index 4ad219972..2abb463ab 100644 --- a/src/bindings/ejdb2_node/install.js +++ b/src/bindings/ejdb2_node/install.js @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,64 +24,65 @@ * SOFTWARE. *************************************************************************************************/ -const { promisify } = require('util'); -const fs = require('fs'); -const os = require('os'); -const path = require('path'); -const rimraf = promisify(require('rimraf')); -const extract = promisify(require('extract-zip')); +const { promisify } = require("util"); +const fs = require("fs"); +const os = require("os"); +const path = require("path"); +const rimraf = promisify(require("rimraf")); +const extract = require("extract-zip"); const readdir = promisify(fs.readdir); -const utils = require('./utils'); -const REVISION = require('./package.json')['revision']; +const utils = require("./utils"); +const REVISION = require("./package.json")["revision"]; function hasRevision() { - return REVISION && REVISION.length && REVISION != '@GIT_REVISION@'; + return REVISION && REVISION.length && REVISION != "@GIT_REVISION@"; } async function install() { - - let out = await utils.runProcessAndGetOutput('cmake', ['--version']).catch(() => { - console.error('Unable to find executable'); + let out = await utils.runProcessAndGetOutput("cmake", ["--version"]).catch(() => { + console.error("Unable to find executable"); process.exit(1); }); console.log(out); - out = await utils.runProcessAndGetOutput('make', ['--version']).catch(() => { - console.error('Unable to find executable'); + out = await utils.runProcessAndGetOutput("make", ["--version"]).catch(() => { + console.error("Unable to find executable"); process.exit(1); }); console.log(out); - console.log('Building EJDB2 native binding...'); - const wdir = await promisify(fs.mkdtemp)(path.join(os.tmpdir(), 'ejdb2-node')); + console.log("Building EJDB2 native binding..."); + const wdir = await promisify(fs.mkdtemp)(path.join(os.tmpdir(), "ejdb2-node")); console.log(`Git revision: ${REVISION}`); console.log(`Build temp dir: ${wdir}`); - let dist = path.join(wdir, 'dist.zip'); + let dist = path.join(wdir, "dist.zip"); await utils.download(`https://github.com/Softmotions/ejdb/archive/${REVISION}.zip`, dist); await extract(dist, { dir: wdir }); - dist = (await readdir(wdir)).find(fn => fn.startsWith(`ejdb-${REVISION}`)); + dist = (await readdir(wdir)).find((fn) => fn.startsWith(`ejdb-${REVISION}`)); if (dist == null) throw Error(`Invalid distrib dir ${wdir}`); dist = path.join(wdir, dist); - const buildDir = path.join(dist, 'build'); + const buildDir = path.join(dist, "build"); fs.mkdirSync(buildDir); await utils.runProcess( - 'cmake', - ['..', '-DCMAKE_BUILD_TYPE=Release', '-DBUILD_NODEJS_BINDING=ON', `-DNODE_BIN_ROOT=${__dirname}`], - buildDir); - await utils.runProcess('make', [], buildDir); + "cmake", + ["..", "-DCMAKE_BUILD_TYPE=Release", "-DBUILD_NODEJS_BINDING=ON", `-DNODE_BIN_ROOT=${__dirname}`], + buildDir + ); + await utils.runProcess("make", [], buildDir); await rimraf(wdir); } -if (process.platform.toLowerCase().indexOf('win') == 0) { // Windows system - console.error('Building for windows is currently not supported'); +if (process.platform.toLowerCase().indexOf("win") == 0) { + // Windows system + console.error("Building for windows is currently not supported"); process.exit(1); } -if (hasRevision() && !fs.existsSync(path.join(utils.binariesDir), 'ejdb2_node.node')) { +if (hasRevision() && !fs.existsSync(path.join(utils.binariesDir, "ejdb2_node.node"))) { install().catch((err) => { console.error(err); process.exit(1); diff --git a/src/bindings/ejdb2_node/package.json b/src/bindings/ejdb2_node/package.json index cf2503280..fca6cdf60 100644 --- a/src/bindings/ejdb2_node/package.json +++ b/src/bindings/ejdb2_node/package.json @@ -34,17 +34,17 @@ ], "revision": "@GIT_REVISION@", "dependencies": { - "extract-zip": "^1.6.7", - "gauge": "^2.7.4", - "request": "^2.88.0", + "extract-zip": "^2.0.1", + "gauge": "^4.0.4", + "request": "^2.88.2", "request-progress": "^3.0.0", - "rimraf": "^2.6.3", - "semver": "^6.2.0" + "rimraf": "^3.0.2", + "semver": "^7.3.7" }, "devDependencies": { "@types/node": "^12.0.10", - "ava": "^2.2.0", - "chai": "^4.2.0" + "ava": "^4.3.1", + "chai": "^4.3.6" }, "resolutions": { "lodash.merge": "4.6.2" diff --git a/src/bindings/ejdb2_node/test.js b/src/bindings/ejdb2_node/test.js index 2e1b94961..e0ba1c0ca 100644 --- a/src/bindings/ejdb2_node/test.js +++ b/src/bindings/ejdb2_node/test.js @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,7 +39,7 @@ test('Main', async (t) => { let id = await db.put('mycoll', { 'foo': 'bar' }); t.is(id, 1); t.throwsAsync(db.put('mycoll', '{"'), { - code: '@ejdb IWRC:86005 put', + code: '@ejdb IWRC:76005 put', message: 'Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)' }); diff --git a/src/bindings/ejdb2_node/utils.js b/src/bindings/ejdb2_node/utils.js index d7637babc..290f15925 100644 --- a/src/bindings/ejdb2_node/utils.js +++ b/src/bindings/ejdb2_node/utils.js @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -125,4 +125,4 @@ module.exports = { awaitProcess, runProcess, runProcessAndGetOutput -}; \ No newline at end of file +}; diff --git a/src/bindings/ejdb2_node/version.txt b/src/bindings/ejdb2_node/version.txt index bf0d87ab1..9d607966b 100644 --- a/src/bindings/ejdb2_node/version.txt +++ b/src/bindings/ejdb2_node/version.txt @@ -1 +1 @@ -4 \ No newline at end of file +11 \ No newline at end of file diff --git a/src/bindings/ejdb2_node/yarn.lock b/src/bindings/ejdb2_node/yarn.lock index 79bf058d9..fa7f55329 100644 --- a/src/bindings/ejdb2_node/yarn.lock +++ b/src/bindings/ejdb2_node/yarn.lock @@ -2,329 +2,27 @@ # yarn lockfile v1 -"@ava/babel-plugin-throws-helper@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@ava/babel-plugin-throws-helper/-/babel-plugin-throws-helper-3.0.0.tgz#2c933ec22da0c4ce1fc5369f2b95452c70420586" - integrity sha512-mN9UolOs4WX09QkheU1ELkVy2WPnwonlO3XMdN8JF8fQqRVgVTR21xDbvEOUsbwz6Zwjq7ji9yzyjuXqDPalxg== - -"@ava/babel-preset-stage-4@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@ava/babel-preset-stage-4/-/babel-preset-stage-4-3.0.0.tgz#32c46b22b640d1ba0c6e38ae4abd58efab965558" - integrity sha512-uI5UBx++UsckkfnbF0HH6jvTIvM4r/Kxt1ROO2YXKu5H15sScAtxUIAHiUVbPIw24zPqz/PlF3xxlIDuyFzlQw== - dependencies: - "@babel/plugin-proposal-async-generator-functions" "^7.2.0" - "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" - "@babel/plugin-transform-dotall-regex" "^7.4.3" - "@babel/plugin-transform-modules-commonjs" "^7.4.3" - -"@ava/babel-preset-transform-test-files@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@ava/babel-preset-transform-test-files/-/babel-preset-transform-test-files-5.0.0.tgz#e06fc762069511e597531cc1120e22216aac6981" - integrity sha512-rqgyQwkT0+j2JzYP51dOv80u33rzAvjBtXRzUON+7+6u26mjoudRXci2+1s18rat8r4uOlZfbzm114YS6pwmYw== - dependencies: - "@ava/babel-plugin-throws-helper" "^3.0.0" - babel-plugin-espower "^3.0.1" - -"@babel/code-frame@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" - integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== - dependencies: - "@babel/highlight" "^7.0.0" - -"@babel/core@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.5.0.tgz#6ed6a2881ad48a732c5433096d96d1b0ee5eb734" - integrity sha512-6Isr4X98pwXqHvtigw71CKgmhL1etZjPs5A67jL/w0TkLM9eqmFR40YrnJvEc1WnMZFsskjsmid8bHZyxKEAnw== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.5.0" - "@babel/helpers" "^7.5.0" - "@babel/parser" "^7.5.0" - "@babel/template" "^7.4.4" - "@babel/traverse" "^7.5.0" - "@babel/types" "^7.5.0" - convert-source-map "^1.1.0" - debug "^4.1.0" - json5 "^2.1.0" - lodash "^4.17.11" - resolve "^1.3.2" - semver "^5.4.1" - source-map "^0.5.0" - -"@babel/generator@^7.0.0", "@babel/generator@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.5.0.tgz#f20e4b7a91750ee8b63656073d843d2a736dca4a" - integrity sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA== - dependencies: - "@babel/types" "^7.5.0" - jsesc "^2.5.1" - lodash "^4.17.11" - source-map "^0.5.0" - trim-right "^1.0.1" - -"@babel/helper-annotate-as-pure@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" - integrity sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q== - dependencies: - "@babel/types" "^7.0.0" - -"@babel/helper-function-name@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" - integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== - dependencies: - "@babel/helper-get-function-arity" "^7.0.0" - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-get-function-arity@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" - integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== - dependencies: - "@babel/types" "^7.0.0" - -"@babel/helper-module-imports@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" - integrity sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A== - dependencies: - "@babel/types" "^7.0.0" - -"@babel/helper-module-transforms@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.4.4.tgz#96115ea42a2f139e619e98ed46df6019b94414b8" - integrity sha512-3Z1yp8TVQf+B4ynN7WoHPKS8EkdTbgAEy0nU0rs/1Kw4pDgmvYH3rz3aI11KgxKCba2cn7N+tqzV1mY2HMN96w== - dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/template" "^7.4.4" - "@babel/types" "^7.4.4" - lodash "^4.17.11" - -"@babel/helper-plugin-utils@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" - integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA== - -"@babel/helper-regex@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.4.4.tgz#a47e02bc91fb259d2e6727c2a30013e3ac13c4a2" - integrity sha512-Y5nuB/kESmR3tKjU8Nkn1wMGEx1tjJX076HBMeL3XLQCu6vA/YRzuTW0bbb+qRnXvQGn+d6Rx953yffl8vEy7Q== - dependencies: - lodash "^4.17.11" - -"@babel/helper-remap-async-to-generator@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" - integrity sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.0.0" - "@babel/helper-wrap-function" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-simple-access@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" - integrity sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w== - dependencies: - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-split-export-declaration@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz#ff94894a340be78f53f06af038b205c49d993677" - integrity sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q== - dependencies: - "@babel/types" "^7.4.4" - -"@babel/helper-wrap-function@^7.1.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz#c4e0012445769e2815b55296ead43a958549f6fa" - integrity sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ== - dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.2.0" - -"@babel/helpers@^7.5.0": - version "7.5.2" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.5.2.tgz#97424dc82fc0041f4c751119b4d2b1ec68cdb5ba" - integrity sha512-NDkkTqDvgFUeo8djXBOiwO/mFjownznOWvmP9hvNdfiFUmx0nwNOqxuaTTbxjH744eQsD9M5ubC7gdANBvIWPw== - dependencies: - "@babel/template" "^7.4.4" - "@babel/traverse" "^7.5.0" - "@babel/types" "^7.5.0" - -"@babel/highlight@^7.0.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" - integrity sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ== - dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^4.0.0" - -"@babel/parser@^7.0.0", "@babel/parser@^7.4.4", "@babel/parser@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.5.0.tgz#3e0713dff89ad6ae37faec3b29dcfc5c979770b7" - integrity sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA== - -"@babel/plugin-proposal-async-generator-functions@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" - integrity sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-remap-async-to-generator" "^7.1.0" - "@babel/plugin-syntax-async-generators" "^7.2.0" - -"@babel/plugin-proposal-optional-catch-binding@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz#135d81edb68a081e55e56ec48541ece8065c38f5" - integrity sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" - -"@babel/plugin-syntax-async-generators@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz#69e1f0db34c6f5a0cf7e2b3323bf159a76c8cb7f" - integrity sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - -"@babel/plugin-syntax-object-rest-spread@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e" - integrity sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz#a94013d6eda8908dfe6a477e7f9eda85656ecf5c" - integrity sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - -"@babel/plugin-transform-dotall-regex@^7.4.3": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz#361a148bc951444312c69446d76ed1ea8e4450c3" - integrity sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.5.4" - -"@babel/plugin-transform-modules-commonjs@^7.4.3": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.5.0.tgz#425127e6045231360858eeaa47a71d75eded7a74" - integrity sha512-xmHq0B+ytyrWJvQTc5OWAC4ii6Dhr0s22STOoydokG51JjWhyYo5mRPXoi+ZmtHQhZZwuXNN+GG5jy5UZZJxIQ== - dependencies: - "@babel/helper-module-transforms" "^7.4.4" - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" - babel-plugin-dynamic-import-node "^2.3.0" - -"@babel/template@^7.1.0", "@babel/template@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" - integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.4.4" - "@babel/types" "^7.4.4" - -"@babel/traverse@^7.1.0", "@babel/traverse@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.5.0.tgz#4216d6586854ef5c3c4592dab56ec7eb78485485" - integrity sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.5.0" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/parser" "^7.5.0" - "@babel/types" "^7.5.0" - debug "^4.1.0" - globals "^11.1.0" - lodash "^4.17.11" - -"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.4.4", "@babel/types@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.5.0.tgz#e47d43840c2e7f9105bc4d3a2c371b4d0c7832ab" - integrity sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ== - dependencies: - esutils "^2.0.2" - lodash "^4.17.11" - to-fast-properties "^2.0.0" - -"@concordance/react@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@concordance/react/-/react-2.0.0.tgz#aef913f27474c53731f4fd79cc2f54897de90fde" - integrity sha512-huLSkUuM2/P+U0uy2WwlKuixMsTODD8p4JVQBI4VKeopkiN0C7M3N9XYVawb4M+4spN5RrO/eLhk7KoQX6nsfA== +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== dependencies: - arrify "^1.0.1" - -"@nodelib/fs.scandir@2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.1.tgz#7fa8fed654939e1a39753d286b48b4836d00e0eb" - integrity sha512-NT/skIZjgotDSiXs0WqYhgcuBKhUMgfekCmCGtkUAiLqZdOnrdjmZr9wRl3ll64J9NF79uZ4fk16Dx0yMc/Xbg== - dependencies: - "@nodelib/fs.stat" "2.0.1" + "@nodelib/fs.stat" "2.0.5" run-parallel "^1.1.9" -"@nodelib/fs.stat@2.0.1", "@nodelib/fs.stat@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.1.tgz#814f71b1167390cfcb6a6b3d9cdeb0951a192c14" - integrity sha512-+RqhBlLn6YRBGOIoVYthsG0J9dfpO79eJyN7BYBkZJtfqrBwf2KK+rD/M/yjZR6WBmIhAgOV7S60eCgaSWtbFw== +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -"@nodelib/fs.walk@^1.2.1": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.2.tgz#6a6450c5e17012abd81450eb74949a4d970d2807" - integrity sha512-J/DR3+W12uCzAJkw7niXDcqcKBg6+5G5Q/ZpThpGNzAUz70eOR6RV4XnnSN01qHZiVl0eavoxJsBypQoKsV2QQ== +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== dependencies: - "@nodelib/fs.scandir" "2.1.1" + "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@sindresorhus/is@^0.14.0": - version "0.14.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" - integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== - -"@szmarczak/http-timer@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" - integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== - dependencies: - defer-to-connect "^1.0.1" - -"@types/events@*": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" - integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== - -"@types/glob@^7.1.1": - version "7.1.1" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" - integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w== - dependencies: - "@types/events" "*" - "@types/minimatch" "*" - "@types/node" "*" - -"@types/minimatch@*": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" - integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== - "@types/node@*": version "12.6.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.1.tgz#d5544f6de0aae03eefbb63d5120f6c8be0691946" @@ -335,51 +33,63 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.10.tgz#51babf9c7deadd5343620055fc8aff7995c8b031" integrity sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ== -ajv@^6.5.5: - version "6.10.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1" - integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg== +"@types/yauzl@^2.9.1": + version "2.10.0" + resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599" + integrity sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw== dependencies: - fast-deep-equal "^2.0.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" + "@types/node" "*" -ansi-align@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb" - integrity sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw== - dependencies: - string-width "^3.0.0" +acorn-walk@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== -ansi-escapes@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.2.0.tgz#c38600259cefba178ee3f7166c5ea3a5dd2e88fc" - integrity sha512-0+VX4uhi8m3aNbzoqKmkAVOEj6uQzcUHXoFPkKjhZPTpGRUBqVh930KbB6PS4zIyDZccphlLIYlu8nsjFzkXwg== +acorn@^8.7.1: + version "8.8.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" + integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== + +aggregate-error@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" + integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== dependencies: - type-fest "^0.5.2" + clean-stack "^2.0.0" + indent-string "^4.0.0" -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= +aggregate-error@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-4.0.1.tgz#25091fe1573b9e0be892aeda15c7c66a545f758e" + integrity sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w== + dependencies: + clean-stack "^4.0.0" + indent-string "^5.0.0" -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= +ajv@^6.12.3: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== -ansi-styles@^3.2.0, ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== ansi-styles@^4.0.0: version "4.0.0" @@ -388,18 +98,23 @@ ansi-styles@^4.0.0: dependencies: color-convert "^2.0.0" -anymatch@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.0.3.tgz#2fb624fe0e84bccab00afee3d0006ed310f22f09" - integrity sha512-c6IvoeBECQlMVuYUjSwimnhmztImpErfxJzWZhIQinIvQWoGOnB0dLIgifbPHQt5heS6mNlaZG16f06H3C8t1g== +ansi-styles@^6.0.0, ansi-styles@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.1.0.tgz#87313c102b8118abd57371afab34618bf7350ed3" + integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== + +anymatch@~3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" + integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" -aproba@^1.0.3: - version "1.2.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" - integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== +"aproba@^1.0.3 || ^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc" + integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== argparse@^1.0.7: version "1.0.10" @@ -408,47 +123,25 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -arr-flatten@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== - array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= -array-union@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" - integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= - dependencies: - array-uniq "^1.0.1" - array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -array-uniq@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" - integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY= - -array-uniq@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-2.1.0.tgz#46603d5e28e79bfd02b046fcc1d77c6820bd8e98" - integrity sha512-bdHxtev7FN6+MXI1YFW0Q8mQ8dTJc2S8AMfju+ZR77pbg2yAdVyDlwkaUI7Har0LyOMRFPHrJ9lYdyjZZswdlQ== - -arrify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= +arrgv@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/arrgv/-/arrgv-1.0.2.tgz#025ed55a6a433cad9b604f8112fc4292715a6ec0" + integrity sha512-a4eg4yhp7mmruZDQFqVMlxNRFGi/i1r87pt8SDHy0/I8PqSXoUTlWZRdAZo0VXgvEARcujbtTk8kiZRi1uDGRw== -arrify@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" - integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== +arrify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-3.0.0.tgz#ccdefb8eaf2a1d2ab0da1ca2ce53118759fd46bc" + integrity sha512-tLkvA81vQG/XqE2mjDkGQHoOINtMHtysSnemrmoGe6PydDPMRbVugqyk4A6V/WDWEfm3l+0d8anA9r8cv/5Jaw== asn1@~0.2.3: version "0.2.4" @@ -467,97 +160,61 @@ assertion-error@^1.1.0: resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= -ava@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ava/-/ava-2.2.0.tgz#5a7d799c2c8cc5926f95d2b76bdfe6081fe9a4f8" - integrity sha512-lROj3eQ8L4ZjfiN5P8UGekEQLfKmseGMtat6pUOHgJLEb2K1kT0ZpR/IlWwuytjvwO6nZpzpD+QsTW/XiayIgg== - dependencies: - "@ava/babel-preset-stage-4" "^3.0.0" - "@ava/babel-preset-transform-test-files" "^5.0.0" - "@babel/core" "^7.5.0" - "@babel/generator" "^7.5.0" - "@babel/plugin-syntax-async-generators" "^7.2.0" - "@babel/plugin-syntax-object-rest-spread" "^7.2.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" - "@concordance/react" "^2.0.0" - ansi-escapes "^4.2.0" - ansi-styles "^4.0.0" - arr-flatten "^1.1.0" - array-union "^2.1.0" - array-uniq "^2.1.0" - arrify "^2.0.1" - bluebird "^3.5.5" - chalk "^2.4.2" - chokidar "^3.0.2" - chunkd "^1.0.0" - ci-parallel-vars "^1.0.0" - clean-stack "^2.1.0" +ava@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/ava/-/ava-4.3.1.tgz#376a788a5a863c39a9dd2dab9fcbbbcf94bf6c38" + integrity sha512-zdSp9QxRTmN5hJeGmg+ZjUKL5yHFLMcP/0KBla8GH25XD8Xm7Uc34CDFlwqGL6JXtjNbVkJ0Zw+DqcTf4ggCCA== + dependencies: + acorn "^8.7.1" + acorn-walk "^8.2.0" + ansi-styles "^6.1.0" + arrgv "^1.0.2" + arrify "^3.0.0" + callsites "^4.0.0" + cbor "^8.1.0" + chalk "^5.0.1" + chokidar "^3.5.3" + chunkd "^2.0.1" + ci-info "^3.3.1" + ci-parallel-vars "^1.0.1" clean-yaml-object "^0.1.0" - cli-cursor "^3.1.0" - cli-truncate "^2.0.0" - code-excerpt "^2.1.1" - common-path-prefix "^1.0.0" - concordance "^4.0.0" - convert-source-map "^1.6.0" + cli-truncate "^3.1.0" + code-excerpt "^4.0.0" + common-path-prefix "^3.0.0" + concordance "^5.0.4" currently-unhandled "^0.4.1" - debug "^4.1.1" - del "^4.1.1" - dot-prop "^5.1.0" - emittery "^0.4.1" - empower-core "^1.2.0" - equal-length "^1.0.0" - escape-string-regexp "^2.0.0" - esm "^3.2.25" - figures "^3.0.0" - find-up "^4.1.0" - get-port "^5.0.0" - globby "^10.0.1" - ignore-by-default "^1.0.0" - import-local "^3.0.1" - indent-string "^4.0.0" - is-ci "^2.0.0" + debug "^4.3.4" + del "^6.1.1" + emittery "^0.11.0" + figures "^4.0.1" + globby "^13.1.1" + ignore-by-default "^2.1.0" + indent-string "^5.0.0" is-error "^2.2.2" - is-observable "^2.0.0" - is-plain-object "^3.0.0" - is-promise "^2.1.0" - lodash "^4.17.11" - loud-rejection "^2.1.0" - make-dir "^3.0.0" - matcher "^2.0.0" - md5-hex "^3.0.0" - meow "^5.0.0" - micromatch "^4.0.2" - ms "^2.1.2" - observable-to-promise "^1.0.0" - ora "^3.4.0" - package-hash "^4.0.0" - pkg-conf "^3.1.0" - plur "^3.1.1" - pretty-ms "^5.0.0" - require-precompiled "^0.1.0" + is-plain-object "^5.0.0" + is-promise "^4.0.0" + matcher "^5.0.0" + mem "^9.0.2" + ms "^2.1.3" + p-event "^5.0.1" + p-map "^5.4.0" + picomatch "^2.3.1" + pkg-conf "^4.0.0" + plur "^5.1.0" + pretty-ms "^7.0.1" resolve-cwd "^3.0.0" slash "^3.0.0" - source-map-support "^0.5.12" - stack-utils "^1.0.2" - strip-ansi "^5.2.0" - strip-bom-buf "^2.0.0" - supertap "^1.0.0" - supports-color "^7.0.0" - trim-off-newlines "^1.0.1" - trim-right "^1.0.1" - unique-temp-dir "^1.0.0" - update-notifier "^3.0.1" - write-file-atomic "^3.0.0" + stack-utils "^2.0.5" + strip-ansi "^7.0.1" + supertap "^3.0.1" + temp-dir "^2.0.0" + write-file-atomic "^4.0.1" + yargs "^17.5.1" aws-sign2@~0.7.0: version "0.7.0" @@ -569,30 +226,10 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ== -babel-plugin-dynamic-import-node@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f" - integrity sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-espower@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-espower/-/babel-plugin-espower-3.0.1.tgz#180db17126f88e754105b8b5216d21e520a6bd4e" - integrity sha512-Ms49U7VIAtQ/TtcqRbD6UBmJBUCSxiC3+zPc+eGqxKUIFO1lTshyEDRUjhoAbd2rWfwYf3cZ62oXozrd8W6J0A== - dependencies: - "@babel/generator" "^7.0.0" - "@babel/parser" "^7.0.0" - call-matcher "^1.0.0" - core-js "^2.0.0" - espower-location-detector "^1.0.0" - espurify "^1.6.0" - estraverse "^4.1.1" - balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== bcrypt-pbkdf@^1.0.0: version "1.0.2" @@ -606,24 +243,10 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== -bluebird@^3.5.5: - version "3.5.5" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f" - integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w== - -boxen@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-3.2.0.tgz#fbdff0de93636ab4450886b6ff45b92d098f45eb" - integrity sha512-cU4J/+NodM3IHdSL2yN8bqYqnmlBTidDR4RC7nJs61ZmtGz8VZzM3HLQX0zY5mrSmPtR3xWwsq2jOUQqFZN8+A== - dependencies: - ansi-align "^3.0.0" - camelcase "^5.3.1" - chalk "^2.4.2" - cli-boxes "^2.2.0" - string-width "^3.0.0" - term-size "^1.2.0" - type-fest "^0.3.0" - widest-line "^2.0.0" +blueimp-md5@^2.10.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.19.0.tgz#b53feea5498dcb53dc6ec4b823adb84b729c4af0" + integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w== brace-expansion@^1.1.7: version "1.1.11" @@ -633,198 +256,128 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1, braces@^3.0.2: +braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" -buffer-from@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" - integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== - -cacheable-request@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" - integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^3.0.0" - lowercase-keys "^2.0.0" - normalize-url "^4.1.0" - responselike "^1.0.2" - -call-matcher@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/call-matcher/-/call-matcher-1.1.0.tgz#23b2c1bc7a8394c8be28609d77ddbd5786680432" - integrity sha512-IoQLeNwwf9KTNbtSA7aEBb1yfDbdnzwjCetjkC8io5oGeOmK2CBNdg0xr+tadRYKO0p7uQyZzvon0kXlZbvGrw== - dependencies: - core-js "^2.0.0" - deep-equal "^1.0.0" - espurify "^1.6.0" - estraverse "^4.0.0" - -call-signature@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/call-signature/-/call-signature-0.0.2.tgz#a84abc825a55ef4cb2b028bd74e205a65b9a4996" - integrity sha1-qEq8glpV70yysCi9dOIFpluaSZY= - -camelcase-keys@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" - integrity sha1-oqpfsa9oh1glnDLBQUJteJI7m3c= - dependencies: - camelcase "^4.1.0" - map-obj "^2.0.0" - quick-lru "^1.0.0" - -camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== -camelcase@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +callsites@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-4.0.0.tgz#8014cea4fedfe681a30e2f7d2d557dd95808a92a" + integrity sha512-y3jRROutgpKdz5vzEhWM34TidDU8vkJppF8dszITeb1PQmSqV3DTxyV8G/lyO/DNvtE1YTedehmw9MPZsCBHxQ== caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -chai@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" - integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw== +cbor@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" + integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== + dependencies: + nofilter "^3.1.0" + +chai@^4.3.6: + version "4.3.6" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c" + integrity sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q== dependencies: assertion-error "^1.1.0" check-error "^1.0.2" deep-eql "^3.0.1" get-func-name "^2.0.0" - pathval "^1.1.0" + loupe "^2.3.1" + pathval "^1.1.1" type-detect "^4.0.5" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" +chalk@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -chokidar@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.0.2.tgz#0d1cd6d04eb2df0327446188cd13736a3367d681" - integrity sha512-c4PR2egjNjI1um6bamCQ6bUNPDiyofNQruHvKgHQ4gDUP/ITSVSzNsiI5OWtHOsX323i5ha/kk4YmOZ1Ktg7KA== - dependencies: - anymatch "^3.0.1" - braces "^3.0.2" - glob-parent "^5.0.0" - is-binary-path "^2.1.0" - is-glob "^4.0.1" - normalize-path "^3.0.0" - readdirp "^3.1.1" +chokidar@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" optionalDependencies: - fsevents "^2.0.6" + fsevents "~2.3.2" -chunkd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/chunkd/-/chunkd-1.0.0.tgz#4ead4a3704bcce510c4bb4d4a8be30c557836dd1" - integrity sha512-xx3Pb5VF9QaqCotolyZ1ywFBgyuJmu6+9dLiqBxgelEse9Xsr3yUlpoX3O4Oh11M00GT2kYMsRByTKIMJW2Lkg== +chunkd@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/chunkd/-/chunkd-2.0.1.tgz#49cd1d7b06992dc4f7fccd962fe2a101ee7da920" + integrity sha512-7d58XsFmOq0j6el67Ug9mHf9ELUXsQXYJBkyxhH/k+6Ke0qXRnv0kbemx+Twc6fRJ07C49lcbdgm9FL1Ei/6SQ== -ci-info@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" - integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== +ci-info@^3.3.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128" + integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg== -ci-parallel-vars@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ci-parallel-vars/-/ci-parallel-vars-1.0.0.tgz#af97729ed1c7381911ca37bcea263d62638701b3" - integrity sha512-u6dx20FBXm+apMi+5x7UVm6EH7BL1gc4XrcnQewjcB7HWRcor/V5qWc3RG2HwpgDJ26gIi2DSEu3B7sXynAw/g== +ci-parallel-vars@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ci-parallel-vars/-/ci-parallel-vars-1.0.1.tgz#e87ff0625ccf9d286985b29b4ada8485ca9ffbc2" + integrity sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg== -clean-stack@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.1.0.tgz#9e7fec7f3f8340a2ab4f127c80273085e8fbbdd0" - integrity sha512-uQWrpRm+iZZUCAp7ZZJQbd4Za9I3AjR/3YTjmcnAtkauaIm/T5CT6U8zVI6e60T6OANqBFAzuR9/HB3NzuZCRA== +clean-stack@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== + +clean-stack@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-4.2.0.tgz#c464e4cde4ac789f4e0735c5d75beb49d7b30b31" + integrity sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg== + dependencies: + escape-string-regexp "5.0.0" clean-yaml-object@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz#63fb110dc2ce1a84dc21f6d9334876d010ae8b68" integrity sha1-Y/sRDcLOGoTcIfbZM0h20BCui2g= -cli-boxes@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d" - integrity sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w== - -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" - integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU= - dependencies: - restore-cursor "^2.0.0" - -cli-cursor@^3.1.0: +cli-truncate@^3.1.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - -cli-spinners@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.2.0.tgz#e8b988d9206c692302d8ee834e7a85c0144d8f77" - integrity sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ== - -cli-truncate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.0.0.tgz#68ff6aaa53b203b52ad89b8b1a80f1f61ad1e1d5" - integrity sha512-C4hp+8GCIFVsUUiXcw+ce+7wexVWImw8rQrgMBFsqerx9LvvcGlwm6sMjQYAEmV/Xb87xc1b5Ttx505MSpZVqg== + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-3.1.0.tgz#3f23ab12535e3d73e839bb43e73c9de487db1389" + integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== dependencies: - slice-ansi "^2.1.0" - string-width "^4.1.0" - -clone-response@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" - integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= - dependencies: - mimic-response "^1.0.0" + slice-ansi "^5.0.0" + string-width "^5.0.0" -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= - -code-excerpt@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/code-excerpt/-/code-excerpt-2.1.1.tgz#5fe3057bfbb71a5f300f659ef2cc0a47651ba77c" - integrity sha512-tJLhH3EpFm/1x7heIW0hemXJTUU5EWl2V0EIX558jp05Mt1U6DVryCgkp3l37cxqs+DNbNgxG43SkwJXpQ14Jw== +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== dependencies: - convert-to-spaces "^1.0.1" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== +code-excerpt@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/code-excerpt/-/code-excerpt-4.0.0.tgz#2de7d46e98514385cb01f7b3b741320115f4c95e" + integrity sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA== dependencies: - color-name "1.1.3" + convert-to-spaces "^2.0.1" color-convert@^2.0.0: version "2.0.0" @@ -833,16 +386,16 @@ color-convert@^2.0.0: dependencies: color-name "~1.1.4" -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +color-support@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" + integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== + combined-stream@^1.0.6, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -850,96 +403,45 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -common-path-prefix@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-1.0.0.tgz#cd52f6f0712e0baab97d6f9732874f22f47752c0" - integrity sha1-zVL28HEuC6q5fW+XModPIvR3UsA= +common-path-prefix@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0" + integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w== concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -concat-stream@1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== +concordance@^5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/concordance/-/concordance-5.0.4.tgz#9896073261adced72f88d60e4d56f8efc4bbbbd2" + integrity sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw== dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - -concordance@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/concordance/-/concordance-4.0.0.tgz#5932fdee397d129bdbc3a1885fbe69839b1b7e15" - integrity sha512-l0RFuB8RLfCS0Pt2Id39/oCPykE01pyxgAFypWTlaGRgvLkZrtczZ8atEHpTeEIW+zYWXTBuA9cCSeEOScxReQ== - dependencies: - date-time "^2.1.0" - esutils "^2.0.2" - fast-diff "^1.1.2" + date-time "^3.1.0" + esutils "^2.0.3" + fast-diff "^1.2.0" js-string-escape "^1.0.1" - lodash.clonedeep "^4.5.0" - lodash.flattendeep "^4.4.0" - lodash.islength "^4.0.1" - lodash.merge "^4.6.1" - md5-hex "^2.0.0" - semver "^5.5.1" + lodash "^4.17.15" + md5-hex "^3.0.1" + semver "^7.3.2" well-known-symbols "^2.0.0" -configstore@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-4.0.0.tgz#5933311e95d3687efb592c528b922d9262d227e7" - integrity sha512-CmquAXFBocrzaSM8mtGPMM/HiWmyIpr4CcJl/rgY2uCObZ/S7cKU0silxslqJejl+t/T9HS8E0PUNQD81JGUEQ== - dependencies: - dot-prop "^4.1.0" - graceful-fs "^4.1.2" - make-dir "^1.0.0" - unique-string "^1.0.0" - write-file-atomic "^2.0.0" - xdg-basedir "^3.0.0" - -console-control-strings@^1.0.0: +console-control-strings@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - -convert-source-map@^1.1.0, convert-source-map@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" - integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A== - dependencies: - safe-buffer "~5.1.1" - -convert-to-spaces@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/convert-to-spaces/-/convert-to-spaces-1.0.2.tgz#7e3e48bbe6d997b1417ddca2868204b4d3d85715" - integrity sha1-fj5Iu+bZl7FBfdyihoIEtNPYVxU= + integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ== -core-js@^2.0.0: - version "2.6.9" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2" - integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A== +convert-to-spaces@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz#61a6c98f8aa626c16b296b862a91412a33bceb6b" + integrity sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ== -core-util-is@1.0.2, core-util-is@~1.0.0: +core-util-is@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -crypto-random-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" - integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= - currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" @@ -954,46 +456,26 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -date-time@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/date-time/-/date-time-2.1.0.tgz#0286d1b4c769633b3ca13e1e62558d2dbdc2eba2" - integrity sha512-/9+C44X7lot0IeiyfgJmETtRMhBidBYM2QFFIkGa0U1k+hSyY87Nw7PY3eDqpvCBm7I3WCSfPeZskW/YYq6m4g== +date-time@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/date-time/-/date-time-3.1.0.tgz#0d1e934d170579f481ed8df1e2b8ff70ee845e1e" + integrity sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg== dependencies: time-zone "^1.0.0" -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@^4.1.0, debug@^4.1.1: +debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: ms "^2.1.1" -decamelize-keys@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" - integrity sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk= - dependencies: - decamelize "^1.1.0" - map-obj "^1.0.0" - -decamelize@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= - -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= +debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: - mimic-response "^1.0.0" + ms "2.1.2" deep-eql@^3.0.1: version "3.0.1" @@ -1002,47 +484,19 @@ deep-eql@^3.0.1: dependencies: type-detect "^4.0.0" -deep-equal@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" - integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU= - -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= - dependencies: - clone "^1.0.2" - -defer-to-connect@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.0.2.tgz#4bae758a314b034ae33902b5aac25a8dd6a8633e" - integrity sha512-k09hcQcTDY+cwgiwa6PYKLm3jlagNzQ+RSvhjzESOGOx+MNOuXkxTfEvPrO1IOQ81tArCFYQgi631clB70RpQw== - -define-properties@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -del@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/del/-/del-4.1.1.tgz#9e8f117222ea44a31ff3a156c049b99052a9f0b4" - integrity sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ== +del@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a" + integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg== dependencies: - "@types/glob" "^7.1.1" - globby "^6.1.0" - is-path-cwd "^2.0.0" - is-path-in-cwd "^2.0.0" - p-map "^2.0.0" - pify "^4.0.1" - rimraf "^2.6.3" + globby "^11.0.1" + graceful-fs "^4.2.4" + is-glob "^4.0.1" + is-path-cwd "^2.2.0" + is-path-inside "^3.0.2" + p-map "^4.0.0" + rimraf "^3.0.2" + slash "^3.0.0" delayed-stream@~1.0.0: version "1.0.0" @@ -1056,24 +510,10 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -dot-prop@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" - integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== - dependencies: - is-obj "^1.0.0" - -dot-prop@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.1.0.tgz#bdd8c986a77b83e3fca524e53786df916cabbd8a" - integrity sha512-n1oC6NBF+KM9oVXtjmen4Yo7HyAVWV2UUl50dCYJdw2924K6dX9bf9TTTWaKtYlRn0FEtxG27KS80ayVLixxJA== - dependencies: - is-obj "^2.0.0" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== ecc-jsbn@~0.1.1: version "0.1.2" @@ -1083,28 +523,20 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -emittery@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.4.1.tgz#abe9d3297389ba424ac87e53d1c701962ce7433d" - integrity sha512-r4eRSeStEGf6M5SKdrQhhLK5bOwOBxQhIE3YSTnZE3GpKiLfnnhE+tPtrJE79+eDJgm39BM6LSoI8SCx4HbwlQ== - -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== +emittery@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.11.0.tgz#eb5f756a200d3431de2c6e850cb2d8afd97a03b9" + integrity sha512-S/7tzL6v5i+4iJd627Nhv9cLFIo5weAIlGccqJFpnBoDB8U1TF2k5tez4J/QNuxyyhWuFqHg1L84Kd3m7iXg6g== emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -empower-core@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/empower-core/-/empower-core-1.2.0.tgz#ce3fb2484d5187fa29c23fba8344b0b2fdf5601c" - integrity sha512-g6+K6Geyc1o6FdXs9HwrXleCFan7d66G5xSCfSF7x1mJDCes6t0om9lFQG3zOrzh3Bkb/45N0cZ5Gqsf7YrzGQ== - dependencies: - call-signature "0.0.2" - core-js "^2.0.0" +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== end-of-stream@^1.1.0: version "1.4.1" @@ -1113,97 +545,46 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" -equal-length@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/equal-length/-/equal-length-1.0.1.tgz#21ca112d48ab24b4e1e7ffc0e5339d31fdfc274c" - integrity sha1-IcoRLUirJLTh5//A5TOdMf38J0w= - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -es6-error@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" - integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@5.0.0, escape-string-regexp@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8" + integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== escape-string-regexp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -esm@^3.2.25: - version "3.2.25" - resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" - integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== - -espower-location-detector@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/espower-location-detector/-/espower-location-detector-1.0.0.tgz#a17b7ecc59d30e179e2bef73fb4137704cb331b5" - integrity sha1-oXt+zFnTDheeK+9z+0E3cEyzMbU= - dependencies: - is-url "^1.2.1" - path-is-absolute "^1.0.0" - source-map "^0.5.0" - xtend "^4.0.0" - esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -espurify@^1.6.0: - version "1.8.1" - resolved "https://registry.yarnpkg.com/espurify/-/espurify-1.8.1.tgz#5746c6c1ab42d302de10bd1d5bf7f0e8c0515056" - integrity sha512-ZDko6eY/o+D/gHCWyHTU85mKDgYcS4FJj7S+YD6WIInm7GQ6AnOjmcL4+buFV/JOztVLELi/7MmuGU5NHta0Mg== - dependencies: - core-js "^2.0.0" - -estraverse@^4.0.0, estraverse@^4.1.1: - version "4.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" - integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM= - -esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= - -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" +esutils@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extract-zip@^1.6.7: - version "1.6.7" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" - integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= +extract-zip@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a" + integrity sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg== dependencies: - concat-stream "1.6.2" - debug "2.6.9" - mkdirp "0.5.1" - yauzl "2.4.1" + debug "^4.1.1" + get-stream "^5.1.0" + yauzl "^2.10.0" + optionalDependencies: + "@types/yauzl" "^2.9.1" extsprintf@1.3.0: version "1.3.0" @@ -1215,32 +596,31 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -fast-deep-equal@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" - integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= +fast-deep-equal@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-diff@^1.1.2: +fast-diff@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== -fast-glob@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.0.4.tgz#d484a41005cb6faeb399b951fd1bd70ddaebb602" - integrity sha512-wkIbV6qg37xTJwqSsdnIphL1e+LaGz4AIQqr00mIubMaEhv1/HEmJ0uuCGZRNRUkZZmOB5mJKO0ZUTVq+SxMQg== +fast-glob@^3.2.11, fast-glob@^3.2.9: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== dependencies: - "@nodelib/fs.stat" "^2.0.1" - "@nodelib/fs.walk" "^1.2.1" - glob-parent "^5.0.0" - is-glob "^4.0.1" - merge2 "^1.2.3" - micromatch "^4.0.2" + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== fastq@^1.6.0: version "1.6.0" @@ -1249,19 +629,20 @@ fastq@^1.6.0: dependencies: reusify "^1.0.0" -fd-slicer@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" - integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU= +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + integrity sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g== dependencies: pend "~1.2.0" -figures@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.0.0.tgz#756275c964646163cc6f9197c7a0295dbfd04de9" - integrity sha512-HKri+WoWoUgr83pehn/SIgLOMZ9nAWC6dcGj26RY2R4F50u4+RTUz0RCrUlOV3nKRAICW1UGzyb+kcX2qK1S/g== +figures@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/figures/-/figures-4.0.1.tgz#27b26609907bc888b3e3b0ef5403643f80aa2518" + integrity sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w== dependencies: - escape-string-regexp "^1.0.5" + escape-string-regexp "^5.0.0" + is-unicode-supported "^1.2.0" fill-range@^7.0.1: version "7.0.1" @@ -1270,27 +651,13 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -find-up@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= - dependencies: - locate-path "^2.0.0" - -find-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" - integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== - dependencies: - locate-path "^3.0.0" - -find-up@^4.0.0, find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== +find-up@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-6.3.0.tgz#2abab3d3280b2dc7ac10199ef324c4e002c8c790" + integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw== dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" + locate-path "^7.1.0" + path-exists "^5.0.0" forever-agent@~0.6.1: version "0.6.1" @@ -1309,56 +676,37 @@ form-data@~2.3.2: fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -fsevents@^2.0.6: - version "2.0.7" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.0.7.tgz#382c9b443c6cbac4c57187cdda23aa3bf1ccfc2a" - integrity sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -gauge@^2.7.4: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +gauge@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce" + integrity sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg== + dependencies: + aproba "^1.0.3 || ^2.0.0" + color-support "^1.1.3" + console-control-strings "^1.1.0" + has-unicode "^2.0.1" + signal-exit "^3.0.7" + string-width "^4.2.3" + strip-ansi "^6.0.1" + wide-align "^1.1.5" + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= -get-port@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.0.0.tgz#aa22b6b86fd926dd7884de3e23332c9f70c031a6" - integrity sha512-imzMU0FjsZqNa6BqOjbbW6w5BivHIuQKopjpPqcnx0AVHJQKCxK1O+Ab3OrVXhrekqfVMjwA9ZYu062R+KcIsQ== - dependencies: - type-fest "^0.3.0" - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - get-stream@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9" @@ -1373,139 +721,70 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -glob-parent@^5.0.0: +glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@^7.0.3, glob@^7.1.3: - version "7.1.4" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" - integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== +glob@^7.1.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.1.1" once "^1.3.0" path-is-absolute "^1.0.0" -global-dirs@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" - integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= +globby@^11.0.1: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: - ini "^1.3.4" - -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -globby@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22" - integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A== - dependencies: - "@types/glob" "^7.1.1" array-union "^2.1.0" dir-glob "^3.0.1" - fast-glob "^3.0.3" - glob "^7.1.3" - ignore "^5.1.1" - merge2 "^1.2.3" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" slash "^3.0.0" -globby@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" - integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw= - dependencies: - array-union "^1.0.1" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -got@^9.6.0: - version "9.6.0" - resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" - integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== - dependencies: - "@sindresorhus/is" "^0.14.0" - "@szmarczak/http-timer" "^1.1.2" - cacheable-request "^6.0.0" - decompress-response "^3.3.0" - duplexer3 "^0.1.4" - get-stream "^4.1.0" - lowercase-keys "^1.0.1" - mimic-response "^1.0.1" - p-cancelable "^1.0.0" - to-readable-stream "^1.0.0" - url-parse-lax "^3.0.0" - -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: - version "4.2.0" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b" - integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg== +globby@^13.1.1: + version "13.1.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-13.1.2.tgz#29047105582427ab6eca4f905200667b056da515" + integrity sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ== + dependencies: + dir-glob "^3.0.1" + fast-glob "^3.2.11" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^4.0.0" + +graceful-fs@^4.2.4: + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= -har-validator@~5.1.0: - version "5.1.3" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" - integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== +har-validator@~5.1.3: + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== dependencies: - ajv "^6.5.5" + ajv "^6.12.3" har-schema "^2.0.0" -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" - integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= - -has-unicode@^2.0.0: +has-unicode@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= - -has-yarn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" - integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== - -hasha@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/hasha/-/hasha-5.0.0.tgz#fdc3785caea03df29535fc8adb512c3d3a709004" - integrity sha512-PqWdhnQhq6tqD32hZv+l1e5mJHNSudjnaAzgAHfkGiU0ABN6lmbZF8abJIulQHbZ7oiHhP8yL6O910ICMc+5pw== - dependencies: - is-stream "^1.1.0" - type-fest "^0.3.0" - -hosted-git-info@^2.1.4: - version "2.8.9" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" - integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== - -http-cache-semantics@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz#495704773277eeef6e43f9ab2c2c7d259dda25c5" - integrity sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew== + integrity sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ== http-signature@~1.2.0: version "1.2.0" @@ -1516,86 +795,56 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -ignore-by-default@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" - integrity sha1-SMptcvbGo68Aqa1K5odr44ieKwk= - -ignore@^5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.2.tgz#e28e584d43ad7e92f96995019cc43b9e1ac49558" - integrity sha512-vdqWBp7MyzdmHkkRWV5nY+PfGRbYbahfuvsBCh277tq+w9zyNi7h5CYJCK0kmzti9kU+O/cB7sE8HvKv6aXAKQ== - -import-lazy@^2.1.0: +ignore-by-default@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" - integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= + resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-2.1.0.tgz#c0e0de1a99b6065bdc93315a6f728867981464db" + integrity sha512-yiWd4GVmJp0Q6ghmM2B/V3oZGRmjrKLXvHR3TE1nfoXsmoggllfZUQe74EN0fJdPFZu2NIvNdrMMLm3OsV7Ohw== -import-local@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.1.tgz#0b0f61a207b6c6b005c931dc72951ddde8303713" - integrity sha512-XlabwTJ9tPOdyjnGdGvxUMnUhmhlnJhdYjp5e8UDb2fO+5Gto1Frlg66ixVAf1Os+zQlrKt3QlTCVodyxYBZjQ== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" +ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= -indent-string@^3.0.0, indent-string@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" - integrity sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok= - indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== +indent-string@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-5.0.0.tgz#4fd2980fccaf8622d14c64d694f4cf33c81951a5" + integrity sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg== + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@~2.0.3: +inherits@2: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -ini@^1.3.4, ini@~1.3.0: - version "1.3.7" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84" - integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ== - -irregular-plurals@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-2.0.0.tgz#39d40f05b00f656d0b7fa471230dd3b714af2872" - integrity sha512-Y75zBYLkh0lJ9qxeHlMjQ7bSbyiSqNW/UOPWDmzC7cXskL1hekSITh1Oc6JV0XCWWZ9DE8VYSB71xocLk3gmGw== - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= +irregular-plurals@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.3.0.tgz#67d0715d4361a60d9fd9ee80af3881c631a31ee2" + integrity sha512-MVBLKUTangM3EfRPFROhmWQQKRDsrgI83J8GS3jXy+OwYqiR2/aoWndYQ5416jLE3uaGgLH7ncme3X9y09gZ3g== -is-binary-path@^2.1.0: +is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: binary-extensions "^2.0.0" -is-ci@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" - integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== - dependencies: - ci-info "^2.0.0" - is-error@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/is-error/-/is-error-2.2.2.tgz#c10ade187b3c93510c5470a5567833ee25649843" @@ -1606,23 +855,16 @@ is-extglob@^2.1.1: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - is-fullwidth-code-point@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== +is-fullwidth-code-point@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== + is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" @@ -1630,121 +872,47 @@ is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" -is-installed-globally@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" - integrity sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA= +is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: - global-dirs "^0.1.0" - is-path-inside "^1.0.0" - -is-npm@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-3.0.0.tgz#ec9147bfb629c43f494cf67936a961edec7e8053" - integrity sha512-wsigDr1Kkschp2opC4G3yA6r9EgVA6NjRpWzIi9axXqeIaAATPRJc4uLujXe3Nd9uO8KoDyA4MD6aZSeXTADhA== + is-extglob "^2.1.1" is-number@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" - integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= - -is-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" - integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== - -is-observable@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-observable/-/is-observable-2.0.0.tgz#327af1e8cdea9cd717f95911b87c5d34301721a6" - integrity sha512-fhBZv3eFKUbyHXZ1oHujdo2tZ+CNbdpdzzlENgCGZUC8keoGxUew2jYFLYcUB4qo7LDD03o4KK11m/QYD7kEjg== - -is-path-cwd@^2.0.0: +is-path-cwd@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== -is-path-in-cwd@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz#bfe2dca26c69f397265a4009963602935a053acb" - integrity sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ== - dependencies: - is-path-inside "^2.1.0" - -is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" - integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= - dependencies: - path-is-inside "^1.0.1" - -is-path-inside@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-2.1.0.tgz#7c9810587d659a40d27bcdb4d5616eab059494b2" - integrity sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg== - dependencies: - path-is-inside "^1.0.2" - -is-plain-obj@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" - integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= - -is-plain-object@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.0.tgz#47bfc5da1b5d50d64110806c199359482e75a928" - integrity sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg== - dependencies: - isobject "^4.0.0" +is-path-inside@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= +is-promise@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-4.0.0.tgz#42ff9f84206c1991d26debf520dd5c01042dd2f3" + integrity sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ== -is-typedarray@^1.0.0, is-typedarray@~1.0.0: +is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-url@^1.2.1: - version "1.2.4" - resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" - integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== - -is-utf8@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= - -is-yarn-global@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232" - integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw== - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" - integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== +is-unicode-supported@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz#f4f54f34d8ebc84a46b93559a036763b6d3e1014" + integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ== isstream@~0.1.2: version "0.1.2" @@ -1756,15 +924,10 @@ js-string-escape@^1.0.1: resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" integrity sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8= -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.10.0: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@^3.14.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== dependencies: argparse "^1.0.7" esprima "^4.0.0" @@ -1774,26 +937,6 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= -jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - -json-buffer@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" - integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= - -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -1809,13 +952,6 @@ json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= -json5@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850" - integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ== - dependencies: - minimist "^1.2.0" - jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -1826,207 +962,83 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -keyv@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" - integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== - dependencies: - json-buffer "3.0.0" - -latest-version@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" - integrity sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA== - dependencies: - package-json "^6.3.0" - -load-json-file@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" - integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= - dependencies: - graceful-fs "^4.1.2" - parse-json "^4.0.0" - pify "^3.0.0" - strip-bom "^3.0.0" - -load-json-file@^5.2.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-5.3.0.tgz#4d3c1e01fa1c03ea78a60ac7af932c9ce53403f3" - integrity sha512-cJGP40Jc/VXUsp8/OrnyKyTZ1y6v/dphm3bioS+RrKXjK2BB6wHUd6JptZEFDGgGahMT+InnZO5i1Ei9mpC8Bw== - dependencies: - graceful-fs "^4.1.15" - parse-json "^4.0.0" - pify "^4.0.1" - strip-bom "^3.0.0" - type-fest "^0.3.0" - -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - -locate-path@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" - integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== - dependencies: - p-locate "^3.0.0" - path-exists "^3.0.0" +load-json-file@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-7.0.1.tgz#a3c9fde6beffb6bedb5acf104fad6bb1604e1b00" + integrity sha512-Gnxj3ev3mB5TkVBGad0JM6dmLiQL+o0t23JPBZ9sd+yvSLk05mFoqKBw5N8gbbkU4TNXyqCgIrl/VM17OgUIgQ== -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== +locate-path@^7.1.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-7.1.1.tgz#8e1e5a75c7343770cef02ff93c4bf1f0aa666374" + integrity sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg== dependencies: - p-locate "^4.1.0" - -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= - -lodash.flattendeep@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" - integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= - -lodash.islength@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.islength/-/lodash.islength-4.0.1.tgz#4e9868d452575d750affd358c979543dc20ed577" - integrity sha1-Tpho1FJXXXUK/9NYyXlUPcIO1Xc= + p-locate "^6.0.0" -lodash.merge@4.6.2, lodash.merge@^4.6.1: +lodash.merge@4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.11: +lodash@^4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log-symbols@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" - integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== +loupe@^2.3.1: + version "2.3.4" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.4.tgz#7e0b9bffc76f148f9be769cb1321d3dcf3cb25f3" + integrity sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ== dependencies: - chalk "^2.0.1" - -loud-rejection@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" - integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= - dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.0" + get-func-name "^2.0.0" -loud-rejection@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-2.1.0.tgz#4020547ddbc39ed711c8434326df9fc7d2395355" - integrity sha512-g/6MQxUXYHeVqZ4PGpPL1fS1fOvlXoi7bay0pizmjAd/3JhyXwxzwrnr74yzdmhuerlslbRJ3x7IOXzFz0cE5w== +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.2" - -lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== + yallist "^4.0.0" -lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - -lru-cache@^4.0.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== +map-age-cleaner@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" + p-defer "^1.0.0" -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== +matcher@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/matcher/-/matcher-5.0.0.tgz#cd82f1c7ae7ee472a9eeaf8ec7cac45e0fe0da62" + integrity sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw== dependencies: - pify "^3.0.0" + escape-string-regexp "^5.0.0" -make-dir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.0.tgz#1b5f39f6b9270ed33f9f054c5c0f84304989f801" - integrity sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw== +md5-hex@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-3.0.1.tgz#be3741b510591434b2784d79e556eefc2c9a8e5c" + integrity sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw== dependencies: - semver "^6.0.0" - -map-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" - integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= - -map-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" - integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk= + blueimp-md5 "^2.10.0" -matcher@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/matcher/-/matcher-2.0.0.tgz#85fe38d97670dbd2a46590cf099401e2ffb4755c" - integrity sha512-nlmfSlgHBFx36j/Pl/KQPbIaqE8Zf0TqmSMjsuddHDg6PMSVgmyW9HpkLs0o0M1n2GIZ/S2BZBLIww/xjhiGng== +mem@^9.0.2: + version "9.0.2" + resolved "https://registry.yarnpkg.com/mem/-/mem-9.0.2.tgz#bbc2d40be045afe30749681e8f5d554cee0c0354" + integrity sha512-F2t4YIv9XQUBHt6AOJ0y7lSmP1+cY7Fm1DRh9GClTGzKST7UWLMx6ly9WZdLH/G/ppM5RL4MlQfRT71ri9t19A== dependencies: - escape-string-regexp "^2.0.0" + map-age-cleaner "^0.1.3" + mimic-fn "^4.0.0" -md5-hex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-2.0.0.tgz#d0588e9f1c74954492ecd24ac0ac6ce997d92e33" - integrity sha1-0FiOnxx0lUSS7NJKwKxs6ZfZLjM= - dependencies: - md5-o-matic "^0.1.1" +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -md5-hex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-3.0.0.tgz#96cf5c62cedea41e04124b9473ef7481db6de5fb" - integrity sha512-uA+EX5IV1r5lKBJecwTSec3k6xl4ziBUZihRiOpOHCeHjKA0ai6+eImamXQy/cI3Qep5mQgFTeJld9tcwdBNFw== +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - md5-o-matic "^0.1.1" - -md5-o-matic@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3" - integrity sha1-givM1l4RfFFPqxdrJZRdVBAKA8M= - -meow@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" - integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== - dependencies: - camelcase-keys "^4.0.0" - decamelize-keys "^1.0.0" - loud-rejection "^1.0.0" - minimist-options "^3.0.1" - normalize-package-data "^2.3.4" - read-pkg-up "^3.0.0" - redent "^2.0.0" - trim-newlines "^2.0.0" - yargs-parser "^10.0.0" - -merge2@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.3.tgz#7ee99dbd69bb6481689253f018488a1b902b0ed5" - integrity sha512-gdUU1Fwj5ep4kplwcmftruWofEFt6lfpkkr3h860CXbAB9c3hGb55EOL2ali0Td5oebvW0E1+3Sr+Ur7XfKpRA== - -micromatch@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" - integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== - dependencies: - braces "^3.0.1" - picomatch "^2.0.5" + braces "^3.0.2" + picomatch "^2.3.1" mime-db@1.40.0: version "1.40.0" @@ -2040,128 +1052,43 @@ mime-types@^2.1.12, mime-types@~2.1.19: dependencies: mime-db "1.40.0" -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -mimic-response@^1.0.0, mimic-response@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== +mimic-fn@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== +minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: brace-expansion "^1.1.7" -minimist-options@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" - integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== - dependencies: - arrify "^1.0.1" - is-plain-obj "^1.1.0" - -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= - -minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= - -mkdirp@0.5.1, mkdirp@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= - dependencies: - minimist "0.0.8" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - -ms@^2.1.1, ms@^2.1.2: +ms@2.1.2, ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: - version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nofilter@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-3.1.0.tgz#c757ba68801d41ff930ba2ec55bab52ca184aa66" + integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== -normalize-path@^3.0.0: +normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -normalize-url@^4.1.0: - version "4.5.1" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a" - integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA== - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= - oauth-sign@~0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-keys@^1.0.11, object-keys@^1.0.12: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - -observable-to-promise@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/observable-to-promise/-/observable-to-promise-1.0.0.tgz#37e136f16a15385ac063411ada0e1202bfff58f4" - integrity sha512-cqnGUrNsE6vdVDTPAX9/WeVzwy/z37vdxupdQXU8vgTXRFH72KCZiZga8aca2ulRPIeem8W3vW9rQHBwfIl2WA== - dependencies: - is-observable "^2.0.0" - symbol-observable "^1.0.4" - once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -2169,176 +1096,75 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ= - dependencies: - mimic-fn "^1.0.0" - -onetime@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" - integrity sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q== - dependencies: - mimic-fn "^2.1.0" - -ora@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/ora/-/ora-3.4.0.tgz#bf0752491059a3ef3ed4c85097531de9fdbcd318" - integrity sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg== - dependencies: - chalk "^2.4.2" - cli-cursor "^2.1.0" - cli-spinners "^2.0.0" - log-symbols "^2.2.0" - strip-ansi "^5.2.0" - wcwidth "^1.0.1" - -os-tmpdir@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -p-cancelable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" - integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== - -p-finally@^1.0.0: +p-defer@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-limit@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" - integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== - dependencies: - p-try "^1.0.0" + resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw== -p-limit@^2.0.0, p-limit@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" - integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== +p-event@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/p-event/-/p-event-5.0.1.tgz#614624ec02ae7f4f13d09a721c90586184af5b0c" + integrity sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ== dependencies: - p-try "^2.0.0" + p-timeout "^5.0.2" -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= +p-limit@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644" + integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ== dependencies: - p-limit "^1.1.0" + yocto-queue "^1.0.0" -p-locate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" - integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== +p-locate@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-6.0.0.tgz#3da9a49d4934b901089dca3302fa65dc5a05c04f" + integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw== dependencies: - p-limit "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-map@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175" - integrity sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw== - -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + p-limit "^4.0.0" -package-hash@^4.0.0: +p-map@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-4.0.0.tgz#3537f654665ec3cc38827387fc904c163c54f506" - integrity sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ== + resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== dependencies: - graceful-fs "^4.1.15" - hasha "^5.0.0" - lodash.flattendeep "^4.4.0" - release-zalgo "^1.0.0" + aggregate-error "^3.0.0" -package-json@^6.3.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-6.4.0.tgz#4f626976604f4a9a41723ce1792b204a60b1b61e" - integrity sha512-bd1T8OBG7hcvMd9c/udgv6u5v9wISP3Oyl9Cm7Weop8EFwrtcQDnS2sb6zhwqus2WslSr5wSTIPiTTpxxmPm7Q== +p-map@^5.4.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-5.5.0.tgz#054ca8ca778dfa4cf3f8db6638ccb5b937266715" + integrity sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg== dependencies: - got "^9.6.0" - registry-auth-token "^3.4.0" - registry-url "^5.0.0" - semver "^6.1.1" + aggregate-error "^4.0.0" -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" +p-timeout@^5.0.2: + version "5.1.0" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-5.1.0.tgz#b3c691cf4415138ce2d9cfe071dba11f0fee085b" + integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew== parse-ms@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-2.1.0.tgz#348565a753d4391fa524029956b172cb7753097d" integrity sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA== -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== +path-exists@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7" + integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ== path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-is-inside@^1.0.1, path-is-inside@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= - -path-key@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" - integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== - dependencies: - pify "^3.0.0" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -pathval@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" - integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA= +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== pend@~1.2.0: version "1.2.0" @@ -2350,86 +1176,42 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picomatch@^2.0.4, picomatch@^2.0.5: +picomatch@^2.0.4: version "2.0.7" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.0.7.tgz#514169d8c7cd0bdbeecc8a2609e34a7163de69f6" integrity sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA== -pify@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - -pify@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" - integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= +picomatch@^2.2.1, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -pkg-conf@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-3.1.0.tgz#d9f9c75ea1bae0e77938cde045b276dac7cc69ae" - integrity sha512-m0OTbR/5VPNPqO1ph6Fqbj7Hv6QU7gR/tQW40ZqrL1rjgCU85W6C1bJn0BItuJqnR98PWzw7Z8hHeChD1WrgdQ== - dependencies: - find-up "^3.0.0" - load-json-file "^5.2.0" - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== +pkg-conf@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-4.0.0.tgz#63ace00cbacfa94c2226aee133800802d3e3b80c" + integrity sha512-7dmgi4UY4qk+4mj5Cd8v/GExPo0K+SlY+hulOSdfZ/T6jVH6//y7NtzZo5WrfhDBxuQ0jCa7fLZmNaNh7EWL/w== dependencies: - find-up "^4.0.0" + find-up "^6.0.0" + load-json-file "^7.0.0" -plur@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/plur/-/plur-3.1.1.tgz#60267967866a8d811504fe58f2faaba237546a5b" - integrity sha512-t1Ax8KUvV3FFII8ltczPn2tJdjqbd1sIzu6t4JL7nQ3EyeL/lTrj5PWKb06ic5/6XYDr65rQ4uzQEGN70/6X5w== +plur@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/plur/-/plur-5.1.0.tgz#bff58c9f557b9061d60d8ebf93959cf4b08594ae" + integrity sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg== dependencies: - irregular-plurals "^2.0.0" + irregular-plurals "^3.3.0" -prepend-http@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" - integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= - -pretty-ms@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-5.0.0.tgz#6133a8f55804b208e4728f6aa7bf01085e951e24" - integrity sha512-94VRYjL9k33RzfKiGokPBPpsmloBYSf5Ri+Pq19zlsEcUKFob+admeXr5eFDRuPjFmEOcjJvPGdillYOJyvZ7Q== +pretty-ms@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-7.0.1.tgz#7d903eaab281f7d8e03c66f867e239dc32fb73e8" + integrity sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q== dependencies: parse-ms "^2.1.0" -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= - -psl@^1.1.24: - version "1.2.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.2.0.tgz#df12b5b1b3a30f51c329eacbdef98f3a6e136dc6" - integrity sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA== +psl@^1.1.28: + version "1.9.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" + integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== pump@^3.0.0: version "3.0.0" @@ -2439,138 +1221,22 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" -punycode@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= - -punycode@^2.1.0: +punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - -quick-lru@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" - integrity sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g= - -rc@^1.1.6, rc@^1.2.8: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - -read-pkg-up@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" - integrity sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= - dependencies: - find-up "^2.0.0" - read-pkg "^3.0.0" - -read-pkg@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" - integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= - dependencies: - load-json-file "^4.0.0" - normalize-package-data "^2.3.2" - path-type "^3.0.0" - -readable-stream@^2.2.2: - version "2.3.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" - integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readdirp@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.1.1.tgz#b158123ac343c8b0f31d65680269cc0fc1025db1" - integrity sha512-XXdSXZrQuvqoETj50+JAitxz1UPdt5dupjT6T5nVB+WvjMv2XKYj+s7hPeAVCXvmJrL36O4YYyWlIC3an2ePiQ== - dependencies: - picomatch "^2.0.4" - -redent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" - integrity sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo= - dependencies: - indent-string "^3.0.0" - strip-indent "^2.0.0" - -regenerate-unicode-properties@^8.0.2: - version "8.1.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" - integrity sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA== - dependencies: - regenerate "^1.4.0" - -regenerate@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" - integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg== - -regexpu-core@^4.5.4: - version "4.5.4" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.5.4.tgz#080d9d02289aa87fe1667a4f5136bc98a6aebaae" - integrity sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ== - dependencies: - regenerate "^1.4.0" - regenerate-unicode-properties "^8.0.2" - regjsgen "^0.5.0" - regjsparser "^0.6.0" - unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.1.0" - -registry-auth-token@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e" - integrity sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A== - dependencies: - rc "^1.1.6" - safe-buffer "^5.0.1" - -registry-url@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-5.1.0.tgz#e98334b50d5434b81136b44ec638d9c2009c5009" - integrity sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw== - dependencies: - rc "^1.2.8" + version "6.5.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" + integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -regjsgen@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.0.tgz#a7634dc08f89209c2049adda3525711fb97265dd" - integrity sha512-RnIrLhrXCX5ow/E5/Mh2O4e/oa1/jW0eaBKTSy3LaCj+M3Bqvm97GWDp2yUtzIs4LEn65zR2yiYGFqb2ApnzDA== - -regjsparser@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.0.tgz#f1e6ae8b7da2bae96c99399b868cd6c933a2ba9c" - integrity sha512-RQ7YyokLiQBomUJuUG8iGVvkgOLxwyZM8k6d3q5SAXpg4r5TZJZigKFvC6PpD+qQ98bCDC5YelPeA3EucDoNeQ== - dependencies: - jsesc "~0.5.0" - -release-zalgo@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730" - integrity sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== dependencies: - es6-error "^4.0.1" + picomatch "^2.2.1" request-progress@^3.0.0: version "3.0.0" @@ -2579,10 +1245,10 @@ request-progress@^3.0.0: dependencies: throttleit "^1.0.0" -request@^2.88.0: - version "2.88.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" - integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== +request@^2.88.2: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== dependencies: aws-sign2 "~0.7.0" aws4 "^1.8.0" @@ -2591,7 +1257,7 @@ request@^2.88.0: extend "~3.0.2" forever-agent "~0.6.1" form-data "~2.3.2" - har-validator "~5.1.0" + har-validator "~5.1.3" http-signature "~1.2.0" is-typedarray "~1.0.0" isstream "~0.1.2" @@ -2601,14 +1267,14 @@ request@^2.88.0: performance-now "^2.1.0" qs "~6.5.2" safe-buffer "^5.1.2" - tough-cookie "~2.4.3" + tough-cookie "~2.5.0" tunnel-agent "^0.6.0" uuid "^3.3.2" -require-precompiled@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/require-precompiled/-/require-precompiled-0.1.0.tgz#5a1b52eb70ebed43eb982e974c85ab59571e56fa" - integrity sha1-WhtS63Dr7UPrmC6XTIWrWVceVvo= +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== resolve-cwd@^3.0.0: version "3.0.0" @@ -2622,45 +1288,15 @@ resolve-from@^5.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== -resolve@^1.10.0, resolve@^1.3.2: - version "1.11.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" - integrity sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw== - dependencies: - path-parse "^1.0.6" - -responselike@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" - integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= - dependencies: - lowercase-keys "^1.0.0" - -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" - integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368= - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" - -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - reusify@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@^2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: glob "^7.1.3" @@ -2669,7 +1305,7 @@ run-parallel@^1.1.9: resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== -safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== @@ -2679,107 +1315,42 @@ safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -semver-diff@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" - integrity sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY= +semver@^7.3.2, semver@^7.3.7: + version "7.3.7" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: - semver "^5.0.3" - -"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.4.1, semver@^5.5.1: - version "5.7.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" - integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== - -semver@^6.0.0, semver@^6.1.1: - version "6.2.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db" - integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A== - -semver@^6.2.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -serialize-error@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-2.1.0.tgz#50b679d5635cdf84667bdc8e59af4e5b81d5f60a" - integrity sha1-ULZ51WNc34Rme9yOWa9OW4HV9go= + lru-cache "^6.0.0" -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= +serialize-error@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-7.0.1.tgz#f1360b0447f61ffb483ec4157c737fab7d778e18" + integrity sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw== dependencies: - shebang-regex "^1.0.0" + type-fest "^0.13.1" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== - dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" - -source-map-support@^0.5.12: - version "0.5.12" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" - integrity sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -spdx-correct@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" - integrity sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz#2ea450aee74f2a89bfb94519c07fcd6f41322977" - integrity sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA== +slash@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" + integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== -spdx-expression-parse@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" - integrity sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg== +slice-ansi@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.4" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz#75ecd1a88de8c184ef015eafb51b5b48bfd11bb1" - integrity sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA== + ansi-styles "^6.0.0" + is-fullwidth-code-point "^4.0.0" sprintf-js@~1.0.2: version "1.0.3" @@ -2801,36 +1372,21 @@ sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" -stack-utils@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.2.tgz#33eba3897788558bebfc2db059dc158ec36cebb8" - integrity sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA== - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -"string-width@^1.0.2 || 2", string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== +stack-utils@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" + integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" + escape-string-regexp "^2.0.0" -string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" string-width@^4.1.0: version "4.1.0" @@ -2841,97 +1397,50 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^5.2.0" -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= +string-width@^5.0.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== dependencies: - ansi-regex "^3.0.0" + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" -strip-ansi@^5.1.0, strip-ansi@^5.2.0: +strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== dependencies: ansi-regex "^4.1.0" -strip-bom-buf@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom-buf/-/strip-bom-buf-2.0.0.tgz#ff9c223937f8e7154b77e9de9bde094186885c15" - integrity sha512-gLFNHucd6gzb8jMsl5QmZ3QgnUJmp7qn4uUSHNwEXumAp7YizoGYw19ZUVfuq4aBOQUtyn2k8X/CwzWB73W2lQ== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - is-utf8 "^0.2.1" + ansi-regex "^5.0.1" -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= - -strip-indent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" - integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g= - -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - -supertap@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supertap/-/supertap-1.0.0.tgz#bd9751c7fafd68c68cf8222a29892206a119fa9e" - integrity sha512-HZJ3geIMPgVwKk2VsmO5YHqnnJYl6bV5A9JW2uzqV43WmpgliNEYbuvukfor7URpaqpxuw3CfZ3ONdVbZjCgIA== - dependencies: - arrify "^1.0.1" - indent-string "^3.2.0" - js-yaml "^3.10.0" - serialize-error "^2.1.0" - strip-ansi "^4.0.0" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== +strip-ansi@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== dependencies: - has-flag "^3.0.0" + ansi-regex "^6.0.1" -supports-color@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.0.0.tgz#f2392c50ab35bb3cae7beebf24d254a19f880c06" - integrity sha512-WRt32iTpYEZWYOpcetGm0NPeSvaebccx7hhS/5M6sAiqnhedtFCHFxkjzZlJvFNCPowiKSFGiZk5USQDFy83vQ== +supertap@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/supertap/-/supertap-3.0.1.tgz#aa89e4522104402c6e8fe470a7d2db6dc4037c6a" + integrity sha512-u1ZpIBCawJnO+0QePsEiOknOfCRq0yERxiAchT0i4li0WHNUJbf0evXXSXOcCAR4M8iMDoajXYmstm/qO81Isw== dependencies: - has-flag "^4.0.0" + indent-string "^5.0.0" + js-yaml "^3.14.1" + serialize-error "^7.0.1" + strip-ansi "^7.0.1" -symbol-observable@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" - integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== - -term-size@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" - integrity sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk= - dependencies: - execa "^0.7.0" +temp-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-2.0.0.tgz#bde92b05bdfeb1516e804c9c00ad45177f31321e" + integrity sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg== throttleit@^1.0.0: version "1.0.0" @@ -2943,16 +1452,6 @@ time-zone@^1.0.0: resolved "https://registry.yarnpkg.com/time-zone/-/time-zone-1.0.0.tgz#99c5bf55958966af6d06d83bdf3800dc82faec5d" integrity sha1-mcW/VZWJZq9tBtg73zgA3IL67F0= -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - -to-readable-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" - integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -2960,28 +1459,13 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -tough-cookie@~2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" - integrity sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ== +tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== dependencies: - psl "^1.1.24" - punycode "^1.4.1" - -trim-newlines@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" - integrity sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA= - -trim-off-newlines@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" - integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + psl "^1.1.28" + punycode "^2.1.1" tunnel-agent@^0.6.0: version "0.6.0" @@ -3000,122 +1484,23 @@ type-detect@^4.0.0, type-detect@^4.0.5: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -type-fest@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1" - integrity sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ== - -type-fest@^0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2" - integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw== - -typedarray-to-buffer@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" - integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== - dependencies: - is-typedarray "^1.0.0" - -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - -uid2@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/uid2/-/uid2-0.0.3.tgz#483126e11774df2f71b8b639dcd799c376162b82" - integrity sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I= - -unicode-canonical-property-names-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" - integrity sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ== - -unicode-match-property-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" - integrity sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg== - dependencies: - unicode-canonical-property-names-ecmascript "^1.0.4" - unicode-property-aliases-ecmascript "^1.0.4" - -unicode-match-property-value-ecmascript@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz#5b4b426e08d13a80365e0d657ac7a6c1ec46a277" - integrity sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g== - -unicode-property-aliases-ecmascript@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz#a9cc6cc7ce63a0a3023fc99e341b94431d405a57" - integrity sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw== - -unique-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" - integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - dependencies: - crypto-random-string "^1.0.0" - -unique-temp-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-temp-dir/-/unique-temp-dir-1.0.0.tgz#6dce95b2681ca003eebfb304a415f9cbabcc5385" - integrity sha1-bc6VsmgcoAPuv7MEpBX5y6vMU4U= - dependencies: - mkdirp "^0.5.1" - os-tmpdir "^1.0.1" - uid2 "0.0.3" - -update-notifier@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-3.0.1.tgz#78ecb68b915e2fd1be9f767f6e298ce87b736250" - integrity sha512-grrmrB6Zb8DUiyDIaeRTBCkgISYUgETNe7NglEbVsrLWXeESnlCSP50WfRSj/GmzMPl6Uchj24S/p80nP/ZQrQ== - dependencies: - boxen "^3.0.0" - chalk "^2.0.1" - configstore "^4.0.0" - has-yarn "^2.1.0" - import-lazy "^2.1.0" - is-ci "^2.0.0" - is-installed-globally "^0.1.0" - is-npm "^3.0.0" - is-yarn-global "^0.3.0" - latest-version "^5.0.0" - semver-diff "^2.0.0" - xdg-basedir "^3.0.0" +type-fest@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" + integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== uri-js@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== dependencies: punycode "^2.1.0" -url-parse-lax@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" - integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= - dependencies: - prepend-http "^2.0.0" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" @@ -3125,88 +1510,77 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= - dependencies: - defaults "^1.0.3" - well-known-symbols@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/well-known-symbols/-/well-known-symbols-2.0.0.tgz#e9c7c07dbd132b7b84212c8174391ec1f9871ba5" integrity sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q== -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -wide-align@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== +wide-align@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3" + integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg== dependencies: - string-width "^1.0.2 || 2" + string-width "^1.0.2 || 2 || 3 || 4" -widest-line@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.1.tgz#7438764730ec7ef4381ce4df82fb98a53142a3fc" - integrity sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA== +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== dependencies: - string-width "^2.1.1" + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -write-file-atomic@^2.0.0: - version "2.4.3" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481" - integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ== - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - -write-file-atomic@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.0.tgz#1b64dbbf77cb58fd09056963d63e62667ab4fb21" - integrity sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q== +write-file-atomic@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.1.tgz#9faa33a964c1c85ff6f849b80b42a88c2c537c8f" + integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ== dependencies: imurmurhash "^0.1.4" - is-typedarray "^1.0.0" - signal-exit "^3.0.2" - typedarray-to-buffer "^3.1.5" + signal-exit "^3.0.7" -xdg-basedir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" - integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= - -xtend@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= - -yargs-parser@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" - integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== - dependencies: - camelcase "^4.1.0" - -yauzl@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" - integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU= - dependencies: - fd-slicer "~1.0.1" +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@^21.0.0: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + +yargs@^17.5.1: + version "17.5.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e" + integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.0.0" + +yauzl@^2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + integrity sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g== + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" + +yocto-queue@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251" + integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== diff --git a/src/bindings/ejdb2_react_native/README.md b/src/bindings/ejdb2_react_native/README.md index ae75f6cb7..89566c6bd 100644 --- a/src/bindings/ejdb2_react_native/README.md +++ b/src/bindings/ejdb2_react_native/README.md @@ -1,3 +1,5 @@ +# WARNING: Unsupported now. Maintainer needed. + # EJDB2 React Native binding Embeddable JSON Database engine http://ejdb.org Node.js binding. @@ -73,4 +75,4 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTS=ON ctest -``` +``` \ No newline at end of file diff --git a/src/bindings/ejdb2_react_native/binding/index.d.ts b/src/bindings/ejdb2_react_native/binding/index.d.ts index e470a7989..c18db3769 100644 --- a/src/bindings/ejdb2_react_native/binding/index.d.ts +++ b/src/bindings/ejdb2_react_native/binding/index.d.ts @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/bindings/ejdb2_react_native/binding/version.txt b/src/bindings/ejdb2_react_native/binding/version.txt index d8263ee98..62f945751 100644 --- a/src/bindings/ejdb2_react_native/binding/version.txt +++ b/src/bindings/ejdb2_react_native/binding/version.txt @@ -1 +1 @@ -2 \ No newline at end of file +6 \ No newline at end of file diff --git a/src/bindings/ejdb2_react_native/tests/App.js b/src/bindings/ejdb2_react_native/tests/App.js index d18a10a02..c281dd99a 100644 --- a/src/bindings/ejdb2_react_native/tests/App.js +++ b/src/bindings/ejdb2_react_native/tests/App.js @@ -40,8 +40,8 @@ export default class App extends Component { t.is(id, 1); await t.throwsAsync(db.put('mycoll', '{"'), { - code: '86005', - message: 'com.softmotions.ejdb2.EJDB2Exception: @ejdb IWRC:86005 errno:0 Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)' + code: '76005', + message: 'com.softmotions.ejdb2.EJDB2Exception: @ejdb IWRC:76005 errno:0 Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)' }); let doc = await db.get('mycoll', 1); diff --git a/src/bindings/ejdb2_swift/EJDB2Swift b/src/bindings/ejdb2_swift/EJDB2Swift index bf9ea394a..aa5d3f9fa 160000 --- a/src/bindings/ejdb2_swift/EJDB2Swift +++ b/src/bindings/ejdb2_swift/EJDB2Swift @@ -1 +1 @@ -Subproject commit bf9ea394a4a42c7442ef93c17036429413f80ae7 +Subproject commit aa5d3f9fa6d5b1926a56641735548ffcfc003e6c diff --git a/src/ejdb2.c b/src/ejdb2.c index f034d6540..4972697b7 100644 --- a/src/ejdb2.c +++ b/src/ejdb2.c @@ -1,39 +1,42 @@ #include "ejdb2_internal.h" +#include -// --------------------------------------------------------------------------- +#ifdef IW_BLOCKS +#include +#endif -static iwrc _jb_put_new_lw(JBCOLL jbc, JBL jbl, int64_t *id); +static iwrc _jb_put_new_lw(struct jbcoll *jbc, struct jbl *jbl, int64_t *id); -static const IWKV_val EMPTY_VAL = { 0 }; +static const struct iwkv_val EMPTY_VAL = { 0 }; -IW_INLINE iwrc _jb_meta_nrecs_removedb(EJDB db, uint32_t dbid) { +IW_INLINE iwrc _jb_meta_nrecs_removedb(struct ejdb *db, uint32_t dbid) { dbid = IW_HTOIL(dbid); - IWKV_val key = { + struct iwkv_val key = { .size = sizeof(dbid), .data = &dbid }; return iwkv_del(db->nrecdb, &key, 0); } -IW_INLINE iwrc _jb_meta_nrecs_update(EJDB db, uint32_t dbid, int64_t delta) { +IW_INLINE iwrc _jb_meta_nrecs_update(struct ejdb *db, uint32_t dbid, int64_t delta) { delta = IW_HTOILL(delta); dbid = IW_HTOIL(dbid); - IWKV_val val = { + struct iwkv_val val = { .size = sizeof(delta), .data = &delta }; - IWKV_val key = { + struct iwkv_val key = { .size = sizeof(dbid), .data = &dbid }; return iwkv_put(db->nrecdb, &key, &val, IWKV_VAL_INCREMENT); } -static int64_t _jb_meta_nrecs_get(EJDB db, uint32_t dbid) { +static int64_t _jb_meta_nrecs_get(struct ejdb *db, uint32_t dbid) { size_t vsz = 0; uint64_t ret = 0; dbid = IW_HTOIL(dbid); - IWKV_val key = { + struct iwkv_val key = { .size = sizeof(dbid), .data = &dbid }; @@ -44,23 +47,17 @@ static int64_t _jb_meta_nrecs_get(EJDB db, uint32_t dbid) { return (int64_t) ret; } -static void _jb_idx_release(JBIDX idx) { - if (idx->idb) { - iwkv_db_cache_release(idx->idb); - } +static void _jb_idx_release(struct jbidx *idx) { free(idx->ptr); free(idx); } -static void _jb_coll_release(JBCOLL jbc) { - if (jbc->cdb) { - iwkv_db_cache_release(jbc->cdb); - } +static void _jb_coll_release(struct jbcoll *jbc) { if (jbc->meta) { jbl_destroy(&jbc->meta); } - JBIDX nidx; - for (JBIDX idx = jbc->idx; idx; idx = nidx) { + struct jbidx *nidx; + for (struct jbidx *idx = jbc->idx; idx; idx = nidx) { nidx = idx->next; _jb_idx_release(idx); } @@ -69,17 +66,17 @@ static void _jb_coll_release(JBCOLL jbc) { free(jbc); } -static iwrc _jb_coll_load_index_lr(JBCOLL jbc, IWKV_val *mval) { +static iwrc _jb_coll_load_index_lr(struct jbcoll *jbc, struct iwkv_val *mval) { + iwrc rc; binn *bn; char *ptr; - struct _JBL imeta; - JBIDX idx = calloc(1, sizeof(*idx)); + struct jbl imeta; + struct jbidx *idx = calloc(1, sizeof(*idx)); if (!idx) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } - iwrc rc = jbl_from_buf_keep_onstack(&imeta, mval->data, mval->size); - RCGO(rc, finish); + RCC(rc, finish, jbl_from_buf_keep_onstack(&imeta, mval->data, mval->size)); bn = &imeta.bn; if ( !binn_object_get_str(bn, "ptr", &ptr) @@ -89,11 +86,10 @@ static iwrc _jb_coll_load_index_lr(JBCOLL jbc, IWKV_val *mval) { rc = EJDB_ERROR_INVALID_COLLECTION_INDEX_META; goto finish; } - rc = jbl_ptr_alloc(ptr, &idx->ptr); - RCGO(rc, finish); - rc = iwkv_db(jbc->db->iwkv, idx->dbid, idx->idbf, &idx->idb); - RCGO(rc, finish); + RCC(rc, finish, jbl_ptr_alloc(ptr, &idx->ptr)); + RCC(rc, finish, iwkv_db(jbc->db->iwkv, idx->dbid, idx->idbf, &idx->idb)); + idx->jbc = jbc; idx->rnum = _jb_meta_nrecs_get(jbc->db, idx->dbid); idx->next = jbc->idx; @@ -106,11 +102,11 @@ static iwrc _jb_coll_load_index_lr(JBCOLL jbc, IWKV_val *mval) { return rc; } -static iwrc _jb_coll_load_indexes_lr(JBCOLL jbc) { +static iwrc _jb_coll_load_indexes_lr(struct jbcoll *jbc) { iwrc rc = 0; - IWKV_cursor cur; - IWKV_val kval; - char buf[sizeof(KEY_PREFIX_IDXMETA) + JBNUMBUF_SIZE]; + struct iwkv_cursor *cur; + struct iwkv_val kval; + char buf[sizeof(KEY_PREFIX_IDXMETA) + IWNUMBUF_SIZE]; // Full key format: i.. int sz = snprintf(buf, sizeof(buf), KEY_PREFIX_IDXMETA "%u.", jbc->dbid); if (sz >= sizeof(buf)) { @@ -126,13 +122,11 @@ static iwrc _jb_coll_load_indexes_lr(JBCOLL jbc) { RCRET(rc); do { - IWKV_val key, val; - rc = iwkv_cursor_key(cur, &key); - RCGO(rc, finish); + struct iwkv_val key, val; + RCC(rc, finish, iwkv_cursor_key(cur, &key)); if ((key.size > sz) && !strncmp(buf, key.data, sz)) { iwkv_val_dispose(&key); - rc = iwkv_cursor_val(cur, &val); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_val(cur, &val)); rc = _jb_coll_load_index_lr(jbc, &val); iwkv_val_dispose(&val); RCBREAK(rc); @@ -149,10 +143,11 @@ static iwrc _jb_coll_load_indexes_lr(JBCOLL jbc) { return rc; } -static iwrc _jb_coll_load_meta_lr(JBCOLL jbc) { - JBL jbv; - IWKV_cursor cur; - JBL jbm = jbc->meta; +static iwrc _jb_coll_load_meta_lr(struct jbcoll *jbc) { + struct jbl *jbv; + struct iwkv_cursor *cur; + struct jbl *jbm = jbc->meta; + iwrc rc = jbl_at(jbm, "/name", &jbv); RCRET(rc); jbc->name = jbl_get_str(jbv); @@ -184,8 +179,7 @@ static iwrc _jb_coll_load_meta_lr(JBCOLL jbc) { } } else { size_t sz; - rc = iwkv_cursor_copy_key(cur, &jbc->id_seq, sizeof(jbc->id_seq), &sz, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_copy_key(cur, &jbc->id_seq, sizeof(jbc->id_seq), &sz, 0)); } finish: @@ -193,14 +187,12 @@ static iwrc _jb_coll_load_meta_lr(JBCOLL jbc) { return rc; } -static iwrc _jb_coll_init(JBCOLL jbc, IWKV_val *meta) { - int rci; +static iwrc _jb_coll_init(struct jbcoll *jbc, struct iwkv_val *meta) { iwrc rc = 0; - pthread_rwlockattr_t attr; pthread_rwlockattr_init(&attr); #if defined __linux__ && (defined __USE_UNIX98 || defined __USE_XOPEN2K) - pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_READER_NP); #endif pthread_rwlock_init(&jbc->rwl, &attr); if (meta) { @@ -214,18 +206,15 @@ static iwrc _jb_coll_init(JBCOLL jbc, IWKV_val *meta) { rc = _jb_coll_load_meta_lr(jbc); RCRET(rc); - khiter_t k = kh_put(JBCOLLM, jbc->db->mcolls, jbc->name, &rci); - if (rci != -1) { - kh_value(jbc->db->mcolls, k) = jbc; - } else { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } + rc = iwhmap_put(jbc->db->mcolls, (void*) jbc->name, jbc); + RCRET(rc); + return rc; } -static iwrc _jb_idx_add_meta_lr(JBIDX idx, binn *list) { +static iwrc _jb_idx_add_meta_lr(struct jbidx *idx, binn *list) { iwrc rc = 0; - IWXSTR *xstr = iwxstr_new(); + struct iwxstr *xstr = iwxstr_new(); if (!xstr) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } @@ -235,8 +224,7 @@ static iwrc _jb_idx_add_meta_lr(JBIDX idx, binn *list) { iwxstr_destroy(xstr); return rc; } - rc = jbl_ptr_serialize(idx->ptr, xstr); - RCGO(rc, finish); + RCC(rc, finish, jbl_ptr_serialize(idx->ptr, xstr)); if ( !binn_object_set_str(meta, "ptr", iwxstr_ptr(xstr)) || !binn_object_set_uint32(meta, "mode", idx->mode) @@ -256,7 +244,7 @@ static iwrc _jb_idx_add_meta_lr(JBIDX idx, binn *list) { return rc; } -static iwrc _jb_coll_add_meta_lr(JBCOLL jbc, binn *list) { +static iwrc _jb_coll_add_meta_lr(struct jbcoll *jbc, binn *list) { iwrc rc = 0; binn *ilist = 0; binn *meta = binn_object(); @@ -275,9 +263,8 @@ static iwrc _jb_coll_add_meta_lr(JBCOLL jbc, binn *list) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; } - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { - rc = _jb_idx_add_meta_lr(idx, ilist); - RCGO(rc, finish); + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { + RCC(rc, finish, _jb_idx_add_meta_lr(idx, ilist)); } if (!binn_object_set_list(meta, "indexes", ilist)) { rc = JBL_ERROR_CREATION; @@ -296,7 +283,7 @@ static iwrc _jb_coll_add_meta_lr(JBCOLL jbc, binn *list) { return rc; } -static iwrc _jb_db_meta_load(EJDB db) { +static iwrc _jb_db_meta_load(struct ejdb *db) { iwrc rc = 0; if (!db->metadb) { rc = iwkv_db(db->iwkv, METADB_ID, 0, &db->metadb); @@ -307,15 +294,14 @@ static iwrc _jb_db_meta_load(EJDB db) { RCRET(rc); } - IWKV_cursor cur; + struct iwkv_cursor *cur; rc = iwkv_cursor_open(db->metadb, &cur, IWKV_CURSOR_BEFORE_FIRST, 0); RCRET(rc); while (!(rc = iwkv_cursor_to(cur, IWKV_CURSOR_NEXT))) { - IWKV_val key, val; - rc = iwkv_cursor_get(cur, &key, &val); - RCGO(rc, finish); + struct iwkv_val key, val; + RCC(rc, finish, iwkv_cursor_get(cur, &key, &val)); if (!strncmp(key.data, KEY_PREFIX_COLLMETA, sizeof(KEY_PREFIX_COLLMETA) - 1)) { - JBCOLL jbc = calloc(1, sizeof(*jbc)); + struct jbcoll *jbc = calloc(1, sizeof(*jbc)); if (!jbc) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); iwkv_val_dispose(&val); @@ -342,24 +328,15 @@ static iwrc _jb_db_meta_load(EJDB db) { return rc; } -static iwrc _jb_db_release(EJDB *dbp) { +static iwrc _jb_db_release(struct ejdb **dbp) { iwrc rc = 0; - EJDB db = *dbp; + struct ejdb *db = *dbp; *dbp = 0; #ifdef JB_HTTP - if (db->jbr) { - IWRC(jbr_shutdown(&db->jbr), rc); - } + jbr_shutdown_wait(db->jbr); #endif if (db->mcolls) { - for (khiter_t k = kh_begin(db->mcolls); k != kh_end(db->mcolls); ++k) { - if (!kh_exist(db->mcolls, k)) { - continue; - } - JBCOLL jbc = kh_val(db->mcolls, k); - _jb_coll_release(jbc); - } - kh_destroy(JBCOLLM, db->mcolls); + iwhmap_destroy(db->mcolls); db->mcolls = 0; } if (db->iwkv) { @@ -367,7 +344,7 @@ static iwrc _jb_db_release(EJDB *dbp) { } pthread_rwlock_destroy(&db->rwl); - EJDB_HTTP *http = &db->opts.http; + struct ejdb_http *http = &db->opts.http; if (http->bind) { free((void*) http->bind); } @@ -378,25 +355,22 @@ static iwrc _jb_db_release(EJDB *dbp) { return rc; } -static iwrc _jb_coll_acquire_keeplock2(EJDB db, const char *coll, jb_coll_acquire_t acm, JBCOLL *jbcp) { - if (strlen(coll) > EJDB_COLLECTION_NAME_MAX_LEN) { +static iwrc _jb_coll_acquire_keeplock2( + struct ejdb *db, const char *coll, jb_coll_acquire_t acm, + struct jbcoll **jbcp) { + if (!coll || *coll == '\0' || strlen(coll) > EJDB_COLLECTION_NAME_MAX_LEN) { return EJDB_ERROR_INVALID_COLLECTION_NAME; } int rci; iwrc rc = 0; *jbcp = 0; - JBCOLL jbc = 0; + struct jbcoll *jbc = 0; bool wl = acm & JB_COLL_ACQUIRE_WRITE; API_RLOCK(db, rci); - khiter_t k = kh_get(JBCOLLM, db->mcolls, coll); - if (k != kh_end(db->mcolls)) { - jbc = kh_value(db->mcolls, k); - assert(jbc); - rci = wl ? pthread_rwlock_wrlock(&jbc->rwl) : pthread_rwlock_rdlock(&jbc->rwl); - if (rci) { - rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci); - goto finish; - } + + jbc = iwhmap_get(db->mcolls, coll); + if (jbc) { + wl ? pthread_rwlock_wrlock(&jbc->rwl) : pthread_rwlock_rdlock(&jbc->rwl); *jbcp = jbc; } else { pthread_rwlock_unlock(&db->rwl); // relock @@ -404,32 +378,24 @@ static iwrc _jb_coll_acquire_keeplock2(EJDB db, const char *coll, jb_coll_acquir return IW_ERROR_NOT_EXISTS; } API_WLOCK(db, rci); - k = kh_get(JBCOLLM, db->mcolls, coll); - if (k != kh_end(db->mcolls)) { - jbc = kh_value(db->mcolls, k); - assert(jbc); - rci = pthread_rwlock_rdlock(&jbc->rwl); - if (rci) { - rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci); - goto finish; - } + jbc = iwhmap_get(db->mcolls, coll); + if (jbc) { + pthread_rwlock_rdlock(&jbc->rwl); *jbcp = jbc; } else { - JBL meta = 0; - IWDB cdb = 0; + struct jbl *meta = 0; + struct iwdb *cdb = 0; uint32_t dbid = 0; - char keybuf[JBNUMBUF_SIZE + sizeof(KEY_PREFIX_COLLMETA)]; - IWKV_val key, val; + char keybuf[IWNUMBUF_SIZE + sizeof(KEY_PREFIX_COLLMETA)]; + struct iwkv_val key, val; - rc = iwkv_new_db(db->iwkv, IWDB_VNUM64_KEYS, &dbid, &cdb); - RCGO(rc, create_finish); + RCC(rc, create_finish, iwkv_new_db(db->iwkv, IWDB_VNUM64_KEYS, &dbid, &cdb)); jbc = calloc(1, sizeof(*jbc)); if (!jbc) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto create_finish; } - rc = jbl_create_empty_object(&meta); - RCGO(rc, create_finish); + RCC(rc, create_finish, jbl_create_empty_object(&meta)); if (!binn_object_set_str(&meta->bn, "name", coll)) { rc = JBL_ERROR_CREATION; goto create_finish; @@ -438,8 +404,7 @@ static iwrc _jb_coll_acquire_keeplock2(EJDB db, const char *coll, jb_coll_acquir rc = JBL_ERROR_CREATION; goto create_finish; } - rc = jbl_as_buf(meta, &val.data, &val.size); - RCGO(rc, create_finish); + RCC(rc, create_finish, jbl_as_buf(meta, &val.data, &val.size)); key.size = snprintf(keybuf, sizeof(keybuf), KEY_PREFIX_COLLMETA "%u", dbid); if (key.size >= sizeof(keybuf)) { @@ -447,8 +412,7 @@ static iwrc _jb_coll_acquire_keeplock2(EJDB db, const char *coll, jb_coll_acquir goto create_finish; } key.data = keybuf; - rc = iwkv_put(db->metadb, &key, &val, IWKV_SYNC); - RCGO(rc, create_finish); + RCC(rc, create_finish, iwkv_put(db->metadb, &key, &val, IWKV_SYNC)); jbc->db = db; jbc->meta = meta; @@ -488,22 +452,22 @@ static iwrc _jb_coll_acquire_keeplock2(EJDB db, const char *coll, jb_coll_acquir return rc; } -IW_INLINE iwrc _jb_coll_acquire_keeplock(EJDB db, const char *coll, bool wl, JBCOLL *jbcp) { +IW_INLINE iwrc _jb_coll_acquire_keeplock(struct ejdb *db, const char *coll, bool wl, struct jbcoll **jbcp) { return _jb_coll_acquire_keeplock2(db, coll, wl ? JB_COLL_ACQUIRE_WRITE : 0, jbcp); } -static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { - IWKV_val key; +static iwrc _jb_idx_record_add(struct jbidx *idx, int64_t id, struct jbl *jbl, struct jbl *jblprev) { + struct iwkv_val key; uint8_t step; char vnbuf[IW_VNUMBUFSZ]; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; bool jbv_found, jbvprev_found; - struct _JBL jbv = { 0 }, jbvprev = { 0 }; + struct jbl jbv = { 0 }, jbvprev = { 0 }; jbl_type_t jbv_type, jbvprev_type; iwrc rc = 0; - IWPOOL *pool = 0; + struct iwpool *pool = 0; int64_t delta = 0; // delta of added/removed index records bool compound = idx->idbf & IWDB_COMPOUND_KEYS; @@ -531,13 +495,11 @@ static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; } - JBL_NODE jbvprev_node, jbv_node; - rc = jbl_to_node(&jbv, &jbv_node, false, pool); - RCGO(rc, finish); + struct jbl_node *jbvprev_node, *jbv_node; + RCC(rc, finish, jbl_to_node(&jbv, &jbv_node, false, pool)); jbv.node = jbv_node; - rc = jbl_to_node(&jbvprev, &jbvprev_node, false, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(&jbvprev, &jbvprev_node, false, pool)); jbvprev.node = jbvprev_node; if (_jbl_compare_nodes(jbv_node, jbvprev_node, &rc) == 0) { @@ -549,16 +511,14 @@ static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { if (jbvprev_found) { // Remove old index elements if (jbvprev_type == JBV_ARRAY) { // TODO: array modification delta? - JBL_NODE n; + struct jbl_node *n; if (!pool) { pool = iwpool_create(1024); if (!pool) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - RCGO(rc, finish); + RCC(rc, finish, iwrc_set_errno(IW_ERROR_ALLOC, errno)); } } - rc = jbl_to_node(&jbvprev, &n, false, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(&jbvprev, &n, false, pool)); for (n = n->child; n; n = n->next) { jbi_node_fill_ikey(idx, n, &key, numbuf); if (key.size) { @@ -589,16 +549,14 @@ static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { if (jbv_found) { // Add index record if (jbv_type == JBV_ARRAY) { // TODO: array modification delta? - JBL_NODE n; + struct jbl_node *n; if (!pool) { pool = iwpool_create(1024); if (!pool) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - RCGO(rc, finish); + RCC(rc, finish, iwrc_set_errno(IW_ERROR_ALLOC, errno)); } } - rc = jbl_to_node(&jbv, &n, false, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(&jbv, &n, false, pool)); for (n = n->child; n; n = n->next) { jbi_node_fill_ikey(idx, n, &key, numbuf); if (key.size) { @@ -626,7 +584,7 @@ static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { } } else { IW_SETVNUMBUF64(step, vnbuf, id); - IWKV_val idval = { + struct iwkv_val idval = { .data = vnbuf, .size = step }; @@ -652,16 +610,16 @@ static iwrc _jb_idx_record_add(JBIDX idx, int64_t id, JBL jbl, JBL jblprev) { return rc; } -IW_INLINE iwrc _jb_idx_record_remove(JBIDX idx, int64_t id, JBL jbl) { +IW_INLINE iwrc _jb_idx_record_remove(struct jbidx *idx, int64_t id, struct jbl *jbl) { return _jb_idx_record_add(idx, id, 0, jbl); } -static iwrc _jb_idx_fill(JBIDX idx) { - IWKV_cursor cur; - IWKV_val key, val; - struct _JBL jbs; +static iwrc _jb_idx_fill(struct jbidx *idx) { + struct iwkv_cursor *cur; + struct iwkv_val key, val; + struct jbl jbs; int64_t llv; - JBL jbl = &jbs; + struct jbl *jbl = &jbs; iwrc rc = iwkv_cursor_open(idx->jbc->cdb, &cur, IWKV_CURSOR_BEFORE_FIRST, 0); while (!rc) { @@ -685,17 +643,17 @@ static iwrc _jb_idx_fill(JBIDX idx) { } // Used to avoid deadlocks within a `iwkv_put` context -static iwrc _jb_put_handler_after(iwrc rc, struct _JBPHCTX *ctx) { - IWKV_val *oldval = &ctx->oldval; +static iwrc _jb_put_handler_after(iwrc rc, struct _jb_put_handler_ctx *ctx) { + struct iwkv_val *oldval = &ctx->oldval; if (rc) { if (oldval->size) { iwkv_val_dispose(oldval); } return rc; } - JBL prev; - struct _JBL jblprev; - JBCOLL jbc = ctx->jbc; + struct jbl *prev; + struct jbl jblprev; + struct jbcoll *jbc = ctx->jbc; if (oldval->size) { rc = jbl_from_buf_keep_onstack(&jblprev, oldval->data, oldval->size); RCRET(rc); @@ -703,8 +661,8 @@ static iwrc _jb_put_handler_after(iwrc rc, struct _JBPHCTX *ctx) { } else { prev = 0; } - JBIDX fail_idx = 0; - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { + struct jbidx *fail_idx = 0; + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { rc = _jb_idx_record_add(idx, ctx->id, ctx->jbl, prev); if (rc) { fail_idx = idx; @@ -722,8 +680,8 @@ static iwrc _jb_put_handler_after(iwrc rc, struct _JBPHCTX *ctx) { } if (rc && !oldval->size) { // Cleanup on error inserting new record - IWKV_val key = { .data = &ctx->id, .size = sizeof(ctx->id) }; - for (JBIDX idx = jbc->idx; idx && idx != fail_idx; idx = idx->next) { + struct iwkv_val key = { .data = &ctx->id, .size = sizeof(ctx->id) }; + for (struct jbidx *idx = jbc->idx; idx && idx != fail_idx; idx = idx->next) { IWRC(_jb_idx_record_remove(idx, ctx->id, ctx->jbl), rc); } IWRC(iwkv_del(jbc->cdb, &key, 0), rc); @@ -731,15 +689,15 @@ static iwrc _jb_put_handler_after(iwrc rc, struct _JBPHCTX *ctx) { return rc; } -static iwrc _jb_put_handler(const IWKV_val *key, const IWKV_val *val, IWKV_val *oldval, void *op) { - struct _JBPHCTX *ctx = op; +static iwrc _jb_put_handler(const struct iwkv_val *key, const struct iwkv_val *val, struct iwkv_val *oldval, void *op) { + struct _jb_put_handler_ctx *ctx = op; if (oldval && oldval->size) { memcpy(&ctx->oldval, oldval, sizeof(*oldval)); } return 0; } -static iwrc _jb_exec_scan_init(JBEXEC *ctx) { +static iwrc _jb_exec_scan_init(struct jbexec *ctx) { ctx->istep = 1; ctx->jblbufsz = ctx->jbc->db->opts.document_buffer_sz; ctx->jblbuf = malloc(ctx->jblbufsz); @@ -747,7 +705,7 @@ static iwrc _jb_exec_scan_init(JBEXEC *ctx) { ctx->jblbufsz = 0; return iwrc_set_errno(IW_ERROR_ALLOC, errno); } - struct JQP_AUX *aux = ctx->ux->q->aux; + struct jqp_aux *aux = ctx->ux->q->aux; if (aux->expr->flags & JQP_EXPR_NODE_FLAG_PK) { // Select by primary key ctx->scanner = jbi_pk_scanner; if (ctx->ux->log) { @@ -772,10 +730,11 @@ static iwrc _jb_exec_scan_init(JBEXEC *ctx) { return 0; } -static void _jb_exec_scan_release(JBEXEC *ctx) { +static void _jb_exec_scan_release(struct jbexec *ctx) { if (ctx->proj_joined_nodes_cache) { // Destroy projected nodes key - iwstree_destroy(ctx->proj_joined_nodes_cache); + iwhmap_destroy(ctx->proj_joined_nodes_cache); + ctx->proj_joined_nodes_cache = 0; } if (ctx->proj_joined_nodes_pool) { iwpool_destroy(ctx->proj_joined_nodes_pool); @@ -783,17 +742,17 @@ static void _jb_exec_scan_release(JBEXEC *ctx) { free(ctx->jblbuf); } -static iwrc _jb_noop_visitor(struct _EJDB_EXEC *ctx, EJDB_DOC doc, int64_t *step) { +static iwrc _jb_noop_visitor(struct ejdb_exec *ctx, struct ejdb_doc *doc, int64_t *step) { return 0; } -IW_INLINE iwrc _jb_put_impl(JBCOLL jbc, JBL jbl, int64_t id) { - IWKV_val val, key = { +IW_INLINE iwrc _jb_put_impl(struct jbcoll *jbc, struct jbl *jbl, int64_t id) { + struct iwkv_val val, key = { .data = &id, .size = sizeof(id) }; - struct _JBPHCTX pctx = { - .id = id, + struct _jb_put_handler_ctx pctx = { + .id = id, .jbc = jbc, .jbl = jbl }; @@ -802,14 +761,14 @@ IW_INLINE iwrc _jb_put_impl(JBCOLL jbc, JBL jbl, int64_t id) { return _jb_put_handler_after(iwkv_puth(jbc->cdb, &key, &val, 0, _jb_put_handler, &pctx), &pctx); } -iwrc jb_put(JBCOLL jbc, JBL jbl, int64_t id) { +iwrc jb_put(struct jbcoll *jbc, struct jbl *jbl, int64_t id) { return _jb_put_impl(jbc, jbl, id); } -iwrc jb_cursor_set(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl) { - IWKV_val val; - struct _JBPHCTX pctx = { - .id = id, +iwrc jb_cursor_set(struct jbcoll *jbc, struct iwkv_cursor *cur, int64_t id, struct jbl *jbl) { + struct iwkv_val val; + struct _jb_put_handler_ctx pctx = { + .id = id, .jbc = jbc, .jbl = jbl }; @@ -818,15 +777,15 @@ iwrc jb_cursor_set(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl) { return _jb_put_handler_after(iwkv_cursor_seth(cur, &val, 0, _jb_put_handler, &pctx), &pctx); } -static iwrc _jb_exec_upsert_lw(JBEXEC *ctx) { - JBL_NODE n; +static iwrc _jb_exec_upsert_lw(struct jbexec *ctx) { + struct jbl_node *n; int64_t id; iwrc rc = 0; - JBL jbl = 0; - EJDB_EXEC *ux = ctx->ux; - JQL q = ux->q; + struct jbl *jbl = 0; + struct ejdb_exec *ux = ctx->ux; + struct jql *q = ux->q; if (q->aux->apply_placeholder) { - JQVAL *pv = jql_find_placeholder(q, q->aux->apply_placeholder); + struct jqval *pv = jql_find_placeholder(q, q->aux->apply_placeholder); if (!pv || (pv->type != JQVAL_JBLNODE) || !pv->vnode) { rc = JQL_ERROR_INVALID_PLACEHOLDER_VALUE_TYPE; goto finish; @@ -843,9 +802,9 @@ static iwrc _jb_exec_upsert_lw(JBEXEC *ctx) { RCC(rc, finish, _jb_put_new_lw(ctx->jbc, jbl, &id)); if (!(q->aux->qmode & JQP_QRY_AGGREGATE)) { - struct _EJDB_DOC doc = { - .id = id, - .raw = jbl, + struct ejdb_doc doc = { + .id = id, + .raw = jbl, .node = n }; do { @@ -862,7 +821,7 @@ static iwrc _jb_exec_upsert_lw(JBEXEC *ctx) { //----------------------- Public API -iwrc ejdb_exec(EJDB_EXEC *ux) { +iwrc ejdb_exec(struct ejdb_exec *ux) { if (!ux || !ux->db || !ux->q) { return IW_ERROR_INVALID_ARGS; } @@ -876,7 +835,7 @@ iwrc ejdb_exec(EJDB_EXEC *ux) { // set terminating NULL to current pos of log iwxstr_cat(ux->log, 0, 0); } - JBEXEC ctx = { + struct jbexec ctx = { .ux = ux }; if (ux->limit < 1) { @@ -899,8 +858,7 @@ iwrc ejdb_exec(EJDB_EXEC *ux) { RCRET(rc); } - rc = _jb_exec_scan_init(&ctx); - RCGO(rc, finish); + RCC(rc, finish, _jb_exec_scan_init(&ctx)); if (ctx.sorting) { if (ux->log) { iwxstr_cat2(ux->log, " [COLLECTOR] SORTER\n"); @@ -925,15 +883,57 @@ iwrc ejdb_exec(EJDB_EXEC *ux) { return rc; } -struct JB_LIST_VISITOR_CTX { - EJDB_DOC head; - EJDB_DOC tail; +#ifdef IW_BLOCKS + +struct _block_visitor_ctx { + struct ejdb_visit_block *bctx; + bool (^visitor)(struct ejdb_doc*); }; -static iwrc _jb_exec_list_visitor(struct _EJDB_EXEC *ctx, EJDB_DOC doc, int64_t *step) { - struct JB_LIST_VISITOR_CTX *lvc = ctx->opaque; - IWPOOL *pool = ctx->pool; - struct _EJDB_DOC *ndoc = iwpool_alloc(sizeof(*ndoc) + sizeof(*doc->raw) + doc->raw->bn.size, pool); +static iwrc _block_visitor(struct ejdb_exec *ux, struct ejdb_doc *doc, int64_t *step) { + struct _block_visitor_ctx *ctx = ux->opaque; + ++ctx->bctx->num_visits; + bool ret = ctx->visitor(doc); + if (!ret) { + *step = 0; + } + return 0; +} + +iwrc ejdb_visit_block2(struct ejdb_visit_block *bctx, bool (^visitor)(struct ejdb_doc*)) { + bctx->num_visits = 0; + struct _block_visitor_ctx ctx = { + .bctx = bctx, + .visitor = visitor, + }; + struct ejdb_exec ux = { + .db = bctx->db, + .q = bctx->q, + .visitor = _block_visitor, + .opaque = &ctx, + .pool = bctx->pool, + }; + return ejdb_exec(&ux); +} + +iwrc ejdb_visit_block(struct ejdb *db, struct jql *q, bool (^visitor)(struct ejdb_doc*)) { + return ejdb_visit_block2(&(struct ejdb_visit_block) { + .db = db, + .q = q, + }, visitor); +} + +#endif + +struct _list_visitor_ctx { + struct ejdb_doc *head; + struct ejdb_doc *tail; +}; + +static iwrc _jb_exec_list_visitor(struct ejdb_exec *ctx, struct ejdb_doc *doc, int64_t *step) { + struct _list_visitor_ctx *lvc = ctx->opaque; + struct iwpool *pool = ctx->pool; + struct ejdb_doc *ndoc = iwpool_alloc(sizeof(*ndoc) + sizeof(*doc->raw) + doc->raw->bn.size, pool); if (!ndoc) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } @@ -958,20 +958,26 @@ static iwrc _jb_exec_list_visitor(struct _EJDB_EXEC *ctx, EJDB_DOC doc, int64_t return 0; } -static iwrc _jb_list(EJDB db, JQL q, EJDB_DOC *first, int64_t limit, IWXSTR *log, IWPOOL *pool) { +static iwrc _jb_list( + struct ejdb *db, + struct jql *q, + struct ejdb_doc **first, + int64_t limit, + struct iwxstr *log, + struct iwpool *pool) { if (!db || !q || !first || !pool) { return IW_ERROR_INVALID_ARGS; } iwrc rc = 0; - struct JB_LIST_VISITOR_CTX lvc = { 0 }; - struct _EJDB_EXEC ux = { - .db = db, - .q = q, + struct _list_visitor_ctx lvc = { 0 }; + struct ejdb_exec ux = { + .db = db, + .q = q, .visitor = _jb_exec_list_visitor, - .pool = pool, - .limit = limit, - .log = log, - .opaque = &lvc + .pool = pool, + .limit = limit, + .log = log, + .opaque = &lvc }; rc = ejdb_exec(&ux); if (rc) { @@ -982,27 +988,27 @@ static iwrc _jb_list(EJDB db, JQL q, EJDB_DOC *first, int64_t limit, IWXSTR *log return rc; } -static iwrc _jb_count(EJDB db, JQL q, int64_t *count, int64_t limit, IWXSTR *log) { +static iwrc _jb_count(struct ejdb *db, struct jql *q, int64_t *count, int64_t limit, struct iwxstr *log) { if (!db || !q || !count) { return IW_ERROR_INVALID_ARGS; } - struct _EJDB_EXEC ux = { - .db = db, - .q = q, + struct ejdb_exec ux = { + .db = db, + .q = q, .limit = limit, - .log = log + .log = log }; iwrc rc = ejdb_exec(&ux); *count = ux.cnt; return rc; } -iwrc ejdb_count(EJDB db, JQL q, int64_t *count, int64_t limit) { +iwrc ejdb_count(struct ejdb *db, struct jql *q, int64_t *count, int64_t limit) { return _jb_count(db, q, count, limit, 0); } -iwrc ejdb_count2(EJDB db, const char *coll, const char *q, int64_t *count, int64_t limit) { - JQL jql; +iwrc ejdb_count2(struct ejdb *db, const char *coll, const char *q, int64_t *count, int64_t limit) { + struct jql *jql; iwrc rc = jql_create(&jql, coll, q); RCRET(rc); rc = _jb_count(db, jql, count, limit, 0); @@ -1010,31 +1016,37 @@ iwrc ejdb_count2(EJDB db, const char *coll, const char *q, int64_t *count, int64 return rc; } -iwrc ejdb_update(EJDB db, JQL q) { +iwrc ejdb_update(struct ejdb *db, struct jql *q) { int64_t count; return ejdb_count(db, q, &count, 0); } -iwrc ejdb_update2(EJDB db, const char *coll, const char *q) { +iwrc ejdb_update2(struct ejdb *db, const char *coll, const char *q) { int64_t count; return ejdb_count2(db, coll, q, &count, 0); } -iwrc ejdb_list(EJDB db, JQL q, EJDB_DOC *first, int64_t limit, IWPOOL *pool) { +iwrc ejdb_list(struct ejdb *db, struct jql *q, struct ejdb_doc **first, int64_t limit, struct iwpool *pool) { return _jb_list(db, q, first, limit, 0, pool); } -iwrc ejdb_list3(EJDB db, const char *coll, const char *query, int64_t limit, IWXSTR *log, EJDB_LIST *listp) { +iwrc ejdb_list3( + struct ejdb *db, + const char *coll, + const char *query, + int64_t limit, + struct iwxstr *log, + struct ejdb_list **listp) { if (!listp) { return IW_ERROR_INVALID_ARGS; } iwrc rc = 0; *listp = 0; - IWPOOL *pool = iwpool_create(1024); + struct iwpool *pool = iwpool_create(1024); if (!pool) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } - EJDB_LIST list = iwpool_alloc(sizeof(*list), pool); + struct ejdb_list *list = iwpool_alloc(sizeof(*list), pool); if (!list) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; @@ -1042,8 +1054,7 @@ iwrc ejdb_list3(EJDB db, const char *coll, const char *query, int64_t limit, IWX list->first = 0; list->db = db; list->pool = pool; - rc = jql_create(&list->q, coll, query); - RCGO(rc, finish); + RCC(rc, finish, jql_create(&list->q, coll, query)); rc = _jb_list(db, list->q, &list->first, limit, log, list->pool); finish: @@ -1055,17 +1066,17 @@ iwrc ejdb_list3(EJDB db, const char *coll, const char *query, int64_t limit, IWX return rc; } -iwrc ejdb_list4(EJDB db, JQL q, int64_t limit, IWXSTR *log, EJDB_LIST *listp) { +iwrc ejdb_list4(struct ejdb *db, struct jql *q, int64_t limit, struct iwxstr *log, struct ejdb_list **listp) { if (!listp) { return IW_ERROR_INVALID_ARGS; } iwrc rc = 0; *listp = 0; - IWPOOL *pool = iwpool_create(1024); + struct iwpool *pool = iwpool_create(1024); if (!pool) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } - EJDB_LIST list = iwpool_alloc(sizeof(*list), pool); + struct ejdb_list *list = iwpool_alloc(sizeof(*list), pool); if (!list) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; @@ -1085,13 +1096,13 @@ iwrc ejdb_list4(EJDB db, JQL q, int64_t limit, IWXSTR *log, EJDB_LIST *listp) { return rc; } -iwrc ejdb_list2(EJDB db, const char *coll, const char *query, int64_t limit, EJDB_LIST *listp) { +iwrc ejdb_list2(struct ejdb *db, const char *coll, const char *query, int64_t limit, struct ejdb_list **listp) { return ejdb_list3(db, coll, query, limit, 0, listp); } -void ejdb_list_destroy(EJDB_LIST *listp) { +void ejdb_list_destroy(struct ejdb_list **listp) { if (listp) { - EJDB_LIST list = *listp; + struct ejdb_list *list = *listp; if (list) { if (list->q) { jql_destroy(&list->q); @@ -1104,23 +1115,22 @@ void ejdb_list_destroy(EJDB_LIST *listp) { } } -iwrc ejdb_remove_index(EJDB db, const char *coll, const char *path, ejdb_idx_mode_t mode) { +iwrc ejdb_remove_index(struct ejdb *db, const char *coll, const char *path, ejdb_idx_mode_t mode) { if (!db || !coll || !path) { return IW_ERROR_INVALID_ARGS; } int rci; - JBCOLL jbc; - IWKV_val key; - JBL_PTR ptr = 0; - char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2 * JBNUMBUF_SIZE]; // Full key format: i.. + struct jbcoll *jbc; + struct iwkv_val key; + struct jbl_ptr *ptr = 0; + char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2UL * IWNUMBUF_SIZE]; // Full key format: i.. iwrc rc = _jb_coll_acquire_keeplock2(db, coll, JB_COLL_ACQUIRE_WRITE | JB_COLL_ACQUIRE_EXISTING, &jbc); RCRET(rc); - rc = jbl_ptr_alloc(path, &ptr); - RCGO(rc, finish); + RCC(rc, finish, jbl_ptr_alloc(path, &ptr)); - for (JBIDX idx = jbc->idx, prev = 0; idx; idx = idx->next) { + for (struct jbidx *idx = jbc->idx, *prev = 0; idx; idx = idx->next) { if (((idx->mode & ~EJDB_IDX_UNIQUE) == (mode & ~EJDB_IDX_UNIQUE)) && !jbl_ptr_cmp(idx->ptr, ptr)) { key.data = keybuf; key.size = snprintf(keybuf, sizeof(keybuf), KEY_PREFIX_IDXMETA "%u" "." "%u", jbc->dbid, idx->dbid); @@ -1128,8 +1138,7 @@ iwrc ejdb_remove_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod rc = IW_ERROR_OVERFLOW; goto finish; } - rc = iwkv_del(db->metadb, &key, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_del(db->metadb, &key, 0)); _jb_meta_nrecs_removedb(db, idx->dbid); if (prev) { prev->next = idx->next; @@ -1151,17 +1160,17 @@ iwrc ejdb_remove_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod return rc; } -iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mode_t mode) { +iwrc ejdb_ensure_index(struct ejdb *db, const char *coll, const char *path, ejdb_idx_mode_t mode) { if (!db || !coll || !path) { return IW_ERROR_INVALID_ARGS; } int rci; - JBCOLL jbc; - IWKV_val key, val; - char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2 * JBNUMBUF_SIZE]; // Full key format: i.. + struct jbcoll *jbc; + struct iwkv_val key, val; + char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2UL * IWNUMBUF_SIZE]; // Full key format: i.. - JBIDX idx = 0; - JBL_PTR ptr = 0; + struct jbidx *idx = 0; + struct jbl_ptr *ptr = 0; binn *imeta = 0; switch (mode & (EJDB_IDX_STR | EJDB_IDX_I64 | EJDB_IDX_F64)) { @@ -1175,8 +1184,8 @@ iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod iwrc rc = _jb_coll_acquire_keeplock(db, coll, true, &jbc); RCRET(rc); - rc = jbl_ptr_alloc(path, &ptr); - RCGO(rc, finish); + + RCC(rc, finish, jbl_ptr_alloc(path, &ptr)); for (idx = jbc->idx; idx; idx = idx->next) { if (((idx->mode & ~EJDB_IDX_UNIQUE) == (mode & ~EJDB_IDX_UNIQUE)) && !jbl_ptr_cmp(idx->ptr, ptr)) { @@ -1206,11 +1215,9 @@ iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod if (!(mode & EJDB_IDX_UNIQUE)) { idx->idbf |= IWDB_COMPOUND_KEYS; } - rc = iwkv_new_db(db->iwkv, idx->idbf, &idx->dbid, &idx->idb); - RCGO(rc, finish); - rc = _jb_idx_fill(idx); - RCGO(rc, finish); + RCC(rc, finish, iwkv_new_db(db->iwkv, idx->idbf, &idx->dbid, &idx->idb)); + RCC(rc, finish, _jb_idx_fill(idx)); // save index meta into metadb imeta = binn_object(); @@ -1236,8 +1243,7 @@ iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod } val.data = binn_ptr(imeta); val.size = binn_size(imeta); - rc = iwkv_put(db->metadb, &key, &val, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_put(db->metadb, &key, &val, 0)); idx->next = jbc->idx; jbc->idx = idx; @@ -1259,23 +1265,22 @@ iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod } static iwrc _jb_patch( - EJDB db, const char *coll, int64_t id, bool upsert, - const char *patchjson, JBL_NODE patchjbn, JBL patchjbl) { - + struct ejdb *db, const char *coll, int64_t id, bool upsert, + const char *patchjson, struct jbl_node *patchjbn, struct jbl *patchjbl) { int rci; - JBCOLL jbc; - struct _JBL sjbl; - JBL_NODE root, patch; - JBL ujbl = 0; - IWPOOL *pool = 0; - IWKV_val val = { 0 }; - IWKV_val key = { + struct jbcoll *jbc; + struct jbl sjbl; + struct jbl_node *root, *patch; + struct jbl *ujbl = 0; + struct iwpool *pool = 0; + struct iwkv_val val = { 0 }; + struct iwkv_val key = { .data = &id, .size = sizeof(id) }; iwrc rc = _jb_coll_acquire_keeplock(db, coll, true, &jbc); - RCGO(rc, finish); + RCRET(rc); rc = iwkv_get(jbc->cdb, &key, &val); if (upsert && (rc == IWKV_ERROR_NOTFOUND)) { @@ -1302,8 +1307,7 @@ static iwrc _jb_patch( RCGO(rc, finish); } - rc = jbl_from_buf_keep_onstack(&sjbl, val.data, val.size); - RCGO(rc, finish); + RCC(rc, finish, jbl_from_buf_keep_onstack(&sjbl, val.data, val.size)); pool = iwpool_create_empty(); if (!pool) { @@ -1311,8 +1315,7 @@ static iwrc _jb_patch( goto finish; } - rc = jbl_to_node(&sjbl, &root, false, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(&sjbl, &root, false, pool)); if (patchjson) { rc = jbn_from_json(patchjson, &patch, pool); @@ -1325,22 +1328,18 @@ static iwrc _jb_patch( } RCGO(rc, finish); - rc = jbn_patch_auto(root, patch, pool); - RCGO(rc, finish); + RCC(rc, finish, jbn_patch_auto(root, patch, pool)); if (root->type == JBV_OBJECT) { - rc = jbl_create_empty_object(&ujbl); - RCGO(rc, finish); + RCC(rc, finish, jbl_create_empty_object(&ujbl)); } else if (root->type == JBV_ARRAY) { - rc = jbl_create_empty_array(&ujbl); - RCGO(rc, finish); + RCC(rc, finish, jbl_create_empty_array(&ujbl)); } else { rc = JBL_ERROR_CREATION; goto finish; } - rc = jbl_fill_from_node(ujbl, root); - RCGO(rc, finish); + RCC(rc, finish, jbl_fill_from_node(ujbl, root)); rc = _jb_put_impl(jbc, ujbl, id); finish: @@ -1358,7 +1357,7 @@ static iwrc _jb_patch( static iwrc _jb_wal_lock_interceptor(bool before, void *op) { int rci; iwrc rc = 0; - EJDB db = op; + struct ejdb *db = op; assert(db); if (before) { API_WLOCK2(db, rci); @@ -1368,36 +1367,36 @@ static iwrc _jb_wal_lock_interceptor(bool before, void *op) { return rc; } -iwrc ejdb_patch(EJDB db, const char *coll, const char *patchjson, int64_t id) { +iwrc ejdb_patch(struct ejdb *db, const char *coll, const char *patchjson, int64_t id) { return _jb_patch(db, coll, id, false, patchjson, 0, 0); } -iwrc ejdb_patch_jbn(EJDB db, const char *coll, JBL_NODE patch, int64_t id) { +iwrc ejdb_patch_jbn(struct ejdb *db, const char *coll, struct jbl_node *patch, int64_t id) { return _jb_patch(db, coll, id, false, 0, patch, 0); } -iwrc ejdb_patch_jbl(EJDB db, const char *coll, JBL patch, int64_t id) { +iwrc ejdb_patch_jbl(struct ejdb *db, const char *coll, struct jbl *patch, int64_t id) { return _jb_patch(db, coll, id, false, 0, 0, patch); } -iwrc ejdb_merge_or_put(EJDB db, const char *coll, const char *patchjson, int64_t id) { +iwrc ejdb_merge_or_put(struct ejdb *db, const char *coll, const char *patchjson, int64_t id) { return _jb_patch(db, coll, id, true, patchjson, 0, 0); } -iwrc ejdb_merge_or_put_jbn(EJDB db, const char *coll, JBL_NODE patch, int64_t id) { +iwrc ejdb_merge_or_put_jbn(struct ejdb *db, const char *coll, struct jbl_node *patch, int64_t id) { return _jb_patch(db, coll, id, true, 0, patch, 0); } -iwrc ejdb_merge_or_put_jbl(EJDB db, const char *coll, JBL patch, int64_t id) { +iwrc ejdb_merge_or_put_jbl(struct ejdb *db, const char *coll, struct jbl *patch, int64_t id) { return _jb_patch(db, coll, id, true, 0, 0, patch); } -iwrc ejdb_put(EJDB db, const char *coll, JBL jbl, int64_t id) { +iwrc ejdb_put(struct ejdb *db, const char *coll, struct jbl *jbl, int64_t id) { if (!jbl) { return IW_ERROR_INVALID_ARGS; } int rci; - JBCOLL jbc; + struct jbcoll *jbc; iwrc rc = _jb_coll_acquire_keeplock(db, coll, true, &jbc); RCRET(rc); rc = _jb_put_impl(jbc, jbl, id); @@ -1408,8 +1407,8 @@ iwrc ejdb_put(EJDB db, const char *coll, JBL jbl, int64_t id) { return rc; } -iwrc ejdb_put_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t id) { - JBL jbl = 0; +iwrc ejdb_put_jbn(struct ejdb *db, const char *coll, struct jbl_node *jbn, int64_t id) { + struct jbl *jbl = 0; iwrc rc = jbl_from_node(&jbl, jbn); RCRET(rc); rc = ejdb_put(db, coll, jbl, id); @@ -1417,15 +1416,15 @@ iwrc ejdb_put_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t id) { return rc; } -static iwrc _jb_put_new_lw(JBCOLL jbc, JBL jbl, int64_t *id) { +static iwrc _jb_put_new_lw(struct jbcoll *jbc, struct jbl *jbl, int64_t *id) { iwrc rc = 0; int64_t oid = jbc->id_seq + 1; - IWKV_val val, key = { + struct iwkv_val val, key = { .data = &oid, .size = sizeof(oid) }; - struct _JBPHCTX pctx = { - .id = oid, + struct _jb_put_handler_ctx pctx = { + .id = oid, .jbc = jbc, .jbl = jbl }; @@ -1442,12 +1441,12 @@ static iwrc _jb_put_new_lw(JBCOLL jbc, JBL jbl, int64_t *id) { return rc; } -iwrc ejdb_put_new(EJDB db, const char *coll, JBL jbl, int64_t *id) { +iwrc ejdb_put_new(struct ejdb *db, const char *coll, struct jbl *jbl, int64_t *id) { if (!jbl) { return IW_ERROR_INVALID_ARGS; } int rci; - JBCOLL jbc; + struct jbcoll *jbc; if (id) { *id = 0; } @@ -1460,8 +1459,8 @@ iwrc ejdb_put_new(EJDB db, const char *coll, JBL jbl, int64_t *id) { return rc; } -iwrc ejdb_put_new_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t *id) { - JBL jbl = 0; +iwrc ejdb_put_new_jbn(struct ejdb *db, const char *coll, struct jbl_node *jbn, int64_t *id) { + struct jbl *jbl = 0; iwrc rc = jbl_from_node(&jbl, jbn); RCRET(rc); rc = ejdb_put_new(db, coll, jbl, id); @@ -1469,23 +1468,24 @@ iwrc ejdb_put_new_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t *id) { return rc; } -iwrc jb_get(EJDB db, const char *coll, int64_t id, jb_coll_acquire_t acm, JBL *jblp) { +iwrc jb_get(struct ejdb *db, const char *coll, int64_t id, jb_coll_acquire_t acm, struct jbl **jblp) { if (!id || !jblp) { return IW_ERROR_INVALID_ARGS; } *jblp = 0; + int rci; - JBCOLL jbc; - JBL jbl = 0; - IWKV_val val = { 0 }; - IWKV_val key = { .data = &id, .size = sizeof(id) }; + struct jbcoll *jbc; + struct jbl *jbl = 0; + struct iwkv_val val = { 0 }; + struct iwkv_val key = { .data = &id, .size = sizeof(id) }; + iwrc rc = _jb_coll_acquire_keeplock2(db, coll, acm, &jbc); RCRET(rc); - rc = iwkv_get(jbc->cdb, &key, &val); - RCGO(rc, finish); - rc = jbl_from_buf_keep(&jbl, val.data, val.size, false); - RCGO(rc, finish); + RCC(rc, finish, iwkv_get(jbc->cdb, &key, &val)); + RCC(rc, finish, jbl_from_buf_keep(&jbl, val.data, val.size, false)); + *jblp = jbl; finish: @@ -1500,30 +1500,28 @@ iwrc jb_get(EJDB db, const char *coll, int64_t id, jb_coll_acquire_t acm, JBL *j return rc; } -iwrc ejdb_get(EJDB db, const char *coll, int64_t id, JBL *jblp) { +iwrc ejdb_get(struct ejdb *db, const char *coll, int64_t id, struct jbl **jblp) { return jb_get(db, coll, id, JB_COLL_ACQUIRE_EXISTING, jblp); } -iwrc ejdb_del(EJDB db, const char *coll, int64_t id) { +iwrc ejdb_del(struct ejdb *db, const char *coll, int64_t id) { int rci; - JBCOLL jbc; - struct _JBL jbl; - IWKV_val val = { 0 }; - IWKV_val key = { .data = &id, .size = sizeof(id) }; + struct jbcoll *jbc; + struct jbl jbl; + struct iwkv_val val = { 0 }; + struct iwkv_val key = { .data = &id, .size = sizeof(id) }; + iwrc rc = _jb_coll_acquire_keeplock2(db, coll, JB_COLL_ACQUIRE_WRITE | JB_COLL_ACQUIRE_EXISTING, &jbc); RCRET(rc); - rc = iwkv_get(jbc->cdb, &key, &val); - RCGO(rc, finish); + RCC(rc, finish, iwkv_get(jbc->cdb, &key, &val)); + RCC(rc, finish, jbl_from_buf_keep_onstack(&jbl, val.data, val.size)); - rc = jbl_from_buf_keep_onstack(&jbl, val.data, val.size); - RCGO(rc, finish); - - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { IWRC(_jb_idx_record_remove(idx, id, &jbl), rc); } - rc = iwkv_del(jbc->cdb, &key, 0); - RCGO(rc, finish); + + RCC(rc, finish, iwkv_del(jbc->cdb, &key, 0)); _jb_meta_nrecs_update(jbc->db, jbc->dbid, -1); jbc->rnum -= 1; @@ -1535,10 +1533,10 @@ iwrc ejdb_del(EJDB db, const char *coll, int64_t id) { return rc; } -iwrc jb_del(JBCOLL jbc, JBL jbl, int64_t id) { +iwrc jb_del(struct jbcoll *jbc, struct jbl *jbl, int64_t id) { iwrc rc = 0; - IWKV_val key = { .data = &id, .size = sizeof(id) }; - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { + struct iwkv_val key = { .data = &id, .size = sizeof(id) }; + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { IWRC(_jb_idx_record_remove(idx, id, jbl), rc); } rc = iwkv_del(jbc->cdb, &key, 0); @@ -1548,9 +1546,9 @@ iwrc jb_del(JBCOLL jbc, JBL jbl, int64_t id) { return rc; } -iwrc jb_cursor_del(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl) { +iwrc jb_cursor_del(struct jbcoll *jbc, struct iwkv_cursor *cur, int64_t id, struct jbl *jbl) { iwrc rc = 0; - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { IWRC(_jb_idx_record_remove(idx, id, jbl), rc); } rc = iwkv_cursor_del(cur, 0); @@ -1560,45 +1558,42 @@ iwrc jb_cursor_del(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl) { return rc; } -iwrc ejdb_ensure_collection(EJDB db, const char *coll) { +iwrc ejdb_ensure_collection(struct ejdb *db, const char *coll) { int rci; - JBCOLL jbc; + struct jbcoll *jbc; iwrc rc = _jb_coll_acquire_keeplock(db, coll, false, &jbc); RCRET(rc); API_COLL_UNLOCK(jbc, rci, rc); return rc; } -iwrc ejdb_remove_collection(EJDB db, const char *coll) { +iwrc ejdb_remove_collection(struct ejdb *db, const char *coll) { int rci; iwrc rc = 0; if (db->oflags & IWKV_RDONLY) { return IW_ERROR_READONLY; } API_WLOCK(db, rci); - JBCOLL jbc; - IWKV_val key; - char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2 * JBNUMBUF_SIZE]; // Full key format: i.. - khiter_t k = kh_get(JBCOLLM, db->mcolls, coll); - - if (k != kh_end(db->mcolls)) { + struct jbcoll *jbc; + struct iwkv_val key; + char keybuf[sizeof(KEY_PREFIX_IDXMETA) + 1 + 2UL * IWNUMBUF_SIZE]; // Full key format: i.. - jbc = kh_value(db->mcolls, k); + jbc = iwhmap_get(db->mcolls, coll); + if (jbc) { key.data = keybuf; key.size = snprintf(keybuf, sizeof(keybuf), KEY_PREFIX_COLLMETA "%u", jbc->dbid); - rc = iwkv_del(jbc->db->metadb, &key, IWKV_SYNC); - RCGO(rc, finish); + + RCC(rc, finish, iwkv_del(jbc->db->metadb, &key, IWKV_SYNC)); _jb_meta_nrecs_removedb(db, jbc->dbid); - for (JBIDX idx = jbc->idx; idx; idx = idx->next) { + for (struct jbidx *idx = jbc->idx; idx; idx = idx->next) { key.data = keybuf; key.size = snprintf(keybuf, sizeof(keybuf), KEY_PREFIX_IDXMETA "%u" "." "%u", jbc->dbid, idx->dbid); - rc = iwkv_del(jbc->db->metadb, &key, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_del(jbc->db->metadb, &key, 0)); _jb_meta_nrecs_removedb(db, idx->dbid); } - for (JBIDX idx = jbc->idx, nidx; idx; idx = nidx) { + for (struct jbidx *idx = jbc->idx, *nidx; idx; idx = nidx) { IWRC(iwkv_db_destroy(&idx->idb), rc); idx->idb = 0; nidx = idx->next; @@ -1606,8 +1601,7 @@ iwrc ejdb_remove_collection(EJDB db, const char *coll) { } jbc->idx = 0; IWRC(iwkv_db_destroy(&jbc->cdb), rc); - kh_del(JBCOLLM, db->mcolls, k); - _jb_coll_release(jbc); + iwhmap_remove(db->mcolls, coll); } finish: @@ -1615,19 +1609,18 @@ iwrc ejdb_remove_collection(EJDB db, const char *coll) { return rc; } -iwrc jb_collection_join_resolver(int64_t id, const char *coll, JBL *out, JBEXEC *ctx) { +iwrc jb_collection_join_resolver(int64_t id, const char *coll, struct jbl **out, struct jbexec *ctx) { assert(out && ctx && coll); - EJDB db = ctx->jbc->db; + struct ejdb *db = ctx->jbc->db; return jb_get(db, coll, id, JB_COLL_ACQUIRE_EXISTING, out); } int jb_proj_node_cache_cmp(const void *v1, const void *v2) { - const struct _JBDOCREF *r1 = v1; - const struct _JBDOCREF *r2 = v2; + const struct jbdocref *r1 = v1; + const struct jbdocref *r2 = v2; int ret = r1->id > r2->id ? 1 : r1->id < r2->id ? -1 : 0; if (!ret) { return strcmp(r1->coll, r2->coll); - ; } return ret; } @@ -1636,7 +1629,12 @@ void jb_proj_node_kvfree(void *key, void *val) { free(key); } -iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new_coll) { +uint32_t jb_proj_node_hash(const void *key) { + const struct jbdocref *ref = key; + return wyhash32(key, sizeof(ref), 0xd31c3939); +} + +iwrc ejdb_rename_collection(struct ejdb *db, const char *coll, const char *new_coll) { if (!coll || !new_coll) { return IW_ERROR_INVALID_ARGS; } @@ -1645,39 +1643,35 @@ iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new_coll) { if (db->oflags & IWKV_RDONLY) { return IW_ERROR_READONLY; } - IWKV_val key, val; - JBL nmeta = 0, jbv = 0; - char keybuf[JBNUMBUF_SIZE + sizeof(KEY_PREFIX_COLLMETA)]; + struct iwkv_val key, val; + struct jbl *nmeta = 0, *jbv = 0; + char keybuf[IWNUMBUF_SIZE + sizeof(KEY_PREFIX_COLLMETA)]; API_WLOCK(db, rci); - khiter_t k = kh_get(JBCOLLM, db->mcolls, coll); - if (k == kh_end(db->mcolls)) { + struct jbcoll *jbc = iwhmap_get(db->mcolls, coll); + if (!jbc) { rc = EJDB_ERROR_COLLECTION_NOT_FOUND; goto finish; } - khiter_t k2 = kh_get(JBCOLLM, db->mcolls, new_coll); - if (k2 != kh_end(db->mcolls)) { + + if (iwhmap_get(db->mcolls, new_coll)) { rc = EJDB_ERROR_TARGET_COLLECTION_EXISTS; goto finish; } - JBCOLL jbc = kh_value(db->mcolls, k); - - rc = jbl_create_empty_object(&nmeta); - RCGO(rc, finish); - + RCC(rc, finish, jbl_create_empty_object(&nmeta)); if (!binn_object_set_str(&nmeta->bn, "name", new_coll)) { rc = JBL_ERROR_CREATION; goto finish; } + if (!binn_object_set_uint32(&nmeta->bn, "id", jbc->dbid)) { rc = JBL_ERROR_CREATION; goto finish; } - rc = jbl_as_buf(nmeta, &val.data, &val.size); - RCGO(rc, finish); + RCC(rc, finish, jbl_as_buf(nmeta, &val.data, &val.size)); key.size = snprintf(keybuf, sizeof(keybuf), KEY_PREFIX_COLLMETA "%u", jbc->dbid); if (key.size >= sizeof(keybuf)) { rc = IW_ERROR_OVERFLOW; @@ -1685,22 +1679,10 @@ iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new_coll) { } key.data = keybuf; - rc = jbl_at(nmeta, "/name", &jbv); - RCGO(rc, finish); - + RCC(rc, finish, jbl_at(nmeta, "/name", &jbv)); const char *new_name = jbl_get_str(jbv); - - rc = iwkv_put(db->metadb, &key, &val, IWKV_SYNC); - RCGO(rc, finish); - - kh_del(JBCOLLM, db->mcolls, k); - k2 = kh_put(JBCOLLM, db->mcolls, new_name, &rci); - if (rci != -1) { - kh_value(db->mcolls, k2) = jbc; - } else { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - goto finish; - } + RCC(rc, finish, iwkv_put(db->metadb, &key, &val, IWKV_SYNC)); + RCC(rc, finish, iwhmap_rename(db->mcolls, coll, (void*) new_name)); jbc->name = new_name; jbl_destroy(&jbc->meta); @@ -1719,10 +1701,10 @@ iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new_coll) { return rc; } -iwrc ejdb_get_meta(EJDB db, JBL *jblp) { +iwrc ejdb_get_meta(struct ejdb *db, struct jbl **jblp) { int rci; *jblp = 0; - JBL jbl; + struct jbl *jbl; iwrc rc = jbl_create_empty_object(&jbl); RCRET(rc); binn *clist = 0; @@ -1744,14 +1726,14 @@ iwrc ejdb_get_meta(EJDB db, JBL *jblp) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; } - for (khiter_t k = kh_begin(db->mcolls); k != kh_end(db->mcolls); ++k) { - if (!kh_exist(db->mcolls, k)) { - continue; - } - JBCOLL jbc = kh_val(db->mcolls, k); - rc = _jb_coll_add_meta_lr(jbc, clist); - RCGO(rc, finish); + + struct iwhmap_iter iter; + iwhmap_iter_init(db->mcolls, &iter); + while (iwhmap_iter_next(&iter)) { + struct jbcoll *jbc = (void*) iter.val; + RCC(rc, finish, _jb_coll_add_meta_lr(jbc, clist)); } + if (!binn_object_set_list(&jbl->bn, "collections", clist)) { rc = JBL_ERROR_CREATION; goto finish; @@ -1772,12 +1754,12 @@ iwrc ejdb_get_meta(EJDB db, JBL *jblp) { return rc; } -iwrc ejdb_online_backup(EJDB db, uint64_t *ts, const char *target_file) { +iwrc ejdb_online_backup(struct ejdb *db, uint64_t *ts, const char *target_file) { ENSURE_OPEN(db); return iwkv_online_backup(db->iwkv, ts, target_file); } -iwrc ejdb_get_iwkv(EJDB db, IWKV *kvp) { +iwrc ejdb_get_iwkv(struct ejdb *db, IWKV *kvp) { if (!db || !kvp) { return IW_ERROR_INVALID_ARGS; } @@ -1785,7 +1767,13 @@ iwrc ejdb_get_iwkv(EJDB db, IWKV *kvp) { return 0; } -iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { +static void _mcolls_map_entry_free(void *key, void *val) { + if (val) { + _jb_coll_release(val); + } +} + +iwrc ejdb_open(const struct ejdb_opts *_opts, struct ejdb **ejdbp) { *ejdbp = 0; int rci; iwrc rc = ejdb_init(); @@ -1794,7 +1782,7 @@ iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { return IW_ERROR_INVALID_ARGS; } - EJDB db = calloc(1, sizeof(*db)); + struct ejdb *db = calloc(1, sizeof(*db)); if (!db) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } @@ -1812,7 +1800,7 @@ iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { if (db->opts.document_buffer_sz < 16 * 1024) { // Min 16Kb db->opts.document_buffer_sz = 16 * 1024; } - EJDB_HTTP *http = &db->opts.http; + struct ejdb_http *http = &db->opts.http; if (http->bind) { http->bind = strdup(http->bind); } @@ -1827,7 +1815,7 @@ iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { pthread_rwlockattr_t attr; pthread_rwlockattr_init(&attr); #if defined __linux__ && (defined __USE_UNIX98 || defined __USE_XOPEN2K) - pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_READER_NP); #endif rci = pthread_rwlock_init(&db->rwl, &attr); if (rci) { @@ -1835,38 +1823,31 @@ iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { free(db); return rc; } - db->mcolls = kh_init(JBCOLLM); - if (!db->mcolls) { - rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci); - goto finish; - } + RCB(finish, db->mcolls = iwhmap_create_str(_mcolls_map_entry_free)); - IWKV_OPTS kvopts; + struct iwkv_opts kvopts; memcpy(&kvopts, &db->opts.kv, sizeof(db->opts.kv)); kvopts.wal.enabled = !db->opts.no_wal; kvopts.wal.wal_lock_interceptor = _jb_wal_lock_interceptor; kvopts.wal.wal_lock_interceptor_opaque = db; - rc = iwkv_open(&kvopts, &db->iwkv); - RCGO(rc, finish); + RCC(rc, finish, iwkv_open(&kvopts, &db->iwkv)); db->oflags = kvopts.oflags; - rc = _jb_db_meta_load(db); - RCGO(rc, finish); + RCC(rc, finish, _jb_db_meta_load(db)); if (db->opts.http.enabled) { // Maximum WS/HTTP API body size. Default: 64Mb, Min: 512K if (!db->opts.http.max_body_size) { - db->opts.http.max_body_size = 64 * 1024 * 1024; - } else if (db->opts.http.max_body_size < 512 * 1024) { - db->opts.http.max_body_size = 512 * 1024; + db->opts.http.max_body_size = 64UL * 1024 * 1024; + } else if (db->opts.http.max_body_size < 512UL * 1024) { + db->opts.http.max_body_size = 512UL * 1024; } } #ifdef JB_HTTP if (db->opts.http.enabled && !db->opts.http.blocking) { - rc = jbr_start(db, &db->opts, &db->jbr); - RCGO(rc, finish); + RCC(rc, finish, jbr_start(db, &db->opts, &db->jbr)); } #endif @@ -1885,11 +1866,11 @@ iwrc ejdb_open(const EJDB_OPTS *_opts, EJDB *ejdbp) { return rc; } -iwrc ejdb_close(EJDB *ejdbp) { +iwrc ejdb_close(struct ejdb **ejdbp) { if (!ejdbp || !*ejdbp) { return IW_ERROR_INVALID_ARGS; } - EJDB db = *ejdbp; + struct ejdb *db = *ejdbp; if (!__sync_bool_compare_and_swap(&db->open, 1, 0)) { iwlog_error2("Database is closed already"); return IW_ERROR_INVALID_STATE; @@ -1898,11 +1879,11 @@ iwrc ejdb_close(EJDB *ejdbp) { return rc; } -const char *ejdb_git_revision(void) { +const char* ejdb_git_revision(void) { return EJDB2_GIT_REVISION; } -const char *ejdb_version_full(void) { +const char* ejdb_version_full(void) { return EJDB2_VERSION; } @@ -1918,7 +1899,7 @@ unsigned int ejdb_version_patch(void) { return EJDB2_VERSION_PATCH; } -static const char *_ejdb_ecodefn(locale_t locale, uint32_t ecode) { +static const char* _ejdb_ecodefn(locale_t locale, uint32_t ecode) { if (!((ecode > _EJDB_ERROR_START) && (ecode < _EJDB_ERROR_END))) { return 0; } @@ -1941,6 +1922,8 @@ static const char *_ejdb_ecodefn(locale_t locale, uint32_t ecode) { return "Target collection exists (EJDB_ERROR_TARGET_COLLECTION_EXISTS)"; case EJDB_ERROR_PATCH_JSON_NOT_OBJECT: return "Patch JSON must be an object (map) (EJDB_ERROR_PATCH_JSON_NOT_OBJECT)"; + default: + break; } return 0; } diff --git a/src/ejdb2.h b/src/ejdb2.h.in similarity index 75% rename from src/ejdb2.h rename to src/ejdb2.h.in index bd7bfeee6..946a493b5 100644 --- a/src/ejdb2.h +++ b/src/ejdb2.h.in @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,11 +28,14 @@ * SOFTWARE. *************************************************************************************************/ -#include +#ifndef IW_BLOCKS +#cmakedefine IW_BLOCKS +#endif + #include "jql.h" -#include "jbl.h" +#include -IW_EXTERN_C_START +IW_EXTERN_C_START; /** * @brief ejdb2 initialization routine. @@ -83,13 +86,13 @@ typedef uint8_t ejdb_idx_mode_t; /** * @brief Database handler. */ -struct _EJDB; -typedef struct _EJDB*EJDB; +struct ejdb; +typedef struct ejdb*EJDB; /** * @brief EJDB HTTP/Websocket Server options. */ -typedef struct _EJDB_HTTP { +typedef struct ejdb_http { bool enabled; /**< If HTTP/Websocket endpoint enabled. Default: false */ int port; /**< Listen port number, required */ const char *bind; /**< Listen IP/host. Default: `localhost` */ @@ -99,45 +102,44 @@ typedef struct _EJDB_HTTP { Otherwise HTTP server will be started in background. */ bool read_anon; /**< Allow anonymous read-only database access */ size_t max_body_size; /**< Maximum WS/HTTP API body size. Default: 64Mb, Min: 512K */ - bool cors; /**< Allow CORS */ + bool cors; /**< Allow CORS */ + const char *ssl_private_key; /**< Path to TLS 1.2 private key PEM */ + const char *ssl_certs; /**< Path to TLS 1.2 certificates */ } EJDB_HTTP; /** * @brief EJDB open options. */ -typedef struct _EJDB_OPTS { - IWKV_OPTS kv; /**< IWKV storage options. @see iwkv.h */ - EJDB_HTTP http; /**< HTTP/Websocket server options */ - bool no_wal; /**< Do not use write-ahead-log. Default: false */ - uint32_t sort_buffer_sz; /**< Max sorting buffer size. If exceeded an overflow temp file for sorted data will - created. - Default 16Mb, min: 1Mb */ - uint32_t document_buffer_sz; /**< Initial size of buffer in bytes used to process/store document during query - execution. - Default 64Kb, min: 16Kb */ +typedef struct ejdb_opts { + struct iwkv_opts kv; /**< IWKV storage options. @see iwkv.h */ + struct ejdb_http http; /**< HTTP/Websocket server options */ + bool no_wal; /**< Do not use write-ahead-log. Default: false */ + uint32_t sort_buffer_sz; /**< Max sorting buffer size. If exceeded an overflow temp file for sorted data will + created. + Default 16Mb, min: 1Mb */ + uint32_t document_buffer_sz; /**< Initial size of sort buffer in bytes used to process/store document during query + execution. Default 64Kb, min: 16Kb */ } EJDB_OPTS; /** * @brief Document representation as result of query execution. * @see ejdb_exec() */ -typedef struct _EJDB_DOC { - int64_t id; /**< Document ID. Not zero. */ - JBL raw; /**< JSON document in compact binary form. - Based on [Binn](https://github.com/liteserver/binn) format. - Not zero. */ - JBL_NODE node; /**< JSON document as in-memory tree. Not zero only if query has `apply` or `projection` +typedef struct ejdb_doc { + int64_t id; /**< Document ID. Not zero. */ + struct jbl *raw; /**< JSON document in compact binary form. + Based on [Binn](https://github.com/liteserver/binn) format. Not zero. */ + struct jbl_node *node; /**< JSON document as in-memory tree. Not zero only if query has `apply` or `projection` parts. + @warning The lifespan of @ref EJDB_DOC.node will be valid only during the call of + @ref EJDB_EXEC_VISITOR + It is true in all cases EXCEPT: + - @ref EJDB_EXEC.pool is not set by `ejdb_exec()` caller + - One of `ejdb_list()` methods used */ - @warning The lifespan of @ref EJDB_DOC.node will be valid only during the call of - @ref EJDB_EXEC_VISITOR - It is true in all cases EXCEPT: - - @ref EJDB_EXEC.pool is not set by `ejdb_exec()` caller - - One of `ejdb_list()` methods used */ - - struct _EJDB_DOC *next; /**< Reference to next document in result list or zero. + struct ejdb_doc *next; /**< Reference to next document in result list or zero. Makes sense only for `ejdb_list()` calls. */ - struct _EJDB_DOC *prev; /**< Reference to the previous document in result list or zero. + struct ejdb_doc *prev; /**< Reference to the previous document in result list or zero. Makes sense only for `ejdb_list()` calls. */ } *EJDB_DOC; @@ -148,14 +150,14 @@ typedef struct _EJDB_DOC { * @warning Getting result of query as list can be very memory consuming for large collections. * Consider use of `ejdb_exec()` with visitor or set `limit` for query. */ -typedef struct _EJDB_LIST { - EJDB db; /**< EJDB storage used for query execution. Not zero. */ - JQL q; /**< Query executed. Not zero. */ - EJDB_DOC first; /**< First document in result list. Zero if result set is empty. */ - IWPOOL *pool; /**< Memory pool used to store list of documents */ +typedef struct ejdb_list { + struct ejdb *db; /**< EJDB storage used for query execution. Not zero. */ + struct jql *q; /**< Query executed. Not zero. */ + struct ejdb_doc *first; /**< First document in result list. Zero if result set is empty. */ + struct iwpool *pool; /**< Memory pool used to store list of documents */ } *EJDB_LIST; -struct _EJDB_EXEC; +struct ejdb_exec; /** * @brief Visitor for matched documents during query execution. @@ -165,24 +167,24 @@ struct _EJDB_EXEC; * processing you need to copy it. * @param step [out] Move forward cursor to given number of steps, `1` by default. */ -typedef iwrc (*EJDB_EXEC_VISITOR)(struct _EJDB_EXEC *ctx, EJDB_DOC doc, int64_t *step); +typedef iwrc (*ejdb_exec_visitor)(struct ejdb_exec *ctx, struct ejdb_doc *doc, int64_t *step); /** * @brief Query execution context. * Passed to `ejdb_exec()` to execute database query. */ -typedef struct _EJDB_EXEC { - EJDB db; /**< EJDB database object. Required. */ - JQL q; /**< Query object to be executed. Created by `jql_create()` Required. */ - EJDB_EXEC_VISITOR visitor; /**< Optional visitor to handle documents in result set. */ - void *opaque; /**< Optional user data passed to visitor functions. */ - int64_t skip; /**< Number of records to skip. Takes precedence over `skip` encoded in query. */ - int64_t limit; /**< Result set size limitation. Zero means no limitations. Takes precedence over `limit` - encoded in query. */ - int64_t cnt; /**< Number of result documents processed by `visitor` */ - IWXSTR *log; /**< Optional query execution log buffer. If set major query execution/index selection - steps will be logged into */ - IWPOOL *pool; /**< Optional pool which can be used in query apply */ +typedef struct ejdb_exec { + struct ejdb *db; /**< EJDB database object. Required. */ + struct jql *q; /**< Query object to be executed. Created by `jql_create()` Required. */ + ejdb_exec_visitor visitor; /**< Optional visitor to handle documents in result set. */ + void *opaque; /**< Optional user data passed to visitor functions. */ + int64_t skip; /**< Number of records to skip. Takes precedence over `skip` encoded in query. */ + int64_t limit; /**< Result set size limitation. Zero means no limitations. Takes precedence over `limit` + encoded in query. */ + int64_t cnt; /**< Number of result documents processed by `visitor` */ + struct iwxstr *log; /**< Optional query execution log buffer. If set major query execution/index selection + steps will be logged into */ + struct iwpool *pool; /**< Optional pool which can be used in query apply */ } EJDB_EXEC; /** @@ -193,16 +195,18 @@ typedef struct _EJDB_EXEC { * @param opts Operating options. Can be stack allocated or disposed after `ejdb_open()` call. * @param [out] ejdbp EJDB storage handle pointer as result. */ -IW_EXPORT WUR iwrc ejdb_open(const EJDB_OPTS *opts, EJDB *ejdbp); +IW_EXPORT WUR iwrc ejdb_open(const struct ejdb_opts *opts, struct ejdb **ejdbp); /** * @brief Closes storage and frees up all resources. - * @param [in,out] ejdbp Pointer to storage handle, will set to zero oncompletion. + * @warning Please ensure what all of application threads stopped + * calling ejdb.h and iowow API before ejdb_close(). * + * @param [in,out] ejdbp Pointer to storage handle, will set to zero oncompletion. * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_close(EJDB *ejdbp); +IW_EXPORT iwrc ejdb_close(struct ejdb **ejdbp); /** * @brief Executes a query. @@ -216,7 +220,7 @@ IW_EXPORT iwrc ejdb_close(EJDB *ejdbp); * * @code {.c} * - * JQL q; + * struct jql *q; * iwrc rc = jql_create(&q, "mycollection", "/[firstName=?]"); * RCRET(rc); * @@ -241,7 +245,23 @@ IW_EXPORT iwrc ejdb_close(EJDB *ejdbp); * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_exec(EJDB_EXEC *ux); +IW_EXPORT WUR iwrc ejdb_exec(struct ejdb_exec *ux); + +#ifdef IW_BLOCKS + +iwrc ejdb_visit_block(struct ejdb *db, struct jql *q, bool (^visitor)(struct ejdb_doc*)); + +struct ejdb_visit_block { + struct ejdb *db; + struct jql *q; + struct iwpool *pool; ///< Optional pool used for doc objects allocations. + void *user_data; + unsigned num_visits; +}; + +iwrc ejdb_visit_block2(struct ejdb_visit_block *ctx, bool (^visitor)(struct ejdb_doc*)); + +#endif /** * @brief Executes a given query and builds a query result as linked list of documents. @@ -259,7 +279,9 @@ IW_EXPORT WUR iwrc ejdb_exec(EJDB_EXEC *ux); * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_list(EJDB db, JQL q, EJDB_DOC *first, int64_t limit, IWPOOL *pool); +IW_EXPORT WUR iwrc ejdb_list( + struct ejdb *db, struct jql *q, struct ejdb_doc **first, int64_t limit, + struct iwpool *pool); /** * @brief Executes a given query `q` then returns `count` of matched documents. @@ -270,7 +292,7 @@ IW_EXPORT WUR iwrc ejdb_list(EJDB db, JQL q, EJDB_DOC *first, int64_t limit, IWP * @param limit Limit of matched rows. Makes sense for update queries. * */ -IW_EXPORT WUR iwrc ejdb_count(EJDB db, JQL q, int64_t *count, int64_t limit); +IW_EXPORT WUR iwrc ejdb_count(struct ejdb *db, struct jql *q, int64_t *count, int64_t limit); /** * @brief Executes a given query `q` then returns `count` of matched documents. @@ -283,7 +305,7 @@ IW_EXPORT WUR iwrc ejdb_count(EJDB db, JQL q, int64_t *count, int64_t limit); * @param limit Limit of matched rows. Makes sense for update queries. * */ -IW_EXPORT WUR iwrc ejdb_count2(EJDB db, const char *coll, const char *q, int64_t *count, int64_t limit); +IW_EXPORT WUR iwrc ejdb_count2(struct ejdb *db, const char *coll, const char *q, int64_t *count, int64_t limit); /** * @brief Executes update query assuming that query object contains `apply` clause. @@ -292,7 +314,7 @@ IW_EXPORT WUR iwrc ejdb_count2(EJDB db, const char *coll, const char *q, int64_t * @param db Database handle. Not zero. * @param q Query object. Not zero. */ -IW_EXPORT WUR iwrc ejdb_update(EJDB db, JQL q); +IW_EXPORT WUR iwrc ejdb_update(struct ejdb *db, struct jql *q); /** * @brief Executes update query assuming that query object contains `apply` clause. @@ -303,7 +325,7 @@ IW_EXPORT WUR iwrc ejdb_update(EJDB db, JQL q); * Can be zero, in what collection name should be encoded in query. * @param q Query text. Not zero. */ -IW_EXPORT WUR iwrc ejdb_update2(EJDB db, const char *coll, const char *q); +IW_EXPORT WUR iwrc ejdb_update2(struct ejdb *db, const char *coll, const char *q); /** * @brief Executes a given `query` and builds a result as linked list of documents. @@ -323,7 +345,12 @@ IW_EXPORT WUR iwrc ejdb_update2(EJDB db, const char *coll, const char *q); * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_list2(EJDB db, const char *coll, const char *query, int64_t limit, EJDB_LIST *listp); +IW_EXPORT WUR iwrc ejdb_list2( + struct ejdb *db, + const char *coll, + const char *query, + int64_t limit, + struct ejdb_list **listp); /** * @brief Executes a given `query` and builds a result as linked list of documents. @@ -344,8 +371,8 @@ IW_EXPORT WUR iwrc ejdb_list2(EJDB db, const char *coll, const char *query, int6 * Any non zero error codes. */ IW_EXPORT WUR iwrc ejdb_list3( - EJDB db, const char *coll, const char *query, int64_t limit, - IWXSTR *log, EJDB_LIST *listp); + struct ejdb *db, const char *coll, const char *query, int64_t limit, + struct iwxstr *log, struct ejdb_list **listp); /** * @brief Executes a given query `q` and builds a result as linked list of documents (`listp`). @@ -364,7 +391,12 @@ IW_EXPORT WUR iwrc ejdb_list3( * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_list4(EJDB db, JQL q, int64_t limit, IWXSTR *log, EJDB_LIST *listp); +IW_EXPORT WUR iwrc ejdb_list4( + struct ejdb *db, + struct jql *q, + int64_t limit, + struct iwxstr *log, + struct ejdb_list **listp); /** * @brief Destroy query result set and set `listp` to zero. @@ -384,7 +416,7 @@ IW_EXPORT void ejdb_list_destroy(EJDB_LIST *listp); * `IWKV_ERROR_NOTFOUND` if document not found. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_patch(EJDB db, const char *coll, const char *patchjson, int64_t id); +IW_EXPORT WUR iwrc ejdb_patch(struct ejdb *db, const char *coll, const char *patchjson, int64_t id); /** * @brief Apply rfc6902/rfc7396 JSON patch to the document identified by `id`. @@ -398,7 +430,7 @@ IW_EXPORT WUR iwrc ejdb_patch(EJDB db, const char *coll, const char *patchjson, * `IWKV_ERROR_NOTFOUND` if document not found. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_patch_jbn(EJDB db, const char *coll, JBL_NODE patch, int64_t id); +IW_EXPORT WUR iwrc ejdb_patch_jbn(struct ejdb *db, const char *coll, struct jbl_node *patch, int64_t id); /** @@ -413,7 +445,7 @@ IW_EXPORT WUR iwrc ejdb_patch_jbn(EJDB db, const char *coll, JBL_NODE patch, int * `IWKV_ERROR_NOTFOUND` if document not found. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_patch_jbl(EJDB db, const char *coll, JBL patch, int64_t id); +IW_EXPORT WUR iwrc ejdb_patch_jbl(struct ejdb *db, const char *coll, struct jbl *patch, int64_t id); /** * @brief Apply JSON merge patch (rfc7396) to the document identified by `id` or @@ -426,7 +458,7 @@ IW_EXPORT WUR iwrc ejdb_patch_jbl(EJDB db, const char *coll, JBL patch, int64_t * @param id Document id. Not zero. * */ -IW_EXPORT WUR iwrc ejdb_merge_or_put(EJDB db, const char *coll, const char *patchjson, int64_t id); +IW_EXPORT WUR iwrc ejdb_merge_or_put(struct ejdb *db, const char *coll, const char *patchjson, int64_t id); /** * @brief Apply JSON merge patch (rfc7396) to the document identified by `id` or @@ -439,7 +471,7 @@ IW_EXPORT WUR iwrc ejdb_merge_or_put(EJDB db, const char *coll, const char *patc * @param id Document id. Not zero. * */ -IW_EXPORT WUR iwrc ejdb_merge_or_put_jbn(EJDB db, const char *coll, JBL_NODE patch, int64_t id); +IW_EXPORT WUR iwrc ejdb_merge_or_put_jbn(struct ejdb *db, const char *coll, JBL_NODE patch, int64_t id); /** * @brief Apply JSON merge patch (rfc7396) to the document identified by `id` or @@ -452,7 +484,7 @@ IW_EXPORT WUR iwrc ejdb_merge_or_put_jbn(EJDB db, const char *coll, JBL_NODE pat * @param id Document id. Not zero. * */ -IW_EXPORT WUR iwrc ejdb_merge_or_put_jbl(EJDB db, const char *coll, JBL patch, int64_t id); +IW_EXPORT WUR iwrc ejdb_merge_or_put_jbl(struct ejdb *db, const char *coll, JBL patch, int64_t id); /** * @brief Save a given `jbl` document under specified `id`. @@ -465,7 +497,7 @@ IW_EXPORT WUR iwrc ejdb_merge_or_put_jbl(EJDB db, const char *coll, JBL patch, i * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_put(EJDB db, const char *coll, JBL jbl, int64_t id); +IW_EXPORT WUR iwrc ejdb_put(struct ejdb *db, const char *coll, JBL jbl, int64_t id); /** * @brief Save a given `jbn` document under specified `id`. @@ -478,7 +510,7 @@ IW_EXPORT WUR iwrc ejdb_put(EJDB db, const char *coll, JBL jbl, int64_t id); * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_put_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t id); +IW_EXPORT WUR iwrc ejdb_put_jbn(struct ejdb *db, const char *coll, JBL_NODE jbn, int64_t id); /** * @brief Save a document into `coll` under new identifier. @@ -491,7 +523,7 @@ IW_EXPORT WUR iwrc ejdb_put_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_put_new(EJDB db, const char *coll, JBL jbl, int64_t *oid); +IW_EXPORT WUR iwrc ejdb_put_new(struct ejdb *db, const char *coll, JBL jbl, int64_t *oid); /** * @brief Save a document into `coll` under new identifier. @@ -504,7 +536,7 @@ IW_EXPORT WUR iwrc ejdb_put_new(EJDB db, const char *coll, JBL jbl, int64_t *oid * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_put_new_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t *id); +IW_EXPORT iwrc ejdb_put_new_jbn(struct ejdb *db, const char *coll, JBL_NODE jbn, int64_t *id); /** * @brief Retrieve document identified by given `id` from collection `coll`. @@ -520,7 +552,7 @@ IW_EXPORT iwrc ejdb_put_new_jbn(EJDB db, const char *coll, JBL_NODE jbn, int64_t * `IW_ERROR_NOT_EXISTS` if collection `coll` is not exists in db. * Any non zero error codes. */ -IW_EXPORT WUR iwrc ejdb_get(EJDB db, const char *coll, int64_t id, JBL *jblp); +IW_EXPORT WUR iwrc ejdb_get(struct ejdb *db, const char *coll, int64_t id, JBL *jblp); /** * @brief Remove document identified by given `id` from collection `coll`. @@ -533,7 +565,7 @@ IW_EXPORT WUR iwrc ejdb_get(EJDB db, const char *coll, int64_t id, JBL *jblp); * `IWKV_ERROR_NOTFOUND` if document not found. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_del(EJDB db, const char *coll, int64_t id); +IW_EXPORT iwrc ejdb_del(struct ejdb *db, const char *coll, int64_t id); /** * @brief Remove collection under the given name `coll`. @@ -545,7 +577,7 @@ IW_EXPORT iwrc ejdb_del(EJDB db, const char *coll, int64_t id); * Will return `0` if collection is not found. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_remove_collection(EJDB db, const char *coll); +IW_EXPORT iwrc ejdb_remove_collection(struct ejdb *db, const char *coll); /** * @brief Rename collection `coll` to `new_coll`. @@ -558,7 +590,7 @@ IW_EXPORT iwrc ejdb_remove_collection(EJDB db, const char *coll); * - `EJDB_ERROR_TARGET_COLLECTION_EXISTS` - if `new_coll` is exists already. * - Any other non zero error codes. */ -IW_EXPORT iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new_coll); +IW_EXPORT iwrc ejdb_rename_collection(struct ejdb *db, const char *coll, const char *new_coll); /** * @brief Create collection with given name if it has not existed before @@ -569,7 +601,7 @@ IW_EXPORT iwrc ejdb_rename_collection(EJDB db, const char *coll, const char *new * @return `0` on success. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_ensure_collection(EJDB db, const char *coll); +IW_EXPORT iwrc ejdb_ensure_collection(struct ejdb *db, const char *coll); /** * @brief Create index with specified parameters if it has not existed before. @@ -606,7 +638,7 @@ IW_EXPORT iwrc ejdb_ensure_collection(EJDB db, const char *coll); * Any non zero error codes. * */ -IW_EXPORT iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mode_t mode); +IW_EXPORT iwrc ejdb_ensure_index(struct ejdb *db, const char *coll, const char *path, ejdb_idx_mode_t mode); /** * @brief Remove index if it has existed before. @@ -620,7 +652,7 @@ IW_EXPORT iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ej * Will return `0` if collection is not found. * Any non zero error codes. */ -IW_EXPORT iwrc ejdb_remove_index(EJDB db, const char *coll, const char *path, ejdb_idx_mode_t mode); +IW_EXPORT iwrc ejdb_remove_index(struct ejdb *db, const char *coll, const char *path, ejdb_idx_mode_t mode); /** * @brief Returns JSON document describind database structure. @@ -656,7 +688,7 @@ IW_EXPORT iwrc ejdb_remove_index(EJDB db, const char *coll, const char *path, ej * @param [out] jblp JSON object describing ejdb storage. * Must be disposed by `jbl_destroy()` */ -IW_EXPORT iwrc ejdb_get_meta(EJDB db, JBL *jblp); +IW_EXPORT iwrc ejdb_get_meta(struct ejdb *db, struct jbl **jblp); /** * Creates an online database backup image and copies it into the specified `target_file`. @@ -675,7 +707,7 @@ IW_EXPORT iwrc ejdb_get_meta(EJDB db, JBL *jblp); * @param [out] ts Backup completion timestamp * @param target_file backup file path */ -IW_EXPORT iwrc ejdb_online_backup(EJDB db, uint64_t *ts, const char *target_file); +IW_EXPORT iwrc ejdb_online_backup(struct ejdb *db, uint64_t *ts, const char *target_file); /** * @brief Get access to underlying IWKV storage. @@ -684,17 +716,17 @@ IW_EXPORT iwrc ejdb_online_backup(EJDB db, uint64_t *ts, const char *target_file * @param db Database handle. Not zero. * @param [out] kvp Placeholder for IWKV storage. */ -IW_EXPORT iwrc ejdb_get_iwkv(EJDB db, IWKV *kvp); +IW_EXPORT iwrc ejdb_get_iwkv(struct ejdb *db, struct iwkv **kvp); /** * @brief Return `\0` terminated ejdb2 source GIT revision hash. */ -IW_EXPORT const char *ejdb_git_revision(void); +IW_EXPORT const char* ejdb_git_revision(void); /** * @brief Return `\0` terminated EJDB version string. */ -IW_EXPORT const char *ejdb_version_full(void); +IW_EXPORT const char* ejdb_version_full(void); /** * @brief Return major library version. @@ -711,5 +743,5 @@ IW_EXPORT unsigned int ejdb_version_minor(void); */ IW_EXPORT unsigned int ejdb_version_patch(void); -IW_EXTERN_C_END -#endif +IW_EXTERN_C_END; +#endif \ No newline at end of file diff --git a/src/ejdb2_internal.h b/src/ejdb2_internal.h index eb495c0d7..bfa389bb5 100644 --- a/src/ejdb2_internal.h +++ b/src/ejdb2_internal.h @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,130 +29,126 @@ *************************************************************************************************/ #include "ejdb2.h" -#include "jql.h" #ifdef JB_HTTP #include "jbr.h" #endif #include "jql_internal.h" -#include "jbl_internal.h" -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include +#include + #include #include #include #include -#include "khash.h" -#include "ejdb2cfg.h" -static_assert(JBNUMBUF_SIZE >= IWFTOA_BUFSIZE, "JBNUMBUF_SIZE >= IWFTOA_BUFSIZE"); +#include "ejdb2cfg.h" #define METADB_ID 1 #define NUMRECSDB_ID 2 // DB for number of records per index/collection #define KEY_PREFIX_COLLMETA "c." // Full key format: c. #define KEY_PREFIX_IDXMETA "i." // Full key format: i.. -#define ENSURE_OPEN(db_) \ - if (!(db_) || !((db_)->open)) { \ - iwlog_error2("Database is not open"); \ - return IW_ERROR_INVALID_STATE; \ - } +#define ENSURE_OPEN(db_) \ + if (!(db_) || !((db_)->open)) { \ + iwlog_error2("Database is not open"); \ + return IW_ERROR_INVALID_STATE; \ + } -#define API_RLOCK(db_, rci_) \ - ENSURE_OPEN(db_); \ - rci_ = pthread_rwlock_rdlock(&(db_)->rwl); \ - if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) +#define API_RLOCK(db_, rci_) \ + ENSURE_OPEN(db_); \ + rci_ = pthread_rwlock_rdlock(&(db_)->rwl); \ + if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) -#define API_WLOCK(db_, rci_) \ - ENSURE_OPEN(db_); \ - rci_ = pthread_rwlock_wrlock(&(db_)->rwl); \ - if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) +#define API_WLOCK(db_, rci_) \ + ENSURE_OPEN(db_); \ + rci_ = pthread_rwlock_wrlock(&(db_)->rwl); \ + if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) -#define API_WLOCK2(db_, rci_) \ - rci_ = pthread_rwlock_wrlock(&(db_)->rwl); \ - if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) +#define API_WLOCK2(db_, rci_) \ + rci_ = pthread_rwlock_wrlock(&(db_)->rwl); \ + if (rci_) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_) -#define API_UNLOCK(db_, rci_, rc_) \ - rci_ = pthread_rwlock_unlock(&(db_)->rwl); \ - if (rci_) IWRC(iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_), rc_) +#define API_UNLOCK(db_, rci_, rc_) \ + rci_ = pthread_rwlock_unlock(&(db_)->rwl); \ + if (rci_) IWRC(iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_), rc_) -#define API_COLL_UNLOCK(jbc_, rci_, rc_) \ - do { \ - rci_ = pthread_rwlock_unlock(&(jbc_)->rwl); \ - if (rci_) IWRC(iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_), rc_); \ - API_UNLOCK((jbc_)->db, rci_, rc_); \ - } while (0) +#define API_COLL_UNLOCK(jbc_, rci_, rc_) \ + do { \ + rci_ = pthread_rwlock_unlock(&(jbc_)->rwl); \ + if (rci_) IWRC(iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci_), rc_); \ + API_UNLOCK((jbc_)->db, rci_, rc_); \ + } while (0) -struct _JBIDX; -typedef struct _JBIDX*JBIDX; +struct jbidx; +typedef struct jbidx*JBIDX; /** Database collection */ -typedef struct _JBCOLL { - uint32_t dbid; /**< IWKV collection database ID */ - const char *name; /**< Collection name */ - IWDB cdb; /**< IWKV collection database */ - EJDB db; /**< Main database reference */ - JBL meta; /**< Collection meta object */ - JBIDX idx; /**< First index in chain */ - int64_t rnum; /**< Number of records stored in collection */ +typedef struct jbcoll { + uint32_t dbid; /**< IWKV collection database ID */ + const char *name; /**< Collection name */ + struct iwdb *cdb; /**< IWKV collection database */ + struct ejdb *db; /**< Main database reference */ + struct jbl *meta; /**< Collection meta object */ + struct jbidx *idx; /**< First index in chain */ + int64_t rnum; /**< Number of records stored in collection */ pthread_rwlock_t rwl; int64_t id_seq; } *JBCOLL; /** Database collection index */ -struct _JBIDX { - struct _JBIDX *next; /**< Next index in chain */ - int64_t rnum; /**< Number of records stored in index */ - JBCOLL jbc; /**< Owner document collection */ - JBL_PTR ptr; /**< Indexed JSON path poiner 0*/ - IWDB idb; /**< KV database for this index */ - uint32_t dbid; /**< IWKV collection database ID */ - ejdb_idx_mode_t mode; /**< Index mode/type mask */ - iwdb_flags_t idbf; /**< Index database flags */ +struct jbidx { + struct jbidx *next; /**< Next index in chain */ + int64_t rnum; /**< Number of records stored in index */ + struct jbcoll *jbc; /**< Owner document collection */ + JBL_PTR ptr; /**< Indexed JSON path poiner 0*/ + struct iwdb *idb; /**< KV database for this index */ + uint32_t dbid; /**< IWKV collection database ID */ + ejdb_idx_mode_t mode; /**< Index mode/type mask */ + iwdb_flags_t idbf; /**< Index database flags */ }; /** Pair: collection name, document id */ -struct _JBDOCREF { +struct jbdocref { int64_t id; const char *coll; }; -// -V:KHASH_MAP_INIT_STR:522 -KHASH_MAP_INIT_STR(JBCOLLM, JBCOLL) - -struct _EJDB { - IWKV iwkv; - IWDB metadb; - IWDB nrecdb; +struct ejdb { + struct iwkv *iwkv; + struct iwdb *metadb; + struct iwdb *nrecdb; #ifdef JB_HTTP - JBR jbr; + struct jbr *jbr; #endif - khash_t(JBCOLLM) * mcolls; - iwkv_openflags oflags; - pthread_rwlock_t rwl; /**< Main RWL */ - struct _EJDB_OPTS opts; - volatile bool open; + struct iwhmap *mcolls; + iwkv_openflags oflags; + pthread_rwlock_t rwl; /**< Main RWL */ + struct ejdb_opts opts; + volatile bool open; }; -struct _JBPHCTX { - int64_t id; - JBCOLL jbc; - JBL jbl; - IWKV_val oldval; +struct _jb_put_handler_ctx { + int64_t id; + struct jbcoll *jbc; + struct jbl *jbl; + struct iwkv_val oldval; }; -struct _JBEXEC; +struct jbexec; -typedef iwrc (*JB_SCAN_CONSUMER)( - struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, +typedef iwrc (*jb_scan_consumer)( + struct jbexec *ctx, struct iwkv_cursor *cur, int64_t id, int64_t *step, bool *matched, iwrc err); /** - * @brief Index can sorter consumer context + * @brief Index scan sorter consumer context */ -struct _JBSSC { +struct jbssc { iwrc rc; /**< RC code used for in `_jb_do_sorting` */ uint32_t *refs; /**< Document references array */ uint32_t refs_asz; /**< Document references array allocated size */ @@ -165,34 +161,36 @@ struct _JBSSC { bool sof_active; }; -struct _JBMIDX { - JBIDX idx; /**< Index matched this filter */ - JQP_FILTER *filter; /**< Query filter */ - JQP_EXPR *nexpr; /**< Filter node expression */ - JQP_EXPR *expr1; /**< Start index expression (optional) */ - JQP_EXPR *expr2; /**< End index expression (optional) */ - IWKV_cursor_op cursor_init; /**< Initial index cursor position (optional) */ - IWKV_cursor_op cursor_step; /**< Next index cursor step */ +struct jbmidx { + struct jbidx *idx; /**< Index matched this filter */ + struct jqp_filter *filter; /**< Query filter */ + struct jqp_expr *nexpr; /**< Filter node expression */ + struct jqp_expr *expr1; /**< Start index expression (optional) */ + struct jqp_expr *expr2; /**< End index expression (optional) */ + enum iwkv_cursor_op cursor_init; /**< Initial index cursor position (optional) */ + enum iwkv_cursor_op cursor_step; /**< Next index cursor step */ bool orderby_support; /**< Index supported first order-by clause */ }; -typedef struct _JBEXEC { - EJDB_EXEC *ux; /**< User defined context */ - JBCOLL jbc; /**< Collection */ +typedef struct jbexec { + struct ejdb_exec *ux; /**< User defined context */ + struct jbcoll *jbc; /**< Collection */ int64_t istep; - iwrc (*scanner)(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer); - uint8_t *jblbuf; /**< Buffer used to keep currently processed document */ - size_t jblbufsz; /**< Size of jblbuf allocated memory */ - bool sorting; /**< Resultset sorting needed */ - IWKV_cursor_op cursor_init; /**< Initial index cursor position (optional) */ - IWKV_cursor_op cursor_step; /**< Next index cursor step */ - struct _JBMIDX midx; /**< Index matching context */ - struct _JBSSC ssc; /**< Result set sorting context */ + iwrc (*scanner)( + struct jbexec *ctx, + jb_scan_consumer consumer); + uint8_t *jblbuf; /**< Buffer used to keep currently processed document */ + size_t jblbufsz; /**< Size of jblbuf allocated memory */ + bool sorting; /**< Resultset sorting needed */ + enum iwkv_cursor_op cursor_init; /**< Initial index cursor position (optional) */ + enum iwkv_cursor_op cursor_step; /**< Next index cursor step */ + struct jbmidx midx; /**< Index matching context */ + struct jbssc ssc; /**< Result set sorting context */ // JQL joned nodes cache - IWSTREE *proj_joined_nodes_cache; - IWPOOL *proj_joined_nodes_pool; + struct iwhmap *proj_joined_nodes_cache; + struct iwpool *proj_joined_nodes_pool; } JBEXEC; @@ -205,27 +203,39 @@ typedef uint8_t jb_coll_acquire_t; #define JB_IDX_EMPIRIC_MIN_INOP_ARRAY_SIZE 10 #define JB_IDX_EMPIRIC_MAX_INOP_ARRAY_RATIO 200 -void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]); -void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]); -void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]); - -iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *step, bool *matched, iwrc err); -iwrc jbi_sorter_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *step, bool *matched, iwrc err); -iwrc jbi_full_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer); -iwrc jbi_selection(JBEXEC *ctx); -iwrc jbi_pk_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer); -iwrc jbi_uniq_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer); -iwrc jbi_dup_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer); -bool jbi_node_expr_matched(JQP_AUX *aux, JBIDX idx, IWKV_cursor cur, JQP_EXPR *expr, iwrc *rcp); - -iwrc jb_get(EJDB db, const char *coll, int64_t id, jb_coll_acquire_t acm, JBL *jblp); -iwrc jb_put(JBCOLL jbc, JBL jbl, int64_t id); -iwrc jb_del(JBCOLL jbc, JBL jbl, int64_t id); -iwrc jb_cursor_set(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl); -iwrc jb_cursor_del(JBCOLL jbc, IWKV_cursor cur, int64_t id, JBL jbl); - -iwrc jb_collection_join_resolver(int64_t id, const char *coll, JBL *out, JBEXEC *ctx); +void jbi_jbl_fill_ikey(struct jbidx *idx, struct jbl *jbv, struct iwkv_val *ikey, char numbuf[static IWNUMBUF_SIZE]); +void jbi_jqval_fill_ikey( + struct jbidx *idx, const struct jqval *jqval, struct iwkv_val *ikey, + char numbuf[static IWNUMBUF_SIZE]); +void jbi_node_fill_ikey( + struct jbidx *idx, struct jbl_node *node, struct iwkv_val *ikey, + char numbuf[static IWNUMBUF_SIZE]); + +iwrc jbi_consumer(struct jbexec *ctx, struct iwkv_cursor *cur, int64_t id, int64_t *step, bool *matched, iwrc err); +iwrc jbi_sorter_consumer( + struct jbexec *ctx, struct iwkv_cursor *cur, int64_t id, int64_t *step, bool *matched, + iwrc err); +iwrc jbi_full_scanner(struct jbexec *ctx, jb_scan_consumer consumer); +iwrc jbi_selection(struct jbexec *ctx); +iwrc jbi_pk_scanner(struct jbexec *ctx, jb_scan_consumer consumer); +iwrc jbi_uniq_scanner(struct jbexec *ctx, jb_scan_consumer consumer); +iwrc jbi_dup_scanner(struct jbexec *ctx, jb_scan_consumer consumer); +bool jbi_node_expr_matched( + struct jqp_aux *aux, + struct jbidx *idx, + struct iwkv_cursor *cur, + struct jqp_expr *expr, + iwrc *rcp); + +iwrc jb_get(struct ejdb *db, const char *coll, int64_t id, jb_coll_acquire_t acm, struct jbl **jblp); +iwrc jb_put(struct jbcoll *jbc, struct jbl *jbl, int64_t id); +iwrc jb_del(struct jbcoll *jbc, struct jbl *jbl, int64_t id); +iwrc jb_cursor_set(struct jbcoll *jbc, struct iwkv_cursor *cur, int64_t id, JBL jbl); +iwrc jb_cursor_del(struct jbcoll *jbc, struct iwkv_cursor *cur, int64_t id, JBL jbl); + +iwrc jb_collection_join_resolver(int64_t id, const char *coll, struct jbl **out, struct jbexec *ctx); int jb_proj_node_cache_cmp(const void *v1, const void *v2); void jb_proj_node_kvfree(void *key, void *val); +uint32_t jb_proj_node_hash(const void *key); #endif diff --git a/src/examples/example1.c b/src/examples/example1.c index 91181f8cf..b38b80866 100644 --- a/src/examples/example1.c +++ b/src/examples/example1.c @@ -1,11 +1,11 @@ /// Sample records put/query example #include -#define CHECK(rc_) \ - if (rc_) { \ - iwlog_ecode_error3(rc_); \ - return 1; \ - } +#define CHECK(rc_) \ + if (rc_) { \ + iwlog_ecode_error3(rc_); \ + return 1; \ + } static iwrc documents_visitor(EJDB_EXEC *ctx, const EJDB_DOC doc, int64_t *step) { // Print document to stderr @@ -13,10 +13,9 @@ static iwrc documents_visitor(EJDB_EXEC *ctx, const EJDB_DOC doc, int64_t *step) } int main() { - EJDB_OPTS opts = { - .kv = { - .path = "example.db", + .kv = { + .path = "example.db", .oflags = IWKV_TRUNC } }; @@ -50,8 +49,8 @@ int main() { RCGO(rc, finish); EJDB_EXEC ux = { - .db = db, - .q = q, + .db = db, + .q = q, .visitor = documents_visitor }; diff --git a/src/jbi/jbi_consumer.c b/src/jbi/jbi_consumer.c index 4b2d070c0..8c3209f93 100644 --- a/src/jbi/jbi_consumer.c +++ b/src/jbi/jbi_consumer.c @@ -1,22 +1,22 @@ #include "ejdb2_internal.h" -iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *step, bool *matched, iwrc err) { +iwrc jbi_consumer(struct jbexec *ctx, struct iwkv_cursor *cur, int64_t id, int64_t *step, bool *matched, iwrc err) { if (!id) { // EOF scan return err; } iwrc rc; - struct _JBL jbl; + struct jbl jbl; size_t vsz = 0; - EJDB_EXEC *ux = ctx->ux; - IWPOOL *pool = ux->pool; + struct ejdb_exec *ux = ctx->ux; + struct iwpool *pool = ux->pool; start: { if (cur) { rc = iwkv_cursor_copy_val(cur, ctx->jblbuf, ctx->jblbufsz, &vsz); } else { - IWKV_val key = { + struct iwkv_val key = { .data = &id, .size = sizeof(id) }; @@ -37,6 +37,7 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste goto finish; } RCGO(rc, finish); + if (vsz > ctx->jblbufsz) { size_t nsize = MAX(vsz, ctx->jblbufsz * 2); void *nbuf = realloc(ctx->jblbuf, nsize); @@ -50,8 +51,7 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste } } - rc = jbl_from_buf_keep_onstack(&jbl, ctx->jblbuf, vsz); - RCGO(rc, finish); + RCC(rc, finish, jbl_from_buf_keep_onstack(&jbl, ctx->jblbuf, vsz)); rc = jql_matched(ux->q, &jbl, matched); if (rc || !*matched || (ux->skip && (ux->skip-- > 0))) { @@ -63,24 +63,23 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste ++ctx->istep; } if (!ctx->istep) { - JQL q = ux->q; + struct jql *q = ux->q; ctx->istep = 1; - struct JQP_AUX *aux = q->aux; - struct _EJDB_DOC doc = { - .id = id, + struct jqp_aux *aux = q->aux; + struct ejdb_doc doc = { + .id = id, .raw = &jbl }; if (aux->apply || aux->apply_placeholder || aux->projection) { - JBL_NODE root; + struct jbl_node *root; if (!pool) { - pool = iwpool_create(jbl.bn.size * 2); + pool = iwpool_create((size_t) jbl.bn.size * 2); if (!pool) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; } } - rc = jbl_to_node(&jbl, &root, true, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(&jbl, &root, true, pool)); doc.node = root; if (aux->qmode & JQP_QRY_APPLY_DEL) { if (cur) { @@ -89,11 +88,9 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste rc = jb_del(ctx->jbc, &jbl, id); } } else if (aux->apply || aux->apply_placeholder) { - struct _JBL sn = { 0 }; - rc = jql_apply(q, root, pool); - RCGO(rc, finish); - rc = _jbl_from_node(&sn, root); - RCGO(rc, finish); + struct jbl sn = { 0 }; + RCC(rc, finish, jql_apply(q, root, pool)); + RCC(rc, finish, _jbl_from_node(&sn, root)); if (cur) { rc = jb_cursor_set(ctx->jbc, cur, id, &sn); } else { @@ -103,8 +100,7 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste } RCGO(rc, finish); if (aux->projection) { - rc = jql_project(q, root, pool, ctx); - RCGO(rc, finish); + RCC(rc, finish, jql_project(q, root, pool, ctx)); } } else if (aux->qmode & JQP_QRY_APPLY_DEL) { if (cur) { @@ -117,8 +113,7 @@ iwrc jbi_consumer(struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, int64_t *ste if (!(aux->qmode & JQP_QRY_AGGREGATE)) { do { ctx->istep = 1; - rc = ux->visitor(ux, &doc, &ctx->istep); - RCGO(rc, finish); + RCC(rc, finish, ux->visitor(ux, &doc, &ctx->istep)); } while (ctx->istep == -1); } ++ux->cnt; diff --git a/src/jbi/jbi_dup_scanner.c b/src/jbi/jbi_dup_scanner.c index 309dcca65..881749ec0 100644 --- a/src/jbi/jbi_dup_scanner.c +++ b/src/jbi/jbi_dup_scanner.c @@ -1,13 +1,13 @@ #include "ejdb2_internal.h" -static iwrc _jbi_consume_eq(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_eq(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { iwrc rc; bool matched; IWKV_cursor cur; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; int64_t step = 1; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; JBIDX idx = midx->idx; IWKV_cursor_op cursor_reverse_step = IWKV_CURSOR_NEXT; midx->cursor_step = IWKV_CURSOR_PREV; @@ -33,14 +33,12 @@ static iwrc _jbi_consume_eq(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER } if (!step) { int64_t id; - rc = iwkv_cursor_is_matched_key(cur, &key, &matched, &id); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_is_matched_key(cur, &key, &matched, &id)); if (!matched) { break; } step = 1; - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); } } while (step && !(rc = iwkv_cursor_to(cur, step > 0 ? midx->cursor_step : cursor_reverse_step))); @@ -61,17 +59,17 @@ static int _jbi_cmp_jqval(const void *v1, const void *v2) { return jql_cmp_jqval_pair(jqv1, jqv2, &rc); } -static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_in_node(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { int i; int64_t id; bool matched; char jqvarrbuf[512]; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; iwrc rc = 0; int64_t step = 1; IWKV_cursor cur = 0; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; JBIDX idx = midx->idx; IWKV_val key = { .compound = INT64_MIN }; JBL_NODE nv = jqval->vnode->child; @@ -106,8 +104,7 @@ static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONS if (cur) { iwkv_cursor_close(&cur); } - rc = iwkv_cursor_open(idx->idb, &cur, IWKV_CURSOR_GE, &key); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_open(idx->idb, &cur, IWKV_CURSOR_GE, &key)); do { if (step > 0) { --step; @@ -115,14 +112,12 @@ static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONS ++step; } if (!step) { - rc = iwkv_cursor_is_matched_key(cur, &key, &matched, &id); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_is_matched_key(cur, &key, &matched, &id)); if (!matched) { break; } step = 1; - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); } } while (step && !(rc = iwkv_cursor_to(cur, IWKV_CURSOR_PREV))); // !!! only one direction } @@ -140,13 +135,13 @@ static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONS return consumer(ctx, 0, 0, 0, 0, rc); } -static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_scan(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { size_t sz; IWKV_cursor cur; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; int64_t step = 1, prev_id = 0; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; JBIDX idx = midx->idx; jqp_op_t expr1_op = midx->expr1->op->value; @@ -163,8 +158,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME key.compound = INT64_MAX; midx->cursor_init = IWKV_CURSOR_BEFORE_FIRST; midx->cursor_step = IWKV_CURSOR_NEXT; - rc = iwkv_cursor_open(idx->idb, &cur, midx->cursor_init, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_open(idx->idb, &cur, midx->cursor_init, 0)); if (!midx->expr2) { // Fail fast midx->expr2 = midx->expr1; } @@ -173,8 +167,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME } if (midx->cursor_init < IWKV_CURSOR_NEXT) { // IWKV_CURSOR_BEFORE_FIRST || IWKV_CURSOR_AFTER_LAST - rc = iwkv_cursor_to(cur, midx->cursor_step); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_to(cur, midx->cursor_step)); } IWKV_cursor_op cursor_reverse_step = (midx->cursor_step == IWKV_CURSOR_PREV) @@ -188,8 +181,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME if (!step) { int64_t id; bool matched = false; - rc = iwkv_cursor_copy_key(cur, 0, 0, &sz, &id); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_copy_key(cur, 0, 0, &sz, &id)); if ( midx->expr2 && !midx->expr2->prematched && !jbi_node_expr_matched(ctx->ux->q->aux, midx->idx, cur, midx->expr2, &rc)) { @@ -202,8 +194,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME RCGO(rc, finish); step = 1; if (id != prev_id) { - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); if (!midx->expr1->prematched && matched && (expr1_op != JQP_OP_PREFIX)) { // Further scan will always match main index expression midx->expr1->prematched = true; @@ -223,19 +214,18 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME return consumer(ctx, 0, 0, 0, 0, rc); } -static iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_noxpr_scan(struct jbexec *ctx, jb_scan_consumer consumer) { + iwrc rc; size_t sz; IWKV_cursor cur; int64_t step = 1, prev_id = 0; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; IWKV_cursor_op cursor_reverse_step = (midx->cursor_step == IWKV_CURSOR_PREV) ? IWKV_CURSOR_NEXT : IWKV_CURSOR_PREV; - iwrc rc = iwkv_cursor_open(midx->idx->idb, &cur, midx->cursor_init, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_open(midx->idx->idb, &cur, midx->cursor_init, 0)); if (midx->cursor_init < IWKV_CURSOR_NEXT) { // IWKV_CURSOR_BEFORE_FIRST || IWKV_CURSOR_AFTER_LAST - rc = iwkv_cursor_to(cur, midx->cursor_step); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_to(cur, midx->cursor_step)); } do { if (step > 0) { @@ -246,12 +236,10 @@ static iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consum if (!step) { int64_t id; bool matched; - rc = iwkv_cursor_copy_key(cur, 0, 0, &sz, &id); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_copy_key(cur, 0, 0, &sz, &id)); step = 1; if (id != prev_id) { - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); prev_id = step < 1 ? 0 : id; } } @@ -267,9 +255,9 @@ static iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consum return consumer(ctx, 0, 0, 0, 0, rc); } -iwrc jbi_dup_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +iwrc jbi_dup_scanner(struct jbexec *ctx, jb_scan_consumer consumer) { iwrc rc; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; if (!midx->expr1) { return _jbi_consume_noxpr_scan(ctx, consumer); } diff --git a/src/jbi/jbi_full_scanner.c b/src/jbi/jbi_full_scanner.c index 7e93a5238..c2bfd621f 100644 --- a/src/jbi/jbi_full_scanner.c +++ b/src/jbi/jbi_full_scanner.c @@ -1,6 +1,6 @@ #include "ejdb2_internal.h" -iwrc jbi_full_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +iwrc jbi_full_scanner(struct jbexec *ctx, jb_scan_consumer consumer) { bool matched; IWKV_cursor cur; int64_t step = 1; diff --git a/src/jbi/jbi_pk_scanner.c b/src/jbi/jbi_pk_scanner.c index b7a9bca02..5f1ffddaf 100644 --- a/src/jbi/jbi_pk_scanner.c +++ b/src/jbi/jbi_pk_scanner.c @@ -1,11 +1,11 @@ #include "ejdb2_internal.h" // Primary key scanner -iwrc jbi_pk_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +iwrc jbi_pk_scanner(struct jbexec *ctx, jb_scan_consumer consumer) { iwrc rc = 0; int64_t id, step; bool matched; - struct JQP_AUX *aux = ctx->ux->q->aux; + struct jqp_aux *aux = ctx->ux->q->aux; assert(aux->expr->flags & JQP_EXPR_NODE_FLAG_PK); JQP_EXPR_NODE_PK *pk = (void*) aux->expr; assert(pk->argument); diff --git a/src/jbi/jbi_selection.c b/src/jbi/jbi_selection.c index 83d241583..c61fbd147 100644 --- a/src/jbi/jbi_selection.c +++ b/src/jbi/jbi_selection.c @@ -2,7 +2,7 @@ #define JB_SOLID_EXPRNUM 127 -static void _jbi_print_index(struct _JBIDX *idx, IWXSTR *xstr) { +static void _jbi_print_index(struct jbidx *idx, IWXSTR *xstr) { int cnt = 0; ejdb_idx_mode_t m = idx->mode; if (m & EJDB_IDX_UNIQUE) { @@ -30,7 +30,7 @@ static void _jbi_print_index(struct _JBIDX *idx, IWXSTR *xstr) { if (cnt++) { iwxstr_cat2(xstr, "|"); } - iwxstr_printf(xstr, "%lld ", idx->rnum); + iwxstr_printf(xstr, "%" PRId64 " ", idx->rnum); jbl_ptr_serialize(idx->ptr, xstr); } @@ -57,7 +57,7 @@ static void _jbi_log_cursor_op(IWXSTR *xstr, IWKV_cursor_op op) { } } -static void _jbi_log_index_rules(IWXSTR *xstr, struct _JBMIDX *mctx) { +static void _jbi_log_index_rules(IWXSTR *xstr, struct jbmidx *mctx) { _jbi_print_index(mctx->idx, xstr); if (mctx->expr1) { iwxstr_cat2(xstr, " EXPR1: \'"); @@ -83,7 +83,7 @@ static void _jbi_log_index_rules(IWXSTR *xstr, struct _JBMIDX *mctx) { iwxstr_cat2(xstr, "\n"); } -IW_INLINE int _jbi_idx_expr_op_weight(struct _JBMIDX *midx) { +IW_INLINE int _jbi_idx_expr_op_weight(struct jbmidx *midx) { jqp_op_t op = midx->expr1->op->value; switch (op) { case JQP_OP_EQ: @@ -115,8 +115,8 @@ static bool _jbi_is_solid_node_expression(const JQP_NODE *n) { JQPUNIT *unit = n->value; for (const JQP_EXPR *expr = &unit->expr; expr; expr = expr->next) { if ( expr->op->negate - || (expr->join && (expr->join->negate || (expr->join->value == JQP_JOIN_OR) )) - || (expr->op->value == JQP_OP_RE) ) { + || (expr->join && (expr->join->negate || (expr->join->value == JQP_JOIN_OR))) + || (expr->op->value == JQP_OP_RE)) { // No negate conditions, No OR, No regexp return false; } @@ -129,7 +129,7 @@ static bool _jbi_is_solid_node_expression(const JQP_NODE *n) { return true; } -static iwrc _jbi_compute_index_rules(JBEXEC *ctx, struct _JBMIDX *mctx) { +static iwrc _jbi_compute_index_rules(JBEXEC *ctx, struct jbmidx *mctx) { JQP_EXPR *expr = mctx->nexpr; // Node expression if (!expr) { return 0; @@ -154,10 +154,10 @@ static iwrc _jbi_compute_index_rules(JBEXEC *ctx, struct _JBMIDX *mctx) { continue; } int vcnt = 0; - for (JBL_NODE n = rv->vnode->child; n; n = n->next, ++vcnt) ; + for (JBL_NODE n = rv->vnode->child; n; n = n->next, ++vcnt); if ( (vcnt > JB_IDX_EMPIRIC_MIN_INOP_ARRAY_SIZE) && ( (vcnt > JB_IDX_EMPIRIC_MAX_INOP_ARRAY_SIZE) - || (mctx->idx->rnum < rv->vbinn->count * JB_IDX_EMPIRIC_MAX_INOP_ARRAY_RATIO) )) { + || (mctx->idx->rnum < (int64_t) rv->vbinn->count * JB_IDX_EMPIRIC_MAX_INOP_ARRAY_RATIO))) { // No index for large IN array | small collection size continue; } @@ -263,18 +263,18 @@ static iwrc _jbi_compute_index_rules(JBEXEC *ctx, struct _JBMIDX *mctx) { return 0; } +// NOLINTNEXTLINE static iwrc _jbi_collect_indexes( JBEXEC *ctx, - const struct JQP_EXPR_NODE *en, - struct _JBMIDX marr[static JB_SOLID_EXPRNUM], + const struct jqp_expr_node *en, + struct jbmidx marr[static JB_SOLID_EXPRNUM], size_t *snp) { - iwrc rc = 0; if (*snp >= JB_SOLID_EXPRNUM - 1) { return 0; } if (en->type == JQP_EXPR_NODE_TYPE) { - struct JQP_EXPR_NODE *cn = en->chain; + struct jqp_expr_node *cn = en->chain; for ( ; cn; cn = cn->next) { if (cn->join && (cn->join->value == JQP_JOIN_OR)) { return 0; @@ -304,12 +304,12 @@ static iwrc _jbi_collect_indexes( } } - struct JQP_AUX *aux = ctx->ux->q->aux; - struct _JBL_PTR *obp = aux->orderby_num ? aux->orderby_ptrs[0] : 0; + struct jqp_aux *aux = ctx->ux->q->aux; + struct jbl_ptr *obp = aux->orderby_num ? aux->orderby_ptrs[0] : 0; - for (struct _JBIDX *idx = ctx->jbc->idx; idx && *snp < JB_SOLID_EXPRNUM; idx = idx->next) { - struct _JBMIDX mctx = { .filter = f }; - struct _JBL_PTR *ptr = idx->ptr; + for (struct jbidx *idx = ctx->jbc->idx; idx && *snp < JB_SOLID_EXPRNUM; idx = idx->next) { + struct jbmidx mctx = { .filter = f }; + struct jbl_ptr *ptr = idx->ptr; if (ptr->cnt > fnc) { continue; } @@ -369,8 +369,8 @@ static iwrc _jbi_collect_indexes( } static int _jbi_idx_cmp(const void *o1, const void *o2) { - struct _JBMIDX *d1 = (struct _JBMIDX*) o1; - struct _JBMIDX *d2 = (struct _JBMIDX*) o2; + struct jbmidx *d1 = (struct jbmidx*) o1; + struct jbmidx *d2 = (struct jbmidx*) o2; assert(d1 && d2); int w1 = _jbi_idx_expr_op_weight(d1); int w2 = _jbi_idx_expr_op_weight(d2); @@ -388,17 +388,17 @@ static int _jbi_idx_cmp(const void *o1, const void *o2) { return (d1->idx->ptr->cnt - d2->idx->ptr->cnt); } -static struct _JBIDX *_jbi_select_index_for_orderby(JBEXEC *ctx) { - struct JQP_AUX *aux = ctx->ux->q->aux; - struct _JBL_PTR *obp = aux->orderby_ptrs[0]; +static struct jbidx* _jbi_select_index_for_orderby(JBEXEC *ctx) { + struct jqp_aux *aux = ctx->ux->q->aux; + struct jbl_ptr *obp = aux->orderby_ptrs[0]; assert(obp); - for (struct _JBIDX *idx = ctx->jbc->idx; idx; idx = idx->next) { - struct _JBL_PTR *ptr = idx->ptr; + for (struct jbidx *idx = ctx->jbc->idx; idx; idx = idx->next) { + struct jbl_ptr *ptr = idx->ptr; if (obp->cnt != ptr->cnt) { continue; } int i = 0; - for ( ; i < obp->cnt && !strcmp(ptr->n[i], obp->n[i]); ++i) ; + for ( ; i < obp->cnt && !strcmp(ptr->n[i], obp->n[i]); ++i); if (i == obp->cnt) { memset(&ctx->midx, 0, sizeof(ctx->midx)); if (!(obp->op & 1)) { // Asc sort @@ -419,8 +419,8 @@ static struct _JBIDX *_jbi_select_index_for_orderby(JBEXEC *ctx) { iwrc jbi_selection(JBEXEC *ctx) { iwrc rc = 0; size_t snp = 0; - struct JQP_AUX *aux = ctx->ux->q->aux; - struct _JBMIDX fctx[JB_SOLID_EXPRNUM] = { 0 }; + struct jqp_aux *aux = ctx->ux->q->aux; + struct jbmidx fctx[JB_SOLID_EXPRNUM] = { 0 }; ctx->cursor_init = IWKV_CURSOR_BEFORE_FIRST; ctx->cursor_step = IWKV_CURSOR_NEXT; @@ -439,7 +439,7 @@ iwrc jbi_selection(JBEXEC *ctx) { if (snp) { // Index selected qsort(fctx, snp, sizeof(fctx[0]), _jbi_idx_cmp); memcpy(&ctx->midx, &fctx[0], sizeof(ctx->midx)); - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; jqp_op_t op = midx->expr1->op->value; if ((op == JQP_OP_EQ) || (op == JQP_OP_IN) || ((op == JQP_OP_GTE) && (ctx->cursor_init == IWKV_CURSOR_GE))) { midx->expr1->prematched = true; diff --git a/src/jbi/jbi_sorter_consumer.c b/src/jbi/jbi_sorter_consumer.c index 0066639c4..0ed10d250 100644 --- a/src/jbi/jbi_sorter_consumer.c +++ b/src/jbi/jbi_sorter_consumer.c @@ -1,8 +1,8 @@ #include "ejdb2_internal.h" #include "sort_r.h" -static void _jbi_scan_sorter_release(struct _JBEXEC *ctx) { - struct _JBSSC *ssc = &ctx->ssc; +static void _jbi_scan_sorter_release(struct jbexec *ctx) { + struct jbssc *ssc = &ctx->ssc; free(ssc->refs); if (ssc->sof_active) { ssc->sof.close(&ssc->sof); @@ -14,11 +14,12 @@ static void _jbi_scan_sorter_release(struct _JBEXEC *ctx) { static int _jbi_scan_sorter_cmp(const void *o1, const void *o2, void *op) { int rv = 0; + iwrc rc; uint32_t r1, r2; - struct _JBL d1, d2; - struct _JBEXEC *ctx = op; - struct _JBSSC *ssc = &ctx->ssc; - struct JQP_AUX *aux = ctx->ux->q->aux; + struct jbl d1, d2; + struct jbexec *ctx = op; + struct jbssc *ssc = &ctx->ssc; + struct jqp_aux *aux = ctx->ux->q->aux; uint8_t *p1, *p2; assert(aux->orderby_num > 0); @@ -28,14 +29,12 @@ static int _jbi_scan_sorter_cmp(const void *o1, const void *o2, void *op) { p1 = ssc->docs + r1 + sizeof(uint64_t) /*id*/; p2 = ssc->docs + r2 + sizeof(uint64_t) /*id*/; - iwrc rc = jbl_from_buf_keep_onstack2(&d1, p1); - RCGO(rc, finish); - rc = jbl_from_buf_keep_onstack2(&d2, p2); - RCGO(rc, finish); + RCC(rc, finish, jbl_from_buf_keep_onstack2(&d1, p1)); + RCC(rc, finish, jbl_from_buf_keep_onstack2(&d2, p2)); for (int i = 0; i < aux->orderby_num; ++i) { - struct _JBL v1 = { 0 }; - struct _JBL v2 = { 0 }; + struct jbl v1 = { 0 }; + struct jbl v2 = { 0 }; JBL_PTR ptr = aux->orderby_ptrs[i]; int desc = (ptr->op & 1) ? -1 : 1; // If `-1` do desc sorting _jbl_at(&d1, ptr, &v1); @@ -54,10 +53,10 @@ static int _jbi_scan_sorter_cmp(const void *o1, const void *o2, void *op) { return rv; } -static iwrc _jbi_scan_sorter_apply(IWPOOL *pool, struct _JBEXEC *ctx, JQL q, struct _EJDB_DOC *doc) { +static iwrc _jbi_scan_sorter_apply(IWPOOL *pool, struct jbexec *ctx, JQL q, struct ejdb_doc *doc) { JBL_NODE root; JBL jbl = doc->raw; - struct JQP_AUX *aux = q->aux; + struct jqp_aux *aux = q->aux; iwrc rc = jbl_to_node(jbl, &root, true, pool); RCRET(rc); doc->node = root; @@ -65,7 +64,7 @@ static iwrc _jbi_scan_sorter_apply(IWPOOL *pool, struct _JBEXEC *ctx, JQL q, str rc = jb_del(ctx->jbc, jbl, doc->id); RCRET(rc); } else if (aux->apply || aux->apply_placeholder) { - struct _JBL sn = { 0 }; + struct jbl sn = { 0 }; rc = jql_apply(q, root, pool); RCRET(rc); rc = _jbl_from_node(&sn, root); @@ -80,14 +79,14 @@ static iwrc _jbi_scan_sorter_apply(IWPOOL *pool, struct _JBEXEC *ctx, JQL q, str return rc; } -static iwrc _jbi_scan_sorter_do(struct _JBEXEC *ctx) { +static iwrc _jbi_scan_sorter_do(struct jbexec *ctx) { iwrc rc = 0; int64_t step = 1, id; - struct _JBL jbl; + struct jbl jbl; EJDB_EXEC *ux = ctx->ux; - struct _JBSSC *ssc = &ctx->ssc; + struct jbssc *ssc = &ctx->ssc; uint32_t rnum = ssc->refs_num; - struct JQP_AUX *aux = ux->q->aux; + struct jqp_aux *aux = ux->q->aux; IWPOOL *pool = ux->pool; if (rnum) { @@ -97,8 +96,7 @@ static iwrc _jbi_scan_sorter_do(struct _JBEXEC *ctx) { } if (!ssc->docs) { size_t sp; - rc = ssc->sof.probe_mmap(&ssc->sof, 0, &ssc->docs, &sp); - RCGO(rc, finish); + RCC(rc, finish, ssc->sof.probe_mmap(&ssc->sof, 0, &ssc->docs, &sp)); } sort_r(ssc->refs, rnum, sizeof(ssc->refs[0]), _jbi_scan_sorter_cmp, ctx); @@ -108,33 +106,33 @@ static iwrc _jbi_scan_sorter_do(struct _JBEXEC *ctx) { uint8_t *rp = ssc->docs + ssc->refs[i]; memcpy(&id, rp, sizeof(id)); rp += sizeof(id); - rc = jbl_from_buf_keep_onstack2(&jbl, rp); - RCGO(rc, finish); - struct _EJDB_DOC doc = { - .id = id, + RCC(rc, finish, jbl_from_buf_keep_onstack2(&jbl, rp)); + + struct ejdb_doc doc = { + .id = id, .raw = &jbl }; + if (aux->apply || aux->projection) { if (!pool) { - pool = iwpool_create(jbl.bn.size * 2); + pool = iwpool_create((size_t) jbl.bn.size * 2); if (!pool) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; } } - rc = _jbi_scan_sorter_apply(pool, ctx, ux->q, &doc); - RCGO(rc, finish); + RCC(rc, finish, _jbi_scan_sorter_apply(pool, ctx, ux->q, &doc)); } else if (aux->qmode & JQP_QRY_APPLY_DEL) { - rc = jb_del(ctx->jbc, &jbl, id); - RCGO(rc, finish); + RCC(rc, finish, jb_del(ctx->jbc, &jbl, id)); } + if (!(aux->qmode & JQP_QRY_AGGREGATE)) { do { step = 1; - rc = ux->visitor(ux, &doc, &step); - RCGO(rc, finish); + RCC(rc, finish, ux->visitor(ux, &doc, &step)); } while (step == -1); } + ++ux->cnt; i += step; if (pool != ux->pool) { @@ -154,13 +152,13 @@ static iwrc _jbi_scan_sorter_do(struct _JBEXEC *ctx) { return rc; } -static iwrc _jbi_scan_sorter_init(struct _JBSSC *ssc, off_t initial_size) { +static iwrc _jbi_scan_sorter_init(struct jbssc *ssc, off_t initial_size) { IWFS_EXT_OPTS opts = { .initial_size = initial_size, - .rspolicy = iw_exfile_szpolicy_fibo, - .file = { - .path = "jb-", - .omode = IWFS_OTMP | IWFS_OUNLINK + .rspolicy = iw_exfile_szpolicy_fibo, + .file = { + .path = "jb-", + .omode = IWFS_OTMP | IWFS_OUNLINK } }; iwrc rc = iwfs_exfile_open(&ssc->sof, &opts); @@ -173,7 +171,7 @@ static iwrc _jbi_scan_sorter_init(struct _JBSSC *ssc, off_t initial_size) { } iwrc jbi_sorter_consumer( - struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id, + struct jbexec *ctx, IWKV_cursor cur, int64_t id, int64_t *step, bool *matched, iwrc err) { if (!id) { // End of scan @@ -188,8 +186,8 @@ iwrc jbi_sorter_consumer( iwrc rc; size_t vsz = 0; - struct _JBL jbl; - struct _JBSSC *ssc = &ctx->ssc; + struct jbl jbl; + struct jbssc *ssc = &ctx->ssc; EJDB db = ctx->jbc->db; IWFS_EXT *sof = &ssc->sof; @@ -230,7 +228,7 @@ iwrc jbi_sorter_consumer( } if (!ssc->refs) { - ssc->refs_asz = 64 * 1024; // 64K + ssc->refs_asz = db->opts.document_buffer_sz; ssc->refs = malloc(db->opts.document_buffer_sz); if (!ssc->refs) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); diff --git a/src/jbi/jbi_uniq_scanner.c b/src/jbi/jbi_uniq_scanner.c index 5cc96b838..4b3c0609d 100644 --- a/src/jbi/jbi_uniq_scanner.c +++ b/src/jbi/jbi_uniq_scanner.c @@ -1,14 +1,14 @@ #include "ejdb2_internal.h" -static_assert(IW_VNUMBUFSZ <= JBNUMBUF_SIZE, "IW_VNUMBUFSZ <= JBNUMBUF_SIZE"); +static_assert(IW_VNUMBUFSZ <= IWNUMBUF_SIZE, "IW_VNUMBUFSZ <= JBNUMBUF_SIZE"); -static iwrc _jbi_consume_eq(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_eq(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { size_t sz; uint64_t id; int64_t step; bool matched; - struct _JBMIDX *midx = &ctx->midx; - char numbuf[JBNUMBUF_SIZE]; + struct jbmidx *midx = &ctx->midx; + char numbuf[IWNUMBUF_SIZE]; IWKV_val key; jbi_jqval_fill_ikey(midx->idx, jqval, &key, numbuf); @@ -28,17 +28,17 @@ static iwrc _jbi_consume_eq(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER return consumer(ctx, 0, 0, 0, 0, rc); } -static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_in_node(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { JQVAL jqv; size_t sz; uint64_t id; bool matched; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; iwrc rc = 0; int64_t step = 1; IWKV_val key; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; JBL_NODE nv = jqval->vnode->child; if (!nv) { @@ -67,8 +67,7 @@ static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONS if (!step) { IW_READVNUMBUF64_2(numbuf, id); step = 1; - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); } } while (step && (step > 0 ? (nv = nv->next) : (nv = nv->prev))); @@ -76,13 +75,13 @@ static iwrc _jbi_consume_in_node(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONS return consumer(ctx, 0, 0, 0, 0, rc); } -static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUMER consumer) { +static iwrc _jbi_consume_scan(struct jbexec *ctx, JQVAL *jqval, jb_scan_consumer consumer) { size_t sz; IWKV_cursor cur; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; int64_t step = 1; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; JBIDX idx = midx->idx; jqp_op_t expr1_op = midx->expr1->op->value; @@ -94,8 +93,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME iwkv_cursor_close(&cur); midx->cursor_init = IWKV_CURSOR_BEFORE_FIRST; midx->cursor_step = IWKV_CURSOR_NEXT; - rc = iwkv_cursor_open(idx->idb, &cur, midx->cursor_init, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_open(idx->idb, &cur, midx->cursor_init, 0)); if (!midx->expr2) { // Fail fast midx->expr2 = midx->expr1; } @@ -107,8 +105,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME ? IWKV_CURSOR_PREV : IWKV_CURSOR_NEXT; if (midx->cursor_init < IWKV_CURSOR_NEXT) { // IWKV_CURSOR_BEFORE_FIRST || IWKV_CURSOR_AFTER_LAST - rc = iwkv_cursor_to(cur, midx->cursor_step); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_to(cur, midx->cursor_step)); } do { if (step > 0) { @@ -119,8 +116,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME if (!step) { int64_t id; bool matched = false; - rc = iwkv_cursor_copy_val(cur, &numbuf, IW_VNUMBUFSZ, &sz); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_copy_val(cur, &numbuf, IW_VNUMBUFSZ, &sz)); if (sz > IW_VNUMBUFSZ) { rc = IWKV_ERROR_CORRUPTED; iwlog_ecode_error3(rc); @@ -139,8 +135,7 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME RCGO(rc, finish); step = 1; - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); if (!midx->expr1->prematched && matched && (expr1_op != JQP_OP_PREFIX)) { // Further scan will always match the main index expression midx->expr1->prematched = true; @@ -158,20 +153,19 @@ static iwrc _jbi_consume_scan(struct _JBEXEC *ctx, JQVAL *jqval, JB_SCAN_CONSUME return consumer(ctx, 0, 0, 0, 0, rc); } -iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +iwrc _jbi_consume_noxpr_scan(struct jbexec *ctx, jb_scan_consumer consumer) { + iwrc rc; size_t sz; IWKV_cursor cur; - char numbuf[JBNUMBUF_SIZE]; + char numbuf[IWNUMBUF_SIZE]; int64_t step = 1; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; IWKV_cursor_op cursor_reverse_step = (midx->cursor_step == IWKV_CURSOR_NEXT) ? IWKV_CURSOR_PREV : IWKV_CURSOR_NEXT; - iwrc rc = iwkv_cursor_open(midx->idx->idb, &cur, midx->cursor_init, 0); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_open(midx->idx->idb, &cur, midx->cursor_init, 0)); if (midx->cursor_init < IWKV_CURSOR_NEXT) { // IWKV_CURSOR_BEFORE_FIRST || IWKV_CURSOR_AFTER_LAST - rc = iwkv_cursor_to(cur, midx->cursor_step); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_to(cur, midx->cursor_step)); } do { if (step > 0) { @@ -182,8 +176,7 @@ iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { if (!step) { int64_t id; bool matched; - rc = iwkv_cursor_copy_val(cur, &numbuf, IW_VNUMBUFSZ, &sz); - RCGO(rc, finish); + RCC(rc, finish, iwkv_cursor_copy_val(cur, &numbuf, IW_VNUMBUFSZ, &sz)); if (sz > IW_VNUMBUFSZ) { rc = IWKV_ERROR_CORRUPTED; iwlog_ecode_error3(rc); @@ -192,8 +185,7 @@ iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { IW_READVNUMBUF64_2(numbuf, id); RCGO(rc, finish); step = 1; - rc = consumer(ctx, 0, id, &step, &matched, 0); - RCGO(rc, finish); + RCC(rc, finish, consumer(ctx, 0, id, &step, &matched, 0)); } } while (step && !(rc = iwkv_cursor_to(cur, step > 0 ? midx->cursor_step : cursor_reverse_step))); @@ -207,9 +199,9 @@ iwrc _jbi_consume_noxpr_scan(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { return consumer(ctx, 0, 0, 0, 0, rc); } -iwrc jbi_uniq_scanner(struct _JBEXEC *ctx, JB_SCAN_CONSUMER consumer) { +iwrc jbi_uniq_scanner(struct jbexec *ctx, jb_scan_consumer consumer) { iwrc rc; - struct _JBMIDX *midx = &ctx->midx; + struct jbmidx *midx = &ctx->midx; if (!midx->expr1) { return _jbi_consume_noxpr_scan(ctx, consumer); } diff --git a/src/jbi/jbi_util.c b/src/jbi/jbi_util.c index efa3ade50..6f800fa2c 100644 --- a/src/jbi/jbi_util.c +++ b/src/jbi/jbi_util.c @@ -1,11 +1,10 @@ #include "ejdb2_internal.h" -#include "convert.h" -#include +#include // --------------------------------------------------------------------------- // fixme: code duplication below -void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]) { +void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static IWNUMBUF_SIZE]) { int64_t *llv = (void*) numbuf; jbl_type_t jbvt = jbl_type(jbv); ejdb_idx_mode_t itype = (idx->mode & ~(EJDB_IDX_UNIQUE)); @@ -20,7 +19,7 @@ void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JB ikey->data = (void*) jbl_get_str(jbv); break; case JBV_I64: - ikey->size = (size_t) iwitoa(jbl_get_i64(jbv), numbuf, JBNUMBUF_SIZE); + ikey->size = (size_t) iwitoa(jbl_get_i64(jbv), numbuf, IWNUMBUF_SIZE); ikey->data = numbuf; break; case JBV_BOOL: @@ -33,7 +32,7 @@ void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JB } break; case JBV_F64: - jbi_ftoa(jbl_get_f64(jbv), numbuf, &ikey->size); + iwjson_ftoa(jbl_get_f64(jbv), numbuf, &ikey->size); ikey->data = numbuf; break; default: @@ -64,10 +63,10 @@ void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JB case JBV_F64: case JBV_I64: case JBV_BOOL: - jbi_ftoa(jbl_get_f64(jbv), numbuf, &ikey->size); + iwjson_ftoa(jbl_get_f64(jbv), numbuf, &ikey->size); break; case JBV_STR: - jbi_ftoa(iwatof(jbl_get_str(jbv)), numbuf, &ikey->size); + iwjson_ftoa(iwatof(jbl_get_str(jbv)), numbuf, &ikey->size); break; default: ikey->size = 0; // -V1048 @@ -80,7 +79,7 @@ void jbi_jbl_fill_ikey(JBIDX idx, JBL jbv, IWKV_val *ikey, char numbuf[static JB } } -void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]) { +void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char numbuf[static IWNUMBUF_SIZE]) { int64_t *llv = (void*) numbuf; ikey->size = 0; ikey->data = numbuf; @@ -95,7 +94,7 @@ void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char num ikey->data = (void*) jqval->vstr; break; case JQVAL_I64: - ikey->size = (size_t) iwitoa(jqval->vi64, numbuf, JBNUMBUF_SIZE); + ikey->size = (size_t) iwitoa(jqval->vi64, numbuf, IWNUMBUF_SIZE); break; case JQVAL_BOOL: if (jqval->vbool) { @@ -107,7 +106,7 @@ void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char num } break; case JQVAL_F64: - jbi_ftoa(jqval->vf64, numbuf, &ikey->size); + iwjson_ftoa(jqval->vf64, numbuf, &ikey->size); break; default: break; @@ -136,16 +135,16 @@ void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char num case EJDB_IDX_F64: switch (jqvt) { case JQVAL_F64: - jbi_ftoa(jqval->vf64, numbuf, &ikey->size); + iwjson_ftoa(jqval->vf64, numbuf, &ikey->size); break; case JQVAL_I64: - jbi_ftoa(jqval->vi64, numbuf, &ikey->size); + iwjson_ftoa(jqval->vi64, numbuf, &ikey->size); break; case JQVAL_BOOL: - jbi_ftoa(jqval->vbool, numbuf, &ikey->size); + iwjson_ftoa(jqval->vbool, numbuf, &ikey->size); break; case JQVAL_STR: - jbi_ftoa(iwatof(jqval->vstr), numbuf, &ikey->size); + iwjson_ftoa(iwatof(jqval->vstr), numbuf, &ikey->size); break; default: ikey->data = 0; @@ -157,7 +156,7 @@ void jbi_jqval_fill_ikey(JBIDX idx, const JQVAL *jqval, IWKV_val *ikey, char num } } -void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[static JBNUMBUF_SIZE]) { +void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[static IWNUMBUF_SIZE]) { int64_t *llv = (void*) numbuf; ikey->size = 0; ikey->data = numbuf; @@ -172,7 +171,7 @@ void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[st ikey->data = (void*) node->vptr; break; case JBV_I64: - ikey->size = (size_t) iwitoa(node->vi64, numbuf, JBNUMBUF_SIZE); + ikey->size = (size_t) iwitoa(node->vi64, numbuf, IWNUMBUF_SIZE); break; case JBV_BOOL: if (node->vbool) { @@ -184,7 +183,7 @@ void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[st } break; case JBV_F64: - jbi_ftoa(node->vf64, numbuf, &ikey->size); + iwjson_ftoa(node->vf64, numbuf, &ikey->size); break; default: break; @@ -214,16 +213,16 @@ void jbi_node_fill_ikey(JBIDX idx, JBL_NODE node, IWKV_val *ikey, char numbuf[st case EJDB_IDX_F64: switch (jbvt) { case JBV_F64: - jbi_ftoa(node->vf64, numbuf, &ikey->size); + iwjson_ftoa(node->vf64, numbuf, &ikey->size); break; case JBV_I64: - jbi_ftoa(node->vi64, numbuf, &ikey->size); + iwjson_ftoa(node->vi64, numbuf, &ikey->size); break; case JBV_BOOL: - jbi_ftoa(node->vbool, numbuf, &ikey->size); + iwjson_ftoa(node->vbool, numbuf, &ikey->size); break; case JBV_STR: - jbi_ftoa(iwatof(node->vptr), numbuf, &ikey->size); + iwjson_ftoa(iwatof(node->vptr), numbuf, &ikey->size); break; default: ikey->data = 0; diff --git a/src/util/sort_r.h b/src/jbi/sort_r.h similarity index 98% rename from src/util/sort_r.h rename to src/jbi/sort_r.h index c6418874b..6769f11b3 100644 --- a/src/util/sort_r.h +++ b/src/jbi/sort_r.h @@ -24,10 +24,10 @@ #define _SORT_R_INLINE inline -#if ( defined __APPLE__ || defined __MACH__ || defined __DARWIN__ \ +#if ( defined __APPLE__ || defined __MACH__ || defined __DARWIN__ \ || defined __FreeBSD__ || defined __DragonFly__) && defined JB_HAVE_QSORT_R # define _SORT_R_BSD -#elif ( defined _GNU_SOURCE || defined __gnu_hurd__ || defined __GNU__ \ +#elif ( defined _GNU_SOURCE || defined __gnu_hurd__ || defined __GNU__ \ || defined __linux__ || defined __MINGW32__ || defined __GLIBC__) && defined JB_HAVE_QSORT_R # define _SORT_R_LINUX #elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__) @@ -240,7 +240,6 @@ static _SORT_R_INLINE void sort_r( const void *_b, void *aarg), void *arg) { - int nested_cmp(const void *a, const void *b) { return compar(a, b, arg); } @@ -257,8 +256,9 @@ static _SORT_R_INLINE void sort_r( /* Ensure qsort_r is defined */ extern void qsort_r( void *base, size_t nel, size_t width, void *thunk, - int (*compar)(void *_thunk, - const void *_a, const void *_b)); + int (*compar)( + void *_thunk, + const void *_a, const void *_b)); #endif diff --git a/src/jbl/binn.c b/src/jbl/binn.c deleted file mode 100644 index bbd7da67b..000000000 --- a/src/jbl/binn.c +++ /dev/null @@ -1,3154 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "binn.h" -#include - -#define INT64_FORMAT PRId64 -#define UINT64_FORMAT PRIu64 -#define INT64_HEX_FORMAT PRIx64 - -#define UNUSED(x) (void) (x) -#define round(dbl) dbl >= 0.0 ? (int) (dbl + 0.5) : ((dbl - (double) (int) dbl) <= -0.5 ? (int) dbl : (int) (dbl - 0.5)) - -#define CHUNK_SIZE 256 // 1024 - -#define BINN_STRUCT 1 -#define BINN_BUFFER 2 - -void*(*malloc_fn)(size_t len) = malloc; -void* (*realloc_fn)(void *ptr, size_t len) = realloc; -void (*free_fn)(void *ptr) = free; - -#if defined(__APPLE__) || defined(_WIN32) -#define __BIG_ENDIAN 0x1000 -#define __LITTLE_ENDIAN 0x0001 -#define __BYTE_ORDER __LITTLE_ENDIAN -#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) -#include -#define __BIG_ENDIAN BIG_ENDIAN -#define __LITTLE_ENDIAN LITTLE_ENDIAN -#define __BYTE_ORDER BYTE_ORDER -#elif defined(_AIX) -#include -#define __BIG_ENDIAN BIG_ENDIAN -#define __LITTLE_ENDIAN LITTLE_ENDIAN -#define __BYTE_ORDER BYTE_ORDER -#else -#include -#endif - -#ifndef __BYTE_ORDER -#error "__BYTE_ORDER not defined" -#endif -#ifndef __BIG_ENDIAN -#error "__BIG_ENDIAN not defined" -#endif -#ifndef __LITTLE_ENDIAN -#error "__LITTLE_ENDIAN not defined" -#endif -#if __BIG_ENDIAN == __LITTLE_ENDIAN -#error "__BIG_ENDIAN == __LITTLE_ENDIAN" -#endif - -#if __BYTE_ORDER == __BIG_ENDIAN -#define tobe16(x) (x) -#define tobe32(x) (x) -#define tobe64(x) (x) -#else -#define tobe16(x) IW_SWAB16(x) -#define tobe32(x) IW_SWAB32(x) -#define tobe64(x) IW_SWAB64(x) -#endif - -#define frombe16 tobe16 -#define frombe32 tobe32 -#define frombe64 tobe64 - -#ifndef WIN32 -#define stricmp strcasecmp -#define strnicmp strncasecmp -#endif - -void binn_set_alloc_functions( - void*(*new_malloc)(size_t), void*(*new_realloc)(void*, size_t), - void (*new_free)(void*)) { - malloc_fn = new_malloc; - realloc_fn = new_realloc; - free_fn = new_free; -} - -IW_INLINE void *binn_malloc(int size) { - return malloc_fn(size); -} - -BINN_PRIVATE void *binn_memdup(const void *src, int size) { - void *dest; - if ((src == NULL) || (size <= 0)) { - return NULL; - } - dest = binn_malloc(size); - if (dest == NULL) { - return NULL; - } - memcpy(dest, src, size); - return dest; -} - -BINN_PRIVATE size_t strlen2(char *str) { - if (str == NULL) { - return 0; - } - return strlen(str); -} - -int binn_create_type(int storage_type, int data_type_index) { - if (data_type_index < 0) { - return -1; - } - if ((storage_type < BINN_STORAGE_MIN) || (storage_type > BINN_STORAGE_MAX)) { - return -1; - } - if (data_type_index < 16) { - return storage_type | data_type_index; - } else if (data_type_index < 4096) { - storage_type |= BINN_STORAGE_HAS_MORE; - storage_type <<= 8; - data_type_index >>= 4; - return storage_type | data_type_index; - } else { - return -1; - } -} - -BOOL binn_get_type_info(int long_type, int *pstorage_type, int *pextra_type) { - int storage_type, extra_type; - BOOL retval = TRUE; - -again: - if (long_type < 0) { - goto loc_invalid; - } else if (long_type <= 0xff) { - storage_type = long_type & BINN_STORAGE_MASK; - extra_type = long_type & BINN_TYPE_MASK; - } else if (long_type <= 0xffff) { - storage_type = long_type & BINN_STORAGE_MASK16; - storage_type >>= 8; - extra_type = long_type & BINN_TYPE_MASK16; - extra_type >>= 4; - } else if (long_type & BINN_STORAGE_VIRTUAL) { - //storage_type = BINN_STORAGE_VIRTUAL; - //extra_type = xxx; - long_type &= 0xffff; - goto again; - } else { -loc_invalid: - storage_type = -1; - extra_type = -1; - retval = FALSE; - } - if (pstorage_type) { - *pstorage_type = storage_type; - } - if (pextra_type) { - *pextra_type = extra_type; - } - return retval; -} - -BOOL binn_create(binn *item, int type, int size, void *pointer) { - BOOL retval = FALSE; - - switch (type) { - case BINN_LIST: - case BINN_MAP: - case BINN_OBJECT: - break; - default: - goto loc_exit; - } - if ((item == NULL) || (size < 0)) { - goto loc_exit; - } - if (size < MIN_BINN_SIZE) { - if (pointer) { - goto loc_exit; - } else { - size = 0; - } - } - memset(item, 0, sizeof(binn)); - - if (pointer) { - item->pre_allocated = TRUE; - item->pbuf = pointer; - item->alloc_size = size; - } else { - item->pre_allocated = FALSE; - if (size == 0) { - size = CHUNK_SIZE; - } - pointer = binn_malloc(size); - if (pointer == 0) { - return INVALID_BINN; - } - item->pbuf = pointer; - item->alloc_size = size; - } - - item->header = BINN_MAGIC; - item->writable = TRUE; - item->used_size = MAX_BINN_HEADER; // save space for the header - item->type = type; - item->dirty = TRUE; // the header is not written to the buffer - retval = TRUE; - -loc_exit: - return retval; -} - -binn *binn_new(int type, int size, void *pointer) { - binn *item; - item = (binn*) binn_malloc(sizeof(binn)); - if (binn_create(item, type, size, pointer) == FALSE) { - free_fn(item); - return NULL; - } - item->allocated = TRUE; - return item; -} - -BOOL binn_create_list(binn *list) { - return binn_create(list, BINN_LIST, 0, NULL); -} - -BOOL binn_create_map(binn *map) { - return binn_create(map, BINN_MAP, 0, NULL); -} - -BOOL binn_create_object(binn *object) { - return binn_create(object, BINN_OBJECT, 0, NULL); -} - -binn *binn_list() { - return binn_new(BINN_LIST, 0, 0); -} - -binn *binn_map() { - return binn_new(BINN_MAP, 0, 0); -} - -binn *binn_object() { - return binn_new(BINN_OBJECT, 0, 0); -} - -BOOL binn_load(void *data, binn *value) { - if ((data == NULL) || (value == NULL)) { - return FALSE; - } - memset(value, 0, sizeof(binn)); - value->header = BINN_MAGIC; - if (binn_is_valid(data, &value->type, &value->count, &value->size) == FALSE) { - return FALSE; - } - value->ptr = data; - return TRUE; -} - -binn *binn_open(void *data) { - binn *item; - item = (binn*) binn_malloc(sizeof(binn)); - if (binn_load(data, item) == FALSE) { - free_fn(item); - return NULL; - } - item->allocated = TRUE; - return item; -} - -BINN_PRIVATE int binn_get_ptr_type(const void *ptr) { - if (ptr == NULL) { - return 0; - } - switch (*(const unsigned int*) ptr) { - case BINN_MAGIC: - return BINN_STRUCT; - default: - return BINN_BUFFER; - } -} - -BOOL binn_is_struct(void *ptr) { - if (ptr == NULL) { - return FALSE; - } - if ((*(unsigned int*) ptr) == BINN_MAGIC) { - return TRUE; - } else { - return FALSE; - } -} - -BINN_PRIVATE int CalcAllocation(int needed_size, int alloc_size) { - int calc_size; - calc_size = alloc_size; - while (calc_size < needed_size) { - calc_size <<= 1; // same as *= 2 - //calc_size += CHUNK_SIZE; -- this is slower than the above line, because there are more reallocations - } - return calc_size; -} - -BINN_PRIVATE BOOL CheckAllocation(binn *item, int add_size) { - int alloc_size; - void *ptr; - if (item->used_size + add_size > item->alloc_size) { - if (item->pre_allocated) { - return FALSE; - } - alloc_size = CalcAllocation(item->used_size + add_size, item->alloc_size); - ptr = realloc_fn(item->pbuf, alloc_size); - if (ptr == NULL) { - return FALSE; - } - item->pbuf = ptr; - item->alloc_size = alloc_size; - } - return TRUE; -} - -#if __BYTE_ORDER == __BIG_ENDIAN - -BINN_PRIVATE int get_storage_size(int storage_type) { - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - return 0; - case BINN_STORAGE_BYTE: - return 1; - case BINN_STORAGE_WORD: - return 2; - case BINN_STORAGE_DWORD: - return 4; - case BINN_STORAGE_QWORD: - return 8; - default: - return 0; - } -} - -#endif - -BINN_PRIVATE unsigned char *AdvanceDataPos(unsigned char *p, unsigned char *plimit) { - unsigned char byte; - int storage_type, dsize; - if (p > plimit) { - return 0; - } - - byte = *p; - p++; - storage_type = byte & BINN_STORAGE_MASK; - if (byte & BINN_STORAGE_HAS_MORE) { - p++; - } - - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_BYTE: - p++; - break; - case BINN_STORAGE_WORD: - p += 2; - break; - case BINN_STORAGE_DWORD: - p += 4; - break; - case BINN_STORAGE_QWORD: - p += 8; - break; - case BINN_STORAGE_BLOB: - if (p + sizeof(int) - 1 > plimit) { - return 0; - } - memcpy(&dsize, p, 4); - dsize = frombe32(dsize); - p += 4 + dsize; - break; - case BINN_STORAGE_CONTAINER: - if (p > plimit) { - return 0; - } - dsize = *((unsigned char*) p); - if (dsize & 0x80) { - if (p + sizeof(int) - 1 > plimit) { - return 0; - } - memcpy(&dsize, p, 4); - dsize = frombe32(dsize); - dsize &= 0x7FFFFFFF; - } - dsize--; // remove the type byte already added before - p += dsize; - break; - case BINN_STORAGE_STRING: - if (p > plimit) { - return 0; - } - dsize = *((unsigned char*) p); - if (dsize & 0x80) { - if (p + sizeof(int) - 1 > plimit) { - return 0; - } - memcpy(&dsize, p, 4); - p += 4; - dsize = frombe32(dsize); - dsize &= 0x7FFFFFFF; - } else { - p++; - } - p += dsize; - p++; // null terminator. - break; - default: - return 0; - } - if (p > plimit) { - return 0; - } - return p; -} - -BINN_PRIVATE unsigned char *SearchForID(unsigned char *p, int header_size, int size, int numitems, int id) { - unsigned char *plimit, *base; - int i, int32; - - base = p; - plimit = p + size - 1; - p += header_size; - - // search for the ID in all the arguments. - for (i = 0; i < numitems; i++) { - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - if (p > plimit) { - break; - } - // Compare if the IDs are equal. - if (int32 == id) { - return p; - } - // xxx - p = AdvanceDataPos(p, plimit); - if ((p == 0) || (p < base)) { - break; - } - } - return NULL; -} - -BINN_PRIVATE unsigned char *SearchForKey( - unsigned char *p, int header_size, int size, int numitems, const char *key, - int keylen) { - unsigned char len, *plimit, *base; - int i; - - base = p; - plimit = p + size - 1; - p += header_size; - - // search for the key in all the arguments. - for (i = 0; i < numitems; i++) { - len = *((unsigned char*) p); - p++; - if (p > plimit) { - break; - } - // Compare if the strings are equal. - if (len > 0) { - if (strnicmp((char*) p, key, len) == 0) { // note that there is no null terminator here - if (keylen == len) { - p += len; - return p; - } - } - p += len; - if (p > plimit) { - break; - } - } else if (len == keylen) { // in the case of empty string: "" - return p; - } - // xxx - p = AdvanceDataPos(p, plimit); - if ((p == 0) || (p < base)) { - break; - } - } - return NULL; -} - -BINN_PRIVATE BOOL AddValue(binn *item, int type, void *pvalue, int size); - -BINN_PRIVATE BOOL binn_list_add_raw(binn *item, int type, void *pvalue, int size) { - if ((item == NULL) || (item->type != BINN_LIST) || (item->writable == FALSE)) { - return FALSE; - } - //if (CheckAllocation(item, 4) == FALSE) return FALSE; // 4 bytes used for data_store and data_format. - if (AddValue(item, type, pvalue, size) == FALSE) { - return FALSE; - } - item->count++; - return TRUE; -} - -BINN_PRIVATE BOOL binn_object_set_raw(binn *item, const char *key, int keylen, int type, void *pvalue, int size) { - unsigned char *p, len; - int int32 = keylen; - - if ( (key == NULL) - || (item == NULL) - || (item->type != BINN_OBJECT) - || (item->writable == FALSE) - || (keylen > 255)) { - return FALSE; - } - - // is the key already in it? - p = SearchForKey(item->pbuf, MAX_BINN_HEADER, item->used_size, item->count, key, keylen); - if (p) { - return FALSE; - } - - // start adding it - if (CheckAllocation(item, 1 + int32) == FALSE) { - return FALSE; // bytes used for the key size and the key itself. - } - p = ((unsigned char*) item->pbuf) + item->used_size; - len = int32; - *p = len; - p++; - memcpy(p, key, int32); - int32++; // now contains the strlen + 1 byte for the len - item->used_size += int32; - - if (AddValue(item, type, pvalue, size) == FALSE) { - item->used_size -= int32; - return FALSE; - } - item->count++; - return TRUE; -} - -BINN_PRIVATE BOOL binn_map_set_raw(binn *item, int id, int type, void *pvalue, int size) { - unsigned char *p; - int int32; - - if ((item == NULL) || (item->type != BINN_MAP) || (item->writable == FALSE)) { - return FALSE; - } - // is the ID already in it? - p = SearchForID(item->pbuf, MAX_BINN_HEADER, item->used_size, item->count, id); - if (p) { - return FALSE; - } - if (CheckAllocation(item, 4) == FALSE) { - return FALSE; // 4 bytes used for the id. - } - int32 = tobe32(id); - p = ((unsigned char*) item->pbuf) + item->used_size; - - memcpy(p, &int32, 4); - item->used_size += 4; - - if (AddValue(item, type, pvalue, size) == FALSE) { - item->used_size -= 4; - return FALSE; - } - item->count++; - return TRUE; -} - -BINN_PRIVATE void *compress_int(int *pstorage_type, int *ptype, void *psource) { - int storage_type, storage_type2, type, type2 = 0; - int64 vint = 0; - uint64 vuint; - char *pvalue; -#if __BYTE_ORDER == __BIG_ENDIAN - int size1, size2; -#endif - - storage_type = *pstorage_type; - if (storage_type == BINN_STORAGE_BYTE) { - return psource; - } - - type = *ptype; - - switch (type) { - case BINN_INT64: - vint = *(int64*) psource; - goto loc_signed; - case BINN_INT32: - vint = *(int*) psource; - goto loc_signed; - case BINN_INT16: - vint = *(short*) psource; - goto loc_signed; - case BINN_UINT64: - vuint = *(uint64*) psource; - goto loc_positive; - case BINN_UINT32: - vuint = *(unsigned int*) psource; - goto loc_positive; - case BINN_UINT16: - vuint = *(unsigned short*) psource; - goto loc_positive; - } - -loc_signed: - if (vint >= 0) { - vuint = vint; - goto loc_positive; - } - //loc_negative: - if (vint >= INT8_MIN) { - type2 = BINN_INT8; - } else if (vint >= INT16_MIN) { - type2 = BINN_INT16; - } else if (vint >= INT32_MIN) { - type2 = BINN_INT32; - } - goto loc_exit; - -loc_positive: - if (vuint <= UINT8_MAX) { - type2 = BINN_UINT8; - } else if (vuint <= UINT16_MAX) { - type2 = BINN_UINT16; - } else if (vuint <= UINT32_MAX) { - type2 = BINN_UINT32; - } - -loc_exit: - pvalue = (char*) psource; - if ((type2) && (type2 != type)) { - *ptype = type2; - storage_type2 = binn_get_write_storage(type2); - *pstorage_type = storage_type2; -#if __BYTE_ORDER == __BIG_ENDIAN - size1 = get_storage_size(storage_type); - size2 = get_storage_size(storage_type2); - pvalue += (size1 - size2); -#endif - } - return pvalue; -} - -BINN_PRIVATE int type_family(int type); - -BINN_PRIVATE BOOL AddValue(binn *item, int type, void *pvalue, int size) { - int32_t argsz, storage_type, extra_type; - uint16_t su; - uint32_t lu; - uint64_t llu; - - unsigned char *p, *ptr; - - binn_get_type_info(type, &storage_type, &extra_type); - - if (pvalue == NULL) { - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_BLOB: - case BINN_STORAGE_STRING: - if (size == 0) { - break; // the 2 above are allowed to have 0 length - } - default: - return FALSE; - } - } - - if (type_family(type) == BINN_FAMILY_INT) { - pvalue = compress_int(&storage_type, &type, pvalue); - } - - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - size = 0; - argsz = size; - break; - case BINN_STORAGE_BYTE: - size = 1; - argsz = size; - break; - case BINN_STORAGE_WORD: - size = 2; - argsz = size; - break; - case BINN_STORAGE_DWORD: - size = 4; - argsz = size; - break; - case BINN_STORAGE_QWORD: - size = 8; - argsz = size; - break; - case BINN_STORAGE_BLOB: - if (size < 0) { - return FALSE; - } - //if (size == 0) ... - argsz = size + 4; - break; - case BINN_STORAGE_STRING: - if (size < 0) { - return FALSE; - } - if (size == 0) { - size = strlen2((char*) pvalue); - } - argsz = size + 5; // at least this size - break; - case BINN_STORAGE_CONTAINER: - if (size <= 0) { - return FALSE; - } - argsz = size; - break; - default: - return FALSE; - } - - argsz += 2; // at least 2 bytes used for data_type. - if (CheckAllocation(item, argsz) == FALSE) { - return FALSE; - } - - // Gets the pointer to the next place in buffer - p = ((unsigned char*) item->pbuf) + item->used_size; - - // If the data is not a container, store the data type - if (storage_type != BINN_STORAGE_CONTAINER) { - ptr = (unsigned char*) &type; - if (type > 255) { - type = tobe16(type); // correct the endianess, if needed - *p = *ptr; - p++; - item->used_size++; - ptr++; - } - *p = *ptr; - p++; - item->used_size++; - } - - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - // Nothing to do. - break; - case BINN_STORAGE_BYTE: - *((char*) p) = *((char*) pvalue); - item->used_size += 1; - break; - case BINN_STORAGE_WORD: - su = *((uint16_t*) pvalue); - su = tobe16(su); - memcpy(p, &su, 2); - item->used_size += 2; - break; - case BINN_STORAGE_DWORD: - lu = *((uint32_t*) pvalue); - lu = tobe32(lu); - memcpy(p, &lu, 4); - item->used_size += 4; - break; - case BINN_STORAGE_QWORD: - // is there an htond or htonq to be used with qwords? (64 bits) - llu = *((uint64_t*) pvalue); - llu = tobe64(llu); - memcpy(p, &llu, 8); - item->used_size += 8; - break; - case BINN_STORAGE_BLOB: - lu = tobe32(size); - memcpy(p, &lu, 4); - p += 4; - memcpy(p, pvalue, size); - item->used_size += 4 + size; - break; - case BINN_STORAGE_STRING: - if (size > 127) { - lu = size | 0x80000000; - lu = tobe32(lu); - memcpy(p, &lu, 4); - p += 4; - item->used_size += 4; - } else { - *((unsigned char*) p) = size; - p++; - item->used_size++; - } - memcpy(p, pvalue, size); - p += size; - *((char*) p) = (char) 0; - size++; // null terminator - item->used_size += size; - break; - case BINN_STORAGE_CONTAINER: - memcpy(p, pvalue, size); - item->used_size += size; - break; - } - item->dirty = TRUE; - return TRUE; -} - -BOOL binn_save_header(binn *item) { - unsigned char byte, *p; - int int32, size; - if (item == NULL) { - return FALSE; - } - -#ifndef BINN_DISABLE_SMALL_HEADER - - p = ((unsigned char*) item->pbuf) + MAX_BINN_HEADER; - size = item->used_size - MAX_BINN_HEADER + 3; // at least 3 bytes for the header - - // write the count - if (item->count > 127) { - p -= 4; - size += 3; - int32 = item->count | 0x80000000; - int32 = tobe32(int32); - memcpy(p, &int32, 4); - } else { - p--; - *p = (unsigned char) item->count; - } - - // write the size - if (size > 127) { - p -= 4; - size += 3; - int32 = size | 0x80000000; - int32 = tobe32(int32); - memcpy(p, &int32, 4); - } else { - p--; - *p = (unsigned char) size; - } - - // write the type. - p--; - *p = (unsigned char) item->type; - - // set the values - item->ptr = p; - item->size = size; - - UNUSED(byte); - -#else - - p = (unsigned char*) item->pbuf; - - // write the type. - byte = item->type; - *p = byte; - p++; - // write the size - int32 = item->used_size | 0x80000000; - int32 = tobe32(int32); - memcpy(p, &int32, 4); - p += 4; - // write the count - int32 = item->count | 0x80000000; - int32 = tobe32(int32); - memcpy(p, &int32, 4); - - item->ptr = item->pbuf; - item->size = item->used_size; - -#endif - - item->dirty = FALSE; - return TRUE; -} - -void binn_free(binn *item) { - if (item == NULL) { - return; - } - if (item->userdata_freefn) { - item->userdata_freefn(item->user_data); - item->userdata_freefn = 0; - } - if ((item->writable) && (item->pre_allocated == FALSE)) { - free_fn(item->pbuf); - } - if (item->freefn) { - item->freefn(item->ptr); - } - if (item->allocated) { - free_fn(item); - } else { - memset(item, 0, sizeof(binn)); - item->header = BINN_MAGIC; - } -} - -// free the binn structure but keeps the binn buffer allocated, returning a pointer to it. use the free function to -// release the buffer later -void *binn_release(binn *item) { - void *data; - if (item == NULL) { - return NULL; - } - data = binn_ptr(item); - if (data > item->pbuf) { - memmove(item->pbuf, data, item->size); - data = item->pbuf; - } - if (item->allocated) { - free_fn(item); - } else { - memset(item, 0, sizeof(binn)); - item->header = BINN_MAGIC; - } - return data; -} - -BINN_PRIVATE BOOL IsValidBinnHeader(const void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize) { - const unsigned char *p, *plimit = 0; - unsigned char byte; - int int32, type, size, count; - if (pbuf == NULL) { - return FALSE; - } - p = (const unsigned char*) pbuf; - if (psize && (*psize > 0)) { - plimit = p + *psize - 1; - } - // get the type - byte = *p; - p++; - if ((byte & BINN_STORAGE_MASK) != BINN_STORAGE_CONTAINER) { - return FALSE; - } - if (byte & BINN_STORAGE_HAS_MORE) { - return FALSE; - } - type = byte; - - switch (type) { - case BINN_LIST: - case BINN_MAP: - case BINN_OBJECT: - break; - default: - return FALSE; - } - - // get the size - if (plimit && (p > plimit)) { - return FALSE; - } - int32 = *((const unsigned char*) p); - if (int32 & 0x80) { - if (plimit && (p + sizeof(int) - 1 > plimit)) { - return FALSE; - } - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - int32 &= 0x7FFFFFFF; - } else { - p++; - } - size = int32; - - // get the count - if (plimit && (p > plimit)) { - return FALSE; - } - int32 = *((const unsigned char*) p); - if (int32 & 0x80) { - if (plimit && (p + sizeof(int) - 1 > plimit)) { - return FALSE; - } - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - int32 &= 0x7FFFFFFF; - } else { - p++; - } - count = int32; - - if (size < MIN_BINN_SIZE) { - return FALSE; - } - // return the values - if (ptype) { - *ptype = type; - } - if (pcount) { - *pcount = count; - } - if (psize && (*psize == 0)) { - *psize = size; - } - if (pheadersize) { - *pheadersize = (int) (p - (const unsigned char*) pbuf); - } - return TRUE; -} - -binn *binn_copy(void *old) { - int type, count, size, header_size; - unsigned char *old_ptr = binn_ptr(old); - binn *item; - size = 0; - if (!IsValidBinnHeader(old_ptr, &type, &count, &size, &header_size)) { - return NULL; - } - item = binn_new(type, size - header_size + MAX_BINN_HEADER, NULL); - if (item) { - unsigned char *dest; - dest = ((unsigned char*) item->pbuf) + MAX_BINN_HEADER; - memcpy(dest, old_ptr + header_size, size - header_size); - item->used_size = MAX_BINN_HEADER + size - header_size; - item->count = count; - } - return item; -} - -BOOL binn_is_valid_header(const void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize) { - return IsValidBinnHeader(pbuf, ptype, pcount, psize, pheadersize); -} - -int binn_buf_type(const void *pbuf) { - int type; - if (!IsValidBinnHeader(pbuf, &type, NULL, NULL, NULL)) { - return INVALID_BINN; - } - return type; -} - -int binn_buf_count(const void *pbuf) { - int nitems; - if (!IsValidBinnHeader(pbuf, NULL, &nitems, NULL, NULL)) { - return 0; - } - return nitems; -} - -int binn_buf_size(const void *pbuf) { - int size = 0; - if (!IsValidBinnHeader(pbuf, NULL, NULL, &size, NULL)) { - return 0; - } - return size; -} - -void *binn_ptr(void *ptr) { - binn *item; - switch (binn_get_ptr_type(ptr)) { - case BINN_STRUCT: - item = (binn*) ptr; - if (item->writable && item->dirty) { - binn_save_header(item); - } - return item->ptr; - case BINN_BUFFER: - return ptr; - default: - return NULL; - } -} - -int binn_size(void *ptr) { - binn *item; - switch (binn_get_ptr_type(ptr)) { - case BINN_STRUCT: - item = (binn*) ptr; - if (item->writable && item->dirty) { - binn_save_header(item); - } - return item->size; - case BINN_BUFFER: - return binn_buf_size(ptr); - default: - return 0; - } -} - -int binn_type(void *ptr) { - binn *item; - switch (binn_get_ptr_type(ptr)) { - case BINN_STRUCT: - item = (binn*) ptr; - return item->type; - case BINN_BUFFER: - return binn_buf_type(ptr); - default: - return -1; - } -} - -int binn_count(void *ptr) { - binn *item; - switch (binn_get_ptr_type(ptr)) { - case BINN_STRUCT: - item = (binn*) ptr; - return item->count; - case BINN_BUFFER: - return binn_buf_count(ptr); - default: - return -1; - } -} - -BOOL binn_is_valid_ex(void *ptr, int *ptype, int *pcount, int *psize) { - int i, type, count, size, header_size; - unsigned char *p, *plimit, *base, len; - void *pbuf; - - pbuf = binn_ptr(ptr); - if (pbuf == NULL) { - return FALSE; - } - - // is there an informed size? - if (psize && (*psize > 0)) { - size = *psize; - } else { - size = 0; - } - if (!IsValidBinnHeader(pbuf, &type, &count, &size, &header_size)) { - return FALSE; - } - // is there an informed size? - if (psize && (*psize > 0)) { - // is it the same as the one in the buffer? - if (size != *psize) { - return FALSE; - } - } - // is there an informed count? - if (pcount && (*pcount > 0)) { - // is it the same as the one in the buffer? - if (count != *pcount) { - return FALSE; - } - } - // is there an informed type? - if (ptype && (*ptype != 0)) { - // is it the same as the one in the buffer? - if (type != *ptype) { - return FALSE; - } - } - // it could compare the content size with the size informed on the header - - p = (unsigned char*) pbuf; - base = p; - plimit = p + size; - p += header_size; - - // process all the arguments. - for (i = 0; i < count; i++) { - switch (type) { - case BINN_OBJECT: - // gets the string size (argument name) - len = *p; - p++; - //if (len == 0) goto Invalid; - // increment the used space - p += len; - break; - case BINN_MAP: - // increment the used space - p += 4; - break; - //case BINN_LIST: - // break; - } - // xxx - p = AdvanceDataPos(p, plimit); - if ((p == 0) || (p < base)) { - goto Invalid; - } - } - - if (ptype && (*ptype == 0)) { - *ptype = type; - } - if (pcount && (*pcount == 0)) { - *pcount = count; - } - if (psize && (*psize == 0)) { - *psize = size; - } - return TRUE; - -Invalid: - return FALSE; -} - -BOOL binn_is_valid(void *ptr, int *ptype, int *pcount, int *psize) { - if (ptype) { - *ptype = 0; - } - if (pcount) { - *pcount = 0; - } - if (psize) { - *psize = 0; - } - return binn_is_valid_ex(ptr, ptype, pcount, psize); -} - -/*** INTERNAL FUNCTIONS ****************************************************/ - -BINN_PRIVATE BOOL GetValue(unsigned char *p, binn *value) { - unsigned char byte; - int data_type, storage_type; //, extra_type; - int datasz; - void *p2; - - if (value == NULL) { - return FALSE; - } - memset(value, 0, sizeof(binn)); - value->header = BINN_MAGIC; - - // saves for use with BINN_STORAGE_CONTAINER - p2 = p; - // read the data type - byte = *p; - p++; - storage_type = byte & BINN_STORAGE_MASK; - if (byte & BINN_STORAGE_HAS_MORE) { - data_type = byte << 8; - byte = *p; - p++; - data_type |= byte; - //extra_type = data_type & BINN_TYPE_MASK16; - } else { - data_type = byte; - //extra_type = byte & BINN_TYPE_MASK; - } - - //value->storage_type = storage_type; - value->type = data_type; - - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_BYTE: - value->vuint8 = *((unsigned char*) p); - value->ptr = p; //value->ptr = &value->vuint8; - break; - case BINN_STORAGE_WORD: - memcpy(&value->vint16, p, 2); - value->vint16 = frombe16(value->vint16); - value->ptr = &value->vint16; - break; - case BINN_STORAGE_DWORD: - memcpy(&value->vint32, p, 4); - value->vint32 = frombe32(value->vint32); - value->ptr = &value->vint32; - break; - case BINN_STORAGE_QWORD: - memcpy(&value->vint64, p, 8); - value->vint64 = frombe64(value->vint64); - value->ptr = &value->vint64; - break; - case BINN_STORAGE_BLOB: - memcpy(&value->size, p, 4); - p += 4; - value->size = frombe32(value->size); - value->ptr = p; - break; - case BINN_STORAGE_CONTAINER: - value->ptr = p2; // <-- it returns the pointer to the container, not the data - if (IsValidBinnHeader(p2, NULL, &value->count, &value->size, NULL) == FALSE) { - return FALSE; - } - break; - case BINN_STORAGE_STRING: - datasz = *((unsigned char*) p); - if (datasz & 0x80) { - memcpy(&datasz, p, 4); - p += 4; - datasz = frombe32(datasz); - datasz &= 0x7FFFFFFF; - } else { - p++; - } - value->size = datasz; - value->ptr = p; - break; - default: - return FALSE; - } - - // convert the returned value, if needed - switch (value->type) { - case BINN_TRUE: - value->type = BINN_BOOL; - value->vbool = TRUE; - value->ptr = &value->vbool; - break; - case BINN_FALSE: - value->type = BINN_BOOL; - value->vbool = FALSE; - value->ptr = &value->vbool; - break; -#ifdef BINN_EXTENDED - case BINN_SINGLE_STR: - value->type = BINN_SINGLE; - value->vfloat = (float) atof((const char*) value->ptr); // converts from string to double, and then to float - value->ptr = &value->vfloat; - break; - case BINN_DOUBLE_STR: - value->type = BINN_DOUBLE; - value->vdouble = atof((const char*) value->ptr); // converts from string to double - value->ptr = &value->vdouble; - break; -#endif - /* - case BINN_DECIMAL: - case BINN_CURRENCYSTR: - case BINN_DATE: - case BINN_DATETIME: - case BINN_TIME: - */ - } - return TRUE; -} - -#if __BYTE_ORDER == __LITTLE_ENDIAN - -// on little-endian devices we store the value so we can return a pointer to integers. -// it's valid only for single-threaded apps. multi-threaded apps must use the _get_ functions instead. - -binn local_value; - -BINN_PRIVATE void *store_value(binn *value) { - memcpy(&local_value, value, sizeof(binn)); - switch (binn_get_read_storage(value->type)) { - case BINN_STORAGE_NOBYTES: - // return a valid pointer - case BINN_STORAGE_WORD: - case BINN_STORAGE_DWORD: - case BINN_STORAGE_QWORD: - return &local_value.vint32; // returns the pointer to the converted value, from big-endian to little-endian - } - return value->ptr; // returns from the on stack value to be thread-safe (for list, map, object, string and blob) -} - -#endif - -/*** READ FUNCTIONS ********************************************************/ - -BOOL binn_object_get_value(void *ptr, const char *key, binn *value) { - int type, count, size = 0, header_size; - unsigned char *p; - - ptr = binn_ptr(ptr); - if ((ptr == 0) || (key == 0) || (value == 0)) { - return FALSE; - } - - // check the header - if (IsValidBinnHeader(ptr, &type, &count, &size, &header_size) == FALSE) { - return FALSE; - } - - if (type != BINN_OBJECT) { - return FALSE; - } - if (count == 0) { - return FALSE; - } - - p = (unsigned char*) ptr; - p = SearchForKey(p, header_size, size, count, key, strlen(key)); - if (p == FALSE) { - return FALSE; - } - return GetValue(p, value); -} - -BOOL binn_map_get_value(void *ptr, int id, binn *value) { - int type, count, size = 0, header_size; - unsigned char *p; - - ptr = binn_ptr(ptr); - if ((ptr == 0) || (value == 0)) { - return FALSE; - } - - // check the header - if (IsValidBinnHeader(ptr, &type, &count, &size, &header_size) == FALSE) { - return FALSE; - } - - if (type != BINN_MAP) { - return FALSE; - } - if (count == 0) { - return FALSE; - } - - p = (unsigned char*) ptr; - p = SearchForID(p, header_size, size, count, id); - if (p == FALSE) { - return FALSE; - } - return GetValue(p, value); -} - -BOOL binn_list_get_value(void *ptr, int pos, binn *value) { - int i, type, count, size = 0, header_size; - unsigned char *p, *plimit, *base; - - ptr = binn_ptr(ptr); - if ((ptr == 0) || (value == 0)) { - return FALSE; - } - - // check the header - if (IsValidBinnHeader(ptr, &type, &count, &size, &header_size) == FALSE) { - return FALSE; - } - - if (type != BINN_LIST) { - return FALSE; - } - if (count == 0) { - return FALSE; - } - if ((pos <= 0) | (pos > count)) { - return FALSE; - } - pos--; // convert from base 1 to base 0 - - p = (unsigned char*) ptr; - base = p; - plimit = p + size; - p += header_size; - - for (i = 0; i < pos; i++) { - p = AdvanceDataPos(p, plimit); - if ((p == 0) || (p < base)) { - return FALSE; - } - } - return GetValue(p, value); -} - -/*** READ PAIR BY POSITION *************************************************/ - -BINN_PRIVATE BOOL binn_read_pair(int expected_type, void *ptr, int pos, int *pid, char *pkey, binn *value) { - int type, count, size = 0, header_size; - int i, int32, id = 0, counter = 0; - unsigned char *p, *plimit, *base, *key = 0, len = 0; - - ptr = binn_ptr(ptr); - - // check the header - if (IsValidBinnHeader(ptr, &type, &count, &size, &header_size) == FALSE) { - return FALSE; - } - - if ((type != expected_type) || (count == 0) || (pos < 1) || (pos > count)) { - return FALSE; - } - - p = (unsigned char*) ptr; - base = p; - plimit = p + size - 1; - p += header_size; - - for (i = 0; i < count; i++) { - switch (type) { - case BINN_MAP: - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - if (p > plimit) { - return FALSE; - } - id = int32; - break; - case BINN_OBJECT: - len = *p; - p++; - if (p > plimit) { - return FALSE; - } - key = p; - p += len; - if (p > plimit) { - return FALSE; - } - break; - } - counter++; - if (counter == pos) { - goto found; - } - // - p = AdvanceDataPos(p, plimit); - if ((p == 0) || (p < base)) { - return FALSE; - } - } - return FALSE; - -found: - switch (type) { - case BINN_MAP: - if (pid) { - *pid = id; - } - break; - case BINN_OBJECT: - if (pkey) { - memcpy(pkey, key, len); - pkey[len] = 0; - } - break; - } - return GetValue(p, value); -} - -BOOL binn_map_get_pair(void *ptr, int pos, int *pid, binn *value) { - return binn_read_pair(BINN_MAP, ptr, pos, pid, NULL, value); -} - -BOOL binn_object_get_pair(void *ptr, int pos, char *pkey, binn *value) { - return binn_read_pair(BINN_OBJECT, ptr, pos, NULL, pkey, value); -} - -binn *binn_map_pair(void *map, int pos, int *pid) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_read_pair(BINN_MAP, map, pos, pid, NULL, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -binn *binn_object_pair(void *obj, int pos, char *pkey) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_read_pair(BINN_OBJECT, obj, pos, NULL, pkey, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -void *binn_map_read_pair(void *ptr, int pos, int *pid, int *ptype, int *psize) { - binn value; - - if (binn_map_get_pair(ptr, pos, pid, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -void *binn_object_read_pair(void *ptr, int pos, char *pkey, int *ptype, int *psize) { - binn value; - - if (binn_object_get_pair(ptr, pos, pkey, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -/*** SEQUENTIAL READ FUNCTIONS *********************************************/ - -BOOL binn_iter_init(binn_iter *iter, void *ptr, int expected_type) { - int type, count, size = 0, header_size; - - ptr = binn_ptr(ptr); - if ((ptr == 0) || (iter == 0)) { - return FALSE; - } - memset(iter, 0, sizeof(binn_iter)); - - // check the header - if (IsValidBinnHeader(ptr, &type, &count, &size, &header_size) == FALSE) { - return FALSE; - } - - if (type != expected_type) { - return FALSE; - } - //if (count == 0) return FALSE; -- should not be used - - iter->plimit = (unsigned char*) ptr + size - 1; - iter->pnext = (unsigned char*) ptr + header_size; - iter->count = count; - iter->current = 0; - iter->type = type; - return TRUE; -} - -BOOL binn_list_next(binn_iter *iter, binn *value) { - unsigned char *pnow; - - if ( (iter == 0) - || (iter->pnext == 0) - || (iter->pnext > iter->plimit) - || (iter->current > iter->count) - || (iter->type != BINN_LIST)) { - return FALSE; - } - - iter->current++; - if (iter->current > iter->count) { - return FALSE; - } - - pnow = iter->pnext; - iter->pnext = AdvanceDataPos(pnow, iter->plimit); - if ((iter->pnext != 0) && (iter->pnext < pnow)) { - return FALSE; - } - return GetValue(pnow, value); -} - -BINN_PRIVATE BOOL binn_read_next_pair(int expected_type, binn_iter *iter, int *pid, char *pkey, binn *value) { - int int32, id; - unsigned char *p, *key; - unsigned short len; - - if ( (iter == 0) - || (iter->pnext == 0) - || (iter->pnext > iter->plimit) - || (iter->current > iter->count) - || (iter->type != expected_type)) { - return FALSE; - } - - iter->current++; - if (iter->current > iter->count) { - return FALSE; - } - - p = iter->pnext; - - switch (expected_type) { - case BINN_MAP: - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - if (p > iter->plimit) { - return FALSE; - } - id = int32; - if (pid) { - *pid = id; - } - break; - case BINN_OBJECT: - len = *((unsigned char*) p); - p++; - key = p; - p += len; - if (p > iter->plimit) { - return FALSE; - } - if (pkey) { - memcpy(pkey, key, len); - pkey[len] = 0; - } - break; - } - iter->pnext = AdvanceDataPos(p, iter->plimit); - if ((iter->pnext != 0) && (iter->pnext < p)) { - return FALSE; - } - return GetValue(p, value); -} - -BOOL binn_read_next_pair2(int expected_type, binn_iter *iter, int *klidx, char **pkey, binn *value) { - int int32, id; - unsigned char *p, *key; - unsigned short len; - - if ( (iter == 0) - || (iter->pnext == 0) - || (iter->pnext > iter->plimit) - || (iter->current > iter->count) - || (iter->type != expected_type)) { - return FALSE; - } - - iter->current++; - if (iter->current > iter->count) { - return FALSE; - } - if (pkey) { - *pkey = 0; - } - p = iter->pnext; - switch (expected_type) { - case BINN_MAP: - memcpy(&int32, p, 4); - p += 4; - int32 = frombe32(int32); - if (p > iter->plimit) { - return FALSE; - } - id = int32; - if (klidx) { - *klidx = id; - } - break; - case BINN_OBJECT: - len = *p; - p++; - key = p; - p += len; - if (p > iter->plimit) { - return FALSE; - } - if (klidx) { - *klidx = len; - } - if (pkey) { - *pkey = (char*) key; - } - break; - } - iter->pnext = AdvanceDataPos(p, iter->plimit); - if ((iter->pnext != 0) && (iter->pnext < p)) { - return FALSE; - } - return GetValue(p, value); -} - -BOOL binn_map_next(binn_iter *iter, int *pid, binn *value) { - return binn_read_next_pair(BINN_MAP, iter, pid, NULL, value); -} - -BOOL binn_object_next(binn_iter *iter, char *pkey, binn *value) { - return binn_read_next_pair(BINN_OBJECT, iter, NULL, pkey, value); -} - -BOOL binn_object_next2(binn_iter *iter, char **pkey, int *klen, binn *value) { - return binn_read_next_pair2(BINN_OBJECT, iter, klen, pkey, value); -} - -binn *binn_list_next_value(binn_iter *iter) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_list_next(iter, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -binn *binn_map_next_value(binn_iter *iter, int *pid) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_map_next(iter, pid, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -binn *binn_object_next_value(binn_iter *iter, char *pkey) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_object_next(iter, pkey, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -void *binn_list_read_next(binn_iter *iter, int *ptype, int *psize) { - binn value; - if (binn_list_next(iter, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -void *binn_map_read_next(binn_iter *iter, int *pid, int *ptype, int *psize) { - binn value; - if (binn_map_next(iter, pid, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -void *binn_object_read_next(binn_iter *iter, char *pkey, int *ptype, int *psize) { - binn value; - - if (binn_object_next(iter, pkey, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -/****** EXTENDED INTERFACE ***********************************************************/ -/****** none of the functions above call the functions below *************************/ - -int binn_get_write_storage(int type) { - int storage_type; - switch (type) { - case BINN_SINGLE_STR: - case BINN_DOUBLE_STR: - return BINN_STORAGE_STRING; - case BINN_BOOL: - return BINN_STORAGE_NOBYTES; - default: - binn_get_type_info(type, &storage_type, NULL); - return storage_type; - } -} - -int binn_get_read_storage(int type) { - int storage_type; - switch (type) { -#ifdef BINN_EXTENDED - case BINN_SINGLE_STR: - return BINN_STORAGE_DWORD; - case BINN_DOUBLE_STR: - return BINN_STORAGE_QWORD; -#endif - case BINN_BOOL: - case BINN_TRUE: - case BINN_FALSE: - return BINN_STORAGE_DWORD; - default: - binn_get_type_info(type, &storage_type, NULL); - return storage_type; - } -} - -BINN_PRIVATE BOOL GetWriteConvertedData(int *ptype, void **ppvalue, const int *psize) { - int type; - float f1; - double d1; - char pstr[128]; - - UNUSED(pstr); - UNUSED(d1); - UNUSED(f1); - - type = *ptype; - - if (*ppvalue == NULL) { - switch (type) { - case BINN_NULL: - case BINN_TRUE: - case BINN_FALSE: - break; - case BINN_STRING: - case BINN_BLOB: - if (*psize == 0) { - break; - } - default: - return FALSE; - } - } - - switch (type) { -#ifdef BINN_EXTENDED - case BINN_SINGLE: - f1 = **(float**) ppvalue; - d1 = f1; // convert from float (32bits) to double (64bits) - type = BINN_SINGLE_STR; - goto conv_double; - case BINN_DOUBLE: - d1 = **(double**) ppvalue; - type = BINN_DOUBLE_STR; -conv_double: - // the '%.17e' is more precise than the '%g' - snprintf(pstr, 127, "%.17e", d1); - *ppvalue = pstr; - *ptype = type; - break; -#endif - case BINN_DECIMAL: - case BINN_CURRENCYSTR: - case BINN_DATE: - case BINN_DATETIME: - case BINN_TIME: - return TRUE; - break; - - case BINN_BOOL: - if (**((BOOL**) ppvalue) == FALSE) { - type = BINN_FALSE; - } else { - type = BINN_TRUE; - } - *ptype = type; - break; - } - return TRUE; -} - -BINN_PRIVATE int type_family(int type) { - switch (type) { - case BINN_LIST: - case BINN_MAP: - case BINN_OBJECT: - return BINN_FAMILY_BINN; - - case BINN_INT8: - case BINN_INT16: - case BINN_INT32: - case BINN_INT64: - case BINN_UINT8: - case BINN_UINT16: - case BINN_UINT32: - case BINN_UINT64: - return BINN_FAMILY_INT; - - case BINN_FLOAT32: - case BINN_FLOAT64: - //case BINN_SINGLE: - case BINN_SINGLE_STR: - //case BINN_DOUBLE: - case BINN_DOUBLE_STR: - return BINN_FAMILY_FLOAT; - - case BINN_STRING: - case BINN_HTML: - case BINN_CSS: - case BINN_XML: - case BINN_JSON: - case BINN_JAVASCRIPT: - return BINN_FAMILY_STRING; - - case BINN_BLOB: - case BINN_JPEG: - case BINN_GIF: - case BINN_PNG: - case BINN_BMP: - return BINN_FAMILY_BLOB; - - case BINN_DECIMAL: - case BINN_CURRENCY: - case BINN_DATE: - case BINN_TIME: - case BINN_DATETIME: - return BINN_FAMILY_STRING; - - case BINN_BOOL: - return BINN_FAMILY_BOOL; - - case BINN_NULL: - return BINN_FAMILY_NULL; - - default: - // if it wasn't found - return BINN_FAMILY_NONE; - } -} - -BINN_PRIVATE int int_type(int type) { - switch (type) { - case BINN_INT8: - case BINN_INT16: - case BINN_INT32: - case BINN_INT64: - return BINN_SIGNED_INT; - case BINN_UINT8: - case BINN_UINT16: - case BINN_UINT32: - case BINN_UINT64: - return BINN_UNSIGNED_INT; - default: - return 0; - } -} - -BINN_PRIVATE BOOL copy_raw_value(const void *psource, void *pdest, int data_store) { - switch (data_store) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_BYTE: - *((char*) pdest) = *(const char*) psource; - break; - case BINN_STORAGE_WORD: - *((short*) pdest) = *(const short*) psource; - break; - case BINN_STORAGE_DWORD: - *((int*) pdest) = *(const int*) psource; - break; - case BINN_STORAGE_QWORD: - *((uint64*) pdest) = *(const uint64*) psource; - break; - case BINN_STORAGE_BLOB: - case BINN_STORAGE_STRING: - case BINN_STORAGE_CONTAINER: - *((const char**) pdest) = (const char*) psource; - break; - default: - return FALSE; - } - return TRUE; -} - -BINN_PRIVATE BOOL copy_int_value(void *psource, void *pdest, int source_type, int dest_type) { - uint64 vuint64 = 0; - int64 vf64 = 0; - switch (source_type) { - case BINN_INT8: - vf64 = *(signed char*) psource; - break; - case BINN_INT16: - vf64 = *(short*) psource; - break; - case BINN_INT32: - vf64 = *(int*) psource; - break; - case BINN_INT64: - vf64 = *(int64*) psource; - break; - case BINN_UINT8: - vuint64 = *(unsigned char*) psource; - break; - case BINN_UINT16: - vuint64 = *(unsigned short*) psource; - break; - case BINN_UINT32: - vuint64 = *(unsigned int*) psource; - break; - case BINN_UINT64: - vuint64 = *(uint64*) psource; - break; - default: - return FALSE; - } - // copy from int64 to uint64, if possible - if ((int_type(source_type) == BINN_UNSIGNED_INT) && (int_type(dest_type) == BINN_SIGNED_INT)) { - if (vuint64 > INT64_MAX) { - return FALSE; - } - vf64 = vuint64; - } else if ((int_type(source_type) == BINN_SIGNED_INT) && (int_type(dest_type) == BINN_UNSIGNED_INT)) { - if (vf64 < 0) { - return FALSE; - } - vuint64 = (uint64) vf64; - } - switch (dest_type) { - case BINN_INT8: - if ((vf64 < INT8_MIN) || (vf64 > INT8_MAX)) { - return FALSE; - } - *(signed char*) pdest = (signed char) vf64; - break; - case BINN_INT16: - if ((vf64 < INT16_MIN) || (vf64 > INT16_MAX)) { - return FALSE; - } - *(short*) pdest = (short) vf64; - break; - case BINN_INT32: - if ((vf64 < INT32_MIN) || (vf64 > INT32_MAX)) { - return FALSE; - } - *(int*) pdest = (int) vf64; - break; - case BINN_INT64: - *(int64*) pdest = vf64; - break; - case BINN_UINT8: - if (vuint64 > UINT8_MAX) { - return FALSE; - } - *(unsigned char*) pdest = (unsigned char) vuint64; - break; - case BINN_UINT16: - if (vuint64 > UINT16_MAX) { - return FALSE; - } - *(unsigned short*) pdest = (unsigned short) vuint64; - break; - case BINN_UINT32: - if (vuint64 > UINT32_MAX) { - return FALSE; - } - *(unsigned int*) pdest = (unsigned int) vuint64; - break; - case BINN_UINT64: - *(uint64*) pdest = vuint64; - break; - default: - return FALSE; - } - return TRUE; -} - -#ifdef IW_TESTS - -BOOL copy_int_value_tests(void *psource, void *pdest, int source_type, int dest_type) { - return copy_int_value(psource, pdest, source_type, dest_type); -} - -#endif - -BINN_PRIVATE BOOL copy_float_value(void *psource, void *pdest, int source_type, int dest_type) { - switch (source_type) { - case BINN_FLOAT32: - *(double*) pdest = *(float*) psource; - break; - case BINN_FLOAT64: - *(float*) pdest = (float) *(double*) psource; - break; - default: - return FALSE; - } - return TRUE; -} - -BINN_PRIVATE void zero_value(void *pvalue, int type) { - switch (binn_get_read_storage(type)) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_BYTE: - memset(pvalue, 0, 1); - break; - case BINN_STORAGE_WORD: - memset(pvalue, 0, 2); - break; - case BINN_STORAGE_DWORD: - memset(pvalue, 0, 4); - break; - case BINN_STORAGE_QWORD: - memset(pvalue, 0, 8); - break; - case BINN_STORAGE_BLOB: - case BINN_STORAGE_STRING: - case BINN_STORAGE_CONTAINER: - *(char**) pvalue = NULL; - break; - } -} - -BINN_PRIVATE BOOL copy_value(void *psource, void *pdest, int source_type, int dest_type, int data_store) { - if (type_family(source_type) != type_family(dest_type)) { - return FALSE; - } - if ((type_family(source_type) == BINN_FAMILY_INT) && (source_type != dest_type)) { - return copy_int_value(psource, pdest, source_type, dest_type); - } else if ((type_family(source_type) == BINN_FAMILY_FLOAT) && (source_type != dest_type)) { - return copy_float_value(psource, pdest, source_type, dest_type); - } else { - return copy_raw_value(psource, pdest, data_store); - } -} - -/*** WRITE FUNCTIONS *****************************************************************/ - -BOOL binn_list_add(binn *list, int type, void *pvalue, int size) { - if (GetWriteConvertedData(&type, &pvalue, &size) == FALSE) { - return FALSE; - } - return binn_list_add_raw(list, type, pvalue, size); -} - -BOOL binn_map_set(binn *map, int id, int type, void *pvalue, int size) { - if (GetWriteConvertedData(&type, &pvalue, &size) == FALSE) { - return FALSE; - } - return binn_map_set_raw(map, id, type, pvalue, size); -} - -BOOL binn_object_set(binn *obj, const char *key, int type, void *pvalue, int size) { - if (GetWriteConvertedData(&type, &pvalue, &size) == FALSE) { - return FALSE; - } - return binn_object_set_raw(obj, key, strlen(key), type, pvalue, size); -} - -BOOL binn_object_set2(binn *obj, const char *key, int keylen, int type, void *pvalue, int size) { - if (GetWriteConvertedData(&type, &pvalue, &size) == FALSE) { - return FALSE; - } - return binn_object_set_raw(obj, key, keylen, type, pvalue, size); -} - -// this function is used by the wrappers -BOOL binn_add_value(binn *item, int binn_type, int id, char *name, int type, void *pvalue, int size) { - switch (binn_type) { - case BINN_LIST: - return binn_list_add(item, type, pvalue, size); - case BINN_MAP: - return binn_map_set(item, id, type, pvalue, size); - case BINN_OBJECT: - return binn_object_set(item, name, type, pvalue, size); - default: - return FALSE; - } -} - -BOOL binn_list_add_new(binn *list, binn *value) { - BOOL retval; - retval = binn_list_add_value(list, value); - binn_free(value); - return retval; -} - -BOOL binn_map_set_new(binn *map, int id, binn *value) { - BOOL retval; - retval = binn_map_set_value(map, id, value); - binn_free(value); - return retval; -} - -BOOL binn_object_set_new(binn *obj, const char *key, binn *value) { - BOOL retval; - retval = binn_object_set_value(obj, key, value); - binn_free(value); - return retval; -} - -BOOL binn_object_set_new2(binn *obj, const char *key, int keylen, binn *value) { - BOOL retval; - retval = binn_object_set_value2(obj, key, keylen, value); - binn_free(value); - return retval; -} - -/*** READ FUNCTIONS ******************************************************************/ - -binn *binn_list_value(void *ptr, int pos) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_list_get_value(ptr, pos, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -binn *binn_map_value(void *ptr, int id) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_map_get_value(ptr, id, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -binn *binn_object_value(void *ptr, const char *key) { - binn *value; - value = (binn*) binn_malloc(sizeof(binn)); - if (binn_object_get_value(ptr, key, value) == FALSE) { - free_fn(value); - return NULL; - } - value->allocated = TRUE; - return value; -} - -void *binn_list_read(void *list, int pos, int *ptype, int *psize) { - binn value; - if (binn_list_get_value(list, pos, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -void *binn_map_read(void *map, int id, int *ptype, int *psize) { - binn value; - if (binn_map_get_value(map, id, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -void *binn_object_read(void *obj, const char *key, int *ptype, int *psize) { - binn value; - if (binn_object_get_value(obj, key, &value) == FALSE) { - return NULL; - } - if (ptype) { - *ptype = value.type; - } - if (psize) { - *psize = value.size; - } -#if __BYTE_ORDER == __LITTLE_ENDIAN - return store_value(&value); -#else - return value.ptr; -#endif -} - -BOOL binn_list_get(void *ptr, int pos, int type, void *pvalue, int *psize) { - binn value; - int storage_type; - storage_type = binn_get_read_storage(type); - if ((storage_type != BINN_STORAGE_NOBYTES) && (pvalue == NULL)) { - return FALSE; - } - zero_value(pvalue, type); - if (binn_list_get_value(ptr, pos, &value) == FALSE) { - return FALSE; - } - if (copy_value(value.ptr, pvalue, value.type, type, storage_type) == FALSE) { - return FALSE; - } - if (psize) { - *psize = value.size; - } - return TRUE; -} - -BOOL binn_map_get(void *ptr, int id, int type, void *pvalue, int *psize) { - binn value; - int storage_type; - storage_type = binn_get_read_storage(type); - if ((storage_type != BINN_STORAGE_NOBYTES) && (pvalue == NULL)) { - return FALSE; - } - zero_value(pvalue, type); - if (binn_map_get_value(ptr, id, &value) == FALSE) { - return FALSE; - } - if (copy_value(value.ptr, pvalue, value.type, type, storage_type) == FALSE) { - return FALSE; - } - if (psize) { - *psize = value.size; - } - return TRUE; -} - -BOOL binn_object_get(void *ptr, const char *key, int type, void *pvalue, int *psize) { - binn value; - int storage_type; - storage_type = binn_get_read_storage(type); - if ((storage_type != BINN_STORAGE_NOBYTES) && (pvalue == NULL)) { - return FALSE; - } - zero_value(pvalue, type); - if (binn_object_get_value(ptr, key, &value) == FALSE) { - return FALSE; - } - if (copy_value(value.ptr, pvalue, value.type, type, storage_type) == FALSE) { - return FALSE; - } - if (psize) { - *psize = value.size; - } - return TRUE; -} - -// these functions below may not be implemented as inline functions, because -// they use a lot of space, even for the variable. so they will be exported. - -// but what about using as static? -// is there any problem with wrappers? can these wrappers implement these functions using the header? -// if as static, will they be present even on modules that don't use the functions? - -signed char binn_list_int8(void *list, int pos) { - signed char value; - binn_list_get(list, pos, BINN_INT8, &value, NULL); - return value; -} - -short binn_list_int16(void *list, int pos) { - short value; - binn_list_get(list, pos, BINN_INT16, &value, NULL); - return value; -} - -int binn_list_int32(void *list, int pos) { - int value; - binn_list_get(list, pos, BINN_INT32, &value, NULL); - return value; -} - -int64 binn_list_int64(void *list, int pos) { - int64 value; - binn_list_get(list, pos, BINN_INT64, &value, NULL); - return value; -} - -unsigned char binn_list_uint8(void *list, int pos) { - unsigned char value; - binn_list_get(list, pos, BINN_UINT8, &value, NULL); - return value; -} - -unsigned short binn_list_uint16(void *list, int pos) { - unsigned short value; - binn_list_get(list, pos, BINN_UINT16, &value, NULL); - return value; -} - -unsigned int binn_list_uint32(void *list, int pos) { - unsigned int value; - binn_list_get(list, pos, BINN_UINT32, &value, NULL); - return value; -} - -uint64 binn_list_uint64(void *list, int pos) { - uint64 value; - binn_list_get(list, pos, BINN_UINT64, &value, NULL); - return value; -} - -float binn_list_float(void *list, int pos) { - float value; - binn_list_get(list, pos, BINN_FLOAT32, &value, NULL); - return value; -} - -double binn_list_double(void *list, int pos) { - double value; - binn_list_get(list, pos, BINN_FLOAT64, &value, NULL); - return value; -} - -BOOL binn_list_bool(void *list, int pos) { - BOOL value; - binn_list_get(list, pos, BINN_BOOL, &value, NULL); - return value; -} - -BOOL binn_list_null(void *list, int pos) { - return binn_list_get(list, pos, BINN_NULL, NULL, NULL); -} - -char *binn_list_str(void *list, int pos) { - char *value; - binn_list_get(list, pos, BINN_STRING, &value, NULL); - return value; -} - -void *binn_list_blob(void *list, int pos, int *psize) { - void *value; - binn_list_get(list, pos, BINN_BLOB, &value, psize); - return value; -} - -void *binn_list_list(void *list, int pos) { - void *value; - binn_list_get(list, pos, BINN_LIST, &value, NULL); - return value; -} - -void *binn_list_map(void *list, int pos) { - void *value; - binn_list_get(list, pos, BINN_MAP, &value, NULL); - return value; -} - -void *binn_list_object(void *list, int pos) { - void *value; - binn_list_get(list, pos, BINN_OBJECT, &value, NULL); - return value; -} - -signed char binn_map_int8(void *map, int id) { - signed char value; - binn_map_get(map, id, BINN_INT8, &value, NULL); - return value; -} - -short binn_map_int16(void *map, int id) { - short value; - binn_map_get(map, id, BINN_INT16, &value, NULL); - return value; -} - -int binn_map_int32(void *map, int id) { - int value; - binn_map_get(map, id, BINN_INT32, &value, NULL); - return value; -} - -int64 binn_map_int64(void *map, int id) { - int64 value; - binn_map_get(map, id, BINN_INT64, &value, NULL); - return value; -} - -unsigned char binn_map_uint8(void *map, int id) { - unsigned char value; - binn_map_get(map, id, BINN_UINT8, &value, NULL); - return value; -} - -unsigned short binn_map_uint16(void *map, int id) { - unsigned short value; - binn_map_get(map, id, BINN_UINT16, &value, NULL); - return value; -} - -unsigned int binn_map_uint32(void *map, int id) { - unsigned int value; - binn_map_get(map, id, BINN_UINT32, &value, NULL); - return value; -} - -uint64 binn_map_uint64(void *map, int id) { - uint64 value; - binn_map_get(map, id, BINN_UINT64, &value, NULL); - return value; -} - -float binn_map_float(void *map, int id) { - float value; - binn_map_get(map, id, BINN_FLOAT32, &value, NULL); - return value; -} - -double binn_map_double(void *map, int id) { - double value; - binn_map_get(map, id, BINN_FLOAT64, &value, NULL); - return value; -} - -BOOL binn_map_bool(void *map, int id) { - BOOL value; - binn_map_get(map, id, BINN_BOOL, &value, NULL); - return value; -} - -BOOL binn_map_null(void *map, int id) { - return binn_map_get(map, id, BINN_NULL, NULL, NULL); -} - -char *binn_map_str(void *map, int id) { - char *value; - binn_map_get(map, id, BINN_STRING, &value, NULL); - return value; -} - -void *binn_map_blob(void *map, int id, int *psize) { - void *value; - binn_map_get(map, id, BINN_BLOB, &value, psize); - return value; -} - -void *binn_map_list(void *map, int id) { - void *value; - binn_map_get(map, id, BINN_LIST, &value, NULL); - return value; -} - -void *binn_map_map(void *map, int id) { - void *value; - binn_map_get(map, id, BINN_MAP, &value, NULL); - return value; -} - -void *binn_map_object(void *map, int id) { - void *value; - binn_map_get(map, id, BINN_OBJECT, &value, NULL); - return value; -} - -signed char binn_object_int8(void *obj, const char *key) { - signed char value; - binn_object_get(obj, key, BINN_INT8, &value, NULL); - return value; -} - -short binn_object_int16(void *obj, const char *key) { - short value; - binn_object_get(obj, key, BINN_INT16, &value, NULL); - return value; -} - -int binn_object_int32(void *obj, const char *key) { - int value; - binn_object_get(obj, key, BINN_INT32, &value, NULL); - return value; -} - -int64 binn_object_int64(void *obj, const char *key) { - int64 value; - binn_object_get(obj, key, BINN_INT64, &value, NULL); - return value; -} - -unsigned char binn_object_uint8(void *obj, const char *key) { - unsigned char value; - binn_object_get(obj, key, BINN_UINT8, &value, NULL); - return value; -} - -unsigned short binn_object_uint16(void *obj, const char *key) { - unsigned short value; - binn_object_get(obj, key, BINN_UINT16, &value, NULL); - return value; -} - -unsigned int binn_object_uint32(void *obj, const char *key) { - unsigned int value; - binn_object_get(obj, key, BINN_UINT32, &value, NULL); - return value; -} - -uint64 binn_object_uint64(void *obj, const char *key) { - uint64 value; - binn_object_get(obj, key, BINN_UINT64, &value, NULL); - return value; -} - -float binn_object_float(void *obj, const char *key) { - float value; - binn_object_get(obj, key, BINN_FLOAT32, &value, NULL); - return value; -} - -double binn_object_double(void *obj, const char *key) { - double value; - binn_object_get(obj, key, BINN_FLOAT64, &value, NULL); - return value; -} - -BOOL binn_object_bool(void *obj, const char *key) { - BOOL value; - binn_object_get(obj, key, BINN_BOOL, &value, NULL); - return value; -} - -BOOL binn_object_null(void *obj, const char *key) { - return binn_object_get(obj, key, BINN_NULL, NULL, NULL); -} - -char *binn_object_str(void *obj, const char *key) { - char *value; - binn_object_get(obj, key, BINN_STRING, &value, NULL); - return value; -} - -void *binn_object_blob(void *obj, const char *key, int *psize) { - void *value; - binn_object_get(obj, key, BINN_BLOB, &value, psize); - return value; -} - -void *binn_object_list(void *obj, const char *key) { - void *value; - binn_object_get(obj, key, BINN_LIST, &value, NULL); - return value; -} - -void *binn_object_map(void *obj, const char *key) { - void *value; - binn_object_get(obj, key, BINN_MAP, &value, NULL); - return value; -} - -void *binn_object_object(void *obj, const char *key) { - void *value; - binn_object_get(obj, key, BINN_OBJECT, &value, NULL); - return value; -} - -BINN_PRIVATE binn *binn_alloc_item() { - binn *item; - item = (binn*) binn_malloc(sizeof(binn)); - if (item) { - memset(item, 0, sizeof(binn)); - item->header = BINN_MAGIC; - item->allocated = TRUE; - } - return item; -} - -binn *binn_value(int type, void *pvalue, int size, binn_mem_free freefn) { - int storage_type; - binn *item = binn_alloc_item(); - if (item) { - item->type = type; - binn_get_type_info(type, &storage_type, NULL); - switch (storage_type) { - case BINN_STORAGE_NOBYTES: - break; - case BINN_STORAGE_STRING: - if (size == 0) { - size = strlen((const char*) pvalue) + 1; - } - case BINN_STORAGE_BLOB: - case BINN_STORAGE_CONTAINER: - if (freefn == BINN_TRANSIENT) { - item->ptr = binn_memdup(pvalue, size); - if (item->ptr == NULL) { - free_fn(item); - return NULL; - } - item->freefn = free_fn; - if (storage_type == BINN_STORAGE_STRING) { - size--; - } - } else { - item->ptr = pvalue; - item->freefn = freefn; - } - item->size = size; - break; - default: - item->ptr = &item->vint32; - copy_raw_value(pvalue, item->ptr, storage_type); - } - } - return item; -} - -BOOL binn_set_string(binn *item, char *str, binn_mem_free pfree) { - if ((item == NULL) || (str == NULL)) { - return FALSE; - } - if (pfree == BINN_TRANSIENT) { - item->ptr = binn_memdup(str, strlen(str) + 1); - if (item->ptr == NULL) { - return FALSE; - } - item->freefn = free_fn; - } else { - item->ptr = str; - item->freefn = pfree; - } - item->type = BINN_STRING; - return TRUE; -} - -BOOL binn_set_blob(binn *item, void *ptr, int size, binn_mem_free pfree) { - if ((item == NULL) || (ptr == NULL)) { - return FALSE; - } - if (pfree == BINN_TRANSIENT) { - item->ptr = binn_memdup(ptr, size); - if (item->ptr == NULL) { - return FALSE; - } - item->freefn = free_fn; - } else { - item->ptr = ptr; - item->freefn = pfree; - } - item->type = BINN_BLOB; - item->size = size; - return TRUE; -} - -/*** READ CONVERTED VALUE ************************************************************/ - -#ifdef _MSC_VER -#define atoi64 _atoi64 -#else - -int64 atoi64(char *str) { - int64 retval; - int is_negative = 0; - - if (*str == '-') { - is_negative = 1; - str++; - } - retval = 0; - for ( ; *str; str++) { - retval = 10 * retval + (*str - '0'); - } - if (is_negative) { - retval *= -1; - } - return retval; -} - -#endif - -BINN_PRIVATE BOOL is_integer(char *p) { - BOOL retval; - if (p == NULL) { - return FALSE; - } - if (*p == '-') { - p++; - } - if (*p == 0) { - return FALSE; - } - retval = TRUE; - for ( ; *p; p++) { - if ((*p < '0') || (*p > '9')) { - retval = FALSE; - } - } - return retval; -} - -BINN_PRIVATE BOOL is_float(char *p) { - BOOL retval, number_found = FALSE; - if (p == NULL) { - return FALSE; - } - if (*p == '-') { - p++; - } - if (*p == 0) { - return FALSE; - } - retval = TRUE; - for ( ; *p; p++) { - if ((*p == '.') || (*p == ',')) { - if (!number_found) { - retval = FALSE; - } - } else if ((*p >= '0') && (*p <= '9')) { - number_found = TRUE; - } else { - return FALSE; - } - } - return retval; -} - -BINN_PRIVATE BOOL is_bool_str(char *str, BOOL *pbool) { - int64 vint; - double vdouble; - if ((str == NULL) || (pbool == NULL)) { - return FALSE; - } - if (stricmp(str, "true") == 0) { - goto loc_true; - } - if (stricmp(str, "yes") == 0) { - goto loc_true; - } - if (stricmp(str, "on") == 0) { - goto loc_true; - } - //if (stricmp(str, "1") == 0) goto loc_true; - - if (stricmp(str, "false") == 0) { - goto loc_false; - } - if (stricmp(str, "no") == 0) { - goto loc_false; - } - if (stricmp(str, "off") == 0) { - goto loc_false; - } - //if (stricmp(str, "0") == 0) goto loc_false; - - if (is_integer(str)) { - vint = atoi64(str); - *pbool = (vint != 0) ? TRUE : FALSE; - return TRUE; - } else if (is_float(str)) { - vdouble = atof(str); - *pbool = (vdouble != 0) ? TRUE : FALSE; - return TRUE; - } - - return FALSE; - -loc_true: - *pbool = TRUE; - return TRUE; - -loc_false: - *pbool = FALSE; - return TRUE; -} - -BOOL binn_get_int32(binn *value, int *pint) { - if ((value == NULL) || (pint == NULL)) { - return FALSE; - } - if (type_family(value->type) == BINN_FAMILY_INT) { - return copy_int_value(value->ptr, pint, value->type, BINN_INT32); - } - switch (value->type) { - case BINN_FLOAT: - *pint = round(value->vfloat); - break; - case BINN_DOUBLE: - *pint = round(value->vdouble); - break; - case BINN_STRING: - if (is_integer((char*) value->ptr)) { - *pint = atoi((char*) value->ptr); - } else if (is_float((char*) value->ptr)) { - *pint = round(atof((char*) value->ptr)); - } else { - return FALSE; - } - break; - case BINN_BOOL: - *pint = value->vbool; - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL binn_get_int64(binn *value, int64 *pint) { - if ((value == NULL) || (pint == NULL)) { - return FALSE; - } - if (type_family(value->type) == BINN_FAMILY_INT) { - return copy_int_value(value->ptr, pint, value->type, BINN_INT64); - } - switch (value->type) { - case BINN_FLOAT: - *pint = round(value->vfloat); - break; - case BINN_DOUBLE: - *pint = round(value->vdouble); - break; - case BINN_STRING: - if (is_integer((char*) value->ptr)) { - *pint = atoi64((char*) value->ptr); - } else if (is_float((char*) value->ptr)) { - *pint = round(atof((char*) value->ptr)); - } else { - return FALSE; - } - break; - case BINN_BOOL: - *pint = value->vbool; - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL binn_get_double(binn *value, double *pfloat) { - int64 vint; - if ((value == NULL) || (pfloat == NULL)) { - return FALSE; - } - if (type_family(value->type) == BINN_FAMILY_INT) { - if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) { - return FALSE; - } - *pfloat = (double) vint; - return TRUE; - } - switch (value->type) { - case BINN_FLOAT: - *pfloat = value->vfloat; - break; - case BINN_DOUBLE: - *pfloat = value->vdouble; - break; - case BINN_STRING: - if (is_integer((char*) value->ptr)) { - *pfloat = (double) atoi64((char*) value->ptr); - } else if (is_float((char*) value->ptr)) { - *pfloat = atof((char*) value->ptr); - } else { - return FALSE; - } - break; - case BINN_BOOL: - *pfloat = value->vbool; - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL binn_get_bool(binn *value, BOOL *pbool) { - int64 vint; - if ((value == NULL) || (pbool == NULL)) { - return FALSE; - } - if (type_family(value->type) == BINN_FAMILY_INT) { - if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) { - return FALSE; - } - *pbool = (vint != 0) ? TRUE : FALSE; - return TRUE; - } - switch (value->type) { - case BINN_BOOL: - *pbool = value->vbool; - break; - case BINN_FLOAT: - *pbool = (value->vfloat != 0) ? TRUE : FALSE; - break; - case BINN_DOUBLE: - *pbool = (value->vdouble != 0) ? TRUE : FALSE; - break; - case BINN_STRING: - return is_bool_str((char*) value->ptr, pbool); - default: - return FALSE; - } - return TRUE; -} - -char *binn_get_str(binn *value) { - int64 vint; - char buf[128]; - if (value == NULL) { - return NULL; - } - if (type_family(value->type) == BINN_FAMILY_INT) { - if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) { - return NULL; - } - snprintf(buf, sizeof(buf), "%" INT64_FORMAT, vint); // -V576 - goto loc_convert_value; - } - switch (value->type) { - case BINN_FLOAT: - value->vdouble = value->vfloat; - case BINN_DOUBLE: - snprintf(buf, sizeof(buf), "%g", value->vdouble); - goto loc_convert_value; - case BINN_STRING: - return (char*) value->ptr; - case BINN_BOOL: - if (value->vbool) { - strcpy(buf, "true"); - } else { - strcpy(buf, "false"); - } - goto loc_convert_value; - } - return NULL; - -loc_convert_value: - value->ptr = strdup(buf); - if (value->ptr == NULL) { - return NULL; - } - value->freefn = free; - value->type = BINN_STRING; - return (char*) value->ptr; -} - -/*** GENERAL FUNCTIONS ***************************************************************/ - -BOOL binn_is_container(binn *item) { - if (item == NULL) { - return FALSE; - } - switch (item->type) { - case BINN_LIST: - case BINN_MAP: - case BINN_OBJECT: - return TRUE; - default: - return FALSE; - } -} - -void binn_set_user_data(binn *item, void *user_data, binn_user_data_free freefn) { - if (item->userdata_freefn) { - item->userdata_freefn(item->user_data); - } - item->user_data = user_data; - item->userdata_freefn = free_fn; -} diff --git a/src/jbl/binn.h b/src/jbl/binn.h deleted file mode 100644 index 78c3e252c..000000000 --- a/src/jbl/binn.h +++ /dev/null @@ -1,1053 +0,0 @@ - -#pragma once -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// TO ENABLE INLINE FUNCTIONS: -// ON MSVC: enable the 'Inline Function Expansion' (/Ob2) compiler option, and maybe the -// 'Whole Program Optimitazion' (/GL), that requires the -// 'Link Time Code Generation' (/LTCG) linker option to be enabled too - -#ifndef BINN_H -#define BINN_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void*) 0) -#endif -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef BOOL -typedef int BOOL; -#endif - -#ifndef BINN_PRIVATE -#ifdef DEBUG -#define BINN_PRIVATE -#else -#define BINN_PRIVATE static -#endif -#endif - -#ifndef int64 -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else -typedef int64_t int64; -typedef uint64_t uint64; -#endif -#endif - -// BINN CONSTANTS ---------------------------------------- - -// magic number: 0x1F 0xb1 0x22 0x1F => 0x1FB1221F or 0x1F22B11F -// because the BINN_STORAGE_NOBYTES (binary 000) may not have so many sub-types (BINN_STORAGE_HAS_MORE = 0x10) -#define BINN_MAGIC 0x1F22B11F -#define MAX_BINN_HEADER 9 // [1:type][4:size][4:count] -#define MIN_BINN_SIZE 3 // [1:type][1:size][1:count] -#define MAX_BIN_KEY_LEN 255 - -#define INVALID_BINN 0 - -// Storage Data Types ------------------------------------ - -#define BINN_STORAGE_NOBYTES 0x00 -#define BINN_STORAGE_BYTE 0x20 // 8 bits -#define BINN_STORAGE_WORD 0x40 // 16 bits -- the endianess (byte order) is automatically corrected -#define BINN_STORAGE_DWORD 0x60 // 32 bits -- the endianess (byte order) is automatically corrected -#define BINN_STORAGE_QWORD 0x80 // 64 bits -- the endianess (byte order) is automatically corrected -#define BINN_STORAGE_STRING 0xA0 // Are stored with null termination -#define BINN_STORAGE_BLOB 0xC0 -#define BINN_STORAGE_CONTAINER 0xE0 -#define BINN_STORAGE_VIRTUAL 0x80000 -//-- -#define BINN_STORAGE_MIN BINN_STORAGE_NOBYTES -#define BINN_STORAGE_MAX BINN_STORAGE_CONTAINER - -#define BINN_STORAGE_MASK 0xE0 -#define BINN_STORAGE_MASK16 0xE000 -#define BINN_STORAGE_HAS_MORE 0x10 -#define BINN_TYPE_MASK 0x0F -#define BINN_TYPE_MASK16 0x0FFF - -#define BINN_MAX_VALUE_MASK 0xFFFFF -//++ - -// Data Formats ------------------------------------------ - -#define BINN_LIST 0xE0 -#define BINN_MAP 0xE1 -#define BINN_OBJECT 0xE2 - -#define BINN_NULL 0x00 -#define BINN_TRUE 0x01 -#define BINN_FALSE 0x02 - -#define BINN_UINT8 0x20 // (BYTE) (unsigned byte) Is the default format for the BYTE type -#define BINN_INT8 0x21 // (BYTE) (signed byte, from -128 to +127. The 0x80 is the sign bit, so the range in hex is - // from 0x80 [-128] to 0x7F [127], being 0x00 = 0 and 0xFF = -1) -#define BINN_UINT16 0x40 // (WORD) (unsigned integer) Is the default format for the WORD type -#define BINN_INT16 0x41 // (WORD) (signed integer) -#define BINN_UINT32 0x60 // (DWORD) (unsigned integer) Is the default format for the DWORD type -#define BINN_INT32 0x61 // (DWORD) (signed integer) -#define BINN_UINT64 0x80 // (QWORD) (unsigned integer) Is the default format for the QWORD type -#define BINN_INT64 0x81 // (QWORD) (signed integer) - -#define BINN_SCHAR BINN_INT8 -#define BINN_UCHAR BINN_UINT8 - -#define BINN_STRING 0xA0 // (STRING) Raw String -#define BINN_DATETIME 0xA1 // (STRING) iso8601 format -- YYYY-MM-DD HH:MM:SS -#define BINN_DATE 0xA2 // (STRING) iso8601 format -- YYYY-MM-DD -#define BINN_TIME 0xA3 // (STRING) iso8601 format -- HH:MM:SS -#define BINN_DECIMAL 0xA4 // (STRING) High precision number - used for generic decimal values and for those ones - // that cannot be represented in the float64 format. -#define BINN_CURRENCYSTR 0xA5 // (STRING) With currency unit/symbol - check for some iso standard format -#define BINN_SINGLE_STR 0xA6 // (STRING) Can be restored to float32 -#define BINN_DOUBLE_STR 0xA7 // (STRING) May be restored to float64 - -#define BINN_FLOAT32 0x62 // (DWORD) -#define BINN_FLOAT64 0x82 // (QWORD) -#define BINN_FLOAT BINN_FLOAT32 -#define BINN_SINGLE BINN_FLOAT32 -#define BINN_DOUBLE BINN_FLOAT64 - -#define BINN_CURRENCY 0x83 // (QWORD) - -#define BINN_BLOB 0xC0 // (BLOB) Raw Blob - - -// virtual types: - -#define BINN_BOOL 0x80061 // (DWORD) The value may be 0 or 1 - -#ifdef BINN_EXTENDED -//#define BINN_SINGLE 0x800A1 // (STRING) Can be restored to float32 -//#define BINN_DOUBLE 0x800A2 // (STRING) May be restored to float64 -#endif - -//#define BINN_BINN 0x800E1 // (CONTAINER) -//#define BINN_BINN_BUFFER 0x800C1 // (BLOB) user binn. it's not open by the parser - -// extended content types: - -// strings: -#define BINN_HTML 0xB001 -#define BINN_XML 0xB002 -#define BINN_JSON 0xB003 -#define BINN_JAVASCRIPT 0xB004 -#define BINN_CSS 0xB005 - -// blobs: -#define BINN_JPEG 0xD001 -#define BINN_GIF 0xD002 -#define BINN_PNG 0xD003 -#define BINN_BMP 0xD004 - -// type families -#define BINN_FAMILY_NONE 0x00 -#define BINN_FAMILY_NULL 0xf1 -#define BINN_FAMILY_INT 0xf2 -#define BINN_FAMILY_FLOAT 0xf3 -#define BINN_FAMILY_STRING 0xf4 -#define BINN_FAMILY_BLOB 0xf5 -#define BINN_FAMILY_BOOL 0xf6 -#define BINN_FAMILY_BINN 0xf7 - -// integer types related to signal -#define BINN_SIGNED_INT 11 -#define BINN_UNSIGNED_INT 22 - -typedef void (*binn_mem_free)(void*); - -typedef void (*binn_user_data_free)(void*); - -#define BINN_STATIC ((binn_mem_free) 0) -#define BINN_TRANSIENT ((binn_mem_free) - 1) - - -#define BINN_IS_CONTAINER_TYPE(type_) ((type_) >= BINN_LIST && (type_) <= BINN_OBJECT) - -#define BINN_IS_INT_TYPE(type_) ((type_) >= BINN_UINT8 && (type_) <= BINN_INT64) - - -// --- BINN STRUCTURE -------------------------------------------------------------- - -struct binn_struct { - int header; // this struct header holds the magic number (BINN_MAGIC) that identifies this memory block as a - // binn structure - BOOL allocated; // the struct can be allocated using malloc_fn() or can be on the stack - BOOL writable; // did it was create for writing? it can use the pbuf if not unified with ptr - BOOL dirty; // the container header is not written to the buffer - // - void *pbuf; // use *ptr below? - BOOL pre_allocated; - int alloc_size; - int used_size; - // - int type; - void *ptr; - int size; - int count; - // - binn_mem_free freefn; // used only when type == BINN_STRING or BINN_BLOB - // - void *user_data; - binn_user_data_free userdata_freefn; - // - union { - int8_t vint8; - int16_t vint16; - int32_t vint32; - int64_t vint64; - uint8_t vuint8; - uint16_t vuint16; - uint32_t vuint32; - uint64_t vuint64; - // - signed char vchar; - unsigned char vuchar; - signed short vshort; - unsigned short vushort; - signed int vint; - unsigned int vuint; - // - float vfloat; - double vdouble; - // - BOOL vbool; - }; -}; - -typedef struct binn_struct binn; - -// --- GENERAL FUNCTIONS ---------------------------------------------------------- - -void binn_set_alloc_functions( - void*(*new_malloc)(size_t), void*(*new_realloc)(void*, size_t), - void (*new_free)(void*)); -int binn_create_type(int storage_type, int data_type_index); -BOOL binn_get_type_info(int long_type, int *pstorage_type, int *pextra_type); -int binn_get_write_storage(int type); -int binn_get_read_storage(int type); -BOOL binn_is_container(binn *item); - -void binn_set_user_data(binn *item, void *user_data, binn_user_data_free freefn); - -// --- WRITE FUNCTIONS ------------------------------------------------------------ - -BOOL binn_save_header(binn *item); - -// create a new binn allocating memory for the structure -IW_ALLOC binn *binn_new(int type, int size, void *buffer); -IW_ALLOC binn *binn_list(); -IW_ALLOC binn *binn_map(); -IW_ALLOC binn *binn_object(); - -// create a new binn storing the structure on the stack -BOOL binn_create(binn *item, int type, int size, void *buffer); -BOOL binn_create_list(binn *list); -BOOL binn_create_map(binn *map); -BOOL binn_create_object(binn *object); - -// create a new binn as a copy from another -IW_ALLOC binn *binn_copy(void *old); - -BOOL binn_list_add_new(binn *list, binn *value); -BOOL binn_map_set_new(binn *map, int id, binn *value); -BOOL binn_object_set_new(binn *obj, const char *key, binn *value); -BOOL binn_object_set_new2(binn *obj, const char *key, int keylen, binn *value); - -// extended interface -BOOL binn_list_add(binn *list, int type, void *pvalue, int size); -BOOL binn_map_set(binn *map, int id, int type, void *pvalue, int size); -BOOL binn_object_set(binn *obj, const char *key, int type, void *pvalue, int size); -BOOL binn_object_set2(binn *obj, const char *key, int keylen, int type, void *pvalue, int size); - -// release memory -void binn_free(binn *item); - -// free the binn structure but keeps the binn buffer allocated, returning a pointer to it. -// use the free function to release the buffer later -void *binn_release(binn *item); - -// --- CREATING VALUES --------------------------------------------------- - -IW_ALLOC binn *binn_value(int type, void *pvalue, int size, binn_mem_free freefn); - -IW_INLINE void binn_init_item(binn *item) { - memset(item, 0, sizeof(binn)); - item->header = BINN_MAGIC; -} - -IW_ALLOC IW_INLINE binn *binn_int8(signed char value) { - return binn_value(BINN_INT8, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_int16(short value) { - return binn_value(BINN_INT16, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_int32(int value) { - return binn_value(BINN_INT32, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_int64(int64 value) { - return binn_value(BINN_INT64, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_uint8(unsigned char value) { - return binn_value(BINN_UINT8, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_uint16(unsigned short value) { - return binn_value(BINN_UINT16, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_uint32(unsigned int value) { - return binn_value(BINN_UINT32, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_uint64(uint64 value) { - return binn_value(BINN_UINT64, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_float(float value) { - return binn_value(BINN_FLOAT, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_double(double value) { - return binn_value(BINN_DOUBLE, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_bool(BOOL value) { - return binn_value(BINN_BOOL, &value, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_null() { - return binn_value(BINN_NULL, NULL, 0, NULL); -} - -IW_ALLOC IW_INLINE binn *binn_string(const char *str, binn_mem_free freefn) { - return binn_value(BINN_STRING, (void*) str, 0, freefn); -} - -IW_ALLOC IW_INLINE binn *binn_blob(void *ptr, int size, binn_mem_free freefn) { - return binn_value(BINN_BLOB, ptr, size, freefn); -} - -// --- READ FUNCTIONS ------------------------------------------------------------- - -// these functions accept pointer to the binn structure and pointer to the binn buffer -void *binn_ptr(void *ptr); -int binn_size(void *ptr); -int binn_buf_size(const void *ptr); -int binn_type(void *ptr); -int binn_buf_type(const void *pbuf); -int binn_count(void *ptr); -int binn_buf_count(const void *pbuf); -BOOL binn_is_valid_header(const void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize); - -BOOL binn_is_valid(void *ptr, int *ptype, int *pcount, int *psize); - -/* the function returns the values (type, count and size) and they don't need to be - initialized. these values are read from the buffer. example: - - int type, count, size; - result = binn_is_valid(ptr, &type, &count, &size); - */ -BOOL binn_is_valid_ex(void *ptr, int *ptype, int *pcount, int *psize); - -/* if some value is informed (type, count or size) then the function will check if - the value returned from the serialized data matches the informed value. otherwise - the values must be initialized to zero. example: - - int type=0, count=0, size = known_size; - result = binn_is_valid_ex(ptr, &type, &count, &size); - */ - -BOOL binn_is_struct(void *ptr); - -// Loading a binn buffer into a binn value - this is optional - -BOOL binn_load(void *data, binn *item); // on stack -binn *binn_open(void *data); // allocated - -// easiest interface to use, but don't check if the value is there - -signed char binn_list_int8(void *list, int pos); -short binn_list_int16(void *list, int pos); -int binn_list_int32(void *list, int pos); -int64 binn_list_int64(void *list, int pos); -unsigned char binn_list_uint8(void *list, int pos); -unsigned short binn_list_uint16(void *list, int pos); -unsigned int binn_list_uint32(void *list, int pos); -uint64 binn_list_uint64(void *list, int pos); -float binn_list_float(void *list, int pos); -double binn_list_double(void *list, int pos); -BOOL binn_list_bool(void *list, int pos); -BOOL binn_list_null(void *list, int pos); -char *binn_list_str(void *list, int pos); -void *binn_list_blob(void *list, int pos, int *psize); -void *binn_list_list(void *list, int pos); -void *binn_list_map(void *list, int pos); -void *binn_list_object(void *list, int pos); - -signed char binn_map_int8(void *map, int id); -short binn_map_int16(void *map, int id); -int binn_map_int32(void *map, int id); -int64 binn_map_int64(void *map, int id); -unsigned char binn_map_uint8(void *map, int id); -unsigned short binn_map_uint16(void *map, int id); -unsigned int binn_map_uint32(void *map, int id); -uint64 binn_map_uint64(void *map, int id); -float binn_map_float(void *map, int id); -double binn_map_double(void *map, int id); -BOOL binn_map_bool(void *map, int id); -BOOL binn_map_null(void *map, int id); -char *binn_map_str(void *map, int id); -void *binn_map_blob(void *map, int id, int *psize); -void *binn_map_list(void *map, int id); -void *binn_map_map(void *map, int id); -void *binn_map_object(void *map, int id); - -signed char binn_object_int8(void *obj, const char *key); -short binn_object_int16(void *obj, const char *key); -int binn_object_int32(void *obj, const char *key); -int64 binn_object_int64(void *obj, const char *key); -unsigned char binn_object_uint8(void *obj, const char *key); -unsigned short binn_object_uint16(void *obj, const char *key); -unsigned int binn_object_uint32(void *obj, const char *key); -uint64 binn_object_uint64(void *obj, const char *key); -float binn_object_float(void *obj, const char *key); -double binn_object_double(void *obj, const char *key); -BOOL binn_object_bool(void *obj, const char *key); -BOOL binn_object_null(void *obj, const char *key); -char *binn_object_str(void *obj, const char *key); -void *binn_object_blob(void *obj, const char *key, int *psize); -void *binn_object_list(void *obj, const char *key); -void *binn_object_map(void *obj, const char *key); -void *binn_object_object(void *obj, const char *key); - - -// return a pointer to an allocated binn structure - must be released with the free() function or equivalent set in -// binn_set_alloc_functions() -binn *binn_list_value(void *list, int pos); -binn *binn_map_value(void *map, int id); -binn *binn_object_value(void *obj, const char *key); - -// read the value to a binn structure on the stack -BOOL binn_list_get_value(void *list, int pos, binn *value); -BOOL binn_map_get_value(void *map, int id, binn *value); -BOOL binn_object_get_value(void *obj, const char *key, binn *value); - -// single interface - these functions check the data type -BOOL binn_list_get(void *list, int pos, int type, void *pvalue, int *psize); -BOOL binn_map_get(void *map, int id, int type, void *pvalue, int *psize); -BOOL binn_object_get(void *obj, const char *key, int type, void *pvalue, int *psize); - -// these 3 functions return a pointer to the value and the data type -// they are thread-safe on big-endian devices -// on little-endian devices they are thread-safe only to return pointers to list, map, object, blob and strings -// the returned pointer to 16, 32 and 64 bits values must be used only by single-threaded applications -void *binn_list_read(void *list, int pos, int *ptype, int *psize); -void *binn_map_read(void *map, int id, int *ptype, int *psize); -void *binn_object_read(void *obj, const char *key, int *ptype, int *psize); - -// READ PAIR FUNCTIONS - -// these functions use base 1 in the 'pos' argument - -// on stack -BOOL binn_map_get_pair(void *map, int pos, int *pid, binn *value); -BOOL binn_object_get_pair( - void *obj, int pos, char *pkey, - binn *value); // must free the memory returned in the pkey - -// allocated -IW_ALLOC binn *binn_map_pair(void *map, int pos, int *pid); -IW_ALLOC binn *binn_object_pair(void *obj, int pos, char *pkey); // must free the memory returned in the pkey - -// these 2 functions return a pointer to the value and the data type -// they are thread-safe on big-endian devices -// on little-endian devices they are thread-safe only to return pointers to list, map, object, blob and strings -// the returned pointer to 16, 32 and 64 bits values must be used only by single-threaded applications -void *binn_map_read_pair(void *ptr, int pos, int *pid, int *ptype, int *psize); -void *binn_object_read_pair(void *ptr, int pos, char *pkey, int *ptype, int *psize); - -// SEQUENTIAL READ FUNCTIONS - -typedef struct binn_iter_struct { - unsigned char *pnext; - unsigned char *plimit; - int type; - int count; - int current; -} binn_iter; - -BOOL binn_iter_init(binn_iter *iter, void *pbuf, int type); - -// allocated -IW_ALLOC binn *binn_list_next_value(binn_iter *iter); -IW_ALLOC binn *binn_map_next_value(binn_iter *iter, int *pid); -IW_ALLOC binn *binn_object_next_value(binn_iter *iter, char *pkey); // the key must be declared as: char key[256]; - -// on stack -BOOL binn_list_next(binn_iter *iter, binn *value); -BOOL binn_map_next(binn_iter *iter, int *pid, binn *value); -BOOL binn_object_next( - binn_iter *iter, char *pkey, - binn *value); // the key must be declared as: char key[256]; -BOOL binn_object_next2(binn_iter *iter, char **pkey, int *klen, binn *value); - -// these 3 functions return a pointer to the value and the data type -// they are thread-safe on big-endian devices -// on little-endian devices they are thread-safe only to return pointers to list, map, object, blob and strings -// the returned pointer to 16, 32 and 64 bits values must be used only by single-threaded applications -void *binn_list_read_next(binn_iter *iter, int *ptype, int *psize); -void *binn_map_read_next(binn_iter *iter, int *pid, int *ptype, int *psize); -void *binn_object_read_next( - binn_iter *iter, char *pkey, int *ptype, - int *psize); // the key must be declared as: char key[256]; - -// --- MACROS ------------------------------------------------------------ - -#define binn_is_writable(item) (item)->writable; - -// set values on stack allocated binn structures - -#define binn_set_null(item) do { (item)->type = BINN_NULL; } while (0) - -#define binn_set_bool(item, value) do { (item)->type = BINN_BOOL; (item)->vbool = value; (item)->ptr = &((item)->vbool); \ -} while (0) - -#define binn_set_int(item, value) do { (item)->type = BINN_INT32; (item)->vint32 = value; \ - (item)->ptr = &((item)->vint32); } while (0) -#define binn_set_int64(item, value) do { (item)->type = BINN_INT64; (item)->vint64 = value; \ - (item)->ptr = &((item)->vint64); } while (0) - -#define binn_set_uint(item, value) do { (item)->type = BINN_UINT32; (item)->vuint32 = value; \ - (item)->ptr = &((item)->vuint32); } while (0) -#define binn_set_uint64(item, value) do { (item)->type = BINN_UINT64; (item)->vuint64 = value; \ - (item)->ptr = &((item)->vuint64); } while (0) - -#define binn_set_float(item, value) do { (item)->type = BINN_FLOAT; (item)->vfloat = value; \ - (item)->ptr = &((item)->vfloat); } while (0) -#define binn_set_double(item, value) do { (item)->type = BINN_DOUBLE; (item)->vdouble = value; \ - (item)->ptr = &((item)->vdouble); } while (0) - -//#define binn_set_string(item,str,pfree) do { (item)->type = BINN_STRING; (item)->ptr = str; (item)->freefn = pfree; -// } while (0) -//#define binn_set_blob(item,ptr,size,pfree) do { (item)->type = BINN_BLOB; (item)->ptr = ptr; (item)->freefn = pfree; -// (item)->size = size; } while (0) -BOOL binn_set_string(binn *item, char *str, binn_mem_free pfree); -BOOL binn_set_blob(binn *item, void *ptr, int size, binn_mem_free pfree); - -//#define binn_double(value) { (item)->type = BINN_DOUBLE; (item)->vdouble = value; (item)->ptr = -// &((item)->vdouble) } - -// FOREACH MACROS -// must use these declarations in the function that will use them: -// binn_iter iter; -// char key[256]; // only for the object -// int id; // only for the map -// binn value; - -#define binn_object_foreach(object, key, value) \ - binn_iter_init(&iter, object, BINN_OBJECT); \ - while (binn_object_next(&iter, key, &value)) - -#define binn_map_foreach(map, id, value) \ - binn_iter_init(&iter, map, BINN_MAP); \ - while (binn_map_next(&iter, &id, &value)) - -#define binn_list_foreach(list, value) \ - binn_iter_init(&iter, list, BINN_LIST); \ - while (binn_list_next(&iter, &value)) - -/*************************************************************************************/ -/*** SET FUNCTIONS *******************************************************************/ -/*************************************************************************************/ - -IW_INLINE BOOL binn_list_add_int8(binn *list, signed char value) { - return binn_list_add(list, BINN_INT8, &value, 0); -} - -IW_INLINE BOOL binn_list_add_int16(binn *list, short value) { - return binn_list_add(list, BINN_INT16, &value, 0); -} - -IW_INLINE BOOL binn_list_add_int32(binn *list, int value) { - return binn_list_add(list, BINN_INT32, &value, 0); -} - -IW_INLINE BOOL binn_list_add_int64(binn *list, int64 value) { - return binn_list_add(list, BINN_INT64, &value, 0); -} - -IW_INLINE BOOL binn_list_add_uint8(binn *list, unsigned char value) { - return binn_list_add(list, BINN_UINT8, &value, 0); -} - -IW_INLINE BOOL binn_list_add_uint16(binn *list, unsigned short value) { - return binn_list_add(list, BINN_UINT16, &value, 0); -} - -IW_INLINE BOOL binn_list_add_uint32(binn *list, unsigned int value) { - return binn_list_add(list, BINN_UINT32, &value, 0); -} - -IW_INLINE BOOL binn_list_add_uint64(binn *list, uint64 value) { - return binn_list_add(list, BINN_UINT64, &value, 0); -} - -IW_INLINE BOOL binn_list_add_float(binn *list, float value) { - return binn_list_add(list, BINN_FLOAT32, &value, 0); -} - -IW_INLINE BOOL binn_list_add_double(binn *list, double value) { - return binn_list_add(list, BINN_FLOAT64, &value, 0); -} - -IW_INLINE BOOL binn_list_add_bool(binn *list, BOOL value) { - return binn_list_add(list, BINN_BOOL, &value, 0); -} - -IW_INLINE BOOL binn_list_add_null(binn *list) { - return binn_list_add(list, BINN_NULL, NULL, 0); -} - -IW_INLINE BOOL binn_list_add_str(binn *list, char *str) { - return binn_list_add(list, BINN_STRING, str, 0); -} - -IW_INLINE BOOL binn_list_add_const_str(binn *list, const char *str) { - return binn_list_add(list, BINN_STRING, (char*) str, 0); -} - -IW_INLINE BOOL binn_list_add_blob(binn *list, void *ptr, int size) { - return binn_list_add(list, BINN_BLOB, ptr, size); -} - -IW_INLINE BOOL binn_list_add_list(binn *list, void *list2) { - return binn_list_add(list, BINN_LIST, binn_ptr(list2), binn_size(list2)); -} - -IW_INLINE BOOL binn_list_add_map(binn *list, void *map) { - return binn_list_add(list, BINN_MAP, binn_ptr(map), binn_size(map)); -} - -IW_INLINE BOOL binn_list_add_object(binn *list, void *obj) { - return binn_list_add(list, BINN_OBJECT, binn_ptr(obj), binn_size(obj)); -} - -IW_INLINE BOOL binn_list_add_value(binn *list, binn *value) { - return binn_list_add(list, value->type, binn_ptr(value), binn_size(value)); -} - -/*************************************************************************************/ - -IW_INLINE BOOL binn_map_set_int8(binn *map, int id, signed char value) { - return binn_map_set(map, id, BINN_INT8, &value, 0); -} - -IW_INLINE BOOL binn_map_set_int16(binn *map, int id, short value) { - return binn_map_set(map, id, BINN_INT16, &value, 0); -} - -IW_INLINE BOOL binn_map_set_int32(binn *map, int id, int value) { - return binn_map_set(map, id, BINN_INT32, &value, 0); -} - -IW_INLINE BOOL binn_map_set_int64(binn *map, int id, int64 value) { - return binn_map_set(map, id, BINN_INT64, &value, 0); -} - -IW_INLINE BOOL binn_map_set_uint8(binn *map, int id, unsigned char value) { - return binn_map_set(map, id, BINN_UINT8, &value, 0); -} - -IW_INLINE BOOL binn_map_set_uint16(binn *map, int id, unsigned short value) { - return binn_map_set(map, id, BINN_UINT16, &value, 0); -} - -IW_INLINE BOOL binn_map_set_uint32(binn *map, int id, unsigned int value) { - return binn_map_set(map, id, BINN_UINT32, &value, 0); -} - -IW_INLINE BOOL binn_map_set_uint64(binn *map, int id, uint64 value) { - return binn_map_set(map, id, BINN_UINT64, &value, 0); -} - -IW_INLINE BOOL binn_map_set_float(binn *map, int id, float value) { - return binn_map_set(map, id, BINN_FLOAT32, &value, 0); -} - -IW_INLINE BOOL binn_map_set_double(binn *map, int id, double value) { - return binn_map_set(map, id, BINN_FLOAT64, &value, 0); -} - -IW_INLINE BOOL binn_map_set_bool(binn *map, int id, BOOL value) { - return binn_map_set(map, id, BINN_BOOL, &value, 0); -} - -IW_INLINE BOOL binn_map_set_null(binn *map, int id) { - return binn_map_set(map, id, BINN_NULL, NULL, 0); -} - -IW_INLINE BOOL binn_map_set_str(binn *map, int id, char *str) { - return binn_map_set(map, id, BINN_STRING, str, 0); -} - -IW_INLINE BOOL binn_map_set_blob(binn *map, int id, void *ptr, int size) { - return binn_map_set(map, id, BINN_BLOB, ptr, size); -} - -IW_INLINE BOOL binn_map_set_list(binn *map, int id, void *list) { - return binn_map_set(map, id, BINN_LIST, binn_ptr(list), binn_size(list)); -} - -IW_INLINE BOOL binn_map_set_map(binn *map, int id, void *map2) { - return binn_map_set(map, id, BINN_MAP, binn_ptr(map2), binn_size(map2)); -} - -IW_INLINE BOOL binn_map_set_object(binn *map, int id, void *obj) { - return binn_map_set(map, id, BINN_OBJECT, binn_ptr(obj), binn_size(obj)); -} - -IW_INLINE BOOL binn_map_set_value(binn *map, int id, binn *value) { - return binn_map_set(map, id, value->type, binn_ptr(value), binn_size(value)); -} - -/*************************************************************************************/ - -IW_INLINE BOOL binn_object_set_int8(binn *obj, const char *key, signed char value) { - return binn_object_set(obj, key, BINN_INT8, &value, 0); -} - -IW_INLINE BOOL binn_object_set_int16(binn *obj, const char *key, short value) { - return binn_object_set(obj, key, BINN_INT16, &value, 0); -} - -IW_INLINE BOOL binn_object_set_int32(binn *obj, const char *key, int value) { - return binn_object_set(obj, key, BINN_INT32, &value, 0); -} - -IW_INLINE BOOL binn_object_set_int64(binn *obj, const char *key, int64 value) { - return binn_object_set(obj, key, BINN_INT64, &value, 0); -} - -IW_INLINE BOOL binn_object_set_uint8(binn *obj, const char *key, unsigned char value) { - return binn_object_set(obj, key, BINN_UINT8, &value, 0); -} - -IW_INLINE BOOL binn_object_set_uint16(binn *obj, const char *key, unsigned short value) { - return binn_object_set(obj, key, BINN_UINT16, &value, 0); -} - -IW_INLINE BOOL binn_object_set_uint32(binn *obj, const char *key, unsigned int value) { - return binn_object_set(obj, key, BINN_UINT32, &value, 0); -} - -IW_INLINE BOOL binn_object_set_uint64(binn *obj, const char *key, uint64 value) { - return binn_object_set(obj, key, BINN_UINT64, &value, 0); -} - -IW_INLINE BOOL binn_object_set_float(binn *obj, const char *key, float value) { - return binn_object_set(obj, key, BINN_FLOAT32, &value, 0); -} - -IW_INLINE BOOL binn_object_set_double(binn *obj, const char *key, double value) { - return binn_object_set(obj, key, BINN_FLOAT64, &value, 0); -} - -IW_INLINE BOOL binn_object_set_bool(binn *obj, const char *key, BOOL value) { - return binn_object_set(obj, key, BINN_BOOL, &value, 0); -} - -IW_INLINE BOOL binn_object_set_null(binn *obj, const char *key) { - return binn_object_set(obj, key, BINN_NULL, NULL, 0); -} - -IW_INLINE BOOL binn_object_set_str(binn *obj, const char *key, const char *str) { - return binn_object_set(obj, key, BINN_STRING, (char*) str, 0); // todo -} - -IW_INLINE BOOL binn_object_set_blob(binn *obj, const char *key, void *ptr, int size) { - return binn_object_set(obj, key, BINN_BLOB, ptr, size); -} - -IW_INLINE BOOL binn_object_set_list(binn *obj, const char *key, void *list) { - return binn_object_set(obj, key, BINN_LIST, binn_ptr(list), binn_size(list)); -} - -IW_INLINE BOOL binn_object_set_map(binn *obj, const char *key, void *map) { - return binn_object_set(obj, key, BINN_MAP, binn_ptr(map), binn_size(map)); -} - -IW_INLINE BOOL binn_object_set_object(binn *obj, const char *key, void *obj2) { - return binn_object_set(obj, key, BINN_OBJECT, binn_ptr(obj2), binn_size(obj2)); -} - -IW_INLINE BOOL binn_object_set_value(binn *obj, const char *key, binn *value) { - return binn_object_set(obj, key, value->type, binn_ptr(value), binn_size(value)); -} - -IW_INLINE BOOL binn_object_set_value2(binn *obj, const char *key, int keylen, binn *value) { - return binn_object_set2(obj, key, keylen, value->type, binn_ptr(value), binn_size(value)); -} - -/*************************************************************************************/ -/*** GET FUNCTIONS *******************************************************************/ -/*************************************************************************************/ - -IW_INLINE BOOL binn_list_get_int8(void *list, int pos, signed char *pvalue) { - return binn_list_get(list, pos, BINN_INT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_int16(void *list, int pos, short *pvalue) { - return binn_list_get(list, pos, BINN_INT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_int32(void *list, int pos, int *pvalue) { - return binn_list_get(list, pos, BINN_INT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_int64(void *list, int pos, int64 *pvalue) { - return binn_list_get(list, pos, BINN_INT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_uint8(void *list, int pos, unsigned char *pvalue) { - return binn_list_get(list, pos, BINN_UINT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_uint16(void *list, int pos, unsigned short *pvalue) { - return binn_list_get(list, pos, BINN_UINT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_uint32(void *list, int pos, unsigned int *pvalue) { - return binn_list_get(list, pos, BINN_UINT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_uint64(void *list, int pos, uint64 *pvalue) { - return binn_list_get(list, pos, BINN_UINT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_float(void *list, int pos, float *pvalue) { - return binn_list_get(list, pos, BINN_FLOAT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_double(void *list, int pos, double *pvalue) { - return binn_list_get(list, pos, BINN_FLOAT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_bool(void *list, int pos, BOOL *pvalue) { - return binn_list_get(list, pos, BINN_BOOL, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_str(void *list, int pos, char **pvalue) { - return binn_list_get(list, pos, BINN_STRING, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_blob(void *list, int pos, void **pvalue, int *psize) { - return binn_list_get(list, pos, BINN_BLOB, pvalue, psize); -} - -IW_INLINE BOOL binn_list_get_list(void *list, int pos, void **pvalue) { - return binn_list_get(list, pos, BINN_LIST, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_map(void *list, int pos, void **pvalue) { - return binn_list_get(list, pos, BINN_MAP, pvalue, NULL); -} - -IW_INLINE BOOL binn_list_get_object(void *list, int pos, void **pvalue) { - return binn_list_get(list, pos, BINN_OBJECT, pvalue, NULL); -} - -/***************************************************************************/ - -IW_INLINE BOOL binn_map_get_int8(void *map, int id, signed char *pvalue) { - return binn_map_get(map, id, BINN_INT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_int16(void *map, int id, short *pvalue) { - return binn_map_get(map, id, BINN_INT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_int32(void *map, int id, int *pvalue) { - return binn_map_get(map, id, BINN_INT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_int64(void *map, int id, int64 *pvalue) { - return binn_map_get(map, id, BINN_INT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_uint8(void *map, int id, unsigned char *pvalue) { - return binn_map_get(map, id, BINN_UINT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_uint16(void *map, int id, unsigned short *pvalue) { - return binn_map_get(map, id, BINN_UINT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_uint32(void *map, int id, unsigned int *pvalue) { - return binn_map_get(map, id, BINN_UINT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_uint64(void *map, int id, uint64 *pvalue) { - return binn_map_get(map, id, BINN_UINT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_float(void *map, int id, float *pvalue) { - return binn_map_get(map, id, BINN_FLOAT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_double(void *map, int id, double *pvalue) { - return binn_map_get(map, id, BINN_FLOAT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_bool(void *map, int id, BOOL *pvalue) { - return binn_map_get(map, id, BINN_BOOL, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_str(void *map, int id, char **pvalue) { - return binn_map_get(map, id, BINN_STRING, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_blob(void *map, int id, void **pvalue, int *psize) { - return binn_map_get(map, id, BINN_BLOB, pvalue, psize); -} - -IW_INLINE BOOL binn_map_get_list(void *map, int id, void **pvalue) { - return binn_map_get(map, id, BINN_LIST, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_map(void *map, int id, void **pvalue) { - return binn_map_get(map, id, BINN_MAP, pvalue, NULL); -} - -IW_INLINE BOOL binn_map_get_object(void *map, int id, void **pvalue) { - return binn_map_get(map, id, BINN_OBJECT, pvalue, NULL); -} - -/***************************************************************************/ - -// usage: -// if (binn_object_get_int32(obj, "key", &value) == FALSE) xxx; - -IW_INLINE BOOL binn_object_get_int8(void *obj, const char *key, signed char *pvalue) { - return binn_object_get(obj, key, BINN_INT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_int16(void *obj, const char *key, short *pvalue) { - return binn_object_get(obj, key, BINN_INT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_int32(void *obj, const char *key, int *pvalue) { - return binn_object_get(obj, key, BINN_INT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_int64(void *obj, const char *key, int64 *pvalue) { - return binn_object_get(obj, key, BINN_INT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_uint8(void *obj, const char *key, unsigned char *pvalue) { - return binn_object_get(obj, key, BINN_UINT8, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_uint16(void *obj, const char *key, unsigned short *pvalue) { - return binn_object_get(obj, key, BINN_UINT16, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_uint32(void *obj, const char *key, unsigned int *pvalue) { - return binn_object_get(obj, key, BINN_UINT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_uint64(void *obj, const char *key, uint64 *pvalue) { - return binn_object_get(obj, key, BINN_UINT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_float(void *obj, const char *key, float *pvalue) { - return binn_object_get(obj, key, BINN_FLOAT32, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_double(void *obj, const char *key, double *pvalue) { - return binn_object_get(obj, key, BINN_FLOAT64, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_bool(void *obj, const char *key, BOOL *pvalue) { - return binn_object_get(obj, key, BINN_BOOL, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_str(void *obj, const char *key, char **pvalue) { - return binn_object_get(obj, key, BINN_STRING, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_blob(void *obj, const char *key, void **pvalue, int *psize) { - return binn_object_get(obj, key, BINN_BLOB, pvalue, psize); -} - -IW_INLINE BOOL binn_object_get_list(void *obj, const char *key, void **pvalue) { - return binn_object_get(obj, key, BINN_LIST, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_map(void *obj, const char *key, void **pvalue) { - return binn_object_get(obj, key, BINN_MAP, pvalue, NULL); -} - -IW_INLINE BOOL binn_object_get_object(void *obj, const char *key, void **pvalue) { - return binn_object_get(obj, key, BINN_OBJECT, pvalue, NULL); -} - -/***************************************************************************/ - -BOOL binn_get_int32(binn *value, int *pint); -BOOL binn_get_int64(binn *value, int64 *pint); -BOOL binn_get_double(binn *value, double *pfloat); -BOOL binn_get_bool(binn *value, BOOL *pbool); -char *binn_get_str(binn *value); - -// boolean string values: -// 1, true, yes, on -// 0, false, no, off - -// boolean number values: -// !=0 [true] -// ==0 [false] - - -#ifdef __cplusplus -} -#endif - -#endif //BINN_H diff --git a/src/jbl/jbl.c b/src/jbl/jbl.c deleted file mode 100644 index 6ddbc86ee..000000000 --- a/src/jbl/jbl.c +++ /dev/null @@ -1,2950 +0,0 @@ -#include "jbl.h" -#include -#include -#include -#include "jbl_internal.h" -#include "utf8proc.h" -#include "convert.h" - -#define _STRX(x) #x -#define _STR(x) _STRX(x) - -IW_INLINE int _jbl_printf_estimate_size(const char *format, va_list ap) { - char buf[1]; - return vsnprintf(buf, sizeof(buf), format, ap) + 1; -} - -IW_INLINE void _jbn_remove_item(JBL_NODE parent, JBL_NODE child); -static void _jbn_add_item(JBL_NODE parent, JBL_NODE node); - -iwrc jbl_create_empty_object(JBL *jblp) { - *jblp = calloc(1, sizeof(**jblp)); - if (!*jblp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - binn_create(&(*jblp)->bn, BINN_OBJECT, 0, 0); - return 0; -} - -iwrc jbl_create_empty_array(JBL *jblp) { - *jblp = calloc(1, sizeof(**jblp)); - if (!*jblp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - binn_create(&(*jblp)->bn, BINN_LIST, 0, 0); - return 0; -} - -void jbl_set_user_data(JBL jbl, void *user_data, void (*user_data_free_fn)(void*)) { - binn_set_user_data(&jbl->bn, user_data, user_data_free_fn); -} - -void *jbl_get_user_data(JBL jbl) { - return jbl->bn.user_data; -} - -iwrc jbl_set_int64(JBL jbl, const char *key, int64_t v) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_int64(bv, key, v)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_int64(bv, v)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_set_f64(JBL jbl, const char *key, double v) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_double(bv, key, v)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_double(bv, v)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_set_string(JBL jbl, const char *key, const char *v) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_str(bv, key, v)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_const_str(bv, v)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_set_string_printf(JBL jbl, const char *key, const char *format, ...) { - iwrc rc = 0; - va_list ap; - - va_start(ap, format); - int size = _jbl_printf_estimate_size(format, ap); - va_end(ap); - - va_start(ap, format); - char *buf = malloc(size); - RCGA(buf, finish); - vsnprintf(buf, size, format, ap); - va_end(ap); - - rc = jbl_set_string(jbl, key, buf); -finish: - free(buf); - return rc; -} - -iwrc jbl_from_json_printf_va(JBL *jblp, const char *format, va_list va) { - iwrc rc = 0; - va_list cva; - - va_copy(cva, va); - int size = _jbl_printf_estimate_size(format, va); - char *buf = malloc(size); - RCGA(buf, finish); - vsnprintf(buf, size, format, cva); - va_end(cva); - - rc = jbl_from_json(jblp, buf); - -finish: - free(buf); - return rc; -} - -iwrc jbl_from_json_printf(JBL *jblp, const char *format, ...) { - va_list ap; - - va_start(ap, format); - iwrc rc = jbl_from_json_printf_va(jblp, format, ap); - va_end(ap); - return rc; -} - -iwrc jbn_from_json_printf_va(JBL_NODE *node, IWPOOL *pool, const char *format, va_list va) { - iwrc rc = 0; - va_list cva; - - va_copy(cva, va); - int size = _jbl_printf_estimate_size(format, va); - char *buf = malloc(size); - RCGA(buf, finish); - vsnprintf(buf, size, format, cva); - va_end(cva); - - rc = jbn_from_json(buf, node, pool); - -finish: - free(buf); - return rc; -} - -iwrc jbn_from_json_printf(JBL_NODE *node, IWPOOL *pool, const char *format, ...) { - va_list ap; - - va_start(ap, format); - iwrc rc = jbn_from_json_printf_va(node, pool, format, ap); - va_end(ap); - return rc; -} - -iwrc jbl_set_bool(JBL jbl, const char *key, bool v) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_bool(bv, key, v)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_bool(bv, v)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_set_null(JBL jbl, const char *key) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_null(bv, key)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_null(bv)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_set_empty_array(JBL jbl, const char *key) { - JBL v = 0; - iwrc rc = jbl_create_empty_array(&v); - RCGO(rc, finish); - rc = jbl_set_nested(jbl, key, v); -finish: - jbl_destroy(&v); - return rc; -} - -iwrc jbl_set_empty_object(JBL jbl, const char *key) { - JBL v = 0; - iwrc rc = jbl_create_empty_object(&v); - RCGO(rc, finish); - rc = jbl_set_nested(jbl, key, v); -finish: - jbl_destroy(&v); - return rc; -} - -iwrc jbl_set_nested(JBL jbl, const char *key, JBL v) { - jbl_type_t t = jbl_type(jbl); - if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { - return JBL_ERROR_CREATION; - } - binn *bv = &jbl->bn; - if (key) { - if (t == JBV_OBJECT) { - if (!binn_object_set_value(bv, key, &v->bn)) { - return JBL_ERROR_CREATION; - } - } else { - return JBL_ERROR_CREATION; - } - return 0; - } else if (t == JBV_ARRAY) { - if (!binn_list_add_value(bv, &v->bn)) { - return JBL_ERROR_CREATION; - } - return 0; - } - return JBL_ERROR_INVALID; -} - -iwrc jbl_from_buf_keep(JBL *jblp, void *buf, size_t bufsz, bool keep_on_destroy) { - int type, size = 0, count = 0; - if ((bufsz < MIN_BINN_SIZE) || !binn_is_valid_header(buf, &type, &count, &size, NULL)) { - return JBL_ERROR_INVALID_BUFFER; - } - if (size > bufsz) { - return JBL_ERROR_INVALID_BUFFER; - } - *jblp = calloc(1, sizeof(**jblp)); - if (!*jblp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - JBL jbl = *jblp; - jbl->bn.header = BINN_MAGIC; - jbl->bn.type = type; - jbl->bn.ptr = buf; - jbl->bn.size = size; - jbl->bn.count = count; - jbl->bn.freefn = keep_on_destroy ? 0 : free; - return 0; -} - -iwrc jbl_clone(JBL src, JBL *targetp) { - *targetp = calloc(1, sizeof(**targetp)); - JBL t = *targetp; - if (!t) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - binn *bn = binn_copy(&src->bn); - if (!bn) { - return JBL_ERROR_CREATION; - } - t->node = 0; - bn->allocated = 0; - memcpy(&t->bn, bn, sizeof(*bn)); - free(bn); - return 0; -} - -IW_EXPORT iwrc jbl_object_copy_to(JBL src, JBL target) { - iwrc rc = 0; - // According to binn spec keys are not null terminated - // and key length is not more than 255 bytes - char *key, kbuf[256]; - int klen; - JBL holder = 0; - JBL_iterator it; - - if ((jbl_type(src) != JBV_OBJECT) || (jbl_type(target) != JBV_OBJECT)) { - return JBL_ERROR_NOT_AN_OBJECT; - } - RCC(rc, finish, jbl_create_iterator_holder(&holder)); - RCC(rc, finish, jbl_iterator_init(src, &it)); - while (jbl_iterator_next(&it, holder, &key, &klen)) { - memcpy(kbuf, key, klen); - kbuf[klen] = '\0'; - RCC(rc, finish, jbl_set_nested(target, kbuf, holder)); - } - -finish: - jbl_destroy(&holder); - return rc; -} - -iwrc jbl_clone_into_pool(JBL src, JBL *targetp, IWPOOL *pool) { - *targetp = 0; - if (src->bn.writable && src->bn.dirty) { - if (!binn_save_header(&src->bn)) { - return JBL_ERROR_INVALID; - } - } - JBL jbl = iwpool_alloc(sizeof(*jbl) + src->bn.size, pool); - if (!jbl) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - jbl->node = 0; - memcpy(&jbl->bn, &src->bn, sizeof(jbl->bn)); - jbl->bn.ptr = (char*) jbl + sizeof(*jbl); - memcpy(jbl->bn.ptr, src->bn.ptr, src->bn.size); - jbl->bn.freefn = 0; - *targetp = jbl; - return 0; -} - -iwrc jbl_from_buf_keep_onstack(JBL jbl, void *buf, size_t bufsz) { - int type, size = 0, count = 0; - if ((bufsz < MIN_BINN_SIZE) || !binn_is_valid_header(buf, &type, &count, &size, NULL)) { - return JBL_ERROR_INVALID_BUFFER; - } - if (size > bufsz) { - return JBL_ERROR_INVALID_BUFFER; - } - memset(jbl, 0, sizeof(*jbl)); - jbl->bn.header = BINN_MAGIC; - jbl->bn.type = type; - jbl->bn.ptr = buf; - jbl->bn.size = size; - jbl->bn.count = count; - return 0; -} - -iwrc jbl_from_buf_keep_onstack2(JBL jbl, void *buf) { - int type, size = 0, count = 0; - if (!binn_is_valid_header(buf, &type, &count, &size, NULL)) { - return JBL_ERROR_INVALID_BUFFER; - } - memset(jbl, 0, sizeof(*jbl)); - jbl->bn.header = BINN_MAGIC; - jbl->bn.type = type; - jbl->bn.ptr = buf; - jbl->bn.size = size; - jbl->bn.count = count; - return 0; -} - -void jbl_destroy(JBL *jblp) { - if (*jblp) { - JBL jbl = *jblp; - binn_free(&jbl->bn); - free(jbl); - *jblp = 0; - } -} - -iwrc jbl_create_iterator_holder(JBL *jblp) { - *jblp = calloc(1, sizeof(**jblp)); - if (!*jblp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - return 0; -} - -iwrc jbl_iterator_init(JBL jbl, JBL_iterator *iter) { - int btype = jbl->bn.type; - if ((btype != BINN_OBJECT) && (btype != BINN_LIST) && (btype != BINN_MAP)) { - memset(iter, 0, sizeof(*iter)); - return 0; - } - binn_iter *biter = (binn_iter*) iter; - if (!binn_iter_init(biter, &jbl->bn, btype)) { - return JBL_ERROR_CREATION; - } - return 0; -} - -bool jbl_iterator_next(JBL_iterator *iter, JBL holder, char **pkey, int *klen) { - binn_iter *biter = (binn_iter*) iter; - if (pkey) { - *pkey = 0; - } - if (klen) { - *klen = 0; - } - if (!iter || (iter->type == 0)) { - return false; - } - if (iter->type == BINN_LIST) { - if (klen) { - *klen = iter->current; - } - return binn_list_next(biter, &holder->bn); - } else { - return binn_read_next_pair2(iter->type, biter, klen, pkey, &holder->bn); - } - return false; -} - -IW_INLINE jbl_type_t _jbl_binn_type(int btype) { - switch (btype) { - case BINN_NULL: - return JBV_NULL; - case BINN_STRING: - return JBV_STR; - case BINN_OBJECT: - case BINN_MAP: - return JBV_OBJECT; - case BINN_LIST: - return JBV_ARRAY; - case BINN_BOOL: - case BINN_TRUE: - case BINN_FALSE: - return JBV_BOOL; - case BINN_UINT8: - case BINN_UINT16: - case BINN_UINT32: - case BINN_UINT64: - case BINN_INT8: - case BINN_INT16: - case BINN_INT32: - case BINN_INT64: - return JBV_I64; - case BINN_FLOAT32: - case BINN_FLOAT64: - return JBV_F64; - default: - return JBV_NONE; - } -} - -jbl_type_t jbl_type(JBL jbl) { - if (jbl) { - return _jbl_binn_type(jbl->bn.type); - } - return JBV_NONE; -} - -size_t jbl_count(JBL jbl) { - return (size_t) jbl->bn.count; -} - -size_t jbl_size(JBL jbl) { - return (size_t) jbl->bn.size; -} - -size_t jbl_structure_size(void) { - return sizeof(struct _JBL); -} - -iwrc jbl_from_json(JBL *jblp, const char *jsonstr) { - *jblp = 0; - iwrc rc = 0; - IWPOOL *pool = iwpool_create(2 * strlen(jsonstr)); - if (!pool) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - JBL jbl; - JBL_NODE node; - rc = jbn_from_json(jsonstr, &node, pool); - RCGO(rc, finish); - if (node->type == JBV_OBJECT) { - rc = jbl_create_empty_object(&jbl); - RCGO(rc, finish); - } else if (node->type == JBV_ARRAY) { - rc = jbl_create_empty_array(&jbl); - RCGO(rc, finish); - } else { - // TODO: Review - rc = JBL_ERROR_CREATION; - goto finish; - } - rc = jbl_fill_from_node(jbl, node); - if (!rc) { - *jblp = jbl; - } - -finish: - iwpool_destroy(pool); - return rc; -} - -iwrc _jbl_write_double(double num, jbl_json_printer pt, void *op) { - size_t sz; - char buf[JBNUMBUF_SIZE]; - jbi_ftoa(num, buf, &sz); - return pt(buf, -1, 0, 0, op); -} - -iwrc _jbl_write_int(int64_t num, jbl_json_printer pt, void *op) { - char buf[JBNUMBUF_SIZE]; - int sz = iwitoa(num, buf, sizeof(buf)); - return pt(buf, sz, 0, 0, op); -} - -iwrc _jbl_write_string(const char *str, int len, jbl_json_printer pt, void *op, jbl_print_flags_t pf) { - iwrc rc = pt(0, 0, '"', 1, op); - RCRET(rc); - static const char *specials = "btnvfr"; - const uint8_t *p = (const uint8_t*) str; - -#define PT(data_, size_, ch_, count_) do { \ - rc = pt((const char*) (data_), size_, ch_, count_, op); \ - RCRET(rc); \ -} while (0) - - if (len < 0) { - len = (int) strlen(str); - } - for (size_t i = 0; i < len; i++) { - uint8_t ch = p[i]; - if ((ch == '"') || (ch == '\\')) { - PT(0, 0, '\\', 1); - PT(0, 0, ch, 1); - } else if ((ch >= '\b') && (ch <= '\r')) { - PT(0, 0, '\\', 1); - PT(0, 0, specials[ch - '\b'], 1); - } else if (isprint(ch)) { - PT(0, 0, ch, 1); - } else if (pf & JBL_PRINT_CODEPOINTS) { - char sbuf[7]; // escaped unicode seq - utf8proc_int32_t cp; - utf8proc_ssize_t sz = utf8proc_iterate(p + i, len - i, &cp); - if (sz < 0) { - return JBL_ERROR_PARSE_INVALID_UTF8; - } - if (cp > 0x0010000UL) { - uint32_t hs = 0xD800, ls = 0xDC00; // surrogates - cp -= 0x0010000UL; - hs |= ((cp >> 10) & 0x3FF); - ls |= (cp & 0x3FF); - snprintf(sbuf, 7, "\\u%04X", hs); - PT(sbuf, 6, 0, 0); - snprintf(sbuf, 7, "\\u%04X", ls); - PT(sbuf, 6, 0, 0); - } else { - snprintf(sbuf, 7, "\\u%04X", cp); - PT(sbuf, 6, 0, 0); - } - i += sz - 1; - } else { - PT(0, 0, ch, 1); - } - } - rc = pt(0, 0, '"', 1, op); - return rc; -#undef PT -} - -static iwrc _jbl_as_json(binn *bn, jbl_json_printer pt, void *op, int lvl, jbl_print_flags_t pf) { - iwrc rc = 0; - binn bv; - binn_iter iter; - int lv; - int64_t llv; - double dv; - char key[MAX_BIN_KEY_LEN + 1]; - bool pretty = pf & JBL_PRINT_PRETTY; - -#define PT(data_, size_, ch_, count_) do { \ - rc = pt(data_, size_, ch_, count_, op); \ - RCGO(rc, finish); \ -} while (0) - - switch (bn->type) { - - case BINN_LIST: - if (!binn_iter_init(&iter, bn, bn->type)) { - rc = JBL_ERROR_INVALID; - goto finish; - } - PT(0, 0, '[', 1); - if (bn->count && pretty) { - PT(0, 0, '\n', 1); - } - for (int i = 0; binn_list_next(&iter, &bv); ++i) { - if (pretty) { - PT(0, 0, ' ', lvl + 1); - } - rc = _jbl_as_json(&bv, pt, op, lvl + 1, pf); - RCGO(rc, finish); - if (i < bn->count - 1) { - PT(0, 0, ',', 1); - } - if (pretty) { - PT(0, 0, '\n', 1); - } - } - if (bn->count && pretty) { - PT(0, 0, ' ', lvl); - } - PT(0, 0, ']', 1); - break; - - case BINN_OBJECT: - case BINN_MAP: - if (!binn_iter_init(&iter, bn, bn->type)) { - rc = JBL_ERROR_INVALID; - goto finish; - } - PT(0, 0, '{', 1); - if (bn->count && pretty) { - PT(0, 0, '\n', 1); - } - if (bn->type == BINN_OBJECT) { - for (int i = 0; binn_object_next(&iter, key, &bv); ++i) { - if (pretty) { - PT(0, 0, ' ', lvl + 1); - } - rc = _jbl_write_string(key, -1, pt, op, pf); - RCGO(rc, finish); - if (pretty) { - PT(": ", -1, 0, 0); - } else { - PT(0, 0, ':', 1); - } - rc = _jbl_as_json(&bv, pt, op, lvl + 1, pf); - RCGO(rc, finish); - if (i < bn->count - 1) { - PT(0, 0, ',', 1); - } - if (pretty) { - PT(0, 0, '\n', 1); - } - } - } else { - for (int i = 0; binn_map_next(&iter, &lv, &bv); ++i) { - if (pretty) { - PT(0, 0, ' ', lvl + 1); - } - PT(0, 0, '"', 1); - rc = _jbl_write_int(lv, pt, op); - RCGO(rc, finish); - PT(0, 0, '"', 1); - if (pretty) { - PT(": ", -1, 0, 0); - } else { - PT(0, 0, ':', 1); - } - rc = _jbl_as_json(&bv, pt, op, lvl + 1, pf); - RCGO(rc, finish); - if (i < bn->count - 1) { - PT(0, 0, ',', 1); - } - if (pretty) { - PT(0, 0, '\n', 1); - } - } - } - if (bn->count && pretty) { - PT(0, 0, ' ', lvl); - } - PT(0, 0, '}', 1); - break; - - case BINN_STRING: - rc = _jbl_write_string(bn->ptr, -1, pt, op, pf); - break; - case BINN_UINT8: - llv = bn->vuint8; - goto loc_int; - case BINN_UINT16: - llv = bn->vuint16; - goto loc_int; - case BINN_UINT32: - llv = bn->vuint32; - goto loc_int; - case BINN_INT8: - llv = bn->vint8; // NOLINT(bugprone-signed-char-misuse) - goto loc_int; - case BINN_INT16: - llv = bn->vint16; - goto loc_int; - case BINN_INT32: - llv = bn->vint32; - goto loc_int; - case BINN_INT64: - llv = bn->vint64; - goto loc_int; - case BINN_UINT64: // overflow? - llv = (int64_t) bn->vuint64; -loc_int: - rc = _jbl_write_int(llv, pt, op); - break; - - case BINN_FLOAT32: - dv = bn->vfloat; - goto loc_float; - case BINN_FLOAT64: - dv = bn->vdouble; -loc_float: - rc = _jbl_write_double(dv, pt, op); - break; - - case BINN_TRUE: - PT("true", 4, 0, 0); - break; - case BINN_FALSE: - PT("false", 5, 0, 0); - break; - case BINN_BOOL: - PT(bn->vbool ? "true" : "false", -1, 0, 1); - break; - case BINN_NULL: - PT("null", 4, 0, 0); - break; - default: - iwlog_ecode_error3(IW_ERROR_ASSERTION); - rc = IW_ERROR_ASSERTION; - break; - } - -finish: - return rc; -#undef PT -} - -iwrc jbl_as_json(JBL jbl, jbl_json_printer pt, void *op, jbl_print_flags_t pf) { - if (!jbl || !pt) { - return IW_ERROR_INVALID_ARGS; - } - return _jbl_as_json(&jbl->bn, pt, op, 0, pf); -} - -iwrc jbl_fstream_json_printer(const char *data, int size, char ch, int count, void *op) { - FILE *file = op; - if (!file) { - return IW_ERROR_INVALID_ARGS; - } - if (!data) { - if (count) { - char cbuf[count]; // TODO: review overflow - memset(cbuf, ch, sizeof(cbuf)); - size_t wc = fwrite(cbuf, 1, count, file); - if (wc != sizeof(cbuf)) { - return iwrc_set_errno(IW_ERROR_IO_ERRNO, errno); - } - } - } else { - if (size < 0) { - size = (int) strlen(data); - } - if (!count) { - count = 1; - } - for (int i = 0; i < count; ++i) { - if (fprintf(file, "%.*s", size, data) < 0) { - return iwrc_set_errno(IW_ERROR_IO_ERRNO, errno); - } - } - } - return 0; -} - -iwrc jbl_xstr_json_printer(const char *data, int size, char ch, int count, void *op) { - IWXSTR *xstr = op; - if (!xstr) { - return IW_ERROR_INVALID_ARGS; - } - if (!data) { - if (count) { - for (int i = 0; i < count; ++i) { - iwrc rc = iwxstr_cat(xstr, &ch, 1); - RCRET(rc); - } - } - } else { - if (size < 0) { - size = (int) strlen(data); - } - if (!count) { - count = 1; - } - for (int i = 0; i < count; ++i) { - iwrc rc = iwxstr_cat(xstr, data, size); - RCRET(rc); - } - } - return 0; -} - -iwrc jbl_count_json_printer(const char *data, int size, char ch, int count, void *op) { - int *cnt = op; - if (!data) { - *cnt = *cnt + count; - } else { - if (size < 0) { - size = (int) strlen(data); - } - if (!count) { - count = 1; - } - *cnt = *cnt + count * size; - } - return 0; -} - -int64_t jbl_get_i64(JBL jbl) { - assert(jbl); - switch (jbl->bn.type) { - case BINN_UINT8: - return jbl->bn.vuint8; - case BINN_UINT16: - return jbl->bn.vuint16; - case BINN_UINT32: - return jbl->bn.vuint32; - case BINN_UINT64: - return jbl->bn.vuint64; - case BINN_INT8: - return jbl->bn.vint8; - case BINN_INT16: - return jbl->bn.vint16; - case BINN_INT32: - return jbl->bn.vint32; - case BINN_INT64: - return jbl->bn.vint64; - case BINN_BOOL: - return jbl->bn.vbool; - case BINN_FLOAT32: - return (int64_t) jbl->bn.vfloat; - case BINN_FLOAT64: - return (int64_t) jbl->bn.vdouble; - default: - return 0; - } -} - -int32_t jbl_get_i32(JBL jbl) { - return (int32_t) jbl_get_i64(jbl); -} - -double jbl_get_f64(JBL jbl) { - assert(jbl); - switch (jbl->bn.type) { - case BINN_FLOAT64: - return jbl->bn.vdouble; - case BINN_FLOAT32: - return jbl->bn.vfloat; - case BINN_UINT8: - return jbl->bn.vuint8; - case BINN_UINT16: - return jbl->bn.vuint16; - case BINN_UINT32: - return jbl->bn.vuint32; - case BINN_UINT64: - return jbl->bn.vuint64; - case BINN_INT8: - return jbl->bn.vint8; - case BINN_INT16: - return jbl->bn.vint16; - case BINN_INT32: - return jbl->bn.vint32; - case BINN_INT64: - return jbl->bn.vint64; - case BINN_BOOL: - return jbl->bn.vbool; - default: - return 0.0; - } -} - -const char *jbl_get_str(JBL jbl) { - assert(jbl && jbl->bn.type == BINN_STRING); - if (jbl->bn.type != BINN_STRING) { - return 0; - } else { - return jbl->bn.ptr; - } -} - -size_t jbl_copy_strn(JBL jbl, char *buf, size_t bufsz) { - assert(jbl && buf && jbl->bn.type == BINN_STRING); - if (jbl->bn.type != BINN_STRING) { - return 0; - } - size_t slen = strlen(jbl->bn.ptr); - size_t ret = MIN(slen, bufsz); - memcpy(buf, jbl->bn.ptr, ret); - return ret; -} - -jbl_type_t jbl_object_get_type(JBL jbl, const char *key) { - if (jbl->bn.type != BINN_OBJECT) { - return JBV_NONE; - } - binn bv; - if (!binn_object_get_value(&jbl->bn, key, &bv)) { - return JBV_NONE; - } - return _jbl_binn_type(bv.type); -} - -iwrc jbl_object_get_i64(JBL jbl, const char *key, int64_t *out) { - *out = 0; - if (jbl->bn.type != BINN_OBJECT) { - return JBL_ERROR_NOT_AN_OBJECT; - } - int64 v; - if (!binn_object_get_int64(&jbl->bn, key, &v)) { - return JBL_ERROR_CREATION; - } - *out = v; - return 0; -} - -iwrc jbl_object_get_f64(JBL jbl, const char *key, double *out) { - *out = 0.0; - if (jbl->bn.type != BINN_OBJECT) { - return JBL_ERROR_NOT_AN_OBJECT; - } - if (!binn_object_get_double(&jbl->bn, key, out)) { - return JBL_ERROR_CREATION; - } - return 0; -} - -iwrc jbl_object_get_bool(JBL jbl, const char *key, bool *out) { - *out = false; - if (jbl->bn.type != BINN_OBJECT) { - return JBL_ERROR_NOT_AN_OBJECT; - } - BOOL v; - if (!binn_object_get_bool(&jbl->bn, key, &v)) { - return JBL_ERROR_CREATION; - } - *out = v; - return 0; -} - -iwrc jbl_object_get_str(JBL jbl, const char *key, const char **out) { - *out = 0; - if (jbl->bn.type != BINN_OBJECT) { - return JBL_ERROR_NOT_AN_OBJECT; - } - if (!binn_object_get_str(&jbl->bn, key, (char**) out)) { - return JBL_ERROR_CREATION; - } - return 0; -} - -iwrc jbl_object_get_fill_jbl(JBL jbl, const char *key, JBL out) { - if (jbl->bn.type != BINN_OBJECT) { - return JBL_ERROR_NOT_AN_OBJECT; - } - binn_free(&out->bn); - if (!binn_object_get_value(&jbl->bn, key, &out->bn)) { - return JBL_ERROR_CREATION; - } - return 0; -} - -iwrc jbl_as_buf(JBL jbl, void **buf, size_t *size) { - assert(jbl && buf && size); - if (jbl->bn.writable && jbl->bn.dirty) { - if (!binn_save_header(&jbl->bn)) { - return JBL_ERROR_INVALID; - } - } - *buf = jbl->bn.ptr; - *size = (size_t) jbl->bn.size; - return 0; -} - -//---------------------------------------------------------------------------------------------------------- - -static iwrc _jbl_ptr_pool(const char *path, JBL_PTR *jpp, IWPOOL *pool) { - iwrc rc = 0; - int cnt = 0, len, sz, doff; - int i, j, k; - JBL_PTR jp; - char *jpr; // raw pointer to jp - *jpp = 0; - if (!path || (path[0] != '/')) { - return JBL_ERROR_JSON_POINTER; - } - for (i = 0; path[i]; ++i) { - if (path[i] == '/') { - ++cnt; - } - } - len = i; - if ((len > 1) && (path[len - 1] == '/')) { - return JBL_ERROR_JSON_POINTER; - } - sz = (int) (sizeof(struct _JBL_PTR) + cnt * sizeof(char*) + len); - if (pool) { - jp = iwpool_alloc(sz, pool); - } else { - jp = malloc(sz); - } - if (!jp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - jpr = (char*) jp; - jp->cnt = cnt; - jp->sz = sz; - - doff = offsetof(struct _JBL_PTR, n) + cnt * sizeof(char*); - assert(sz - doff >= len); - - for (i = 0, j = 0, cnt = 0; path[i] && cnt < jp->cnt; ++i, ++j) { - if (path[i++] == '/') { - jp->n[cnt] = jpr + doff + j; - for (k = 0; ; ++i, ++k) { - if (!path[i] || (path[i] == '/')) { - --i; - *(jp->n[cnt] + k) = '\0'; - break; - } - if (path[i] == '~') { - if (path[i + 1] == '0') { - *(jp->n[cnt] + k) = '~'; - } else if (path[i + 1] == '1') { - *(jp->n[cnt] + k) = '/'; - } - ++i; - } else { - *(jp->n[cnt] + k) = path[i]; - } - } - j += k; - ++cnt; - } - } - *jpp = jp; - return rc; -} - -iwrc jbl_ptr_alloc(const char *path, JBL_PTR *jpp) { - return _jbl_ptr_pool(path, jpp, 0); -} - -iwrc jbl_ptr_alloc_pool(const char *path, JBL_PTR *jpp, IWPOOL *pool) { - return _jbl_ptr_pool(path, jpp, pool); -} - -int jbl_ptr_cmp(JBL_PTR p1, JBL_PTR p2) { - if (p1->sz != p2->sz) { - return p1->sz - p2->sz; - } - if (p1->cnt != p2->cnt) { - return p1->cnt - p2->cnt; - } - for (int i = 0; i < p1->cnt; ++i) { - int r = strcmp(p1->n[i], p2->n[i]); - if (r) { - return r; - } - } - return 0; -} - -iwrc jbl_ptr_serialize(JBL_PTR ptr, IWXSTR *xstr) { - for (int i = 0; i < ptr->cnt; ++i) { - iwrc rc = iwxstr_cat(xstr, "/", 1); - RCRET(rc); - rc = iwxstr_cat(xstr, ptr->n[i], strlen(ptr->n[i])); - RCRET(rc); - } - return 0; -} - -iwrc _jbl_visit(binn_iter *iter, int lvl, JBL_VCTX *vctx, JBL_VISITOR visitor) { - iwrc rc = 0; - binn *bn = vctx->bn; - jbl_visitor_cmd_t cmd; - int idx; - binn bv; - - if (lvl > JBL_MAX_NESTING_LEVEL) { - return JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED; - } - if (!iter) { - binn_iter it; - if (!BINN_IS_CONTAINER_TYPE(bn->type)) { - return JBL_ERROR_INVALID; - } - if (!binn_iter_init(&it, bn, bn->type)) { - return JBL_ERROR_INVALID; - } - rc = _jbl_visit(&it, 0, vctx, visitor); - return rc; - } - - switch (iter->type) { - case BINN_OBJECT: { - char key[MAX_BIN_KEY_LEN + 1]; - while (!vctx->terminate && binn_object_next(iter, key, &bv)) { - cmd = visitor(lvl, &bv, key, -1, vctx, &rc); - RCRET(rc); - if (cmd & JBL_VCMD_TERMINATE) { - vctx->terminate = true; - break; - } - if (!(cmd & JBL_VCMD_SKIP_NESTED) && BINN_IS_CONTAINER_TYPE(bv.type)) { - binn_iter it; - if (!binn_iter_init(&it, &bv, bv.type)) { - return JBL_ERROR_INVALID; - } - rc = _jbl_visit(&it, lvl + 1, vctx, visitor); - RCRET(rc); - } - } - break; - } - case BINN_MAP: { - while (!vctx->terminate && binn_map_next(iter, &idx, &bv)) { - cmd = visitor(lvl, &bv, 0, idx, vctx, &rc); - RCRET(rc); - if (cmd & JBL_VCMD_TERMINATE) { - vctx->terminate = true; - break; - } - if (!(cmd & JBL_VCMD_SKIP_NESTED) && BINN_IS_CONTAINER_TYPE(bv.type)) { - binn_iter it; - if (!binn_iter_init(&it, &bv, bv.type)) { - return JBL_ERROR_INVALID; - } - rc = _jbl_visit(&it, lvl + 1, vctx, visitor); - RCRET(rc); - } - } - break; - } - case BINN_LIST: { - for (idx = 0; !vctx->terminate && binn_list_next(iter, &bv); ++idx) { - cmd = visitor(lvl, &bv, 0, idx, vctx, &rc); - RCRET(rc); - if (cmd & JBL_VCMD_TERMINATE) { - vctx->terminate = true; - break; - } - if (!(cmd & JBL_VCMD_SKIP_NESTED) && BINN_IS_CONTAINER_TYPE(bv.type)) { - binn_iter it; - if (!binn_iter_init(&it, &bv, bv.type)) { - return JBL_ERROR_INVALID; - } - rc = _jbl_visit(&it, lvl + 1, vctx, visitor); - RCRET(rc); - } - } - break; - } - } - return rc; -} - -iwrc jbn_visit(JBL_NODE node, int lvl, JBN_VCTX *vctx, JBN_VISITOR visitor) { - iwrc rc = 0; - if (lvl > JBL_MAX_NESTING_LEVEL) { - return JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED; - } - if (!node) { - node = vctx->root; - lvl = 0; - if (!node) { - return IW_ERROR_INVALID_ARGS; - } - } - JBL_NODE n = node; - switch (node->type) { - case JBV_OBJECT: - case JBV_ARRAY: { - for (n = n->child; !vctx->terminate && n; n = n->next) { - jbn_visitor_cmd_t cmd = visitor(lvl, n, n->key, n->klidx, vctx, &rc); - RCRET(rc); - if (cmd & JBL_VCMD_TERMINATE) { - vctx->terminate = true; - } - if (cmd & JBN_VCMD_DELETE) { - JBL_NODE nn = n->next; // Keep pointer to next - _jbn_remove_item(node, n); - n->next = nn; - } else if (!(cmd & JBL_VCMD_SKIP_NESTED) && (n->type >= JBV_OBJECT)) { - rc = jbn_visit(n, lvl + 1, vctx, visitor); - RCRET(rc); - } - } - break; - } - default: - break; - } - RCRET(rc); - if (lvl == 0) { - visitor(-1, node, 0, 0, vctx, &rc); - } - return rc; -} - -IW_INLINE bool _jbl_visitor_update_jptr_cursor(JBL_VCTX *vctx, int lvl, const char *key, int idx) { - JBL_PTR jp = vctx->op; - if (lvl < jp->cnt) { - if (vctx->pos >= lvl) { - vctx->pos = lvl - 1; - } - if (vctx->pos + 1 == lvl) { - const char *keyptr; - char buf[JBNUMBUF_SIZE]; - if (key) { - keyptr = key; - } else { - iwitoa(idx, buf, JBNUMBUF_SIZE); - keyptr = buf; - } - if (!strcmp(keyptr, jp->n[lvl]) || ((jp->n[lvl][0] == '*') && (jp->n[lvl][1] == '\0'))) { - vctx->pos = lvl; - return (jp->cnt == lvl + 1); - } - } - } - return false; -} - -IW_INLINE bool _jbn_visitor_update_jptr_cursor(JBN_VCTX *vctx, int lvl, const char *key, int idx) { - JBL_PTR jp = vctx->op; - if (lvl < jp->cnt) { - if (vctx->pos >= lvl) { - vctx->pos = lvl - 1; - } - if (vctx->pos + 1 == lvl) { - const char *keyptr; - char buf[JBNUMBUF_SIZE]; - if (key) { - keyptr = key; - } else { - iwitoa(idx, buf, JBNUMBUF_SIZE); - keyptr = buf; - idx = (int) strlen(keyptr); - } - int jplen = (int) strlen(jp->n[lvl]); - if (( (idx == jplen) - && !strncmp(keyptr, jp->n[lvl], idx)) || ((jp->n[lvl][0] == '*') && (jp->n[lvl][1] == '\0') )) { - vctx->pos = lvl; - return (jp->cnt == lvl + 1); - } - } - } - return false; -} - -static jbl_visitor_cmd_t _jbl_get_visitor2(int lvl, binn *bv, const char *key, int idx, JBL_VCTX *vctx, iwrc *rc) { - JBL_PTR jp = vctx->op; - assert(jp); - if (_jbl_visitor_update_jptr_cursor(vctx, lvl, key, idx)) { // Pointer matched - JBL jbl = vctx->result; - memcpy(&jbl->bn, bv, sizeof(*bv)); - vctx->found = true; - return JBL_VCMD_TERMINATE; - } else if (jp->cnt < lvl + 1) { - return JBL_VCMD_SKIP_NESTED; - } - return JBL_VCMD_OK; -} - -static jbl_visitor_cmd_t _jbl_get_visitor(int lvl, binn *bv, const char *key, int idx, JBL_VCTX *vctx, iwrc *rc) { - JBL_PTR jp = vctx->op; - assert(jp); - if (_jbl_visitor_update_jptr_cursor(vctx, lvl, key, idx)) { // Pointer matched - JBL jbl = malloc(sizeof(struct _JBL)); - if (!jbl) { - *rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return JBL_VCMD_TERMINATE; - } - memcpy(&jbl->bn, bv, sizeof(*bv)); - vctx->result = jbl; - return JBL_VCMD_TERMINATE; - } else if (jp->cnt < lvl + 1) { - return JBL_VCMD_SKIP_NESTED; - } - return JBL_VCMD_OK; -} - -bool _jbl_at(JBL jbl, JBL_PTR jp, JBL res) { - JBL_VCTX vctx = { - .bn = &jbl->bn, - .op = jp, - .pos = -1, - .result = res - }; - _jbl_visit(0, 0, &vctx, _jbl_get_visitor2); - return vctx.found; -} - -iwrc jbl_at2(JBL jbl, JBL_PTR jp, JBL *res) { - JBL_VCTX vctx = { - .bn = &jbl->bn, - .op = jp, - .pos = -1 - }; - iwrc rc = _jbl_visit(0, 0, &vctx, _jbl_get_visitor); - if (rc) { - *res = 0; - } else { - if (!vctx.result) { - rc = JBL_ERROR_PATH_NOTFOUND; - *res = 0; - } else { - *res = (JBL) vctx.result; - } - } - return rc; -} - -iwrc jbl_at(JBL jbl, const char *path, JBL *res) { - JBL_PTR jp; - iwrc rc = _jbl_ptr_pool(path, &jp, 0); - if (rc) { - *res = 0; - return rc; - } - rc = jbl_at2(jbl, jp, res); - free(jp); - return rc; -} - -static jbn_visitor_cmd_t _jbn_get_visitor(int lvl, JBL_NODE n, const char *key, int klidx, JBN_VCTX *vctx, iwrc *rc) { - if (lvl < 0) { // EOF - return JBL_VCMD_OK; - } - JBL_PTR jp = vctx->op; - assert(jp); - if (_jbn_visitor_update_jptr_cursor(vctx, lvl, key, klidx)) { // Pointer matched - vctx->result = n; - return JBL_VCMD_TERMINATE; - } else if (jp->cnt < lvl + 1) { - return JBL_VCMD_SKIP_NESTED; - } - return JBL_VCMD_OK; -} - -iwrc jbn_at2(JBL_NODE node, JBL_PTR jp, JBL_NODE *res) { - JBN_VCTX vctx = { - .root = node, - .op = jp, - .pos = -1 - }; - iwrc rc = jbn_visit(node, 0, &vctx, _jbn_get_visitor); - if (rc) { - *res = 0; - } else { - if (!vctx.result) { - rc = JBL_ERROR_PATH_NOTFOUND; - *res = 0; - } else { - *res = (JBL_NODE) vctx.result; - } - } - return rc; -} - -iwrc jbn_at(JBL_NODE node, const char *path, JBL_NODE *res) { - JBL_PTR jp; - iwrc rc = _jbl_ptr_pool(path, &jp, 0); - if (rc) { - *res = 0; - return rc; - } - rc = jbn_at2(node, jp, res); - free(jp); - return rc; -} - -int jbn_paths_compare(JBL_NODE n1, const char *n1path, JBL_NODE n2, const char *n2path, jbl_type_t vtype, iwrc *rcp) { - *rcp = 0; - JBL_NODE v1 = 0, v2 = 0; - iwrc rc = jbn_at(n1, n1path, &v1); - if (rc && (rc != JBL_ERROR_PATH_NOTFOUND)) { - *rcp = rc; - return -2; - } - rc = jbn_at(n2, n2path, &v2); - if (rc && (rc != JBL_ERROR_PATH_NOTFOUND)) { - *rcp = rc; - return -2; - } - if (vtype) { - if (((v1 == 0) || (v1->type != vtype)) || ((v2 == 0) || (v2->type != vtype))) { - *rcp = JBL_ERROR_TYPE_MISMATCHED; - return -2; - } - } - return _jbl_compare_nodes(v1, v2, rcp); -} - -int jbn_path_compare(JBL_NODE n1, JBL_NODE n2, const char *path, jbl_type_t vtype, iwrc *rcp) { - return jbn_paths_compare(n1, path, n2, path, vtype, rcp); -} - -int jbn_path_compare_str(JBL_NODE n, const char *path, const char *sv, iwrc *rcp) { - *rcp = 0; - JBL_NODE v; - iwrc rc = jbn_at(n, path, &v); - if (rc) { - *rcp = rc; - return -2; - } - struct _JBL_NODE cn = { - .type = JBV_STR, - .vptr = sv, - .vsize = (int) strlen(sv) - }; - return _jbl_compare_nodes(v, &cn, rcp); -} - -int jbn_path_compare_i64(JBL_NODE n, const char *path, int64_t iv, iwrc *rcp) { - *rcp = 0; - JBL_NODE v; - iwrc rc = jbn_at(n, path, &v); - if (rc) { - *rcp = rc; - return -2; - } - struct _JBL_NODE cn = { - .type = JBV_I64, - .vi64 = iv - }; - return _jbl_compare_nodes(v, &cn, rcp); -} - -int jbn_path_compare_f64(JBL_NODE n, const char *path, double fv, iwrc *rcp) { - *rcp = 0; - JBL_NODE v; - iwrc rc = jbn_at(n, path, &v); - if (rc) { - *rcp = rc; - return -2; - } - struct _JBL_NODE cn = { - .type = JBV_F64, - .vf64 = fv - }; - return _jbl_compare_nodes(v, &cn, rcp); -} - -int jbn_path_compare_bool(JBL_NODE n, const char *path, bool bv, iwrc *rcp) { - *rcp = 0; - JBL_NODE v; - iwrc rc = jbn_at(n, path, &v); - if (rc) { - *rcp = rc; - return -2; - } - struct _JBL_NODE cn = { - .type = JBV_BOOL, - .vbool = bv - }; - return _jbl_compare_nodes(v, &cn, rcp); -} - -IW_INLINE void _jbl_node_reset_data(JBL_NODE target) { - jbl_type_t t = target->type; - memset(((uint8_t*) target) + offsetof(struct _JBL_NODE, child), - 0, - sizeof(struct _JBL_NODE) - offsetof(struct _JBL_NODE, child)); - target->type = t; -} - -IW_INLINE void _jbl_copy_node_data(JBL_NODE target, JBL_NODE value) { - memcpy(((uint8_t*) target) + offsetof(struct _JBL_NODE, child), - ((uint8_t*) value) + offsetof(struct _JBL_NODE, child), - sizeof(struct _JBL_NODE) - offsetof(struct _JBL_NODE, child)); -} - -iwrc _jbl_increment_node_data(JBL_NODE target, JBL_NODE value) { - if ((value->type != JBV_I64) && (value->type != JBV_F64)) { - return JBL_ERROR_PATCH_INVALID_VALUE; - } - if (target->type == JBV_I64) { - if (value->type == JBV_I64) { - target->vi64 += value->vi64; - } else { - target->vi64 += (int64_t) value->vf64; - } - return 0; - } else if (target->type == JBV_F64) { - if (value->type == JBV_F64) { - target->vf64 += value->vf64; - } else { - target->vf64 += (double) value->vi64; - } - return 0; - } else { - return JBL_ERROR_PATCH_TARGET_INVALID; - } -} - -void jbn_data(JBL_NODE node) { - _jbl_node_reset_data(node); -} - -int jbn_length(JBL_NODE node) { - int ret = 0; - for (JBL_NODE n = node->child; n; n = n->next) { - ++ret; - } - return ret; -} - -static void _jbn_add_item(JBL_NODE parent, JBL_NODE node) { - assert(parent && node); - node->next = 0; - node->prev = 0; - node->parent = parent; - if (parent->child) { - JBL_NODE prev = parent->child->prev; - parent->child->prev = node; - if (prev) { // -V1051 - prev->next = node; - node->prev = prev; - } else { - parent->child->next = node; - node->prev = parent->child; - } - } else { - parent->child = node; - } - if (parent->type == JBV_ARRAY) { - node->key = 0; - if (node->prev) { - node->klidx = node->prev->klidx + 1; - } else { - node->klidx = 0; - } - } -} - -void jbn_add_item(JBL_NODE parent, JBL_NODE node) { - _jbn_add_item(parent, node); -} - -iwrc jbn_add_item_str(JBL_NODE parent, const char *key, const char *val, int vlen, JBL_NODE *node_out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_STR; - if (val) { - if (vlen < 0) { - vlen = (int) strlen(val); - } - n->vptr = iwpool_strndup(pool, val, vlen, &rc); - RCGO(rc, finish); - n->vsize = vlen; - } - jbn_add_item(parent, n); - if (node_out) { - *node_out = n; - } -finish: - return rc; -} - -iwrc jbn_add_item_null(JBL_NODE parent, const char *key, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_NULL; - jbn_add_item(parent, n); -finish: - return rc; -} - -iwrc jbn_add_item_i64(JBL_NODE parent, const char *key, int64_t val, JBL_NODE *node_out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_I64; - n->vi64 = val; - jbn_add_item(parent, n); - if (node_out) { - *node_out = n; - } -finish: - return rc; -} - -iwrc jbn_add_item_f64(JBL_NODE parent, const char *key, double val, JBL_NODE *node_out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_F64; - n->vf64 = val; - jbn_add_item(parent, n); - if (node_out) { - *node_out = n; - } -finish: - return rc; -} - -iwrc jbn_add_item_bool(JBL_NODE parent, const char *key, bool val, JBL_NODE *node_out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_BOOL; - n->vbool = val; - jbn_add_item(parent, n); - if (node_out) { - *node_out = n; - } -finish: - return rc; -} - -iwrc jbn_add_item_obj(JBL_NODE parent, const char *key, JBL_NODE *out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_OBJECT; - jbn_add_item(parent, n); - if (out) { - *out = n; - } -finish: - return rc; -} - -iwrc jbn_add_item_arr(JBL_NODE parent, const char *key, JBL_NODE *out, IWPOOL *pool) { - if (!parent || !pool || (parent->type < JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - if (parent->type == JBV_OBJECT) { - if (!key) { - return IW_ERROR_INVALID_ARGS; - } - n->key = iwpool_strdup(pool, key, &rc); - RCGO(rc, finish); - n->klidx = (int) strlen(n->key); - } - n->type = JBV_ARRAY; - jbn_add_item(parent, n); - if (out) { - *out = n; - } -finish: - return rc; -} - -iwrc jbn_copy_path( - JBL_NODE src, - const char *src_path, - JBL_NODE target, - const char *target_path, - bool overwrite_on_nulls, - bool no_src_clone, - IWPOOL *pool) { - if (!src || !src_path || !target || !target_path || !pool) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - JBL_NODE n1, n2; - jbp_patch_t op = JBP_REPLACE; - - if (strcmp("/", src_path) != 0) { // -V526 - rc = jbn_at(src, src_path, &n1); - if (rc == JBL_ERROR_PATH_NOTFOUND) { - return 0; - } - RCRET(rc); - } else { - n1 = src; - } - if (!overwrite_on_nulls && (n1->type <= JBV_NULL)) { - return 0; - } - if (no_src_clone) { - n2 = n1; - } else { - rc = jbn_clone(n1, &n2, pool); - RCRET(rc); - } - - rc = jbn_at(target, target_path, &n1); - if (rc == JBL_ERROR_PATH_NOTFOUND) { - rc = 0; - op = JBP_ADD_CREATE; - } - JBL_PATCH p[] = { - { - .op = op, - .path = target_path, - .vnode = n2 - } - }; - return jbn_patch(target, p, sizeof(p) / sizeof(p[0]), pool); -} - -IW_EXPORT iwrc jbn_copy_paths( - JBL_NODE src, - JBL_NODE target, - const char **paths, - bool overwrite_on_nulls, - bool no_src_clone, - IWPOOL *pool) { - if (!target || !src || !paths || !pool) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - for (const char **p = paths; *p; ++p) { - const char *path = *p; - rc = jbn_copy_path(src, path, target, path, overwrite_on_nulls, no_src_clone, pool); - RCBREAK(rc); - } - return rc; -} - -IW_INLINE void _jbn_remove_item(JBL_NODE parent, JBL_NODE child) { - assert(parent->child); - if (parent->child == child) { // First element - if (child->next) { - parent->child = child->next; - parent->child->prev = child->prev; - if (child->prev) { - child->prev->next = 0; - } - } else { - parent->child = 0; - } - } else if (parent->child->prev == child) { // Last element - parent->child->prev = child->prev; - if (child->prev) { - child->prev->next = 0; - } - } else { // Somewhere in middle - if (child->next) { - child->next->prev = child->prev; - } - if (child->prev) { - child->prev->next = child->next; - } - } - child->next = 0; - child->prev = 0; - child->child = 0; - child->parent = 0; -} - -void jbn_remove_item(JBL_NODE parent, JBL_NODE child) { - _jbn_remove_item(parent, child); -} - -static iwrc _jbl_create_node( - JBLDRCTX *ctx, - const binn *bv, - JBL_NODE parent, - const char *key, - int klidx, - JBL_NODE *node, - bool clone_strings) { - iwrc rc = 0; - JBL_NODE n = iwpool_alloc(sizeof(*n), ctx->pool); - if (node) { - *node = 0; - } - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - memset(n, 0, sizeof(*n)); - if (key && clone_strings) { - n->key = iwpool_strndup(ctx->pool, key, klidx, &rc); - RCGO(rc, finish); - } else { - n->key = key; - } - n->klidx = klidx; - n->parent = parent; - switch (bv->type) { - case BINN_NULL: - n->type = JBV_NULL; - break; - case BINN_STRING: - n->type = JBV_STR; - if (!clone_strings) { - n->vptr = bv->ptr; - n->vsize = bv->size; - } else { - n->vptr = iwpool_strndup(ctx->pool, bv->ptr, bv->size, &rc); - n->vsize = bv->size; - RCGO(rc, finish); - } - break; - case BINN_OBJECT: - case BINN_MAP: - n->type = JBV_OBJECT; - break; - case BINN_LIST: - n->type = JBV_ARRAY; - break; - case BINN_TRUE: - n->type = JBV_BOOL; - n->vbool = true; - break; - case BINN_FALSE: - n->type = JBV_BOOL; - n->vbool = false; - break; - case BINN_BOOL: - n->type = JBV_BOOL; - n->vbool = bv->vbool; - break; - case BINN_UINT8: - n->vi64 = bv->vuint8; - n->type = JBV_I64; - break; - case BINN_UINT16: - n->vi64 = bv->vuint16; - n->type = JBV_I64; - break; - case BINN_UINT32: - n->vi64 = bv->vuint32; - n->type = JBV_I64; - break; - case BINN_UINT64: - n->vi64 = bv->vuint64; - n->type = JBV_I64; - break; - case BINN_INT8: - n->vi64 = bv->vint8; // NOLINT(bugprone-signed-char-misuse) - n->type = JBV_I64; - break; - case BINN_INT16: - n->vi64 = bv->vint16; - n->type = JBV_I64; - break; - case BINN_INT32: - n->vi64 = bv->vint32; - n->type = JBV_I64; - break; - case BINN_INT64: - n->vi64 = bv->vint64; - n->type = JBV_I64; - break; - case BINN_FLOAT32: - case BINN_FLOAT64: - n->vf64 = bv->vdouble; - n->type = JBV_F64; - break; - default: - rc = JBL_ERROR_CREATION; - goto finish; - } - if (parent) { - _jbn_add_item(parent, n); - } - -finish: - if (rc) { - free(n); - } else { - if (node) { - *node = n; - } - } - return rc; -} - -static iwrc _jbl_node_from_binn_impl( - JBLDRCTX *ctx, - const binn *bn, - JBL_NODE parent, - char *key, - int klidx, - bool clone_strings) { - binn bv; - binn_iter iter; - iwrc rc = 0; - - switch (bn->type) { - case BINN_OBJECT: - case BINN_MAP: - rc = _jbl_create_node(ctx, bn, parent, key, klidx, &parent, clone_strings); - RCRET(rc); - if (!ctx->root) { - ctx->root = parent; - } - if (!binn_iter_init(&iter, (binn*) bn, bn->type)) { - return JBL_ERROR_INVALID; - } - if (bn->type == BINN_OBJECT) { - for (int i = 0; binn_object_next2(&iter, &key, &klidx, &bv); ++i) { - rc = _jbl_node_from_binn_impl(ctx, &bv, parent, key, klidx, clone_strings); - RCRET(rc); - } - } else if (bn->type == BINN_MAP) { - for (int i = 0; binn_map_next(&iter, &klidx, &bv); ++i) { - rc = _jbl_node_from_binn_impl(ctx, &bv, parent, 0, klidx, clone_strings); - RCRET(rc); - } - } - break; - case BINN_LIST: - rc = _jbl_create_node(ctx, bn, parent, key, klidx, &parent, clone_strings); - RCRET(rc); - if (!ctx->root) { - ctx->root = parent; - } - if (!binn_iter_init(&iter, (binn*) bn, bn->type)) { - return JBL_ERROR_INVALID; - } - for (int i = 0; binn_list_next(&iter, &bv); ++i) { - rc = _jbl_node_from_binn_impl(ctx, &bv, parent, 0, i, clone_strings); - RCRET(rc); - } - break; - default: { - rc = _jbl_create_node(ctx, bn, parent, key, klidx, 0, clone_strings); - RCRET(rc); - break; - } - } - return rc; -} - -iwrc _jbl_node_from_binn(const binn *bn, JBL_NODE *node, bool clone_strings, IWPOOL *pool) { - JBLDRCTX ctx = { - .pool = pool - }; - iwrc rc = _jbl_node_from_binn_impl(&ctx, bn, 0, 0, -1, clone_strings); - if (rc) { - *node = 0; - } else { - *node = ctx.root; - } - return rc; -} - -static JBL_NODE _jbl_node_find(JBL_NODE node, JBL_PTR ptr, int from, int to) { - if (!ptr || !node) { - return 0; - } - JBL_NODE n = node; - - for (int i = from; n && i < ptr->cnt && i < to; ++i) { - if (n->type == JBV_OBJECT) { - int ptrnlen = (int) strlen(ptr->n[i]); - for (n = n->child; n; n = n->next) { - if (!strncmp(n->key, ptr->n[i], n->klidx) && (ptrnlen == n->klidx)) { - break; - } - } - } else if (n->type == JBV_ARRAY) { - int64_t idx = iwatoi(ptr->n[i]); - for (n = n->child; n; n = n->next) { - if (idx == n->klidx) { - break; - } - } - } else { - return 0; - } - } - return n; -} - -IW_INLINE JBL_NODE _jbl_node_find2(JBL_NODE node, JBL_PTR ptr) { - if (!node || !ptr || !ptr->cnt) { - return 0; - } - return _jbl_node_find(node, ptr, 0, ptr->cnt - 1); -} - -static JBL_NODE _jbl_node_detach(JBL_NODE target, JBL_PTR path) { - if (!path) { - return 0; - } - JBL_NODE parent = (path->cnt > 1) ? _jbl_node_find(target, path, 0, path->cnt - 1) : target; - if (!parent) { - return 0; - } - JBL_NODE child = _jbl_node_find(parent, path, path->cnt - 1, path->cnt); - if (!child) { - return 0; - } - _jbn_remove_item(parent, child); - return child; -} - -JBL_NODE jbn_detach2(JBL_NODE target, JBL_PTR path) { - return _jbl_node_detach(target, path); -} - -JBL_NODE jbn_detach(JBL_NODE target, const char *path) { - JBL_PTR jp; - iwrc rc = _jbl_ptr_pool(path, &jp, 0); - if (rc) { - return 0; - } - JBL_NODE res = jbn_detach2(target, jp); - free(jp); - return res; -} - -static int _jbl_cmp_node_keys(const void *o1, const void *o2) { - JBL_NODE n1 = *((JBL_NODE*) o1); - JBL_NODE n2 = *((JBL_NODE*) o2); - if (!n1 && !n2) { - return 0; - } - if (!n2 || (n1->klidx > n2->klidx)) { // -V522 - return 1; - } else if (!n1 || (n1->klidx < n2->klidx)) { // -V522 - return -1; - } - return strncmp(n1->key, n2->key, n1->klidx); -} - -static uint32_t _jbl_node_count(JBL_NODE n) { - uint32_t ret = 0; - n = n->child; - while (n) { - ret++; - n = n->next; - } - return ret; -} - -static int _jbl_compare_objects(JBL_NODE n1, JBL_NODE n2, iwrc *rcp) { - int ret = 0; - uint32_t cnt = _jbl_node_count(n1); - uint32_t i = _jbl_node_count(n2); - if (cnt > i) { - return 1; - } else if (cnt < i) { - return -1; - } else if (cnt == 0) { - return 0; - } - JBL_NODE *s1 = malloc(2 * sizeof(JBL_NODE) * cnt); - if (!s1) { - *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return 0; - } - JBL_NODE *s2 = s1 + cnt; - - i = 0; - n1 = n1->child; - n2 = n2->child; - while (n1 && n2) { - s1[i] = n1; - s2[i] = n2; - n1 = n1->next; - n2 = n2->next; - ++i; - } - qsort(s1, cnt, sizeof(JBL_NODE), _jbl_cmp_node_keys); - qsort(s2, cnt, sizeof(JBL_NODE), _jbl_cmp_node_keys); - for (i = 0; i < cnt; ++i) { - ret = _jbl_cmp_node_keys(s1 + i, s2 + i); - if (ret) { - goto finish; - } - ret = _jbl_compare_nodes(s1[i], s2[i], rcp); - if (*rcp || ret) { - goto finish; - } - } - -finish: - free(s1); - return ret; -} - -int _jbl_compare_nodes(JBL_NODE n1, JBL_NODE n2, iwrc *rcp) { - if (!n1 && !n2) { - return 0; - } else if (!n1) { - return -1; - } else if (!n2) { - return 1; - } else if (n1->type != n2->type) { - return (int) n1->type - (int) n2->type; - } - switch (n1->type) { - case JBV_BOOL: - return n1->vbool - n2->vbool; - case JBV_I64: - return n1->vi64 > n2->vi64 ? 1 : n1->vi64 < n2->vi64 ? -1 : 0; - case JBV_F64: { - size_t sz1, sz2; - char b1[JBNUMBUF_SIZE]; - char b2[JBNUMBUF_SIZE]; - jbi_ftoa(n1->vf64, b1, &sz1); - jbi_ftoa(n2->vf64, b2, &sz2); - return iwafcmp(b1, sz1, b2, sz2); - } - case JBV_STR: - if (n1->vsize != n2->vsize) { - return n1->vsize - n2->vsize; - } - return strncmp(n1->vptr, n2->vptr, n1->vsize); - case JBV_ARRAY: - for (n1 = n1->child, n2 = n2->child; n1 && n2; n1 = n1->next, n2 = n2->next) { - int res = _jbl_compare_nodes(n1, n2, rcp); - if (res) { - return res; - } - } - if (n1) { - return 1; - } else if (n2) { - return -1; - } else { - return 0; - } - case JBV_OBJECT: - return _jbl_compare_objects(n1, n2, rcp); - case JBV_NULL: - case JBV_NONE: - break; - } - return 0; -} - -int jbn_compare_nodes(JBL_NODE n1, JBL_NODE n2, iwrc *rcp) { - return _jbl_compare_nodes(n1, n2, rcp); -} - -static iwrc _jbl_target_apply_patch(JBL_NODE target, const JBL_PATCHEXT *ex, IWPOOL *pool) { - - struct _JBL_NODE *ntmp; - jbp_patch_t op = ex->p->op; - JBL_PTR path = ex->path; - JBL_NODE value = ex->p->vnode; - bool oproot = ex->path->cnt == 1 && *ex->path->n[0] == '\0'; - - if (op == JBP_TEST) { - iwrc rc = 0; - if (!value) { - return JBL_ERROR_PATCH_NOVALUE; - } - if (_jbl_compare_nodes(oproot ? target : _jbl_node_find(target, path, 0, path->cnt), value, &rc)) { - RCRET(rc); - return JBL_ERROR_PATCH_TEST_FAILED; - } else { - return rc; - } - } - if (oproot) { // Root operation - if (op == JBP_REMOVE) { - memset(target, 0, sizeof(*target)); - } else if ((op == JBP_REPLACE) || (op == JBP_ADD) || (op == JBP_ADD_CREATE)) { - if (!value) { - return JBL_ERROR_PATCH_NOVALUE; - } - memmove(target, value, sizeof(*value)); - } - } else { // Not a root - if ((op == JBP_REMOVE) || (op == JBP_REPLACE)) { - _jbl_node_detach(target, ex->path); - } - if (op == JBP_REMOVE) { - return 0; - } else if ((op == JBP_MOVE) || (op == JBP_COPY) || (op == JBP_SWAP)) { - if (op == JBP_MOVE) { - value = _jbl_node_detach(target, ex->from); - } else { - value = _jbl_node_find(target, ex->from, 0, ex->from->cnt); - } - if (!value) { - return JBL_ERROR_PATH_NOTFOUND; - } - if (op == JBP_SWAP) { - ntmp = iwpool_calloc(sizeof(*ntmp), pool); - if (!ntmp) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - } - } else { // ADD/REPLACE/INCREMENT - if (!value) { - return JBL_ERROR_PATCH_NOVALUE; - } - } - int lastidx = path->cnt - 1; - JBL_NODE parent = (path->cnt > 1) ? _jbl_node_find(target, path, 0, lastidx) : target; - if (!parent) { - if (op == JBP_ADD_CREATE) { - parent = target; - for (int i = 0; i < lastidx; ++i) { - JBL_NODE pn = _jbl_node_find(parent, path, i, i + 1); - if (!pn) { - pn = iwpool_calloc(sizeof(*pn), pool); - if (!pn) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - pn->type = JBV_OBJECT; - pn->key = path->n[i]; - pn->klidx = (int) strlen(pn->key); - _jbn_add_item(parent, pn); - } else if (pn->type != JBV_OBJECT) { - return JBL_ERROR_PATCH_TARGET_INVALID; - } - parent = pn; - } - } else { - return JBL_ERROR_PATCH_TARGET_INVALID; - } - } - if (parent->type == JBV_ARRAY) { - if ((path->n[lastidx][0] == '-') && (path->n[lastidx][1] == '\0')) { - if (op == JBP_SWAP) { - value = _jbl_node_detach(target, ex->from); - } - _jbn_add_item(parent, value); // Add to end of array - } else { // Insert into the specified index - int idx = iwatoi(path->n[lastidx]); - int cnt = idx; - JBL_NODE child = parent->child; - while (child && cnt > 0) { - cnt--; - child = child->next; - } - if (cnt > 0) { - return JBL_ERROR_PATCH_INVALID_ARRAY_INDEX; - } - value->klidx = idx; - if (child) { - if (op == JBP_SWAP) { - _jbl_copy_node_data(ntmp, value); - _jbl_copy_node_data(value, child); - _jbl_copy_node_data(child, ntmp); - } else { - value->parent = parent; - value->next = child; - value->prev = child->prev; - child->prev = value; - if (child == parent->child) { - parent->child = value; - } else { - value->prev->next = value; - } - while (child) { - child->klidx++; - child = child->next; - } - } - } else { - if (op == JBP_SWAP) { - value = _jbl_node_detach(target, ex->from); - } - _jbn_add_item(parent, value); - } - } - } else if (parent->type == JBV_OBJECT) { - JBL_NODE child = _jbl_node_find(parent, path, path->cnt - 1, path->cnt); - if (child) { - if (op == JBP_INCREMENT) { - return _jbl_increment_node_data(child, value); - } else { - if (op == JBP_SWAP) { - _jbl_copy_node_data(ntmp, value); - _jbl_copy_node_data(value, child); - _jbl_copy_node_data(child, ntmp); - } else { - _jbl_copy_node_data(child, value); - } - } - } else if (op != JBP_INCREMENT) { - if (op == JBP_SWAP) { - value = _jbl_node_detach(target, ex->from); - } - value->key = path->n[path->cnt - 1]; - value->klidx = (int) strlen(value->key); - _jbn_add_item(parent, value); - } else { - return JBL_ERROR_PATCH_TARGET_INVALID; - } - } else { - return JBL_ERROR_PATCH_TARGET_INVALID; - } - } - return 0; -} - -static iwrc _jbl_from_node_impl(binn *res, JBL_NODE node) { - iwrc rc = 0; - switch (node->type) { - case JBV_OBJECT: - if (!binn_create(res, BINN_OBJECT, 0, NULL)) { - return JBL_ERROR_CREATION; - } - for (JBL_NODE n = node->child; n; n = n->next) { - binn bv; - rc = _jbl_from_node_impl(&bv, n); - RCRET(rc); - if (!binn_object_set_value2(res, n->key, n->klidx, &bv)) { - rc = JBL_ERROR_CREATION; - } - binn_free(&bv); - RCRET(rc); - } - break; - case JBV_ARRAY: - if (!binn_create(res, BINN_LIST, 0, NULL)) { - return JBL_ERROR_CREATION; - } - for (JBL_NODE n = node->child; n; n = n->next) { - binn bv; - rc = _jbl_from_node_impl(&bv, n); - RCRET(rc); - if (!binn_list_add_value(res, &bv)) { - rc = JBL_ERROR_CREATION; - } - binn_free(&bv); - RCRET(rc); - } - break; - case JBV_STR: - binn_init_item(res); - binn_set_string(res, (void*) node->vptr, 0); - break; - case JBV_I64: - binn_init_item(res); - binn_set_int64(res, node->vi64); - break; - case JBV_F64: - binn_init_item(res); - binn_set_double(res, node->vf64); - break; - case JBV_BOOL: - binn_init_item(res); - binn_set_bool(res, node->vbool); - break; - case JBV_NULL: - binn_init_item(res); - binn_set_null(res); - break; - case JBV_NONE: - rc = JBL_ERROR_CREATION; - break; - } - return rc; -} - -iwrc _jbl_binn_from_node(binn *res, JBL_NODE node) { - iwrc rc = _jbl_from_node_impl(res, node); - if (!rc) { - if (res->writable && res->dirty) { - binn_save_header(res); - } - } - return rc; -} - -iwrc _jbl_from_node(JBL jbl, JBL_NODE node) { - jbl->node = node; - return _jbl_binn_from_node(&jbl->bn, node); -} - -static iwrc _jbl_patch_node(JBL_NODE root, const JBL_PATCH *p, size_t cnt, IWPOOL *pool) { - if (cnt < 1) { - return 0; - } - if (!root || !p) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - size_t i = 0; - JBL_PATCHEXT parr[cnt]; - memset(parr, 0, cnt * sizeof(JBL_PATCHEXT)); - for (i = 0; i < cnt; ++i) { - JBL_PATCHEXT *ext = &parr[i]; - ext->p = &p[i]; - rc = _jbl_ptr_pool(p[i].path, &ext->path, pool); - RCRET(rc); - if (p[i].from) { - rc = _jbl_ptr_pool(p[i].from, &ext->from, pool); - RCRET(rc); - } - } - for (i = 0; i < cnt; ++i) { - rc = _jbl_target_apply_patch(root, &parr[i], pool); - RCRET(rc); - } - return rc; -} - -static iwrc _jbl_patch(JBL jbl, const JBL_PATCH *p, size_t cnt, IWPOOL *pool) { - if (cnt < 1) { - return 0; - } - if (!jbl || !p) { - return IW_ERROR_INVALID_ARGS; - } - binn bv; - binn *bn; - JBL_NODE root; - iwrc rc = _jbl_node_from_binn(&jbl->bn, &root, false, pool); - RCRET(rc); - rc = _jbl_patch_node(root, p, cnt, pool); - RCRET(rc); - if (root->type != JBV_NONE) { - rc = _jbl_from_node_impl(&bv, root); - RCRET(rc); - bn = &bv; - } else { - bn = 0; - } - binn_free(&jbl->bn); - if (bn) { - if (bn->writable && bn->dirty) { - binn_save_header(bn); - } - memcpy(&jbl->bn, bn, sizeof(jbl->bn)); - jbl->bn.allocated = 0; - } else { - memset(&jbl->bn, 0, sizeof(jbl->bn)); - root->type = JBV_NONE; - } - return rc; -} - -int _jbl_cmp_atomic_values(JBL v1, JBL v2) { - jbl_type_t t1 = jbl_type(v1); - jbl_type_t t2 = jbl_type(v2); - if (t1 != t2) { - return (int) t1 - (int) t2; - } - switch (t1) { - case JBV_BOOL: - case JBV_I64: { - int64_t vv1 = jbl_get_i64(v1); - int64_t vv2 = jbl_get_i64(v2); - return vv1 > vv2 ? 1 : vv1 < vv2 ? -1 : 0; - } - case JBV_STR: - return strcmp(jbl_get_str(v1), jbl_get_str(v2)); // -V575 - case JBV_F64: { - double vv1 = jbl_get_f64(v1); - double vv2 = jbl_get_f64(v2); - return vv1 > vv2 ? 1 : vv1 < vv2 ? -1 : 0; - } - default: - return 0; - } -} - -bool _jbl_is_eq_atomic_values(JBL v1, JBL v2) { - jbl_type_t t1 = jbl_type(v1); - jbl_type_t t2 = jbl_type(v2); - if (t1 != t2) { - return false; - } - switch (t1) { - case JBV_BOOL: - case JBV_I64: - return jbl_get_i64(v1) == jbl_get_i64(v2); - case JBV_STR: - return !strcmp(jbl_get_str(v1), jbl_get_str(v2)); // -V575 - case JBV_F64: - return jbl_get_f64(v1) == jbl_get_f64(v2); // -V550 - case JBV_OBJECT: - case JBV_ARRAY: - return false; - default: - return true; - } -} - -// --------------------------- Public API - -void jbn_apply_from(JBL_NODE target, JBL_NODE from) { - const int off = offsetof(struct _JBL_NODE, child); - memcpy((char*) target + off, - (char*) from + off, - sizeof(struct _JBL_NODE) - off); -} - -iwrc jbl_to_node(JBL jbl, JBL_NODE *node, bool clone_strings, IWPOOL *pool) { - if (jbl->node) { - *node = jbl->node; - return 0; - } - return _jbl_node_from_binn(&jbl->bn, node, clone_strings, pool); -} - -iwrc jbn_patch(JBL_NODE root, const JBL_PATCH *p, size_t cnt, IWPOOL *pool) { - return _jbl_patch_node(root, p, cnt, pool); -} - -iwrc jbl_patch(JBL jbl, const JBL_PATCH *p, size_t cnt) { - if (cnt < 1) { - return 0; - } - if (!jbl || !p) { - return IW_ERROR_INVALID_ARGS; - } - IWPOOL *pool = iwpool_create(jbl->bn.size); - if (!pool) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - iwrc rc = _jbl_patch(jbl, p, cnt, pool); - iwpool_destroy(pool); - return rc; -} - -static iwrc _jbl_create_patch(JBL_NODE node, JBL_PATCH **pptr, int *cntp, IWPOOL *pool) { - *pptr = 0; - *cntp = 0; - int i = 0; - for (JBL_NODE n = node->child; n; n = n->next) { - if (n->type != JBV_OBJECT) { - return JBL_ERROR_PATCH_INVALID; - } - ++i; - } - JBL_PATCH *p = iwpool_alloc(i * sizeof(*p), pool); - if (!p) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - memset(p, 0, i * sizeof(*p)); - i = 0; - for (JBL_NODE n = node->child; n; n = n->next, ++i) { - JBL_PATCH *pp = p + i; - for (JBL_NODE n2 = n->child; n2; n2 = n2->next) { - if (!strncmp("op", n2->key, n2->klidx)) { - if (n2->type != JBV_STR) { - return JBL_ERROR_PATCH_INVALID; - } - if (!strncmp("add", n2->vptr, n2->vsize)) { - pp->op = JBP_ADD; - } else if (!strncmp("remove", n2->vptr, n2->vsize)) { - pp->op = JBP_REMOVE; - } else if (!strncmp("replace", n2->vptr, n2->vsize)) { - pp->op = JBP_REPLACE; - } else if (!strncmp("copy", n2->vptr, n2->vsize)) { - pp->op = JBP_COPY; - } else if (!strncmp("move", n2->vptr, n2->vsize)) { - pp->op = JBP_MOVE; - } else if (!strncmp("test", n2->vptr, n2->vsize)) { - pp->op = JBP_TEST; - } else if (!strncmp("increment", n2->vptr, n2->vsize)) { - pp->op = JBP_INCREMENT; - } else if (!strncmp("add_create", n2->vptr, n2->vsize)) { - pp->op = JBP_ADD_CREATE; - } else if (!strncmp("swap", n2->vptr, n2->vsize)) { - pp->op = JBP_SWAP; - } else { - return JBL_ERROR_PATCH_INVALID_OP; - } - } else if (!strncmp("value", n2->key, n2->klidx)) { - pp->vnode = n2; - } else if (!strncmp("path", n2->key, n2->klidx)) { - if (n2->type != JBV_STR) { - return JBL_ERROR_PATCH_INVALID; - } - pp->path = n2->vptr; - } else if (!strncmp("from", n2->key, n2->klidx)) { - if (n2->type != JBV_STR) { - return JBL_ERROR_PATCH_INVALID; - } - pp->from = n2->vptr; - } - } - } - *cntp = i; - *pptr = p; - return 0; -} - -iwrc jbl_patch_from_json(JBL jbl, const char *patchjson) { - if (!jbl || !patchjson) { - return IW_ERROR_INVALID_ARGS; - } - JBL_PATCH *p; - JBL_NODE patch; - int cnt = (int) strlen(patchjson); - IWPOOL *pool = iwpool_create(MAX(cnt, 1024U)); - if (!pool) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - iwrc rc = jbn_from_json(patchjson, &patch, pool); - RCGO(rc, finish); - if (patch->type == JBV_ARRAY) { - rc = _jbl_create_patch(patch, &p, &cnt, pool); - RCGO(rc, finish); - rc = _jbl_patch(jbl, p, cnt, pool); - } else if (patch->type == JBV_OBJECT) { - // FIXME: Merge patch not implemented - //_jbl_merge_patch_node() - rc = IW_ERROR_NOT_IMPLEMENTED; - } else { - rc = JBL_ERROR_PATCH_INVALID; - } - -finish: - iwpool_destroy(pool); - return rc; -} - -iwrc jbl_fill_from_node(JBL jbl, JBL_NODE node) { - if (!jbl || !node) { - return IW_ERROR_INVALID_ARGS; - } - if (node->type == JBV_NONE) { - memset(jbl, 0, sizeof(*jbl)); - return 0; - } - binn bv = { 0 }; - iwrc rc = _jbl_binn_from_node(&bv, node); - RCRET(rc); - binn_free(&jbl->bn); - memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); - jbl->bn.allocated = 0; - return rc; -} - -iwrc jbl_from_node(JBL *jblp, JBL_NODE node) { - if (!jblp || !node) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - if (node->type == JBV_OBJECT) { - rc = jbl_create_empty_object(jblp); - } else if (node->type == JBV_ARRAY) { - rc = jbl_create_empty_array(jblp); - } else { - rc = IW_ERROR_INVALID_ARGS; - } - RCRET(rc); - return jbl_fill_from_node(*jblp, node); -} - -static JBL_NODE _jbl_merge_patch_node(JBL_NODE target, JBL_NODE patch, IWPOOL *pool, iwrc *rcp) { - *rcp = 0; - if (!patch) { - return 0; - } - if (patch->type == JBV_OBJECT) { - if (!target) { - target = iwpool_alloc(sizeof(*target), pool); - if (!target) { - *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return 0; - } - memset(target, 0, sizeof(*target)); - target->type = JBV_OBJECT; - target->key = patch->key; - target->klidx = patch->klidx; - } else if (target->type != JBV_OBJECT) { - _jbl_node_reset_data(target); - target->type = JBV_OBJECT; - } - patch = patch->child; - while (patch) { - JBL_NODE patch_next = patch->next; - if (patch->type == JBV_NULL) { - JBL_NODE node = target->child; - while (node) { - if ((node->klidx == patch->klidx) && !strncmp(node->key, patch->key, node->klidx)) { - _jbn_remove_item(target, node); - break; - } - node = node->next; - } - } else { - JBL_NODE node = target->child; - while (node) { - if ((node->klidx == patch->klidx) && !strncmp(node->key, patch->key, node->klidx)) { - _jbl_copy_node_data(node, _jbl_merge_patch_node(node, patch, pool, rcp)); - break; - } - node = node->next; - } - if (!node) { - _jbn_add_item(target, _jbl_merge_patch_node(0, patch, pool, rcp)); - } - } - patch = patch_next; - } - return target; - } else { - return patch; - } -} - -iwrc jbn_merge_patch_from_json(JBL_NODE root, const char *patchjson, IWPOOL *pool) { - if (!root || !patchjson || !pool) { - return IW_ERROR_INVALID_ARGS; - } - JBL_NODE patch, res; - iwrc rc = jbn_from_json(patchjson, &patch, pool); - RCRET(rc); - res = _jbl_merge_patch_node(root, patch, pool, &rc); - RCGO(rc, finish); - if (res != root) { - memcpy(root, res, sizeof(*root)); // -V575 - } - -finish: - return rc; -} - -iwrc jbl_merge_patch(JBL jbl, const char *patchjson) { - if (!jbl || !patchjson) { - return IW_ERROR_INVALID_ARGS; - } - binn bv; - JBL_NODE target; - IWPOOL *pool = iwpool_create(jbl->bn.size * 2); - if (!pool) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - iwrc rc = _jbl_node_from_binn(&jbl->bn, &target, false, pool); - RCGO(rc, finish); - rc = jbn_merge_patch_from_json(target, patchjson, pool); - RCGO(rc, finish); - - rc = _jbl_binn_from_node(&bv, target); - RCGO(rc, finish); - - binn_free(&jbl->bn); - memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); - jbl->bn.allocated = 0; - -finish: - iwpool_destroy(pool); - return 0; -} - -iwrc jbl_merge_patch_jbl(JBL jbl, JBL patch) { - - IWXSTR *xstr = iwxstr_new(); - if (!xstr) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - iwrc rc = jbl_as_json(patch, jbl_xstr_json_printer, xstr, 0); - RCGO(rc, finish); - rc = jbl_merge_patch(jbl, iwxstr_ptr(xstr)); -finish: - iwxstr_destroy(xstr); - return rc; -} - -iwrc jbn_patch_auto(JBL_NODE root, JBL_NODE patch, IWPOOL *pool) { - if (!root || !patch || !pool) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - if (patch->type == JBV_OBJECT) { - _jbl_merge_patch_node(root, patch, pool, &rc); - } else if (patch->type == JBV_ARRAY) { - int cnt; - JBL_PATCH *p; - rc = _jbl_create_patch(patch, &p, &cnt, pool); - RCRET(rc); - rc = _jbl_patch_node(root, p, cnt, pool); - } else { - return IW_ERROR_INVALID_ARGS; - } - return rc; -} - -iwrc jbn_merge_patch(JBL_NODE root, JBL_NODE patch, IWPOOL *pool) { - if (!root || !patch || !pool || (root->type != JBV_OBJECT)) { - return IW_ERROR_INVALID_ARGS; - } - iwrc rc = 0; - _jbl_merge_patch_node(root, patch, pool, &rc); - return rc; -} - -static const char *_jbl_ecodefn(locale_t locale, uint32_t ecode) { - if (!((ecode > _JBL_ERROR_START) && (ecode < _JBL_ERROR_END))) { - return 0; - } - switch (ecode) { - case JBL_ERROR_INVALID_BUFFER: - return "Invalid JBL buffer (JBL_ERROR_INVALID_BUFFER)"; - case JBL_ERROR_CREATION: - return "Cannot create JBL object (JBL_ERROR_CREATION)"; - case JBL_ERROR_INVALID: - return "Invalid JBL object (JBL_ERROR_INVALID)"; - case JBL_ERROR_PARSE_JSON: - return "Failed to parse JSON string (JBL_ERROR_PARSE_JSON)"; - case JBL_ERROR_PARSE_UNQUOTED_STRING: - return "Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)"; - case JBL_ERROR_PARSE_INVALID_CODEPOINT: - return "Invalid unicode codepoint/escape sequence (JBL_ERROR_PARSE_INVALID_CODEPOINT)"; - case JBL_ERROR_PARSE_INVALID_UTF8: - return "Invalid utf8 string (JBL_ERROR_PARSE_INVALID_UTF8)"; - case JBL_ERROR_JSON_POINTER: - return "Invalid JSON pointer (rfc6901) path (JBL_ERROR_JSON_POINTER)"; - case JBL_ERROR_PATH_NOTFOUND: - return "JSON object not matched the path specified (JBL_ERROR_PATH_NOTFOUND)"; - case JBL_ERROR_PATCH_INVALID: - return "Invalid JSON patch specified (JBL_ERROR_PATCH_INVALID)"; - case JBL_ERROR_PATCH_INVALID_OP: - return "Invalid JSON patch operation specified (JBL_ERROR_PATCH_INVALID_OP)"; - case JBL_ERROR_PATCH_NOVALUE: - return "No value specified in JSON patch (JBL_ERROR_PATCH_NOVALUE)"; - case JBL_ERROR_PATCH_TARGET_INVALID: - return "Could not find target object to set value (JBL_ERROR_PATCH_TARGET_INVALID)"; - case JBL_ERROR_PATCH_INVALID_VALUE: - return "Invalid value specified by patch (JBL_ERROR_PATCH_INVALID_VALUE)"; - case JBL_ERROR_PATCH_INVALID_ARRAY_INDEX: - return "Invalid array index in JSON patch path (JBL_ERROR_PATCH_INVALID_ARRAY_INDEX)"; - case JBL_ERROR_PATCH_TEST_FAILED: - return "JSON patch test operation failed (JBL_ERROR_PATCH_TEST_FAILED)"; - case JBL_ERROR_NOT_AN_OBJECT: - return "JBL is not an object (JBL_ERROR_NOT_AN_OBJECT)"; - case JBL_ERROR_TYPE_MISMATCHED: - return "Type of JBL object mismatched user type constraints (JBL_ERROR_TYPE_MISMATCHED)"; - case JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED: - return "Exceeded the maximal object nesting level: " _STR(JBL_MAX_NESTING_LEVEL) - " (JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED)"; - } - return 0; -} - -iwrc jbl_init() { - static int _jbl_initialized = 0; - if (!__sync_bool_compare_and_swap(&_jbl_initialized, 0, 1)) { - return 0; - } - return iwlog_register_ecodefn(_jbl_ecodefn); -} diff --git a/src/jbl/jbl.h b/src/jbl/jbl.h deleted file mode 100644 index 415fc7fef..000000000 --- a/src/jbl/jbl.h +++ /dev/null @@ -1,894 +0,0 @@ -#pragma once -#ifndef JBLOB_H -#define JBLOB_H - -/************************************************************************************************** - * EJDB2 - * - * MIT License - * - * Copyright (c) 2012-2021 Softmotions Ltd - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *************************************************************************************************/ - -/** @file - * - * @brief JSON serialization and patching routines. - * - * Supported standards: - * - * - [JSON Patch](https://tools.ietf.org/html/rfc6902) - * - [JSON Merge patch](https://tools.ietf.org/html/rfc7386) - * - [JSON Path specification](https://tools.ietf.org/html/rfc6901) - * - * JSON document can be represented in three different formats: - * - * - Plain JSON text. - * - * - @ref JBL Memory compact binary format [Binn](https://github.com/liteserver/binn) - * Used for JSON serialization but lacks of data modification flexibility. - * - * - @ref JBL_NODE In memory JSON document presented as tree. Convenient for in-place - * document modification and patching. - * - * Library function allows conversion of JSON document between above formats. - */ - -#include -#include -#include -#include - -IW_EXTERN_C_START - -/** - * @brief JSON document in compact binary format [Binn](https://github.com/liteserver/binn) - */ -struct _JBL; -typedef struct _JBL*JBL; - -typedef enum { - _JBL_ERROR_START = (IW_ERROR_START + 15000UL + 1000), - JBL_ERROR_INVALID_BUFFER, /**< Invalid JBL buffer (JBL_ERROR_INVALID_BUFFER) */ - JBL_ERROR_CREATION, /**< Cannot create JBL object (JBL_ERROR_CREATION) */ - JBL_ERROR_INVALID, /**< Invalid JBL object (JBL_ERROR_INVALID) */ - JBL_ERROR_PARSE_JSON, /**< Failed to parse JSON string (JBL_ERROR_PARSE_JSON) */ - JBL_ERROR_PARSE_UNQUOTED_STRING, /**< Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING) */ - JBL_ERROR_PARSE_INVALID_CODEPOINT, - /**< Invalid unicode codepoint/escape sequence - (JBL_ERROR_PARSE_INVALID_CODEPOINT) */ - JBL_ERROR_PARSE_INVALID_UTF8, /**< Invalid utf8 string (JBL_ERROR_PARSE_INVALID_UTF8) */ - JBL_ERROR_JSON_POINTER, /**< Invalid JSON pointer (rfc6901) path (JBL_ERROR_JSON_POINTER) */ - JBL_ERROR_PATH_NOTFOUND, /**< JSON object not matched the path specified (JBL_ERROR_PATH_NOTFOUND) */ - JBL_ERROR_PATCH_INVALID, /**< Invalid JSON patch specified (JBL_ERROR_PATCH_INVALID) */ - JBL_ERROR_PATCH_INVALID_OP, /**< Invalid JSON patch operation specified (JBL_ERROR_PATCH_INVALID_OP) */ - JBL_ERROR_PATCH_NOVALUE, /**< No value specified in JSON patch (JBL_ERROR_PATCH_NOVALUE) */ - JBL_ERROR_PATCH_TARGET_INVALID, - /**< Could not find target object to set value (JBL_ERROR_PATCH_TARGET_INVALID) - */ - JBL_ERROR_PATCH_INVALID_VALUE, /**< Invalid value specified by patch (JBL_ERROR_PATCH_INVALID_VALUE) */ - JBL_ERROR_PATCH_INVALID_ARRAY_INDEX, - /**< Invalid array index in JSON patch path - (JBL_ERROR_PATCH_INVALID_ARRAY_INDEX) */ - JBL_ERROR_NOT_AN_OBJECT, /**< JBL is not an object (JBL_ERROR_NOT_AN_OBJECT) */ - JBL_ERROR_TYPE_MISMATCHED, - /**< Type of JBL object mismatched user type constraints - (JBL_ERROR_TYPE_MISMATCHED) */ - JBL_ERROR_PATCH_TEST_FAILED, /**< JSON patch test operation failed (JBL_ERROR_PATCH_TEST_FAILED) */ - JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED, - /**< Reached the maximal object nesting level: 1000 - (JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED) */ - _JBL_ERROR_END, -} jbl_ecode_t; - -typedef struct _JBL_iterator { - unsigned char *pnext; - unsigned char *plimit; - int type; - int count; - int current; -} JBL_iterator; - -typedef uint8_t jbl_print_flags_t; -#define JBL_PRINT_PRETTY ((jbl_print_flags_t) 0x01U) -#define JBL_PRINT_CODEPOINTS ((jbl_print_flags_t) 0x02U) - -typedef uint8_t jbn_visitor_cmd_t; -#define JBL_VCMD_OK ((jbn_visitor_cmd_t) 0x00U) -#define JBL_VCMD_TERMINATE ((jbn_visitor_cmd_t) 0x01U) -#define JBL_VCMD_SKIP_NESTED ((jbn_visitor_cmd_t) 0x02U) -#define JBN_VCMD_DELETE ((jbn_visitor_cmd_t) 0x04U) - -typedef enum { - JBV_NONE = 0, // Do not reorder - JBV_NULL, - JBV_BOOL, // Do not reorder - JBV_I64, - JBV_F64, - JBV_STR, - JBV_OBJECT, // Do not reorder - JBV_ARRAY, -} jbl_type_t; - -/** - * @brief JSON document as in-memory tree (DOM tree). - */ -typedef struct _JBL_NODE { - struct _JBL_NODE *next; - struct _JBL_NODE *prev; - struct _JBL_NODE *parent; /**< Optional parent */ - const char *key; - int klidx; - uint32_t flags; /**< Utility node flags */ - - // Do not sort/add members after this point (offsetof usage below) - struct _JBL_NODE *child; - int vsize; - jbl_type_t type; - union { - const char *vptr; - bool vbool; - int64_t vi64; - double vf64; - }; -} *JBL_NODE; - -/** - * @brief JSON Patch operation according to rfc6902 - */ -typedef enum { - JBP_ADD = 1, - JBP_REMOVE, - JBP_REPLACE, - JBP_COPY, - JBP_MOVE, - JBP_TEST, - // Non standard operations - JBP_INCREMENT, /**< Value increment */ - JBP_ADD_CREATE, /**< Create intermediate object nodes for missing path segments */ - JBP_SWAP, /**< Swap values of two nodes */ -} jbp_patch_t; - -/** - * @brief JSON patch specification - */ -typedef struct _JBL_PATCH { - jbp_patch_t op; - const char *path; - const char *from; - const char *vjson; - JBL_NODE vnode; -} JBL_PATCH; - -/** - * @brief JSON pointer rfc6901 - * @see jbl_ptr_alloc() - */ -typedef struct _JBL_PTR { - uint64_t op; /**< Opaque data associated with pointer */ - int cnt; /**< Number of nodes */ - int sz; /**< Size of JBL_PTR allocated area */ - char *n[1]; /**< Path nodes */ -} *JBL_PTR; - -/** Prints JSON to some oputput specified by `op` */ -typedef iwrc (*jbl_json_printer)(const char *data, int size, char ch, int count, void *op); - -/** - * @brief Create empty binary JSON object. - * - * @note `jblp` should be disposed by `jbl_destroy()` - * @see `jbl_fill_from_node()` - * @param [out] jblp Pointer to be initialized by new object. - */ -IW_EXPORT WUR iwrc jbl_create_empty_object(JBL *jblp); - -/** - * @brief Create empty binary JSON array. - * - * @note `jblp` should be disposed by `jbl_destroy()` - * @see `jbl_fill_from_node()` - * @param [out] jblp Pointer to be initialized by new object. - */ -IW_EXPORT WUR iwrc jbl_create_empty_array(JBL *jblp); - -/** - * @brief Sets arbitrary user data associated with JBL object. - * - * @param jbl JBL container - * @param user_data User data pointer. Optional. - * @param user_data_free_fn User data dispose function. Optional. - */ -IW_EXPORT void jbl_set_user_data(JBL jbl, void *user_data, void (*user_data_free_fn)(void*)); - -/** - * @brief Returns user data associated with given `jbl` container. - * - * @param jbl JBL container. - */ -IW_EXPORT void *jbl_get_user_data(JBL jbl); - -/** - * @brief Set integer JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_int64(JBL jbl, const char *key, int64_t v); - -/** - * @brief Set double JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_f64(JBL jbl, const char *key, double v); - -/** - * @brief Set string JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_string(JBL jbl, const char *key, const char *v); - -IW_EXPORT iwrc jbl_set_string_printf(JBL jbl, const char *key, const char *format, ...); - -/** - * @brief Set bool JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_bool(JBL jbl, const char *key, bool v); - - -/** - * @brief Set null JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_null(JBL jbl, const char *key); - -IW_EXPORT iwrc jbl_set_empty_array(JBL jbl, const char *key); - -IW_EXPORT iwrc jbl_set_empty_object(JBL jbl, const char *key); - -/** - * @brief Set nested JBL object property value - * or add a new entry to end of array JBL object. - * - * In the case when `jbl` object is array value will be added to end array. - * - * @warning `jbl` object must writable in other words created with - * `jbl_create_empty_object()` or `jbl_create_empty_array()` - * - * @param jbl JBL container - * @param key Object key. Does't makes sense for array objects. - * @param v Value to set - */ -IW_EXPORT iwrc jbl_set_nested(JBL jbl, const char *key, JBL nested); - -/** - * @brief Initialize new `JBL` document by `binn` data from buffer. - * @note Created document will be allocated by `malloc()` - * and should be destroyed by `jbl_destroy()`. - * - * @param [out] jblp Pointer initialized by created JBL document. Not zero. - * @param buf Memory buffer with `binn` data. Not zero. - * @param bufsz Size of `buf` - * @param keep_on_destroy If true `buf` not will be freed by `jbl_destroy()` - */ -IW_EXPORT iwrc jbl_from_buf_keep(JBL *jblp, void *buf, size_t bufsz, bool keep_on_destroy); - -/** - * @brief Clones the given `src` JBL object into newly allocated `targetp` object. - * - * JBL object stored into `targetp` should be disposed by `jbl_destroy()`. - * - * @param src Source object to clone - * @param targetp Pointer on target object. - */ -IW_EXPORT iwrc jbl_clone(JBL src, JBL *targetp); - -/** - * @brief Copy all keys from `src` object into `target` object. - * @note Function does not care about keys duplication. - * - * @param src Source JBL object. Must be object. - * @param target Target JBL object. Must be object. - */ -IW_EXPORT iwrc jbl_object_copy_to(JBL src, JBL target); - -/** - * @brief Clones the given `src` JBL_NODE object into new `targetp` instance. - * Memory allocateted by given memor `pool` instance. - * - * @param src Source object to clone - * @param target Pointer on new instance - * @param pool Memory pool used for allocations during clone object construction - */ -IW_EXPORT iwrc jbn_clone(JBL_NODE src, JBL_NODE *targetp, IWPOOL *pool); - -/** - * @brief Assign a JSON node value from `from` node into `target` node. - * Context elements of `target` node: `parent`, `next` are not touched. - * - * @param target Node - * @param from - * @return IW_EXPORT jbn_apply_from - */ -IW_EXPORT void jbn_apply_from(JBL_NODE target, JBL_NODE from); - -/** - * @brief Copies JSON subtree under given `src_path` into `target` object under `target_path`. - * If some tree exists under `target_path` it will be replaced by copied subtree. - * - * Copied subtree will be allocated in using given memory `pool`. - * - * @param src Source JSON tree. - * @param src_path Path where copied subtree located. If src_path is `/` then `src` object itself will be cloned. - * @param target Target JSON tree. - * @param target_path Path to place copied subtree. - * @param overwrite_on_nulls If true `null` values will be copied to `src` object as well. - * @param no_src_clone If true object pointed by `src_path` object will not be cloned into `pool` before applying patch. - * It is a dangerous option if you use same memory pool for source and target objects. - * Do not set it to `true` until you clearly understand what are you doing. - * @param pool Memory pool used for allocations - */ -IW_EXPORT iwrc jbn_copy_path( - JBL_NODE src, - const char *src_path, - JBL_NODE target, - const char *target_path, - bool overwrite_on_nulls, - bool no_src_clone, - IWPOOL *pool); - -/** - * @brief Copies a set of values pointed by `paths` zero terminated array - * of `src` object into respective paths of `target` object. - * - * @param src Source object whose keys will be copied. - * @param target Target object to recieve key values of `src` obejct - * @param paths Zero terminated array of pointers to zero terminated key names. - * @param overwrite_on_nulls If true `null` values will be copied to `src` object as well. - * @param no_src_clone If true copied objects will not be cloned into given `pool` before copying. - * It is a dangerous option if you use same memory pool for source and target objects. - * Do not set it to `true` until you clearly understand what are you doing. - * @param pool Memory pool used for allocations - */ -IW_EXPORT iwrc jbn_copy_paths( - JBL_NODE src, - JBL_NODE target, - const char **paths, - bool overwrite_on_nulls, - bool no_src_clone, - IWPOOL *pool); - -/** - * @brief Clones a given `src` JBL object and stores it in memory allocated from `pool`. - * - * @param src Source object to clone - * @param targetp Pointer on target object - * @param pool Memory pool - */ -IW_EXPORT iwrc jbl_clone_into_pool(JBL src, JBL *targetp, IWPOOL *pool); - -/** - * @brief Constructs new `JBL` object from JSON string. - * @note `jblp` should be disposed by `jbl_destroy()` - * @param [out] jblp Pointer initialized by created JBL document. Not zero. - * @param jsonstr JSON string to be converted - */ -IW_EXPORT iwrc jbl_from_json(JBL *jblp, const char *jsonstr); - - -IW_EXPORT iwrc jbl_from_json_printf(JBL *jblp, const char *format, ...); - -IW_EXPORT iwrc jbl_from_json_printf_va(JBL *jblp, const char *format, va_list va); - -/** - * @brief Get type of `jbl` value. - */ -IW_EXPORT jbl_type_t jbl_type(JBL jbl); - -/** - * @brief Get number of child elements in `jbl` container (object/array) or zero. - */ -IW_EXPORT size_t jbl_count(JBL jbl); - -/** - * @brief Get size of undelying data buffer of `jbl` value passed. - */ -IW_EXPORT size_t jbl_size(JBL jbl); - -/** - * @brief Returns size of JBL underlying data structure - */ -IW_EXPORT size_t jbl_structure_size(void); - -IW_EXPORT iwrc jbl_from_buf_keep_onstack(JBL jbl, void *buf, size_t bufsz); - -/** - * @brief Interpret `jbl` value as `int32_t`. - * Returns zero if value cannot be converted. - */ -IW_EXPORT int32_t jbl_get_i32(JBL jbl); - -/** - * @brief Interpret `jbl` value as `int64_t`. - * Returns zero if value cannot be converted. - */ -IW_EXPORT int64_t jbl_get_i64(JBL jbl); - -/** - * @brief Interpret `jbl` value as `double` value. - * Returns zero if value cannot be converted. - */ -IW_EXPORT double jbl_get_f64(JBL jbl); - -/** - * @brief Interpret `jbl` value as `\0` terminated character array. - * Returns zero if value cannot be converted. - */ -IW_EXPORT const char *jbl_get_str(JBL jbl); - -IW_EXPORT iwrc jbl_object_get_i64(JBL jbl, const char *key, int64_t *out); - -IW_EXPORT iwrc jbl_object_get_f64(JBL jbl, const char *key, double *out); - -IW_EXPORT iwrc jbl_object_get_bool(JBL jbl, const char *key, bool *out); - -IW_EXPORT iwrc jbl_object_get_str(JBL jbl, const char *key, const char **out); - -IW_EXPORT iwrc jbl_object_get_fill_jbl(JBL jbl, const char *key, JBL out); - -IW_EXPORT jbl_type_t jbl_object_get_type(JBL jbl, const char *key); - -/** - * @brief Same as `jbl_get_str()` but copies at most `bufsz` into target `buf`. - * Target buffer not touched if `jbl` value cannot be converted. - */ -IW_EXPORT size_t jbl_copy_strn(JBL jbl, char *buf, size_t bufsz); - -/** - * @brief Finds value in `jbl` document pointed by rfc6901 `path` and store it into `res`. - * - * @note `res` should be disposed by `jbl_destroy()`. - * @note If value is not fount `res` will be set to zero. - * @param jbl JBL document. Not zero. - * @param path rfc6901 JSON pointer. Not zero. - * @param [out] res Output value holder - */ -IW_EXPORT iwrc jbl_at(JBL jbl, const char *path, JBL *res); - -IW_EXPORT iwrc jbn_at(JBL_NODE node, const char *path, JBL_NODE *res); - -IW_EXPORT int jbn_path_compare(JBL_NODE n1, JBL_NODE n2, const char *path, jbl_type_t vtype, iwrc *rcp); - -IW_EXPORT int jbn_paths_compare( - JBL_NODE n1, const char *n1path, JBL_NODE n2, const char *n2path, jbl_type_t vtype, - iwrc *rcp); - -IW_EXPORT int jbn_path_compare_str(JBL_NODE n, const char *path, const char *sv, iwrc *rcp); - -IW_EXPORT int jbn_path_compare_i64(JBL_NODE n, const char *path, int64_t iv, iwrc *rcp); - -IW_EXPORT int jbn_path_compare_f64(JBL_NODE n, const char *path, double fv, iwrc *rcp); - -IW_EXPORT int jbn_path_compare_bool(JBL_NODE n, const char *path, bool bv, iwrc *rcp); - -/** - * @brief @brief Finds value in `jbl` document pointed by `jp` structure and store it into `res`. - * - * @note `res` should be disposed by `jbl_destroy()`. - * @note If value is not fount `res` will be set to zero. - * @see `jbl_ptr_alloc()` - * @param jbl JBL document. Not zero. - * @param jp JSON pointer. - * @param [out] res Output value holder - */ -IW_EXPORT iwrc jbl_at2(JBL jbl, JBL_PTR jp, JBL *res); - -IW_EXPORT iwrc jbn_at2(JBL_NODE node, JBL_PTR jp, JBL_NODE *res); - -/** - * @brief Represent `jbl` document as raw data buffer. - * - * @note Caller do not require release `buf` explicitly. - * @param jbl JBL document. Not zero. - * @param [out] buf Pointer to data buffer. Not zero. - * @param [out] size Pointer to data buffer size. Not zero. - */ -IW_EXPORT iwrc jbl_as_buf(JBL jbl, void **buf, size_t *size); - -/** - * @brief Prints JBL document as JSON string. - * - * @see jbl_fstream_json_printer() - * @see jbl_xstr_json_printer() - * @see jbl_count_json_printer() - * - * @param jbl JBL document. Not zero. - * @param pt JSON printer function pointer. Not zero. - * @param op Pointer to user data for JSON printer function. - * @param pf JSON printing mode. - */ -IW_EXPORT iwrc jbl_as_json(JBL jbl, jbl_json_printer pt, void *op, jbl_print_flags_t pf); - -/** - * @brief JSON printer to stdlib `FILE*`pointer. Eg: `stderr`, `stdout` - * @param op `FILE*` pointer - */ -IW_EXPORT iwrc jbl_fstream_json_printer(const char *data, int size, char ch, int count, void *op); - -/** - * @brief JSON printer to extended string buffer `IWXSTR` - * @param op `IWXSTR*` pointer - */ -IW_EXPORT iwrc jbl_xstr_json_printer(const char *data, int size, char ch, int count, void *op); - -/** - * @brief Just counts bytes in JSON text. - * @param op `int*` Pointer to counter number. - */ -IW_EXPORT iwrc jbl_count_json_printer(const char *data, int size, char ch, int count, void *op); - -/** - * @brief Destroys JBL document and releases its heap resources. - * @note Will set `jblp` to zero. - * @param jblp Pointer holder of JBL document. Not zero. - */ -IW_EXPORT void jbl_destroy(JBL *jblp); - -/** - * @brief Initializes placeholder for jbl iteration. - * Must be freed by `jbl_destroy()` after iteration. - * @param [out] jblp Pointer to be initialized by new object. - */ -IW_EXPORT iwrc jbl_create_iterator_holder(JBL *jblp); - -/** - * @brief Initialize allocated iterator over given `jbl` object. - * - * @param jbl JBL object to iterate - * @param iter Iterator state placeholder allocated by `jbl_create_iter_placeholder()` - */ -IW_EXPORT iwrc jbl_iterator_init(JBL jbl, JBL_iterator *iter); - -/** - * @brief Get next value from JBL_iterator. - * Returns `false` if iteration is over. - * - * @param iter Iterator object. - * @param holder Holder to object pointed by current iteration. - * @param pkey Key value holder. Zero in the case of iteration over array. - * @param klen Key length or array index in the case of iteration over array. - */ -IW_EXPORT bool jbl_iterator_next(JBL_iterator *iter, JBL holder, char **pkey, int *klen); - -//--- JBL_NODE - -/** - * @brief Converts `jbl` value to `JBL_NODE` tree. - * @note `node` resources will be released when `pool` destroyed. - * - * @param jbl JSON document in compact `binn` format. Not zero. - * @param [out] node Holder of new `JBL_NODE` value. Not zero. - * @param clone_strings If `true` JSON keys and string values will be cloned into given `pool` - * otherwise only pointers to strings will be assigned. - * Use `true` if you want to be completely safe when given `jbl` - * object will be destroyed. - * @param pool Memory used to allocate new `JBL_NODE` tree. Not zero. - */ -IW_EXPORT iwrc jbl_to_node(JBL jbl, JBL_NODE *node, bool clone_strings, IWPOOL *pool); - -/** - * @brief Converts `json` text to `JBL_NODE` tree. - * @note `node` resources will be released when `pool` destroyed. - * - * @param json JSON text - * @param [out] node Holder of new `JBL_NODE` value. Not zero. - * @param pool Memory used to allocate new `JBL_NODE` tree. Not zero. - */ -IW_EXPORT iwrc jbn_from_json(const char *json, JBL_NODE *node, IWPOOL *pool); - -IW_EXPORT iwrc jbn_from_json_printf(JBL_NODE *node, IWPOOL *pool, const char *format, ...); - -IW_EXPORT iwrc jbn_from_json_printf_va(JBL_NODE *node, IWPOOL *pool, const char *format, va_list va); - -/** - * @brief Prints JBL_NODE document as JSON string. - * - * @see jbl_fstream_json_printer() - * @see jbl_xstr_json_printer() - * @see jbl_count_json_printer() - * - * @param node `JBL_NODE` document. Not zero. - * @param pt JSON printer function. Not zero. - * @param op Pointer to user data for JSON printer function. - * @param pf JSON printing mode. - */ -IW_EXPORT iwrc jbn_as_json(JBL_NODE node, jbl_json_printer pt, void *op, jbl_print_flags_t pf); - -// Depreacted. Use: jbn_as_json -IW_EXPORT IW_DEPRECATED iwrc jbl_node_as_json(JBL_NODE node, jbl_json_printer pt, void *op, jbl_print_flags_t pf); - -// Depreacted. Use: jbn_as_json -IW_EXPORT IW_DEPRECATED iwrc jbl_node_from_json(const char *json, JBL_NODE *node, IWPOOL *pool); - -/** - * @brief Fill `jbl` document by data from `node`. - * - * Common use case: - * Create empty document with `jbl_create_empty_object()` `jbl_create_empty_array()` - * then fill it with `jbl_fill_from_node()` - * - * @param jbl JBL document to be filled. Not zero. - * @param node Source tree node. Not zero. - */ -IW_EXPORT iwrc jbl_fill_from_node(JBL jbl, JBL_NODE node); - - -/** - * @brief Converts `node` object into JBL form. - * - * @param jblp JBL pointer holder. Not zero. - * @param node Source tree node. Not zero. - * @return IW_EXPORT jbl_from_node - */ -IW_EXPORT iwrc jbl_from_node(JBL *jblp, JBL_NODE node); - -/** - * @brief Compares JSON tree nodes. - * - * - Primitive JSON values compared as is. - * - JSON arrays compared by values held in the same position in array. - * - JSON objects compared by corresponding values held under lexicographically sorted keys. - * - * @param n1 - * @param n2 - * @param [out] rcp - * - * @return - Not zero if `n1` and `n2` have different types. - * - Zero if `n1` and `n2` are equal. - * - Greater than zero if `n1` greater than `n2` - * - Lesser than zero if `n1` lesser than `n2` - */ -IW_EXPORT int jbn_compare_nodes(JBL_NODE n1, JBL_NODE n2, iwrc *rcp); - -/** - * @brief Add item to the `parent` container. - */ -IW_EXPORT void jbn_add_item(JBL_NODE parent, JBL_NODE node); - -/** - * @brief Adds string JSON node to the given `parent` node. - * Key and value are copied into allocated node. - * - * @param parent Parent holder. - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param val Child node value copied. - * @param vlen Langth of child node value. - * If `vlen` is lesser then zero length of `val` will be determined my `strlen`. - * @param node_out Optional placeholder for new node. - * @param pool Allocation pool. - */ -IW_EXPORT iwrc jbn_add_item_str( - JBL_NODE parent, const char *key, const char *val, int vlen, JBL_NODE *node_out, - IWPOOL *pool); - -/** - * @brief Adds null JSON value to the given `parent` node. - * - * @param parent Parent holder. - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param pool Allocation pool. - */ -IW_EXPORT iwrc jbn_add_item_null(JBL_NODE parent, const char *key, IWPOOL *pool); - -/** - * @brief Adds integer JSON node to the given `parent` node. - * - * @param parent Parent holder. - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param val Integer value. - * @param node_out Optional placeholder for new node. - * @param pool Allocation pool. - */ -IW_EXPORT iwrc jbn_add_item_i64(JBL_NODE parent, const char *key, int64_t val, JBL_NODE *node_out, IWPOOL *pool); - -/** - * @brief Adds fp number JSON node to the given `parent` node. - * - * @param parent Parent holder. - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param val Floating point value. - * @param node_out Optional placeholder for new node. - * @param pool Allocation pool. - */ -IW_EXPORT iwrc jbn_add_item_f64(JBL_NODE parent, const char *key, double val, JBL_NODE *node_out, IWPOOL *pool); - -/** - * @brief Add nested object under the given `key` - * - * @param parent Parent holder - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param node_out [out] Pointer to new node, can be zero. - * @param pool Allocation pool - * @return IW_EXPORT jbn_add_item_obj - */ -IW_EXPORT iwrc jbn_add_item_obj(JBL_NODE parent, const char *key, JBL_NODE *node_out, IWPOOL *pool); - -/** - * @brief Add nested array under the given `key` - * - * @param parent Parent holder - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param node_out [out] Pointer to new node, can be zero. - * @param pool Allocation pool - * @return IW_EXPORT jbn_add_item_obj - */ -IW_EXPORT iwrc jbn_add_item_arr(JBL_NODE parent, const char *key, JBL_NODE *node_out, IWPOOL *pool); - -/** - * @brief Adds boolean JSON node to the given `parent` node. - * - * @param parent Parent holder. - * @param key Child node key cloned into node. Can be zero if parent is an array. - * @param val Boolean node value. - * @param node_out [out] Pointer to new node, can be zero. - * @param pool Allocation pool. - */ -IW_EXPORT iwrc jbn_add_item_bool(JBL_NODE parent, const char *key, bool val, JBL_NODE *node_out, IWPOOL *pool); - -/** - * @brief Add item from the `parent` container. - */ -IW_EXPORT void jbn_remove_item(JBL_NODE parent, JBL_NODE child); - -/** - * @brief Remove subtree from `target` node pointed by `path` - */ -IW_EXPORT JBL_NODE jbn_detach2(JBL_NODE target, JBL_PTR path); - -IW_EXPORT JBL_NODE jbn_detach(JBL_NODE target, const char *path); - -/** - * @brief Reset tree `node` data. - */ -IW_EXPORT void jbn_data(JBL_NODE node); - -/** - * @brief Returns number of child elements of given node. - * - * @param node JBL node - */ -IW_EXPORT int jbn_length(JBL_NODE node); - -/** - * @brief Parses rfc6901 JSON path. - * @note `jpp` structure should be disposed by `free()`. - * - * @param path JSON path string. Not zero. - * @param [out] jpp Holder for parsed path structure. Not zero. - */ -IW_EXPORT iwrc jbl_ptr_alloc(const char *path, JBL_PTR *jpp); - -/** - * @brief Parses rfc6901 JSON path. - * - * @param path JSON path string. Not zero. - * @param [out] jpp JSON path string. Not zero. - * @param pool Pool used for memory allocation. Not zero. - */ -IW_EXPORT iwrc jbl_ptr_alloc_pool(const char *path, JBL_PTR *jpp, IWPOOL *pool); - -/** - * @brief Compare JSON pointers. - */ -IW_EXPORT int jbl_ptr_cmp(JBL_PTR p1, JBL_PTR p2); - -/** - * @brief Serialize JSON pointer to as text. - * @param ptr JSON pointer. Not zero. - * @param xstr Output string buffer. Not zero. - */ -IW_EXPORT iwrc jbl_ptr_serialize(JBL_PTR ptr, IWXSTR *xstr); - -/** - * @brief JBL_NODE visitor context - */ -typedef struct _JBN_VCTX { - JBL_NODE root; /**< Root node from which started visitor */ - void *op; /**< Arbitrary opaque data */ - void *result; - IWPOOL *pool; /**< Pool placeholder, initialization is responsibility of `JBN_VCTX` creator */ - int pos; /**< Aux position, not actually used by visitor core */ - bool terminate; /**< It `true` document traversal will be terminated immediately. */ -} JBN_VCTX; - -/** - * Call with lvl: `-1` means end of visiting whole object tree. - */ -typedef jbn_visitor_cmd_t (*JBN_VISITOR)(int lvl, JBL_NODE n, const char *key, int klidx, JBN_VCTX *vctx, iwrc *rc); - -IW_EXPORT iwrc jbn_visit(JBL_NODE node, int lvl, JBN_VCTX *vctx, JBN_VISITOR visitor); - -//--- PATCHING - -IW_EXPORT iwrc jbn_patch_auto(JBL_NODE root, JBL_NODE patch, IWPOOL *pool); - -IW_EXPORT iwrc jbn_merge_patch(JBL_NODE root, JBL_NODE patch, IWPOOL *pool); - -IW_EXPORT iwrc jbn_patch(JBL_NODE root, const JBL_PATCH *patch, size_t cnt, IWPOOL *pool); - -IW_EXPORT iwrc jbn_merge_patch_from_json(JBL_NODE root, const char *patchjson, IWPOOL *pool); - -IW_EXPORT iwrc jbl_patch(JBL jbl, const JBL_PATCH *patch, size_t cnt); - -IW_EXPORT iwrc jbl_patch_from_json(JBL jbl, const char *patchjson); - -IW_EXPORT iwrc jbl_merge_patch(JBL jbl, const char *patchjson); - -IW_EXPORT iwrc jbl_merge_patch_jbl(JBL jbl, JBL patch); - - -IW_EXPORT iwrc jbl_init(void); - -IW_EXTERN_C_END -#endif diff --git a/src/jbl/jbl_internal.h b/src/jbl/jbl_internal.h deleted file mode 100644 index 8790143a1..000000000 --- a/src/jbl/jbl_internal.h +++ /dev/null @@ -1,91 +0,0 @@ -#pragma once -#ifndef JBL_INTERNAL_H -#define JBL_INTERNAL_H - -/************************************************************************************************** - * EJDB2 - * - * MIT License - * - * Copyright (c) 2012-2021 Softmotions Ltd - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *************************************************************************************************/ - -#include "jbl.h" -#include "binn.h" -#include -#include -#include -#include "ejdb2cfg.h" - -#define JBL_MAX_NESTING_LEVEL 999 - -struct _JBL { - binn bn; - JBL_NODE node; -}; - -/** - * @brief JBL visitor context - */ -typedef struct _JBL_VCTX { - binn *bn; /**< Root node from which started visitor */ - void *op; /**< Arbitrary opaque data */ - void *result; - IWPOOL *pool; /**< Pool placeholder, initialization is responsibility of `JBL_VCTX` creator */ - int pos; /**< Aux position, not actually used by visitor core */ - bool terminate; - bool found; /**< Used in _jbl_at() */ -} JBL_VCTX; - -typedef jbn_visitor_cmd_t jbl_visitor_cmd_t; - -typedef struct _JBL_PATCHEXT { - const JBL_PATCH *p; - JBL_PTR path; - JBL_PTR from; -} JBL_PATCHEXT; - -typedef struct _JBLDRCTX { - IWPOOL *pool; - JBL_NODE root; -} JBLDRCTX; - -iwrc jbl_from_buf_keep_onstack(JBL jbl, void *buf, size_t bufsz); -iwrc jbl_from_buf_keep_onstack2(JBL jbl, void *buf); - -iwrc _jbl_write_double(double num, jbl_json_printer pt, void *op); -iwrc _jbl_write_int(int64_t num, jbl_json_printer pt, void *op); -iwrc _jbl_write_string(const char *str, int len, jbl_json_printer pt, void *op, jbl_print_flags_t pf); -iwrc _jbl_node_from_binn(const binn *bn, JBL_NODE *node, bool clone_strings, IWPOOL *pool); -iwrc _jbl_binn_from_node(binn *res, JBL_NODE node); -iwrc _jbl_from_node(JBL jbl, JBL_NODE node); -bool _jbl_at(JBL jbl, JBL_PTR jp, JBL res); -int _jbl_compare_nodes(JBL_NODE n1, JBL_NODE n2, iwrc *rcp); - -typedef jbl_visitor_cmd_t (*JBL_VISITOR)(int lvl, binn *bv, const char *key, int idx, JBL_VCTX *vctx, iwrc *rc); -iwrc _jbl_visit(binn_iter *iter, int lvl, JBL_VCTX *vctx, JBL_VISITOR visitor); - -bool _jbl_is_eq_atomic_values(JBL v1, JBL v2); -int _jbl_cmp_atomic_values(JBL v1, JBL v2); - -BOOL binn_read_next_pair2(int expected_type, binn_iter *iter, int *klidx, char **pkey, binn *value); - -#endif diff --git a/src/jbl/jbl_json.c b/src/jbl/jbl_json.c deleted file mode 100644 index 660c1a06b..000000000 --- a/src/jbl/jbl_json.c +++ /dev/null @@ -1,605 +0,0 @@ -#include "jbl.h" -#include "utf8proc.h" -#include "jbl_internal.h" -#include - -#include -#include -#include - -#define IS_WHITESPACE(c_) ((unsigned char) (c_) <= (unsigned char) ' ') - -/** JSON parsing context */ -typedef struct JCTX { - IWPOOL *pool; - JBL_NODE root; - const char *buf; - const char *sp; - iwrc rc; -} JCTX; - -static void _jbn_add_item(JBL_NODE parent, JBL_NODE node) { - assert(parent && node); - node->next = 0; - node->parent = parent; - if (parent->child) { - JBL_NODE prev = parent->child->prev; - parent->child->prev = node; - if (prev) { // -V1051 - prev->next = node; - node->prev = prev; - } else { - parent->child->next = node; - node->prev = parent->child; - } - } else { - parent->child = node; - } - if (parent->type == JBV_ARRAY) { - if (node->prev) { - node->klidx = node->prev->klidx + 1; - } else { - node->klidx = 0; - } - } -} - -static JBL_NODE _jbl_json_create_node(jbl_type_t type, const char *key, int klidx, JBL_NODE parent, JCTX *ctx) { - - JBL_NODE node = iwpool_calloc(sizeof(*node), ctx->pool); - if (!node) { - ctx->rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return 0; - } - node->type = type; - node->key = key; - node->klidx = klidx; - if (parent) { - _jbn_add_item(parent, node); - } - if (!ctx->root) { - ctx->root = node; - } - return node; -} - -IW_INLINE void _jbl_skip_bom(JCTX *ctx) { - const char *p = ctx->buf; - if ((p[0] == '\xEF') && (p[1] == '\xBB') && (p[2] == '\xBF')) { - ctx->buf += 3; - } -} - -IW_INLINE int _jbl_hex(char c) { - if ((c >= '0') && (c <= '9')) { - return c - '0'; - } - if ((c >= 'a') && (c <= 'f')) { - return c - 'a' + 10; - } - if ((c >= 'A') && (c <= 'F')) { - return c - 'A' + 10; - } - return -1; -} - -static int _jbl_unescape_json_string(const char *p, char *d, int dlen, const char **end, iwrc *rcp) { - *rcp = 0; - char c; - char *ds = d; - char *de = d + dlen; - - while ((c = *p++)) { - if (c == '"') { // string closing quotes - if (end) { - *end = p; - } - return d - ds; - } else if (c == '\\') { - switch (*p) { - case '\\': - case '/': - case '"': - if (d < de) { - *d = *p; - } - ++p, ++d; - break; - case 'b': - if (d < de) { - *d = '\b'; - } - ++p, ++d; - break; - case 'f': - if (d < de) { - *d = '\f'; - } - ++p, ++d; - break; - case 'n': - case 'r': - if (d < de) { - *d = '\n'; - } - ++p, ++d; - break; - case 't': - if (d < de) { - *d = '\t'; - } - ++p, ++d; - break; - case 'u': { - uint32_t cp, cp2; - int h1, h2, h3, h4; - if ( ((h1 = _jbl_hex(p[1])) < 0) || ((h2 = _jbl_hex(p[2])) < 0) - || ((h3 = _jbl_hex(p[3])) < 0) || ((h4 = _jbl_hex(p[4])) < 0)) { - *rcp = JBL_ERROR_PARSE_INVALID_CODEPOINT; - return 0; - } - cp = h1 << 12 | h2 << 8 | h3 << 4 | h4; - if ((cp & 0xfc00) == 0xd800) { - p += 6; - if ( (p[-1] != '\\') || (*p != 'u') - || ((h1 = _jbl_hex(p[1])) < 0) || ((h2 = _jbl_hex(p[2])) < 0) - || ((h3 = _jbl_hex(p[3])) < 0) || ((h4 = _jbl_hex(p[4])) < 0)) { - *rcp = JBL_ERROR_PARSE_INVALID_CODEPOINT; - return 0; - } - cp2 = h1 << 12 | h2 << 8 | h3 << 4 | h4; - if ((cp2 & 0xfc00) != 0xdc00) { - *rcp = JBL_ERROR_PARSE_INVALID_CODEPOINT; - return 0; - } - cp = 0x10000 + ((cp - 0xd800) << 10) + (cp2 - 0xdc00); - } - if (!utf8proc_codepoint_valid(cp)) { - *rcp = JBL_ERROR_PARSE_INVALID_CODEPOINT; - return 0; - } - uint8_t uchars[4]; - utf8proc_ssize_t ulen = utf8proc_encode_char(cp, uchars); - assert(ulen <= sizeof(uchars)); - for (int i = 0; i < ulen; ++i) { - if (d < de) { - *d = uchars[i]; - } - ++d; - } - p += 5; - break; - } - default: - if (d < de) { - *d = c; - } - ++d; - } - } else { - if (d < de) { - *d = c; - } - ++d; - } - } - *rcp = JBL_ERROR_PARSE_UNQUOTED_STRING; - return 0; -} - -static const char* _jbl_parse_key(const char **key, const char *p, JCTX *ctx) { - char c; - *key = ""; - while ((c = *p++)) { - if (c == '"') { - int len = _jbl_unescape_json_string(p, 0, 0, 0, &ctx->rc); - if (ctx->rc) { - return 0; - } - if (len) { - char *kptr = iwpool_alloc(len + 1, ctx->pool); - if (!kptr) { - ctx->rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return 0; - } - if ((len != _jbl_unescape_json_string(p, kptr, len, &p, &ctx->rc)) || ctx->rc) { - if (!ctx->rc) { - ctx->rc = JBL_ERROR_PARSE_JSON; - } - return 0; - } - kptr[len] = '\0'; - *key = kptr; - } - while (*p && IS_WHITESPACE(*p)) p++; - if (*p == ':') { - return p + 1; - } - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - } else if (c == '}') { - return p - 1; - } else if (IS_WHITESPACE(c) || (c == ',')) { - continue; - } else { - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - } - } - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; -} - -static const char* _jbl_parse_value( - int lvl, - JBL_NODE parent, - const char *key, int klidx, - const char *p, - JCTX *ctx) { - - if (lvl > JBL_MAX_NESTING_LEVEL) { - ctx->rc = JBL_ERROR_MAX_NESTING_LEVEL_EXCEEDED; - return 0; - } - - JBL_NODE node; - while (1) { - switch (*p) { - case '\0': - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - case ' ': - case '\t': - case '\n': - case '\r': - case ',': - ++p; - break; - case 'n': - if (!strncmp(p, "null", 4)) { - _jbl_json_create_node(JBV_NULL, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - return p + 4; - } - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - case 't': - if (!strncmp(p, "true", 4)) { - node = _jbl_json_create_node(JBV_BOOL, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - node->vbool = true; // -V522 - return p + 4; - } - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - case 'f': - if (!strncmp(p, "false", 5)) { - node = _jbl_json_create_node(JBV_BOOL, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - node->vbool = false; - return p + 5; - } - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - case '"': - ++p; - const char *end; - int len = _jbl_unescape_json_string(p, 0, 0, &end, &ctx->rc); - if (ctx->rc) { - return 0; - } - node = _jbl_json_create_node(JBV_STR, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - if (len) { - char *vptr = iwpool_alloc(len + 1, ctx->pool); - if (!vptr) { - ctx->rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return 0; - } - if ((len != _jbl_unescape_json_string(p, vptr, len, &p, &ctx->rc)) || ctx->rc) { - if (!ctx->rc) { - ctx->rc = JBL_ERROR_PARSE_JSON; - } - return 0; - } - vptr[len] = '\0'; - node->vptr = vptr; - node->vsize = len; - } else { - p = end; - node->vptr = ""; - node->vsize = 0; - } - return p; - case '{': - node = _jbl_json_create_node(JBV_OBJECT, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - ++p; - while (1) { - const char *nkey; - p = _jbl_parse_key(&nkey, p, ctx); - if (ctx->rc) { - return 0; - } - if (*p == '}') { - return p + 1; // -V522 - } - p = _jbl_parse_value(lvl + 1, node, nkey, (int) strlen(nkey), p, ctx); - if (ctx->rc) { - return 0; - } - } - break; - case '[': - node = _jbl_json_create_node(JBV_ARRAY, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - ++p; - for (int i = 0; ; ++i) { - p = _jbl_parse_value(lvl + 1, node, 0, i, p, ctx); - if (ctx->rc) { - return 0; - } - if (*p == ']') { - return p + 1; - } - } - break; - case ']': - return p; - break; - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - node = _jbl_json_create_node(JBV_I64, key, klidx, parent, ctx); - if (ctx->rc) { - return 0; - } - char *pe; - node->vi64 = strtoll(p, &pe, 0); - if ((pe == p) || (errno == ERANGE)) { - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - } - if ((*pe == '.') || (*pe == 'e') || (*pe == 'E')) { - node->type = JBV_F64; - node->vf64 = iwstrtod(p, &pe); - if ((pe == p) || (errno == ERANGE)) { - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - } - } - return pe; - } - default: - ctx->rc = JBL_ERROR_PARSE_JSON; - return 0; - } - } - return p; -} - -static iwrc _jbl_node_as_json(JBL_NODE node, jbl_json_printer pt, void *op, int lvl, jbl_print_flags_t pf) { - iwrc rc = 0; - bool pretty = pf & JBL_PRINT_PRETTY; - -#define PT(data_, size_, ch_, count_) do { \ - rc = pt(data_, size_, ch_, count_, op); \ - RCRET(rc); \ -} while (0) - - switch (node->type) { - case JBV_ARRAY: - PT(0, 0, '[', 1); - if (node->child && pretty) { - PT(0, 0, '\n', 1); - } - for (JBL_NODE n = node->child; n; n = n->next) { - if (pretty) { - PT(0, 0, ' ', lvl + 1); - } - rc = _jbl_node_as_json(n, pt, op, lvl + 1, pf); - RCRET(rc); - if (n->next) { - PT(0, 0, ',', 1); - } - if (pretty) { - PT(0, 0, '\n', 1); - } - } - if (node->child && pretty) { - PT(0, 0, ' ', lvl); - } - PT(0, 0, ']', 1); - break; - case JBV_OBJECT: - PT(0, 0, '{', 1); - if (node->child && pretty) { - PT(0, 0, '\n', 1); - } - for (JBL_NODE n = node->child; n; n = n->next) { - if (pretty) { - PT(0, 0, ' ', lvl + 1); - } - rc = _jbl_write_string(n->key, n->klidx, pt, op, pf); - RCRET(rc); - if (pretty) { - PT(": ", -1, 0, 0); - } else { - PT(0, 0, ':', 1); - } - rc = _jbl_node_as_json(n, pt, op, lvl + 1, pf); - RCRET(rc); - if (n->next) { - PT(0, 0, ',', 1); - } - if (pretty) { - PT(0, 0, '\n', 1); - } - } - if (node->child && pretty) { - PT(0, 0, ' ', lvl); - } - PT(0, 0, '}', 1); - break; - case JBV_STR: - rc = _jbl_write_string(node->vptr, node->vsize, pt, op, pf); - break; - case JBV_I64: - rc = _jbl_write_int(node->vi64, pt, op); - break; - case JBV_F64: - rc = _jbl_write_double(node->vf64, pt, op); - break; - case JBV_BOOL: - if (node->vbool) { - PT("true", 4, 0, 1); - } else { - PT("false", 5, 0, 1); - } - break; - case JBV_NULL: - PT("null", 4, 0, 1); - break; - default: - iwlog_ecode_error3(IW_ERROR_ASSERTION); - return IW_ERROR_ASSERTION; - } -#undef PT - return rc; -} - -static JBL_NODE _jbl_clone_node_struct(JBL_NODE src, IWPOOL *pool) { - iwrc rc; - JBL_NODE n = iwpool_calloc(sizeof(*n), pool); - if (!n) { - return 0; - } - n->vsize = src->vsize; - n->type = src->type; - n->klidx = src->klidx; - n->flags = src->flags; - - if (src->key) { - n->key = iwpool_strndup(pool, src->key, src->klidx, &rc); - if (!n->key) { - return 0; - } - } - switch (src->type) { - case JBV_STR: { - n->vptr = iwpool_strndup(pool, src->vptr, src->vsize, &rc); - if (!n->vptr) { - return 0; - } - break; - } - case JBV_I64: - n->vi64 = src->vi64; - break; - case JBV_BOOL: - n->vbool = src->vbool; - break; - case JBV_F64: - n->vf64 = src->vf64; - break; - default: - break; - } - ; - return n; -} - -static jbn_visitor_cmd_t _jbl_clone_node_visit( - int lvl, JBL_NODE n, const char *key, int klidx, JBN_VCTX *vctx, - iwrc *rc) { - if (lvl < 0) { - return JBL_VCMD_OK; - } - JBL_NODE parent = vctx->root; - if (lvl < vctx->pos) { // Pop - for ( ; lvl < vctx->pos; --vctx->pos) { - parent = parent->parent; - assert(parent); - } - vctx->root = parent; - assert(vctx->root); - } else if (lvl > vctx->pos) { // Push - vctx->pos = lvl; - parent = vctx->op; - vctx->root = parent; - assert(parent); - } - JBL_NODE nn = _jbl_clone_node_struct(n, vctx->pool); - if (!nn) { - *rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return JBL_VCMD_TERMINATE; - } - _jbn_add_item(parent, nn); - if (nn->type >= JBV_OBJECT) { - vctx->op = nn; // Remeber the last container object - } - return JBL_VCMD_OK; -} - -iwrc jbn_clone(JBL_NODE src, JBL_NODE *targetp, IWPOOL *pool) { - *targetp = 0; - JBL_NODE n = _jbl_clone_node_struct(src, pool); - if (!n) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - JBN_VCTX vctx = { - .pool = pool, - .root = n, - .op = n - }; - iwrc rc = jbn_visit(src, 0, &vctx, _jbl_clone_node_visit); - RCRET(rc); - *targetp = n; - return 0; -} - -iwrc jbn_as_json(JBL_NODE node, jbl_json_printer pt, void *op, jbl_print_flags_t pf) { - return _jbl_node_as_json(node, pt, op, 0, pf); -} - -iwrc jbn_from_json(const char *json, JBL_NODE *node, IWPOOL *pool) { - *node = 0; - JCTX ctx = { - .pool = pool, - .buf = json - }; - _jbl_skip_bom(&ctx); - _jbl_parse_value(0, 0, 0, 0, ctx.buf, &ctx); - *node = ctx.root; - return ctx.rc; -} - -// Depreacated -iwrc jbl_node_from_json(const char *json, JBL_NODE *node, IWPOOL *pool) { - return jbn_from_json(json, node, pool); -} - -// Depreacated -iwrc jbl_node_as_json(JBL_NODE node, jbl_json_printer pt, void *op, jbl_print_flags_t pf) { - return _jbl_node_as_json(node, pt, op, 0, pf); -} diff --git a/src/jbl/tests/CMakeLists.txt b/src/jbl/tests/CMakeLists.txt deleted file mode 100644 index 1ac06b01a..000000000 --- a/src/jbl/tests/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -link_libraries(ejdb2_s ${CUNIT_LIBRARIES}) -include_directories(${CUNIT_INCLUDE_DIRS}) - -file(GLOB datafiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/data" "data/*") -foreach (file ${datafiles}) - configure_file("data/${file}" "data/${file}" COPYONLY) -endforeach () - -set(TEST_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TEST_DATA_DIR}) - -foreach (TN IN ITEMS jbl_test1 - jbl_test_binn1 - jbl_test_binn2) - add_executable(${TN} ${TN}.c) - set_target_properties(${TN} PROPERTIES - COMPILE_FLAGS "-DIW_STATIC") - add_test(NAME ${TN} WORKING_DIRECTORY ${TEST_DATA_DIR} - COMMAND ${TEST_TOOL_CMD} $) -endforeach () diff --git a/src/jbl/tests/data/001.expected.json b/src/jbl/tests/data/001.expected.json deleted file mode 100644 index d3426dea5..000000000 --- a/src/jbl/tests/data/001.expected.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "str": "𝌆", - "str1": "15øC 3đ", - "str2": "Mа二𐌂", - "str3": "привет", - "na": [ - 0.1, - 0.000006, - 0.000001 - ], - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": [ - "GML", - "XML", - true, - false - ] - }, - "GlossSee": "markup" - } - } - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/001.json b/src/jbl/tests/data/001.json deleted file mode 100644 index ccdcd7009..000000000 --- a/src/jbl/tests/data/001.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "str": "\uD834\uDF06", - "str1": "15\u00f8C 3\u0111", - "str2": "\u004d\u0430\u4e8c\ud800\udf02", - "str3": "привет", - "na": [ - 0.1000, - 6E-06, - 1E-06 - ], - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": [ - "GML", - "XML", - true, - false - ] - }, - "GlossSee": "markup" - } - } - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/002.expected.json b/src/jbl/tests/data/002.expected.json deleted file mode 100644 index 3e6293433..000000000 --- a/src/jbl/tests/data/002.expected.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "str": "\uD834\uDF06", - "str1": "15\u00F8C 3\u0111", - "str2": "M\u0430\u4E8C\uD800\uDF02", - "str3": "\u043F\u0440\u0438\u0432\u0435\u0442", - "na": [ - 0.00012, - 0.000006, - 0.000001 - ], - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": [ - "GML", - "XML", - true, - false - ] - }, - "GlossSee": "markup" - } - } - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/002.json b/src/jbl/tests/data/002.json deleted file mode 100644 index 2dea984b9..000000000 --- a/src/jbl/tests/data/002.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "str": "\uD834\uDF06", - "str1": "15\u00f8C 3\u0111", - "str2": "\u004d\u0430\u4e8c\ud800\udf02", - "str3": "привет", - "na": [ - 0.00011999999999999999, - 6E-06, - 1E-06 - ], - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": [ - "GML", - "XML", - true, - false - ] - }, - "GlossSee": "markup" - } - } - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/003.expected.json b/src/jbl/tests/data/003.expected.json deleted file mode 100644 index 2fd06e5bb..000000000 --- a/src/jbl/tests/data/003.expected.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "empty": "" -} \ No newline at end of file diff --git a/src/jbl/tests/data/003.json b/src/jbl/tests/data/003.json deleted file mode 100644 index 5f12ebfa2..000000000 --- a/src/jbl/tests/data/003.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "empty": "" -} \ No newline at end of file diff --git a/src/jbl/tests/data/004.expected.json b/src/jbl/tests/data/004.expected.json deleted file mode 100644 index 43f0446c2..000000000 --- a/src/jbl/tests/data/004.expected.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "web-app": { - "servlet": [ - { - "servlet-name": "cofaxCDS", - "servlet-class": "org.cofax.cds.CDSServlet", - "init-param": { - "configGlossary:installationAt": "Philadelphia, PA", - "configGlossary:adminEmail": "ksm@pobox.com", - "configGlossary:poweredBy": "Cofax", - "configGlossary:poweredByIcon": "/images/cofax.gif", - "configGlossary:staticPath": "/content/static", - "templateProcessorClass": "org.cofax.WysiwygTemplate", - "templateLoaderClass": "org.cofax.FilesTemplateLoader", - "templatePath": "templates", - "templateOverridePath": "", - "defaultListTemplate": "listTemplate.htm", - "defaultFileTemplate": "articleTemplate.htm", - "useJSP": false, - "jspListTemplate": "listTemplate.jsp", - "jspFileTemplate": "articleTemplate.jsp", - "cachePackageTagsTrack": 200, - "cachePackageTagsStore": 200, - "cachePackageTagsRefresh": 60, - "cacheTemplatesTrack": 100, - "cacheTemplatesStore": 50, - "cacheTemplatesRefresh": 15, - "cachePagesTrack": 200, - "cachePagesStore": 100, - "cachePagesRefresh": 10, - "cachePagesDirtyRead": 10, - "searchEngineListTemplate": "forSearchEnginesList.htm", - "searchEngineFileTemplate": "forSearchEngines.htm", - "searchEngineRobotsDb": "WEB-INF/robots.db", - "useDataStore": true, - "dataStoreClass": "org.cofax.SqlDataStore", - "redirectionClass": "org.cofax.SqlRedirection", - "dataStoreName": "cofax", - "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", - "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", - "dataStoreUser": "sa", - "dataStorePassword": "dataStoreTestQuery", - "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", - "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", - "dataStoreInitConns": 10, - "dataStoreMaxConns": 100, - "dataStoreConnUsageLimit": 100, - "dataStoreLogLevel": "debug", - "maxUrlLength": 500 - } - }, - { - "servlet-name": "cofaxEmail", - "servlet-class": "org.cofax.cds.EmailServlet", - "init-param": { - "mailHost": "mail1", - "mailHostOverride": "mail2" - } - }, - { - "servlet-name": "cofaxAdmin", - "servlet-class": "org.cofax.cds.AdminServlet" - }, - { - "servlet-name": "fileServlet", - "servlet-class": "org.cofax.cds.FileServlet" - }, - { - "servlet-name": "cofaxTools", - "servlet-class": "org.cofax.cms.CofaxToolsServlet", - "init-param": { - "templatePath": "toolstemplates/", - "log": 1, - "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", - "logMaxSize": "", - "dataLog": 1, - "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", - "dataLogMaxSize": "", - "removePageCache": "/content/admin/remove?cache=pages&id=", - "removeTemplateCache": "/content/admin/remove?cache=templates&id=", - "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", - "lookInContext": 1, - "adminGroupID": 4, - "betaServer": true - } - } - ], - "servlet-mapping": { - "cofaxCDS": "/", - "cofaxEmail": "/cofaxutil/aemail/*", - "cofaxAdmin": "/admin/*", - "fileServlet": "/static/*", - "cofaxTools": "/tools/*" - }, - "taglib": { - "taglib-uri": "cofax.tld", - "taglib-location": "/WEB-INF/tlds/cofax.tld" - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/004.json b/src/jbl/tests/data/004.json deleted file mode 100644 index 1ee80ebac..000000000 --- a/src/jbl/tests/data/004.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "web-app": { - "servlet": [ - { - "servlet-name": "cofaxCDS", - "servlet-class": "org.cofax.cds.CDSServlet", - "init-param": { - "configGlossary:installationAt": "Philadelphia, PA", - "configGlossary:adminEmail": "ksm@pobox.com", - "configGlossary:poweredBy": "Cofax", - "configGlossary:poweredByIcon": "/images/cofax.gif", - "configGlossary:staticPath": "/content/static", - "templateProcessorClass": "org.cofax.WysiwygTemplate", - "templateLoaderClass": "org.cofax.FilesTemplateLoader", - "templatePath": "templates", - "templateOverridePath": "", - "defaultListTemplate": "listTemplate.htm", - "defaultFileTemplate": "articleTemplate.htm", - "useJSP": false, - "jspListTemplate": "listTemplate.jsp", - "jspFileTemplate": "articleTemplate.jsp", - "cachePackageTagsTrack": 200, - "cachePackageTagsStore": 200, - "cachePackageTagsRefresh": 60, - "cacheTemplatesTrack": 100, - "cacheTemplatesStore": 50, - "cacheTemplatesRefresh": 15, - "cachePagesTrack": 200, - "cachePagesStore": 100, - "cachePagesRefresh": 10, - "cachePagesDirtyRead": 10, - "searchEngineListTemplate": "forSearchEnginesList.htm", - "searchEngineFileTemplate": "forSearchEngines.htm", - "searchEngineRobotsDb": "WEB-INF/robots.db", - "useDataStore": true, - "dataStoreClass": "org.cofax.SqlDataStore", - "redirectionClass": "org.cofax.SqlRedirection", - "dataStoreName": "cofax", - "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", - "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", - "dataStoreUser": "sa", - "dataStorePassword": "dataStoreTestQuery", - "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", - "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", - "dataStoreInitConns": 10, - "dataStoreMaxConns": 100, - "dataStoreConnUsageLimit": 100, - "dataStoreLogLevel": "debug", - "maxUrlLength": 500 - } - }, - { - "servlet-name": "cofaxEmail", - "servlet-class": "org.cofax.cds.EmailServlet", - "init-param": { - "mailHost": "mail1", - "mailHostOverride": "mail2" - } - }, - { - "servlet-name": "cofaxAdmin", - "servlet-class": "org.cofax.cds.AdminServlet" - }, - { - "servlet-name": "fileServlet", - "servlet-class": "org.cofax.cds.FileServlet" - }, - { - "servlet-name": "cofaxTools", - "servlet-class": "org.cofax.cms.CofaxToolsServlet", - "init-param": { - "templatePath": "toolstemplates/", - "log": 1, - "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", - "logMaxSize": "", - "dataLog": 1, - "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", - "dataLogMaxSize": "", - "removePageCache": "/content/admin/remove?cache=pages&id=", - "removeTemplateCache": "/content/admin/remove?cache=templates&id=", - "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", - "lookInContext": 1, - "adminGroupID": 4, - "betaServer": true - } - } - ], - "servlet-mapping": { - "cofaxCDS": "/", - "cofaxEmail": "/cofaxutil/aemail/*", - "cofaxAdmin": "/admin/*", - "fileServlet": "/static/*", - "cofaxTools": "/tools/*" - }, - "taglib": { - "taglib-uri": "cofax.tld", - "taglib-location": "/WEB-INF/tlds/cofax.tld" - } - } -} \ No newline at end of file diff --git a/src/jbl/tests/data/005.expected.json b/src/jbl/tests/data/005.expected.json deleted file mode 100644 index 3e1a73a83..000000000 --- a/src/jbl/tests/data/005.expected.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "foo": "b\"ar", - "num1": 1223, - "n\"um2": 10.1226222, - "list": [ - 3, - 2.1, - 1, - "one", - "two", - {}, - { - "z": false, - "t": true - } - ] -} \ No newline at end of file diff --git a/src/jbl/tests/data/005.json b/src/jbl/tests/data/005.json deleted file mode 100644 index 5323a4c70..000000000 --- a/src/jbl/tests/data/005.json +++ /dev/null @@ -1 +0,0 @@ -{"foo": "b\"ar", "num1":1223,"n\"um2":10.1226222, "list":[3,2.1,1,"one", "two", {}, {"z":false, "t":true}]} diff --git a/src/jbl/tests/jbl_test1.c b/src/jbl/tests/jbl_test1.c deleted file mode 100644 index 3dd70d109..000000000 --- a/src/jbl/tests/jbl_test1.c +++ /dev/null @@ -1,907 +0,0 @@ -#include "ejdb2.h" -#include -#include - -#include "jbl.h" -#include "jbl_internal.h" - -#include - -int init_suite(void) { - int rc = ejdb_init(); - return rc; -} - -int clean_suite(void) { - return 0; -} - -void _jbl_test1_1(int num, iwrc expected, jbl_print_flags_t pf) { - iwrc rc; - char path[64]; - char path_expected[64]; - JBL_NODE node = 0; - IWPOOL *pool; - char *data; - char *edata = 0; - IWXSTR *res = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(res); - - snprintf(path, sizeof(path), "data%c%03d.json", IW_PATH_CHR, num); - snprintf(path_expected, sizeof(path_expected), "data%c%03d.expected.json", IW_PATH_CHR, num); - data = iwu_file_read_as_buf(path); - CU_ASSERT_PTR_NOT_NULL_FATAL(data); - - pool = iwpool_create(1024); - CU_ASSERT_PTR_NOT_NULL_FATAL(pool); - - rc = jbn_from_json(data, &node, pool); - if (rc) { - iwlog_ecode_error3(rc); - } - CU_ASSERT_EQUAL_FATAL(rc, expected); - CU_ASSERT_PTR_NOT_NULL_FATAL(node); - if (expected) { - goto finish; - } - - rc = jbn_as_json(node, jbl_xstr_json_printer, res, pf); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - edata = iwu_file_read_as_buf(path_expected); - CU_ASSERT_PTR_NOT_NULL_FATAL(edata); - - FILE *f1 = fopen("f1.txt", "w"); - FILE *f2 = fopen("f2.txt", "w"); - fprintf(f1, "\n%s", edata); - fprintf(f2, "\n%s", iwxstr_ptr(res)); - fclose(f1); - fclose(f2); - - fprintf(stderr, "ED %s\n", edata); - fprintf(stderr, "ED %s\n", iwxstr_ptr(res)); - - CU_ASSERT_EQUAL_FATAL(strcmp(edata, iwxstr_ptr(res)), 0); - -finish: - if (edata) { - free(edata); - } - free(data); - iwpool_destroy(pool); - iwxstr_destroy(res); -} - -void jbl_test1_1() { - _jbl_test1_1(1, 0, JBL_PRINT_PRETTY); - _jbl_test1_1(2, 0, JBL_PRINT_PRETTY | JBL_PRINT_CODEPOINTS); - _jbl_test1_1(3, 0, JBL_PRINT_PRETTY); - _jbl_test1_1(4, 0, JBL_PRINT_PRETTY); - _jbl_test1_1(5, 0, JBL_PRINT_PRETTY); -} - -void jbl_test1_2() { - const char *data = "{\"foo\": \"b\\\"ar\", \"num1\":1223," - "\"n\\\"um2\":10.1226222, " - "\"list\":[3,2.1,1,\"one\", \"two\", " - "{}, {\"z\":false, \"t\":true}]}"; - JBL jbl; - iwrc rc = jbl_from_json(&jbl, data); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - IWXSTR *xstr = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); - - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, false); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - int res = strcmp(iwxstr_ptr(xstr), - "{\"foo\":\"b\\\"ar\",\"num1\":1223,\"n\\\"um2\":10.1226222," - "\"list\":[3,2.1,1,\"one\",\"two\",{},{\"z\":false,\"t\":true}]}"); - CU_ASSERT_EQUAL(res, 0); - jbl_destroy(&jbl); - - // - rc = jbl_from_json(&jbl, "{ "); - CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PARSE_JSON); - - iwxstr_destroy(xstr); -} - -void jbl_test1_3() { - JBL_PTR jp; - iwrc rc = jbl_ptr_alloc("/", &jp); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_EQUAL(jp->cnt, 1); - CU_ASSERT_TRUE(*jp->n[0] == '\0') - free(jp); - - rc = jbl_ptr_alloc("/foo", &jp); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_EQUAL(jp->cnt, 1); - CU_ASSERT_FALSE(strcmp(jp->n[0], "foo")); - free(jp); - - rc = jbl_ptr_alloc("/foo/bar", &jp); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_EQUAL(jp->cnt, 2); - CU_ASSERT_FALSE(strcmp(jp->n[0], "foo")); - CU_ASSERT_FALSE(strcmp(jp->n[1], "bar")); - free(jp); - - rc = jbl_ptr_alloc("/foo/bar/0/baz", &jp); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_EQUAL(jp->cnt, 4); - CU_ASSERT_FALSE(strcmp(jp->n[0], "foo")); - CU_ASSERT_FALSE(strcmp(jp->n[1], "bar")); - CU_ASSERT_FALSE(strcmp(jp->n[2], "0")); - CU_ASSERT_FALSE(strcmp(jp->n[3], "baz")); - free(jp); - - rc = jbl_ptr_alloc("/foo/b~0ar/0/b~1az", &jp); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_EQUAL(jp->cnt, 4); - CU_ASSERT_FALSE(strcmp(jp->n[0], "foo")); - CU_ASSERT_FALSE(strcmp(jp->n[1], "b~ar")); - CU_ASSERT_FALSE(strcmp(jp->n[2], "0")); - CU_ASSERT_FALSE(strcmp(jp->n[3], "b/az")); - free(jp); - - rc = jbl_ptr_alloc("/foo/", &jp); - CU_ASSERT_EQUAL(rc, JBL_ERROR_JSON_POINTER); - free(jp); - - rc = jbl_ptr_alloc("//", &jp); - CU_ASSERT_EQUAL(rc, JBL_ERROR_JSON_POINTER); - free(jp); - - rc = jbl_ptr_alloc("", &jp); - CU_ASSERT_EQUAL(rc, JBL_ERROR_JSON_POINTER); - free(jp); - - rc = jbl_ptr_alloc("~", &jp); - CU_ASSERT_EQUAL(rc, JBL_ERROR_JSON_POINTER); - free(jp); -} - -void jbl_test1_4() { - // { "foo": "bar", - // "foo2": { - // "foo3": { - // "foo4": "bar4" - // }, - // "foo5": "bar5" - // }, - // "num1": 1, - // "list1": ["one", "two", {"three": 3}] - // } - char *data - = iwu_replace_char( - strdup("{'foo':'bar','foo2':{'foo3':{'foo4':'bar4'},'foo5':'bar5'}," - "'num1':1,'list1':['one','two',{'three':3}]}"), - '\'', '"'); - JBL jbl, at, at2; - const char *sval; - int ival; - iwrc rc = jbl_from_json(&jbl, data); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_at(jbl, "/foo", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - - sval = jbl_get_str(at); - CU_ASSERT_PTR_NOT_NULL_FATAL(sval); - CU_ASSERT_STRING_EQUAL(sval, "bar"); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/foo2/foo3", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - CU_ASSERT_TRUE(at->bn.type == BINN_OBJECT); - rc = jbl_at(at, "/foo4", &at2); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at2); - sval = jbl_get_str(at2); - CU_ASSERT_PTR_NOT_NULL_FATAL(sval); - CU_ASSERT_STRING_EQUAL(sval, "bar4"); - jbl_destroy(&at2); - jbl_destroy(&at); - - at = (void*) 1; - rc = jbl_at(jbl, "/foo2/foo10", &at); - CU_ASSERT_EQUAL(rc, JBL_ERROR_PATH_NOTFOUND); - CU_ASSERT_PTR_NULL(at); - rc = 0; - - rc = jbl_at(jbl, "/foo2/*/foo4", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - sval = jbl_get_str(at); - CU_ASSERT_PTR_NOT_NULL_FATAL(sval); - CU_ASSERT_STRING_EQUAL(sval, "bar4"); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/list1/1", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - sval = jbl_get_str(at); - CU_ASSERT_STRING_EQUAL(sval, "two"); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/list1/2/three", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - ival = jbl_get_i32(at); - CU_ASSERT_EQUAL(ival, 3); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/list1/*/three", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - ival = jbl_get_i32(at); - CU_ASSERT_EQUAL(ival, 3); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/list1/*/*", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - ival = jbl_get_i32(at); - CU_ASSERT_EQUAL(ival, 3); - jbl_destroy(&at); - - jbl_destroy(&jbl); - free(data); -} - -void jbl_test1_5() { - IWXSTR *xstr = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); - - // { "foo": "bar", - // "foo2": { - // "foo3": { - // "foo4": "bar4" - // }, - // "foo5": "bar5" - // }, - // "num1": 1, - // "list1": ["one", "two", {"three": 3}] - // } - char *data - = iwu_replace_char( - strdup("{'foo':'bar','foo2':{'foo3':{'foo4':'bar4'},'foo5':'bar5'}," - "'num1':1,'list1':['one','two',{'three':3}]}"), - '\'', '"'); - JBL jbl; - int res = 0; - - // Remove ROOT - JBL_PATCH p1[] = { { .op = JBP_REMOVE, .path = "/" } }; - iwrc rc = jbl_from_json(&jbl, data); - CU_ASSERT_EQUAL_FATAL(rc, 0); - rc = jbl_patch(jbl, p1, sizeof(p1) / sizeof(p1[0])); - CU_ASSERT_EQUAL_FATAL(rc, 0); - jbl_destroy(&jbl); - - - // Remove "/foo" - JBL_PATCH p2[] = { { .op = JBP_REMOVE, .path = "/foo" } }; - rc = jbl_from_json(&jbl, data); - CU_ASSERT_EQUAL_FATAL(rc, 0); - rc = jbl_patch(jbl, p2, sizeof(p2) / sizeof(p2[0])); - CU_ASSERT_EQUAL_FATAL(rc, 0); - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, false); - CU_ASSERT_EQUAL_FATAL(rc, 0); - res = strcmp(iwxstr_ptr( - xstr), - "{\"foo2\":{\"foo3\":{\"foo4\":\"bar4\"},\"foo5\":\"bar5\"},\"num1\":1,\"list1\":[\"one\",\"two\",{\"three\":3}]}"); - CU_ASSERT_EQUAL(res, 0); - jbl_destroy(&jbl); - iwxstr_clear(xstr); - - // Remove /foo2/foo3/foo4 - // Remove /list1/1 - JBL_PATCH p3[] = { - { .op = JBP_REMOVE, .path = "/foo2/foo3/foo4" }, - { .op = JBP_REMOVE, .path = "/list1/1" } - }; - rc = jbl_from_json(&jbl, data); - CU_ASSERT_EQUAL_FATAL(rc, 0); - rc = jbl_patch(jbl, p3, sizeof(p3) / sizeof(p3[0])); - CU_ASSERT_EQUAL_FATAL(rc, 0); - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, false); - CU_ASSERT_EQUAL_FATAL(rc, 0); - res = strcmp(iwxstr_ptr(xstr), - "{\"foo\":\"bar\",\"foo2\":{\"foo3\":{},\"foo5\":\"bar5\"},\"num1\":1,\"list1\":[\"one\",{\"three\":3}]}"); - CU_ASSERT_EQUAL(res, 0); - jbl_destroy(&jbl); - iwxstr_clear(xstr); - iwxstr_destroy(xstr); - free(data); -} - -void apply_patch(const char *data, const char *patch, const char *result, IWXSTR *xstr, iwrc *rcp) { - CU_ASSERT_TRUE_FATAL(data && patch && xstr && rcp); - JBL jbl = 0; - char *data2 = iwu_replace_char(strdup(data), '\'', '"'); - char *patch2 = iwu_replace_char(strdup(patch), '\'', '"'); - char *result2 = result ? iwu_replace_char(strdup(result), '\'', '"') : 0; - CU_ASSERT_TRUE_FATAL(data2 && patch2); - - iwrc rc = jbl_from_json(&jbl, data2); - RCGO(rc, finish); - - rc = jbl_patch_from_json(jbl, patch2); - RCGO(rc, finish); - - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, false); - RCGO(rc, finish); - - if (result2) { - CU_ASSERT_STRING_EQUAL(result2, iwxstr_ptr(xstr)); - } - -finish: - if (data2) { - free(data2); - } - if (patch2) { - free(patch2); - } - if (result2) { - free(result2); - } - if (jbl) { - jbl_destroy(&jbl); - } - *rcp = rc; -} - -void apply_merge_patch(const char *data, const char *patch, const char *result, IWXSTR *xstr, iwrc *rcp) { - CU_ASSERT_TRUE_FATAL(data && patch && xstr && rcp); - JBL jbl = 0; - char *data2 = iwu_replace_char(strdup(data), '\'', '"'); - char *patch2 = iwu_replace_char(strdup(patch), '\'', '"'); - char *result2 = result ? iwu_replace_char(strdup(result), '\'', '"') : 0; - CU_ASSERT_TRUE_FATAL(data2 && patch2); - - iwrc rc = jbl_from_json(&jbl, data2); - RCGO(rc, finish); - - rc = jbl_merge_patch(jbl, patch2); - RCGO(rc, finish); - - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, false); - RCGO(rc, finish); - - if (result2) { - CU_ASSERT_STRING_EQUAL(result2, iwxstr_ptr(xstr)); - } - -finish: - if (data2) { - free(data2); - } - if (patch2) { - free(patch2); - } - if (result2) { - free(result2); - } - if (jbl) { - jbl_destroy(&jbl); - } - *rcp = rc; -} - -// Run tests: https://github.com/json-patch/json-patch-tests/blob/master/spec_tests.json -void jbl_test1_6() { - iwrc rc; - IWXSTR *xstr = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); - - apply_patch("{'foo':'bar','foo2':{'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{'op':'remove', 'path':'/foo'}]", - "{'foo2':{'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // 4.1. add with missing object - apply_patch("{ 'q': { 'bar': 2 } }", - "[ {'op': 'add', 'path': '/a/b', 'value': 1} ]", - 0, xstr, &rc); - CU_ASSERT_EQUAL(rc, JBL_ERROR_PATCH_TARGET_INVALID); - iwxstr_clear(xstr); - - // A.1. Adding an Object Member - apply_patch("{'foo': 'bar'}", - "[ { 'op': 'add', 'path': '/baz', 'value': 'qux' } ]", - "{'foo':'bar','baz':'qux'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.2. Adding an Array Element - apply_patch("{'foo': [ 'bar', 'baz' ]}", - "[{ 'op': 'add', 'path': '/foo/1', 'value': 'qux' }]", - "{'foo':['bar','qux','baz']}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.3. Removing an Object Member - apply_patch("{'baz': 'qux','foo': 'bar'}", - "[{ 'op': 'remove', 'path': '/baz' }]", - "{'foo':'bar'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.4. Removing an Array Element - apply_patch("{'foo': [ 'bar', 'qux', 'baz' ]}", - "[{ 'op': 'remove', 'path': '/foo/1' }]", - "{'foo':['bar','baz']}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.5. Replacing a Value - apply_patch("{'baz': 'qux','foo': 'bar'}", - "[{ 'op': 'replace', 'path': '/baz', 'value': 'boo' }]", - "{'foo':'bar','baz':'boo'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.5.1 #232 - apply_patch("{'a':{'c':'N','s':'F'}}", - "[{'op':'replace', 'path':'/a/s', 'value':'A'}]", - "{'a':{'c':'N','s':'A'}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.6. Moving a Value - apply_patch("{'foo': {'bar': 'baz','waldo': 'fred'},'qux': {'corge': 'grault'}}", - "[{ 'op': 'move', 'from': '/foo/waldo', 'path': '/qux/thud' }]", - "{'foo':{'bar':'baz'},'qux':{'corge':'grault','thud':'fred'}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.7. Moving an Array Element - apply_patch("{'foo': [ 'all', 'grass', 'cows', 'eat' ]}", - "[{ 'op': 'move', 'from': '/foo/1', 'path': '/foo/3' }]", - "{'foo':['all','cows','eat','grass']}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.8. Testing a Value: Success - apply_patch("{'baz': 'qux','foo': [ 'a', 2, 'c' ]}", - "[" - "{ 'op': 'test', 'path': '/baz', 'value': 'qux' }," - "{ 'op': 'test', 'path': '/foo/1', 'value': 2 }" - "]", - "{'baz':'qux','foo':['a',2,'c']}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.8. Testing a Value Object - apply_patch( - "{'foo':'bar','foo2':{'zaz':25, 'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{ 'op': 'test', 'path': '/foo2', 'value': {'foo5':'bar5', 'zaz':25, 'foo3':{'foo4':'bar4'}} }]", - 0, - xstr, - &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch( - "{'foo':'bar','foo2':{'zaz':25, 'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{ 'op': 'test', 'path': '/foo2', 'value': {'foo5':'bar5', 'zaz':25, 'foo3':{'foo41':'bar4'}} }]", - 0, - xstr, - &rc); - CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATCH_TEST_FAILED); - iwxstr_clear(xstr); - - apply_patch( - "{'foo':'bar','foo2':{'zaz':25, 'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{ 'op': 'test', 'path': '/', 'value': {'num1':1, 'foo2':{'foo3':{'foo4':'bar4'}, 'zaz':25, 'foo5':'bar5'},'list1':['one','two',{'three':3}],'foo':'bar'} }]", - 0, - xstr, - &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch( - "{'foo':'bar','foo2':{'zaz':25, 'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{ 'op': 'test', 'path': '/list1', 'value':['one','two',{'three':3}] }]", - 0, - xstr, - &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch( - "{'foo':'bar','foo2':{'zaz':25, 'foo3':{'foo4':'bar4'},'foo5':'bar5'},'num1':1,'list1':['one','two',{'three':3}]}", - "[{ 'op': 'test', 'path': '/list1', 'value':['two','one',{'three':3}] }]", - 0, - xstr, - &rc); - CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATCH_TEST_FAILED); - iwxstr_clear(xstr); - - // A.9. Testing a Value: Error - apply_patch("{ 'baz': 'qux'}", - "[{ 'op': 'test', 'path': '/baz', 'value': 'bar' }]", - 0, xstr, &rc); - CU_ASSERT_EQUAL(rc, JBL_ERROR_PATCH_TEST_FAILED); - iwxstr_clear(xstr); - - // A.10. Adding a nested Member Object - apply_patch("{'foo': 'bar'}", - "[{ 'op': 'add', 'path': '/child', 'value': { 'grandchild': { } } }]", - "{'foo':'bar','child':{'grandchild':{}}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.11. Ignoring Unrecognized Elements - apply_patch("{'foo': 'bar'}", - "[{ 'op': 'add', 'path': '/baz', 'value': 'qux', 'xyz': 123 }]", - "{'foo':'bar','baz':'qux'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.12. Adding to a Non-existent Target - apply_patch("{'foo': 'bar'}", - "[{ 'op': 'add', 'path': '/baz/bat', 'value': 'qux' }]", - 0, xstr, &rc); - CU_ASSERT_EQUAL(rc, JBL_ERROR_PATCH_TARGET_INVALID); - iwxstr_clear(xstr); - - // A.14. ~ Escape Ordering - apply_patch("{'/': 9,'~1': 10}", - "[{'op': 'test', 'path': '/~01', 'value': 10}]", - "{'/':9,'~1':10}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // A.15. Comparing Strings and Numbers - apply_patch("{'/': 9,'~1': 10}", - "[{'op': 'test', 'path': '/~01', 'value': '10'}]", - "{'/':9,'~1':10}", xstr, &rc); - CU_ASSERT_EQUAL(rc, JBL_ERROR_PATCH_TEST_FAILED); - iwxstr_clear(xstr); - - // A.16. Adding an Array Value - apply_patch("{'foo': ['bar']}", - "[{'op': 'add', 'path': '/foo/-', 'value': ['abc', 'def'] }]", - "{'foo':['bar',['abc','def']]}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // Apply non standard `increment` patch - apply_patch("{'foo': 1}", - "[{'op': 'increment', 'path': '/foo', 'value': 2}]", - "{'foo':3}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - // Apply non standard `swap` patch - apply_patch("{'foo': ['bar'], 'baz': {'gaz': 11}}", - "[{'op': 'swap', 'from': '/foo/0', 'path': '/baz/gaz'}]", - "{'foo':[11],'baz':{'gaz':'bar'}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch("{'foo': ['bar'], 'baz': {'gaz': 11}}", - "[{'op': 'swap', 'from': '/foo/0', 'path': '/baz/zaz'}]", - "{'foo':[],'baz':{'gaz':11,'zaz':'bar'}}", xstr, &rc); - - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch("{'foo': 1}", - "[{'op': 'increment', 'path': '/foo', 'value': true}]", - "{'foo':3}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATCH_INVALID_VALUE); - iwxstr_clear(xstr); - - // Apply non standard add_create patch - apply_patch("{'foo': {'bar': 1}}", - "[{'op': 'add_create', 'path': '/foo/zaz/gaz', 'value': 22}]", - "{'foo':{'bar':1,'zaz':{'gaz':22}}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_patch("{'foo': {'bar': 1}}", - "[{'op': 'add_create', 'path': '/foo/bar/gaz', 'value': 22}]", - "{}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATCH_TARGET_INVALID); - iwxstr_clear(xstr); - - apply_patch("{'foo': {'bar': 1}}", - "[{'op': 'add_create', 'path': '/zaz/gaz', 'value': [1,2,3]}]", - "{'foo':{'bar':1},'zaz':{'gaz':[1,2,3]}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - iwxstr_destroy(xstr); -} - -void jbl_test1_7() { - iwrc rc; - IWXSTR *xstr = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); - - // #233 - apply_merge_patch("{'n':'nv'}", - "{'a':{'c':'v','d':'k'}}", - "{'n':'nv','a':{'c':'v','d':'k'}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':'b'}", - "{'a':'c'}", - "{'a':'c'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - - apply_merge_patch("{'a':'b'}", - "{'b':'c'}", - "{'a':'b','b':'c'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':'b'}", - "{'a':null}", - "{}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':'b','b':'c'}", - "{'a':null}", - "{'b':'c'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':['b']}", - "{'a':'c'}", - "{'a':'c'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':'c'}", - "{'a':['b']}", - "{'a':['b']}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':{'b':'c'}}", - "{'a':{'b':'d','c':null}}", - "{'a':{'b':'d'}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':[{'b':'c'}]}", - "{'a':[1]}", - "{'a':[1]}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("['a','b']", - "['c','d']", - "['c','d']", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'a':'b'}", - "['c']", - "['c']", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{'e':null}", - "{'a':1}", - "{'e':null,'a':1}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("[1,2]", - "{'a':'b','c':null}", - "{'a':'b'}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - apply_merge_patch("{}", - "{'a':{'bb':{'ccc':null}}}", - "{'a':{'bb':{}}}", xstr, &rc); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwxstr_clear(xstr); - - - iwxstr_destroy(xstr); -} - -void jbl_test1_8() { - JBL jbl, nested, at; - iwrc rc = jbl_create_empty_object(&jbl); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_create_empty_object(&nested); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_set_int64(nested, "nnum", 2233); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_set_int64(jbl, "mynum", 13223); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_set_string(jbl, "foo", "bar"); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_set_nested(jbl, "nested", nested); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbl_at(jbl, "/mynum", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - CU_ASSERT_EQUAL(jbl_get_i64(at), 13223); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/foo", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - CU_ASSERT_STRING_EQUAL(jbl_get_str(at), "bar"); - jbl_destroy(&at); - - rc = jbl_at(jbl, "/nested/nnum", &at); - CU_ASSERT_EQUAL_FATAL(rc, 0); - CU_ASSERT_PTR_NOT_NULL_FATAL(at); - CU_ASSERT_EQUAL(jbl_get_i64(at), 2233); - jbl_destroy(&at); - - jbl_destroy(&jbl); - jbl_destroy(&nested); -} - -void jbl_test1_9(void) { - IWPOOL *pool = iwpool_create(512); - IWPOOL *cpool = iwpool_create(512); - CU_ASSERT_PTR_NOT_NULL_FATAL(pool); - CU_ASSERT_PTR_NOT_NULL_FATAL(cpool); - const char *data = "{\"foo\": \"b\\\"ar\", \"num1\":1223," - "\"n\\\"um2\":10.1226222, " - "\"list\":[3,2.1,1,\"one\" \"two\", " - "{}, {\"z\":false, \"arr\":[9,8], \"t\":true}]}"; - - JBL_NODE n, cn; - iwrc rc = jbn_from_json(data, &n, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_clone(n, &cn, cpool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - IWXSTR *xstr = iwxstr_new(); - CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); - - iwpool_destroy(pool); - - rc = jbn_as_json(cn, jbl_xstr_json_printer, xstr, 0); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - CU_ASSERT_STRING_EQUAL(iwxstr_ptr( - xstr), - "{\"foo\":\"b\\\"ar\",\"num1\":1223,\"n\\\"um2\":10.1226222,\"list\":[3,2.1,1,\"one\",\"two\",{},{\"z\":false,\"arr\":[9,8],\"t\":true}]}" - ); - - iwpool_destroy(cpool); - iwxstr_destroy(xstr); -} - -void jbl_test1_10(void) { - IWPOOL *pool = iwpool_create(512); - IWPOOL *tpool = iwpool_create(512); - IWXSTR *xstr = iwxstr_new(); - - const char *src_data = "{\"foo\": \"b\\\"ar\", \"num1\":1223," - "\"n\\\"um2\":10.1226222, " - "\"list\":[3,2.1,1,\"one\" \"two\", " - "{}, {\"z\":false, \"arr\":[9,8], \"t\":true}]}"; - const char *tgt_data = "{\"test\":{\"nested1\":22}}"; - JBL_NODE n1, n2; - iwrc rc = jbn_from_json(src_data, &n1, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_from_json(tgt_data, &n2, tpool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_copy_path(n1, "/list/6/arr", n2, "/test/nested1", false, false, tpool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_copy_path(n1, "/list/6/t", n2, "/test/t2", false, false, tpool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_copy_path(n1, "/foo", n2, "/bar", false, false, tpool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - iwpool_destroy(pool); - - rc = jbn_as_json(n2, jbl_xstr_json_printer, xstr, 0); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - CU_ASSERT_STRING_EQUAL(iwxstr_ptr(xstr), - "{\"test\":{\"nested1\":[9,8],\"t2\":true},\"bar\":\"b\\\"ar\"}"); - - iwpool_destroy(tpool); - iwxstr_destroy(xstr); -} - -void jbl_test1_11(void) { - IWPOOL *pool = iwpool_create(512); - IWXSTR *xstr = iwxstr_new(); - - const char *src_data = "{\"foo\": \"b\\\"ar\", \"num1\":1223," - "\"n\\\"um2\":10.1226222, " - "\"list\":[3,2.1,1,\"one\" \"two\", " - "{}, {\"z\":false, \"arr\":[9,8], \"t\":true}]}"; - const char *tgt_data = "{\"test\":{\"nested1\":22}, \"list\":[0,99]}"; - - JBL_NODE n1, n2; - iwrc rc = jbn_from_json(src_data, &n1, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_from_json(tgt_data, &n2, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - const char *paths[] = { "/foo", "/list/1", 0 }; - rc = jbn_copy_paths(n1, n2, paths, false, false, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - rc = jbn_as_json(n2, jbl_xstr_json_printer, xstr, 0); - CU_ASSERT_EQUAL_FATAL(rc, 0); - - CU_ASSERT_STRING_EQUAL(iwxstr_ptr(xstr), - "{\"test\":{\"nested1\":22},\"list\":[0,2.1],\"foo\":\"b\\\"ar\"}"); - - iwpool_destroy(pool); - iwxstr_destroy(xstr); -} - -void jbl_test1_12(void) { - IWPOOL *pool = iwpool_create_empty(); - JBL_NODE n; - iwrc rc = jbn_from_json("{\"foo\":1.1}", &n, pool); - CU_ASSERT_EQUAL_FATAL(rc, 0); - iwpool_destroy(pool); -} - -int main() { - CU_pSuite pSuite = NULL; - if (CUE_SUCCESS != CU_initialize_registry()) { - return CU_get_error(); - } - pSuite = CU_add_suite("jbl_test1", init_suite, clean_suite); - if (NULL == pSuite) { - CU_cleanup_registry(); - return CU_get_error(); - } - if ( (NULL == CU_add_test(pSuite, "jbl_test1_1", jbl_test1_1)) - || (NULL == CU_add_test(pSuite, "jbl_test1_2", jbl_test1_2)) - || (NULL == CU_add_test(pSuite, "jbl_test1_3", jbl_test1_3)) - || (NULL == CU_add_test(pSuite, "jbl_test1_4", jbl_test1_4)) - || (NULL == CU_add_test(pSuite, "jbl_test1_5", jbl_test1_5)) - || (NULL == CU_add_test(pSuite, "jbl_test1_6", jbl_test1_6)) - || (NULL == CU_add_test(pSuite, "jbl_test1_7", jbl_test1_7)) - || (NULL == CU_add_test(pSuite, "jbl_test1_8", jbl_test1_8)) - || (NULL == CU_add_test(pSuite, "jbl_test1_9", jbl_test1_9)) - || (NULL == CU_add_test(pSuite, "jbl_test1_10", jbl_test1_10)) - || (NULL == CU_add_test(pSuite, "jbl_test1_11", jbl_test1_11)) - || (NULL == CU_add_test(pSuite, "jbl_test1_12", jbl_test1_12)) - ) { - CU_cleanup_registry(); - return CU_get_error(); - } - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - int ret = CU_get_error() || CU_get_number_of_failures(); - CU_cleanup_registry(); - return ret; -} diff --git a/src/jbl/tests/jbl_test_binn1.c b/src/jbl/tests/jbl_test_binn1.c deleted file mode 100644 index bd0a18202..000000000 --- a/src/jbl/tests/jbl_test_binn1.c +++ /dev/null @@ -1,1844 +0,0 @@ -#include "ejdb2.h" -#include "jbl.h" -#include "jbl_internal.h" -#include - -#define INT64_FORMAT PRId64 -#define UINT64_FORMAT PRIu64 -#define INT64_HEX_FORMAT PRIx64 - -typedef unsigned short int u16; -typedef unsigned int u32; -typedef unsigned long long int u64; - -int init_suite(void) { - int rc = ejdb_init(); - return rc; -} - -int clean_suite(void) { - return 0; -} - -static int CalcAllocation(int needed_size, int alloc_size) { - int calc_size; - calc_size = alloc_size; - while (calc_size < needed_size) { - calc_size <<= 1; // same as *= 2 - //calc_size += CHUNK_SIZE; -- this is slower than the above line, because there are more reallocations - } - return calc_size; -} - -static BOOL CheckAllocation(binn *item, int add_size) { - int alloc_size; - void *ptr; - if (item->used_size + add_size > item->alloc_size) { - if (item->pre_allocated) { - return FALSE; - } - alloc_size = CalcAllocation(item->used_size + add_size, item->alloc_size); - ptr = realloc(item->pbuf, alloc_size); - if (ptr == NULL) { - return FALSE; - } - item->pbuf = ptr; - item->alloc_size = alloc_size; - } - return TRUE; -} - -#define BINN_MAGIC 0x1F22B11F - -#define MAX_BINN_HEADER 9 // [1:type][4:size][4:count] -#define MIN_BINN_SIZE 3 // [1:type][1:size][1:count] -#define CHUNK_SIZE 256 // 1024 - -extern void*(*malloc_fn)(int len); -extern void* (*realloc_fn)(void *ptr, int len); -extern void (*free_fn)(void *ptr); - -/*************************************************************************************/ - -typedef unsigned short int u16; -typedef unsigned int u32; -typedef unsigned long long int u64; - -/***************************************************************************/ - -void *memdup(void *src, int size) { - void *dest; - if ((src == NULL) || (size <= 0)) { - return NULL; - } - dest = malloc(size); - if (dest == NULL) { - return NULL; - } - memcpy(dest, src, size); - return dest; -} - -/***************************************************************************/ - -char *i64toa(int64 value, char *buf, int radix) { -#ifdef _MSC_VER - return _i64toa(value, buf, radix); -#else - switch (radix) { - case 10: - snprintf(buf, 64, "%" INT64_FORMAT, value); - break; - case 16: - snprintf(buf, 64, "%" INT64_HEX_FORMAT, value); - break; - default: - buf[0] = 0; - } - return buf; -#endif -} - -/*************************************************************************************/ - -void pass_int64(int64 a) { - - CU_ASSERT(a == 9223372036854775807); - CU_ASSERT(a > 9223372036854775806); -} - -int64 return_int64() { - - return 9223372036854775807; -} - -int64 return_passed_int64(int64 a) { - - return a; -} - -/*************************************************************************************/ - -void test_int64() { - int64 i64; - //uint64 b; - //long long int b; -- did not work! - char buf[64]; - - printf("testing int64... "); - - pass_int64(9223372036854775807); - - i64 = return_int64(); - CU_ASSERT(i64 == 9223372036854775807); - - /* do not worked! - b = 9223372036854775807; - printf("value of b1=%" G_GINT64_FORMAT "\n", b); - snprintf(64, buf, "%" G_GINT64_FORMAT, b); - printf(" value of b2=%s\n", buf); - - ltoa(i64, buf, 10); - printf(" value of i64=%s\n", buf); - */ - - i64toa(i64, buf, 10); - //printf(" value of i64=%s\n", buf); - CU_ASSERT(strcmp(buf, "9223372036854775807") == 0); - - i64 = return_passed_int64(-987654321987654321); - CU_ASSERT(i64 == -987654321987654321); - - //snprintf(64, buf, "%" G_GINT64_FORMAT, i64); - i64toa(i64, buf, 10); - CU_ASSERT(strcmp(buf, "-987654321987654321") == 0); - - printf("OK\n"); -} - -/*************************************************************************************/ - -//! this code may not work on processors that does not use the default float standard -// original name: AlmostEqual2sComplement -BOOL AlmostEqualFloats(float A, float B, int maxUlps) { - int aInt, bInt, intDiff; - // Make sure maxUlps is non-negative and small enough that the - // default NAN won't compare as equal to anything. - CU_ASSERT(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); - aInt = *(int*) &A; - bInt = *(int*) &B; - // Make aInt lexicographically ordered as a twos-complement int - if (aInt < 0) { - aInt = 0x80000000 - aInt; - } - if (bInt < 0) { - bInt = 0x80000000 - bInt; - } - intDiff = abs(aInt - bInt); - if (intDiff <= maxUlps) { - return TRUE; - } - return FALSE; -} - -/*************************************************************************************/ - -#define VERYSMALL (1.0E-150) -#define EPSILON (1.0E-8) - -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -BOOL AlmostEqualDoubles(double a, double b) { - double absDiff, maxAbs, absA, absB; - - absDiff = fabs(a - b); - if (absDiff < VERYSMALL) { - return TRUE; - } - - absA = fabs(a); - absB = fabs(b); - maxAbs = max(absA, absB); - if ((absDiff / maxAbs) < EPSILON) { - return TRUE; - } - printf("a=%g b=%g\n", a, b); - return FALSE; -} - -/*************************************************************************************/ - -void test_floating_point_numbers() { - char buf[256]; - float f1; - double d1; - - printf("testing floating point... "); - - f1 = 1.25; - CU_ASSERT(f1 == 1.25); - d1 = 1.25; - CU_ASSERT(d1 == 1.25); - - d1 = 0; - d1 = f1; - CU_ASSERT(d1 == 1.25); - f1 = 0; - f1 = d1; - CU_ASSERT(f1 == 1.25); - - d1 = 1.234; - CU_ASSERT(AlmostEqualDoubles(d1, 1.234) == TRUE); - f1 = d1; - CU_ASSERT(AlmostEqualFloats(f1, 1.234, 2) == TRUE); - - d1 = 1.2345; - CU_ASSERT(AlmostEqualDoubles(d1, 1.2345) == TRUE); - f1 = d1; - CU_ASSERT(AlmostEqualFloats(f1, 1.2345, 2) == TRUE); - - - // from string to number, and back to string - - d1 = atof("1.234"); // converts from string to double - CU_ASSERT(AlmostEqualDoubles(d1, 1.234) == TRUE); - f1 = d1; // converts from double to float - CU_ASSERT(AlmostEqualFloats(f1, 1.234, 2) == TRUE); - - /* - sprintf(buf, "%f", d1); // from double to string - CU_ASSERT(buf[0] != 0); - CU_ASSERT(strcmp(buf, "1.234") == 0); - */ - - sprintf(buf, "%g", d1); - CU_ASSERT(buf[0] != 0); - CU_ASSERT(strcmp(buf, "1.234") == 0); - - - d1 = atof("12.34"); - CU_ASSERT(d1 == 12.34); - f1 = d1; - CU_ASSERT(AlmostEqualFloats(f1, 12.34, 2) == TRUE); - - /* - sprintf(buf, "%f", d1); // from double to string - CU_ASSERT(buf[0] != 0); - CU_ASSERT(strcmp(buf, "12.34") == 0); - */ - - sprintf(buf, "%g", d1); - CU_ASSERT(buf[0] != 0); - CU_ASSERT(strcmp(buf, "12.34") == 0); - - - d1 = atof("1.234e25"); - CU_ASSERT(AlmostEqualDoubles(d1, 1.234e25) == TRUE); - f1 = d1; - CU_ASSERT(AlmostEqualFloats(f1, 1.234e25, 2) == TRUE); - - sprintf(buf, "%g", d1); - CU_ASSERT(buf[0] != 0); - //printf("\nbuf=%s\n", buf); - //CU_ASSERT(strcmp(buf, "1.234e+025") == 0); - - - printf("OK\n"); -} - -/*************************************************************************************/ - -void test1() { - static const int fix_size = 512; - int i = 8768787, blobsize; - char *ptr, *p2, *ptr2; - binn *obj1, *list, *map, *obj; //, *list2=INVALID_BINN, *map2=INVALID_BINN, *obj2=INVALID_BINN; - binn value; - // test values - char vbyte, *pblob; - signed short vint16; - unsigned short vuint16; - signed int vint32; - unsigned int vuint32; - signed long long int vint64; - unsigned long long int vuint64; - - printf("testing binn 1... "); - - // CalcAllocation and CheckAllocation ------------------------------------------------- - - CU_ASSERT(CalcAllocation(512, 512) == 512); - CU_ASSERT(CalcAllocation(510, 512) == 512); - CU_ASSERT(CalcAllocation(1, 512) == 512); - CU_ASSERT(CalcAllocation(0, 512) == 512); - - CU_ASSERT(CalcAllocation(513, 512) == 1024); - CU_ASSERT(CalcAllocation(512 + CHUNK_SIZE, 512) == 1024); - CU_ASSERT(CalcAllocation(1025, 512) == 2048); - CU_ASSERT(CalcAllocation(1025, 1024) == 2048); - CU_ASSERT(CalcAllocation(2100, 1024) == 4096); - - //CU_ASSERT(CheckAllocation(xxx) == xxx); - - - // binn_new() ---------------------------------------------------------------------- - - // invalid create calls - CU_ASSERT(binn_new(-1, 0, NULL) == INVALID_BINN); - CU_ASSERT(binn_new(0, 0, NULL) == INVALID_BINN); - CU_ASSERT(binn_new(5, 0, NULL) == INVALID_BINN); - CU_ASSERT(binn_new(BINN_MAP, -1, NULL) == INVALID_BINN); - ptr = (char*) &obj1; // create a valid pointer - CU_ASSERT(binn_new(BINN_MAP, -1, ptr) == INVALID_BINN); - CU_ASSERT(binn_new(BINN_MAP, MIN_BINN_SIZE - 1, ptr) == INVALID_BINN); - - // first valid create call - obj1 = binn_new(BINN_LIST, 0, NULL); - CU_ASSERT(obj1 != INVALID_BINN); - - CU_ASSERT(obj1->header == BINN_MAGIC); - CU_ASSERT(obj1->type == BINN_LIST); - CU_ASSERT(obj1->count == 0); - CU_ASSERT(obj1->pbuf != NULL); - CU_ASSERT(obj1->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(obj1->used_size == MAX_BINN_HEADER); - CU_ASSERT(obj1->pre_allocated == FALSE); - - binn_free(obj1); - - - // valid create call - list = binn_new(BINN_LIST, 0, NULL); - CU_ASSERT(list != INVALID_BINN); - - // valid create call - map = binn_new(BINN_MAP, 0, NULL); - CU_ASSERT(map != INVALID_BINN); - - // valid create call - obj = binn_new(BINN_OBJECT, 0, NULL); - CU_ASSERT(obj != INVALID_BINN); - - CU_ASSERT(list->header == BINN_MAGIC); - CU_ASSERT(list->type == BINN_LIST); - CU_ASSERT(list->count == 0); - CU_ASSERT(list->pbuf != NULL); - CU_ASSERT(list->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(list->used_size == MAX_BINN_HEADER); - CU_ASSERT(list->pre_allocated == FALSE); - - CU_ASSERT(map->header == BINN_MAGIC); - CU_ASSERT(map->type == BINN_MAP); - CU_ASSERT(map->count == 0); - CU_ASSERT(map->pbuf != NULL); - CU_ASSERT(map->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(map->used_size == MAX_BINN_HEADER); - CU_ASSERT(map->pre_allocated == FALSE); - - CU_ASSERT(obj->header == BINN_MAGIC); - CU_ASSERT(obj->type == BINN_OBJECT); - CU_ASSERT(obj->count == 0); - CU_ASSERT(obj->pbuf != NULL); - CU_ASSERT(obj->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(obj->used_size == MAX_BINN_HEADER); - CU_ASSERT(obj->pre_allocated == FALSE); - - - // test create with pre-allocated buffer ---------------------------------------------- - - ptr = malloc(fix_size); - CU_ASSERT(ptr != NULL); - - obj1 = binn_new(BINN_OBJECT, fix_size, ptr); - CU_ASSERT(obj1 != INVALID_BINN); - - CU_ASSERT(obj1->header == BINN_MAGIC); - CU_ASSERT(obj1->type == BINN_OBJECT); - CU_ASSERT(obj1->count == 0); - CU_ASSERT(obj1->pbuf != NULL); - CU_ASSERT(obj1->alloc_size == fix_size); - CU_ASSERT(obj1->used_size == MAX_BINN_HEADER); - CU_ASSERT(obj1->pre_allocated == TRUE); - - - // add values - invalid --------------------------------------------------------------- - - CU_ASSERT(binn_map_set(list, 55001, BINN_INT32, &i, 0) == FALSE); - CU_ASSERT(binn_object_set(list, "test", BINN_INT32, &i, 0) == FALSE); - - CU_ASSERT(binn_list_add(map, BINN_INT32, &i, 0) == FALSE); - CU_ASSERT(binn_object_set(map, "test", BINN_INT32, &i, 0) == FALSE); - - CU_ASSERT(binn_list_add(obj, BINN_INT32, &i, 0) == FALSE); - CU_ASSERT(binn_map_set(obj, 55001, BINN_INT32, &i, 0) == FALSE); - - // invalid type - CU_ASSERT(binn_list_add(list, -1, &i, 0) == FALSE); - CU_ASSERT(binn_list_add(list, 0x1FFFF, &i, 0) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, -1, &i, 0) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, 0x1FFFF, &i, 0) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", -1, &i, 0) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", 0x1FFFF, &i, 0) == FALSE); - - // null pointers - CU_ASSERT(binn_list_add(list, BINN_INT8, NULL, 0) == FALSE); - CU_ASSERT(binn_list_add(list, BINN_INT16, NULL, 0) == FALSE); - CU_ASSERT(binn_list_add(list, BINN_INT32, NULL, 0) == FALSE); - CU_ASSERT(binn_list_add(list, BINN_INT64, NULL, 0) == FALSE); - //CU_ASSERT(binn_list_add(list, BINN_STRING, NULL, 0) == TRUE); //* - CU_ASSERT(binn_map_set(map, 5501, BINN_INT8, NULL, 0) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT16, NULL, 0) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT32, NULL, 0) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT64, NULL, 0) == FALSE); - //CU_ASSERT(binn_map_set(map, 5501, BINN_STRING, NULL, 0) == TRUE); //* - CU_ASSERT(binn_object_set(obj, "test", BINN_INT8, NULL, 0) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_INT16, NULL, 0) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_INT32, NULL, 0) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_INT64, NULL, 0) == FALSE); - //CU_ASSERT(binn_object_set(obj, "test", BINN_STRING, NULL, 0) == TRUE); //* - - // blobs with null pointers - CU_ASSERT(binn_list_add(list, BINN_BLOB, NULL, -1) == FALSE); - CU_ASSERT(binn_list_add(list, BINN_BLOB, NULL, 10) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_BLOB, NULL, -1) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_BLOB, NULL, 10) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_BLOB, NULL, -1) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_BLOB, NULL, 10) == FALSE); - - // blobs with negative values - CU_ASSERT(binn_list_add(list, BINN_BLOB, &i, -1) == FALSE); - CU_ASSERT(binn_list_add(list, BINN_BLOB, &i, -15) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_BLOB, &i, -1) == FALSE); - CU_ASSERT(binn_map_set(map, 5501, BINN_BLOB, &i, -15) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_BLOB, &i, -1) == FALSE); - CU_ASSERT(binn_object_set(obj, "test", BINN_BLOB, &i, -15) == FALSE); - - - // read values - invalid 1 - empty binns ------------------------------------------- - - ptr2 = binn_ptr(list); - CU_ASSERT(ptr2 != NULL); - CU_ASSERT(binn_list_get_value(ptr2, 0, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 1, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 2, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, -1, &value) == FALSE); - - ptr2 = binn_ptr(map); - CU_ASSERT(ptr2 != NULL); - CU_ASSERT(binn_list_get_value(ptr2, 0, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 1, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 2, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, -1, &value) == FALSE); - - - ptr2 = binn_ptr(obj); - CU_ASSERT(ptr2 != NULL); - CU_ASSERT(binn_list_get_value(ptr2, 0, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 1, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, 2, &value) == FALSE); - CU_ASSERT(binn_list_get_value(ptr2, -1, &value) == FALSE); - - // add values - valid ----------------------------------------------------------------- - - CU_ASSERT(binn_list_add(list, BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT32, &i, 0) == FALSE); // with the same ID - CU_ASSERT(binn_object_set(obj, "test", BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_object_set(obj, "test", BINN_INT32, &i, 0) == FALSE); // with the same name - - vbyte = (char) 255; - vint16 = -32000; - vuint16 = 65000; - vint32 = -65000000; - vuint32 = 65000000; - vint64 = -6500000000000000; - vuint64 = 6500000000000000; - blobsize = 150; - pblob = malloc(blobsize); - CU_ASSERT(pblob != NULL); - memset(pblob, 55, blobsize); - - CU_ASSERT(binn_list_add(list, BINN_NULL, 0, 0) == TRUE); // second - CU_ASSERT(binn_list_add(list, BINN_UINT8, &vbyte, 0) == TRUE); // third - CU_ASSERT(binn_list_add(list, BINN_INT16, &vint16, 0) == TRUE); // fourth - CU_ASSERT(binn_list_add(list, BINN_UINT16, &vuint16, 0) == TRUE); // fifth - CU_ASSERT(binn_list_add(list, BINN_INT32, &vint32, 0) == TRUE); // 6th - CU_ASSERT(binn_list_add(list, BINN_UINT32, &vuint32, 0) == TRUE); // 7th - CU_ASSERT(binn_list_add(list, BINN_INT64, &vint64, 0) == TRUE); // 8th - CU_ASSERT(binn_list_add(list, BINN_UINT64, &vuint64, 0) == TRUE); // 9th - CU_ASSERT(binn_list_add(list, BINN_STRING, "this is the string", 0) == TRUE); // 10th - CU_ASSERT(binn_list_add(list, BINN_BLOB, pblob, blobsize) == TRUE); // 11th - - CU_ASSERT(binn_map_set(map, 99000, BINN_NULL, 0, 0) == TRUE); // third - CU_ASSERT(binn_map_set(map, 99001, BINN_UINT8, &vbyte, 0) == TRUE); // fourth - CU_ASSERT(binn_map_set(map, 99002, BINN_INT16, &vint16, 0) == TRUE); // fifth - CU_ASSERT(binn_map_set(map, 99003, BINN_UINT16, &vuint16, 0) == TRUE); // 6th - CU_ASSERT(binn_map_set(map, 99004, BINN_INT32, &vint32, 0) == TRUE); // 7th - CU_ASSERT(binn_map_set(map, 99005, BINN_UINT32, &vuint32, 0) == TRUE); // 8th - CU_ASSERT(binn_map_set(map, 99006, BINN_INT64, &vint64, 0) == TRUE); // 9th - CU_ASSERT(binn_map_set(map, 99007, BINN_UINT64, &vuint64, 0) == TRUE); // 10th - CU_ASSERT(binn_map_set(map, 99008, BINN_STRING, "this is the string", 0) == TRUE); // 11th - CU_ASSERT(binn_map_set(map, 99009, BINN_BLOB, pblob, blobsize) == TRUE); // 12th - - CU_ASSERT(binn_object_set(obj, "key0", BINN_NULL, 0, 0) == TRUE); // third - CU_ASSERT(binn_object_set(obj, "key1", BINN_UINT8, &vbyte, 0) == TRUE); // fourth - CU_ASSERT(binn_object_set(obj, "key2", BINN_INT16, &vint16, 0) == TRUE); // fifth - CU_ASSERT(binn_object_set(obj, "key3", BINN_UINT16, &vuint16, 0) == TRUE); // 6th - CU_ASSERT(binn_object_set(obj, "key4", BINN_INT32, &vint32, 0) == TRUE); // 7th - CU_ASSERT(binn_object_set(obj, "key5", BINN_UINT32, &vuint32, 0) == TRUE); // 8th - CU_ASSERT(binn_object_set(obj, "key6", BINN_INT64, &vint64, 0) == TRUE); // 9th - CU_ASSERT(binn_object_set(obj, "key7", BINN_UINT64, &vuint64, 0) == TRUE); // 10th - CU_ASSERT(binn_object_set(obj, "key8", BINN_STRING, "this is the string", 0) == TRUE); // 11th - CU_ASSERT(binn_object_set(obj, "key9", BINN_BLOB, pblob, blobsize) == TRUE); // 12th - - // blobs with size = 0 - CU_ASSERT(binn_list_add(list, BINN_BLOB, ptr, 0) == TRUE); - CU_ASSERT(binn_list_add(list, BINN_STRING, "", 0) == TRUE); - CU_ASSERT(binn_list_add(list, BINN_STRING, "after the empty items", 0) == TRUE); - - - // add values to a fixed-size binn (pre-allocated buffer) -------------------------- - - CU_ASSERT(binn_list_add(obj1, BINN_INT32, &i, 0) == FALSE); - CU_ASSERT(binn_map_set(obj1, 55001, BINN_INT32, &i, 0) == FALSE); - - CU_ASSERT(binn_object_set(obj1, "test", BINN_UINT32, &vuint32, 0) == TRUE); - CU_ASSERT(binn_object_set(obj1, "test", BINN_UINT32, &vuint32, 0) == FALSE); // with the same name - - CU_ASSERT(binn_object_set(obj1, "key1", BINN_STRING, "this is the value", 0) == TRUE); - CU_ASSERT(binn_object_set(obj1, "key2", BINN_STRING, "the second value", 0) == TRUE); - - // create a long string buffer to make the test. the string is longer than the available space - // in the binn. - ptr2 = malloc(fix_size); - CU_ASSERT(ptr2 != NULL); - p2 = ptr2; - for (i = 0; i < fix_size - 1; i++) { - *p2 = 'A'; - p2++; - } - *p2 = '\0'; - CU_ASSERT(strlen(ptr2) == fix_size - 1); - - CU_ASSERT(binn_object_set(obj1, "v2", BINN_STRING, ptr2, - 0) == FALSE); // it fails because it uses a pre-allocated memory block - - CU_ASSERT(binn_object_set(obj, "v2", BINN_STRING, ptr2, - 0) == TRUE); // but this uses a dynamically allocated memory block, so it works with it - CU_ASSERT(binn_object_set(obj, "Key00", BINN_STRING, "after the big string", - 0) == TRUE); // and test the 'Key00' against the 'Key0' - - CU_ASSERT(binn_object_set(obj, "list", BINN_LIST, binn_ptr(list), binn_size(list)) == TRUE); - CU_ASSERT(binn_object_set(obj, "Key10", BINN_STRING, "after the list", - 0) == TRUE); // and test the 'Key10' against the 'Key1' - - - // read values - invalid 2 ------------------------------------------------------------ - - - // read keys -------------------------------------------------------------------------- - - - // binn_size - invalid and valid args -------------------------------------------- - - CU_ASSERT(binn_size(NULL) == 0); - - CU_ASSERT(binn_size(list) == list->size); - CU_ASSERT(binn_size(map) == map->size); - CU_ASSERT(binn_size(obj) == obj->size); - CU_ASSERT(binn_size(obj1) == obj1->size); - - - // destroy them all ------------------------------------------------------------------- - - binn_free(list); - binn_free(map); - binn_free(obj); - binn_free(obj1); - free(pblob); - free(ptr); - free(ptr2); - - - printf("OK\n"); -} - -/*************************************************************************************/ - -void _test2() { - binn *list = INVALID_BINN, *map = INVALID_BINN, *obj = INVALID_BINN; - binn value; - BOOL vbool; - int blobsize; - char *pblob, *pstr; - signed int vint32; - double vdouble; - - char *str_list = "test list"; - char *str_map = "test map"; - char *str_obj = "test object"; - - printf("testing binn 2"); - - blobsize = 150; - pblob = malloc(blobsize); - CU_ASSERT(pblob != NULL); - memset(pblob, 55, blobsize); - - CU_ASSERT(list == INVALID_BINN); - CU_ASSERT(map == INVALID_BINN); - CU_ASSERT(obj == INVALID_BINN); - - // add values without creating before - - CU_ASSERT(binn_list_add_int32(list, 123) == FALSE); - CU_ASSERT(binn_map_set_int32(map, 1001, 456) == FALSE); - CU_ASSERT(binn_object_set_int32(obj, "int", 789) == FALSE); - - // create the structures - - list = binn_list(); - map = binn_map(); - obj = binn_object(); - - CU_ASSERT(list != INVALID_BINN); - CU_ASSERT(map != INVALID_BINN); - CU_ASSERT(obj != INVALID_BINN); - - // add values without creating before - - CU_ASSERT(binn_list_add_int32(list, 123) == TRUE); - CU_ASSERT(binn_map_set_int32(map, 1001, 456) == TRUE); - CU_ASSERT(binn_object_set_int32(obj, "int", 789) == TRUE); - - // check the structures - - CU_ASSERT(list->header == BINN_MAGIC); - CU_ASSERT(list->type == BINN_LIST); - CU_ASSERT(list->count == 1); - CU_ASSERT(list->pbuf != NULL); - CU_ASSERT(list->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(list->used_size > MAX_BINN_HEADER); - CU_ASSERT(list->pre_allocated == FALSE); - - CU_ASSERT(map->header == BINN_MAGIC); - CU_ASSERT(map->type == BINN_MAP); - CU_ASSERT(map->count == 1); - CU_ASSERT(map->pbuf != NULL); - CU_ASSERT(map->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(map->used_size > MAX_BINN_HEADER); - CU_ASSERT(map->pre_allocated == FALSE); - - CU_ASSERT(obj->header == BINN_MAGIC); - CU_ASSERT(obj->type == BINN_OBJECT); - CU_ASSERT(obj->count == 1); - CU_ASSERT(obj->pbuf != NULL); - CU_ASSERT(obj->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(obj->used_size > MAX_BINN_HEADER); - CU_ASSERT(obj->pre_allocated == FALSE); - - - // continue adding values - - CU_ASSERT(binn_list_add_double(list, 1.23) == TRUE); - CU_ASSERT(binn_map_set_double(map, 1002, 4.56) == TRUE); - CU_ASSERT(binn_object_set_double(obj, "double", 7.89) == TRUE); - - CU_ASSERT(list->count == 2); - CU_ASSERT(map->count == 2); - CU_ASSERT(obj->count == 2); - - CU_ASSERT(binn_list_add_bool(list, TRUE) == TRUE); - CU_ASSERT(binn_map_set_bool(map, 1003, TRUE) == TRUE); - CU_ASSERT(binn_object_set_bool(obj, "bool", TRUE) == TRUE); - - CU_ASSERT(list->count == 3); - CU_ASSERT(map->count == 3); - CU_ASSERT(obj->count == 3); - - CU_ASSERT(binn_list_add_str(list, str_list) == TRUE); - CU_ASSERT(binn_map_set_str(map, 1004, str_map) == TRUE); - CU_ASSERT(binn_object_set_str(obj, "text", str_obj) == TRUE); - - CU_ASSERT(list->count == 4); - CU_ASSERT(map->count == 4); - CU_ASSERT(obj->count == 4); - - CU_ASSERT(binn_list_add_blob(list, pblob, blobsize) == TRUE); - CU_ASSERT(binn_map_set_blob(map, 1005, pblob, blobsize) == TRUE); - CU_ASSERT(binn_object_set_blob(obj, "blob", pblob, blobsize) == TRUE); - - CU_ASSERT(list->count == 5); - CU_ASSERT(map->count == 5); - CU_ASSERT(obj->count == 5); - - CU_ASSERT(binn_count(list) == 5); - CU_ASSERT(binn_count(map) == 5); - CU_ASSERT(binn_count(obj) == 5); - - CU_ASSERT(binn_size(list) == list->size); - CU_ASSERT(binn_size(map) == map->size); - CU_ASSERT(binn_size(obj) == obj->size); - - CU_ASSERT(binn_type(list) == BINN_LIST); - CU_ASSERT(binn_type(map) == BINN_MAP); - CU_ASSERT(binn_type(obj) == BINN_OBJECT); - - - // try to read them - - // integer - - CU_ASSERT(binn_list_get_value(list, 1, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.allocated == FALSE); - - CU_ASSERT(value.type == BINN_UINT8); - CU_ASSERT(value.ptr != &value.vuint8); // it must return a pointer to the byte in the buffer - - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vint == 123); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_map_get_value(map, 1001, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - - CU_ASSERT(value.type == BINN_UINT16); - CU_ASSERT(value.ptr == &value.vuint16); - - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vint == 456); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_object_get_value(obj, "int", &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - - CU_ASSERT(value.type == BINN_UINT16); - CU_ASSERT(value.ptr == &value.vuint16); - - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vint == 789); - - memset(&value, 0, sizeof(binn)); - - - // double - - CU_ASSERT(binn_list_get_value(list, 2, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vdouble == 1.23); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_map_get_value(map, 1002, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vdouble == 4.56); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_object_get_value(obj, "double", &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vdouble == 7.89); - - memset(&value, 0, sizeof(binn)); - - - // bool - - CU_ASSERT(binn_list_get_value(list, 3, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vbool == TRUE); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_map_get_value(map, 1003, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vbool == TRUE); - - CU_ASSERT(binn_object_get_value(obj, "bool", &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.ptr == &value.vint); - CU_ASSERT(value.size == 0); - CU_ASSERT(value.count == 0); - CU_ASSERT(value.vbool == TRUE); - - memset(&value, 0, sizeof(binn)); - - - // string - - CU_ASSERT(binn_list_get_value(list, 4, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == strlen(str_list)); - CU_ASSERT(strcmp(value.ptr, str_list) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_map_get_value(map, 1004, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(value.size == strlen(str_map)); - CU_ASSERT(strcmp(value.ptr, str_map) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_object_get_value(obj, "text", &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(value.size == strlen(str_obj)); - CU_ASSERT(strcmp(value.ptr, str_obj) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - - // blob - - CU_ASSERT(binn_list_get_value(list, 5, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_map_get_value(map, 1005, &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - CU_ASSERT(binn_object_get_value(obj, "blob", &value) == TRUE); - - CU_ASSERT(value.header == BINN_MAGIC); - CU_ASSERT(value.writable == FALSE); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - CU_ASSERT(value.count == 0); - - memset(&value, 0, sizeof(binn)); - - - // read with other interface - - CU_ASSERT(binn_list_get_int32(list, 1, &vint32) == TRUE); - CU_ASSERT(vint32 == 123); - - CU_ASSERT(binn_map_get_int32(map, 1001, &vint32) == TRUE); - CU_ASSERT(vint32 == 456); - - CU_ASSERT(binn_object_get_int32(obj, "int", &vint32) == TRUE); - CU_ASSERT(vint32 == 789); - - // double - - CU_ASSERT(binn_list_get_double(list, 2, &vdouble) == TRUE); - CU_ASSERT(vdouble == 1.23); - - CU_ASSERT(binn_map_get_double(map, 1002, &vdouble) == TRUE); - CU_ASSERT(vdouble == 4.56); - - CU_ASSERT(binn_object_get_double(obj, "double", &vdouble) == TRUE); - CU_ASSERT(vdouble == 7.89); - - // bool - - CU_ASSERT(binn_list_get_bool(list, 3, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - - CU_ASSERT(binn_map_get_bool(map, 1003, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - - CU_ASSERT(binn_object_get_bool(obj, "bool", &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - - // string - - CU_ASSERT(binn_list_get_str(list, 4, &pstr) == TRUE); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_list) == 0); - - CU_ASSERT(binn_map_get_str(map, 1004, &pstr) == TRUE); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_map) == 0); - - CU_ASSERT(binn_object_get_str(obj, "text", &pstr) == TRUE); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_obj) == 0); - - // blob - - value.ptr = 0; - value.size = 0; - CU_ASSERT(binn_list_get_blob(list, 5, &value.ptr, &value.size) == TRUE); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - value.ptr = 0; - value.size = 0; - CU_ASSERT(binn_map_get_blob(map, 1005, &value.ptr, &value.size) == TRUE); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - value.ptr = 0; - value.size = 0; - CU_ASSERT(binn_object_get_blob(obj, "blob", &value.ptr, &value.size) == TRUE); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - - // read with other interface - - CU_ASSERT(binn_list_int32(list, 1) == 123); - CU_ASSERT(binn_map_int32(map, 1001) == 456); - CU_ASSERT(binn_object_int32(obj, "int") == 789); - - // double - - CU_ASSERT(binn_list_double(list, 2) == 1.23); - CU_ASSERT(binn_map_double(map, 1002) == 4.56); - CU_ASSERT(binn_object_double(obj, "double") == 7.89); - - // bool - - CU_ASSERT(binn_list_bool(list, 3) == TRUE); - CU_ASSERT(binn_map_bool(map, 1003) == TRUE); - CU_ASSERT(binn_object_bool(obj, "bool") == TRUE); - - // string - - pstr = binn_list_str(list, 4); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_list) == 0); - - pstr = binn_map_str(map, 1004); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_map) == 0); - - pstr = binn_object_str(obj, "text"); - CU_ASSERT(pstr != 0); - CU_ASSERT(strcmp(pstr, str_obj) == 0); - - // blob - - value.ptr = binn_list_blob(list, 5, &value.size); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - value.ptr = binn_map_blob(map, 1005, &value.size); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - value.ptr = binn_object_blob(obj, "blob", &value.size); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(value.size == blobsize); - CU_ASSERT(memcmp(value.ptr, pblob, blobsize) == 0); - - - binn_free(list); - binn_free(map); - binn_free(obj); - - - free(pblob); - - printf("OK\n"); -} - -void test2() { - _test2(); -} - -/*************************************************************************************/ - -void test4() { - static const int fix_size = 512; - int i, id, type, count, size, header_size, blobsize; - char *ptr, *p2, *pstr, key[256]; - binn *list, *map, *obj, *obj1; - binn value; - // test values - char vbyte, *pblob; - signed short vint16, *pint16; - unsigned short vuint16, *puint16; - signed int vint32, *pint32; - unsigned int vuint32, *puint32; - signed long long int vint64, *pint64; - unsigned long long int vuint64, *puint64; - - printf("testing binn 3... "); - - list = binn_list(); - CU_ASSERT(list != INVALID_BINN); - - map = binn_map(); - CU_ASSERT(map != INVALID_BINN); - - obj = binn_object(); - CU_ASSERT(obj != INVALID_BINN); - - CU_ASSERT(list->header == BINN_MAGIC); - CU_ASSERT(list->type == BINN_LIST); - CU_ASSERT(list->count == 0); - CU_ASSERT(list->pbuf != NULL); - CU_ASSERT(list->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(list->used_size == MAX_BINN_HEADER); - CU_ASSERT(list->pre_allocated == FALSE); - - CU_ASSERT(map->header == BINN_MAGIC); - CU_ASSERT(map->type == BINN_MAP); - CU_ASSERT(map->count == 0); - CU_ASSERT(map->pbuf != NULL); - CU_ASSERT(map->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(map->used_size == MAX_BINN_HEADER); - CU_ASSERT(map->pre_allocated == FALSE); - - CU_ASSERT(obj->header == BINN_MAGIC); - CU_ASSERT(obj->type == BINN_OBJECT); - CU_ASSERT(obj->count == 0); - CU_ASSERT(obj->pbuf != NULL); - CU_ASSERT(obj->alloc_size > MAX_BINN_HEADER); - CU_ASSERT(obj->used_size == MAX_BINN_HEADER); - CU_ASSERT(obj->pre_allocated == FALSE); - - - // test create with pre-allocated buffer ---------------------------------------------- - - ptr = malloc(fix_size); - CU_ASSERT(ptr != NULL); - - obj1 = binn_new(BINN_OBJECT, fix_size, ptr); - CU_ASSERT(obj1 != INVALID_BINN); - - CU_ASSERT(obj1->header == BINN_MAGIC); - CU_ASSERT(obj1->type == BINN_OBJECT); - CU_ASSERT(obj1->count == 0); - CU_ASSERT(obj1->pbuf != NULL); - CU_ASSERT(obj1->alloc_size == fix_size); - CU_ASSERT(obj1->used_size == MAX_BINN_HEADER); - CU_ASSERT(obj1->pre_allocated == TRUE); - - - // add values - invalid --------------------------------------------------------------- - - - // read values - invalid 1 - empty binns ------------------------------------------- - - ptr = binn_ptr(list); - CU_ASSERT(ptr != NULL); - CU_ASSERT(binn_list_read(ptr, 0, &type, &size) == NULL); - CU_ASSERT(binn_list_read(ptr, 1, &type, &size) == NULL); - CU_ASSERT(binn_list_read(ptr, 2, &type, &size) == NULL); - CU_ASSERT(binn_list_read(ptr, -1, &type, &size) == NULL); - - ptr = binn_ptr(map); - CU_ASSERT(ptr != NULL); - CU_ASSERT(binn_map_read(ptr, 0, &type, &size) == NULL); - CU_ASSERT(binn_map_read(ptr, 55001, &type, &size) == NULL); - CU_ASSERT(binn_map_read(ptr, -1, &type, &size) == NULL); - - ptr = binn_ptr(obj); - CU_ASSERT(ptr != NULL); - CU_ASSERT(binn_object_read(ptr, NULL, &type, &size) == NULL); - CU_ASSERT(binn_object_read(ptr, "", &type, &size) == NULL); - CU_ASSERT(binn_object_read(ptr, "test", &type, &size) == NULL); - - - // add values - valid ----------------------------------------------------------------- - - CU_ASSERT(binn_list_add(list, BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_map_set(map, 5501, BINN_INT32, &i, 0) == FALSE); // with the same ID - CU_ASSERT(binn_object_set(obj, "test", BINN_INT32, &i, 0) == TRUE); - CU_ASSERT(binn_object_set(obj, "test", BINN_INT32, &i, 0) == FALSE); // with the same name - - vbyte = (char) 255; - vint16 = -32000; - vuint16 = 65000; - vint32 = -65000000; - vuint32 = 65000000; - vint64 = -6500000000000000; - vuint64 = 6500000000000000; - blobsize = 150; - pblob = malloc(blobsize); - CU_ASSERT(pblob != NULL); - memset(pblob, 55, blobsize); - - CU_ASSERT(binn_list_add(list, BINN_NULL, 0, 0) == TRUE); // second - CU_ASSERT(binn_list_add(list, BINN_UINT8, &vbyte, 0) == TRUE); // third - CU_ASSERT(binn_list_add(list, BINN_INT16, &vint16, 0) == TRUE); // fourth - CU_ASSERT(binn_list_add(list, BINN_UINT16, &vuint16, 0) == TRUE); // fifth - CU_ASSERT(binn_list_add(list, BINN_INT32, &vint32, 0) == TRUE); // 6th - CU_ASSERT(binn_list_add(list, BINN_UINT32, &vuint32, 0) == TRUE); // 7th - CU_ASSERT(binn_list_add(list, BINN_INT64, &vint64, 0) == TRUE); // 8th - CU_ASSERT(binn_list_add(list, BINN_UINT64, &vuint64, 0) == TRUE); // 9th - CU_ASSERT(binn_list_add(list, BINN_STRING, "this is the string", 0) == TRUE); // 10th - CU_ASSERT(binn_list_add(list, BINN_BLOB, pblob, blobsize) == TRUE); // 11th - - CU_ASSERT(binn_map_set(map, 99000, BINN_NULL, 0, 0) == TRUE); // third - CU_ASSERT(binn_map_set(map, 99001, BINN_UINT8, &vbyte, 0) == TRUE); // fourth - CU_ASSERT(binn_map_set(map, 99002, BINN_INT16, &vint16, 0) == TRUE); // fifth - CU_ASSERT(binn_map_set(map, 99003, BINN_UINT16, &vuint16, 0) == TRUE); // 6th - CU_ASSERT(binn_map_set(map, 99004, BINN_INT32, &vint32, 0) == TRUE); // 7th - CU_ASSERT(binn_map_set(map, 99005, BINN_UINT32, &vuint32, 0) == TRUE); // 8th - CU_ASSERT(binn_map_set(map, 99006, BINN_INT64, &vint64, 0) == TRUE); // 9th - CU_ASSERT(binn_map_set(map, 99007, BINN_UINT64, &vuint64, 0) == TRUE); // 10th - CU_ASSERT(binn_map_set(map, 99008, BINN_STRING, "this is the string", 0) == TRUE); // 11th - CU_ASSERT(binn_map_set(map, 99009, BINN_BLOB, pblob, blobsize) == TRUE); // 12th - - CU_ASSERT(binn_object_set(obj, "key0", BINN_NULL, 0, 0) == TRUE); // third - CU_ASSERT(binn_object_set(obj, "key1", BINN_UINT8, &vbyte, 0) == TRUE); // fourth - CU_ASSERT(binn_object_set(obj, "key2", BINN_INT16, &vint16, 0) == TRUE); // fifth - CU_ASSERT(binn_object_set(obj, "key3", BINN_UINT16, &vuint16, 0) == TRUE); // 6th - CU_ASSERT(binn_object_set(obj, "key4", BINN_INT32, &vint32, 0) == TRUE); // 7th - CU_ASSERT(binn_object_set(obj, "key5", BINN_UINT32, &vuint32, 0) == TRUE); // 8th - CU_ASSERT(binn_object_set(obj, "key6", BINN_INT64, &vint64, 0) == TRUE); // 9th - CU_ASSERT(binn_object_set(obj, "key7", BINN_UINT64, &vuint64, 0) == TRUE); // 10th - CU_ASSERT(binn_object_set(obj, "key8", BINN_STRING, "this is the string", 0) == TRUE); // 11th - CU_ASSERT(binn_object_set(obj, "key9", BINN_BLOB, pblob, blobsize) == TRUE); // 12th - - // blobs with size = 0 - CU_ASSERT(binn_list_add(list, BINN_BLOB, ptr, 0) == TRUE); - CU_ASSERT(binn_list_add(list, BINN_STRING, "", 0) == TRUE); - CU_ASSERT(binn_list_add(list, BINN_STRING, "after the empty items", 0) == TRUE); - - - // add values to a fixed-size binn (pre-allocated buffer) -------------------------- - - CU_ASSERT(binn_list_add(obj1, BINN_INT32, &i, 0) == FALSE); - CU_ASSERT(binn_map_set(obj1, 55001, BINN_INT32, &i, 0) == FALSE); - - CU_ASSERT(binn_object_set(obj1, "test", BINN_UINT32, &vuint32, 0) == TRUE); - CU_ASSERT(binn_object_set(obj1, "test", BINN_UINT32, &vuint32, 0) == FALSE); // with the same name - - CU_ASSERT(binn_object_set(obj1, "key1", BINN_STRING, "this is the value", 0) == TRUE); - CU_ASSERT(binn_object_set(obj1, "key2", BINN_STRING, "the second value", 0) == TRUE); - - // create a long string buffer to make the test. the string is longer than the available space - // in the binn. - ptr = malloc(fix_size); - CU_ASSERT(ptr != NULL); - p2 = ptr; - for (i = 0; i < fix_size - 1; i++) { - *p2 = 'A'; - p2++; - } - *p2 = '\0'; - CU_ASSERT(strlen(ptr) == fix_size - 1); - - CU_ASSERT(binn_object_set(obj1, "v2", BINN_STRING, ptr, - 0) == FALSE); // it fails because it uses a pre-allocated memory block - - CU_ASSERT(binn_object_set(obj, "v2", BINN_STRING, ptr, - 0) == TRUE); // but this uses a dynamically allocated memory block, so it works with it - CU_ASSERT(binn_object_set(obj, "Key00", BINN_STRING, "after the big string", - 0) == TRUE); // and test the 'Key00' against the 'Key0' - - free(ptr); - ptr = 0; - - CU_ASSERT(binn_object_set(obj, "list", BINN_LIST, binn_ptr(list), binn_size(list)) == TRUE); - CU_ASSERT(binn_object_set(obj, "Key10", BINN_STRING, "after the list", - 0) == TRUE); // and test the 'Key10' against the 'Key1' - - - // read values - invalid 2 ------------------------------------------------------------ - - - // read keys -------------------------------------------------------------------------- - - ptr = binn_ptr(map); - CU_ASSERT(ptr != NULL); - - CU_ASSERT(binn_map_get_pair(ptr, -1, &id, &value) == FALSE); - CU_ASSERT(binn_map_get_pair(ptr, 0, &id, &value) == FALSE); - - CU_ASSERT(binn_map_get_pair(ptr, 1, &id, &value) == TRUE); - CU_ASSERT(id == 5501); - CU_ASSERT(binn_map_get_pair(ptr, 2, &id, &value) == TRUE); - CU_ASSERT(id == 99000); - CU_ASSERT(binn_map_get_pair(ptr, 3, &id, &value) == TRUE); - CU_ASSERT(id == 99001); - CU_ASSERT(binn_map_get_pair(ptr, 10, &id, &value) == TRUE); - CU_ASSERT(id == 99008); - CU_ASSERT(binn_map_get_pair(ptr, 11, &id, &value) == TRUE); - CU_ASSERT(id == 99009); - - - ptr = binn_ptr(obj); - CU_ASSERT(ptr != NULL); - - CU_ASSERT(binn_object_get_pair(ptr, -1, key, &value) == FALSE); - CU_ASSERT(binn_object_get_pair(ptr, 0, key, &value) == FALSE); - - CU_ASSERT(binn_object_get_pair(ptr, 1, key, &value) == TRUE); - CU_ASSERT(strcmp(key, "test") == 0); - CU_ASSERT(binn_object_get_pair(ptr, 2, key, &value) == TRUE); - CU_ASSERT(strcmp(key, "key0") == 0); - CU_ASSERT(binn_object_get_pair(ptr, 3, key, &value) == TRUE); - CU_ASSERT(strcmp(key, "key1") == 0); - CU_ASSERT(binn_object_get_pair(ptr, 10, key, &value) == TRUE); - CU_ASSERT(strcmp(key, "key8") == 0); - CU_ASSERT(binn_object_get_pair(ptr, 11, key, &value) == TRUE); - CU_ASSERT(strcmp(key, "key9") == 0); - - - // read values - valid ---------------------------------------------------------------- - - ptr = binn_ptr(obj1); - CU_ASSERT(ptr != NULL); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key1", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "this is the value") == 0); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key2", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "the second value") == 0); - - type = 0; - size = 0; - pint32 = binn_object_read(ptr, "test", &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_UINT32); - //CU_ASSERT(size > 0); - CU_ASSERT(*pint32 == vuint32); - - - ptr = binn_ptr(list); - CU_ASSERT(ptr != NULL); - - type = 0; - size = 0; - pstr = binn_list_read(ptr, 2, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_NULL); - //CU_ASSERT(size > 0); - //CU_ASSERT(strcmp(pstr, "this is the value") == 0); - - type = 0; - size = 0; - p2 = binn_list_read(ptr, 3, &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_UINT8); - CU_ASSERT(*p2 == vbyte); - - type = 0; - size = 0; - pint16 = binn_list_read(ptr, 4, &type, &size); - CU_ASSERT(pint16 != NULL); - CU_ASSERT(type == BINN_INT16); - CU_ASSERT(*pint16 == vint16); - - type = 0; - size = 0; - puint16 = binn_list_read(ptr, 5, &type, &size); - CU_ASSERT(puint16 != NULL); - CU_ASSERT(type == BINN_UINT16); - CU_ASSERT(*puint16 == vuint16); - - type = 0; - size = 0; - pint32 = binn_list_read(ptr, 6, &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - // in the second time the value must be the same... - type = 0; - size = 0; - pint32 = binn_list_read(ptr, 6, &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - - type = 0; - size = 0; - puint32 = binn_list_read(ptr, 7, &type, &size); - CU_ASSERT(puint32 != NULL); - CU_ASSERT(type == BINN_UINT32); - CU_ASSERT(*puint32 == vuint32); - - type = 0; - size = 0; - pint64 = binn_list_read(ptr, 8, &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - // in the second time the value must be the same... - type = 0; - size = 0; - pint64 = binn_list_read(ptr, 8, &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - - type = 0; - size = 0; - puint64 = binn_list_read(ptr, 9, &type, &size); - CU_ASSERT(puint64 != NULL); - CU_ASSERT(type == BINN_UINT64); - CU_ASSERT(*puint64 == vuint64); - - type = 0; - size = 0; - pstr = binn_list_read(ptr, 10, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "this is the string") == 0); - - type = 0; - size = 0; - p2 = binn_list_read(ptr, 11, &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_BLOB); - CU_ASSERT(size == blobsize); - CU_ASSERT(memcmp(p2, pblob, blobsize) == 0); - - - ptr = binn_ptr(map); - CU_ASSERT(ptr != NULL); - - type = 0; - size = 0; - pstr = binn_map_read(ptr, 99000, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_NULL); - //CU_ASSERT(size > 0); - //CU_ASSERT(strcmp(pstr, "this is the value") == 0); - - type = 0; - size = 0; - p2 = binn_map_read(ptr, 99001, &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_UINT8); - CU_ASSERT(*p2 == vbyte); - - type = 0; - size = 0; - pint16 = binn_map_read(ptr, 99002, &type, &size); - CU_ASSERT(pint16 != NULL); - CU_ASSERT(type == BINN_INT16); - CU_ASSERT(*pint16 == vint16); - - type = 0; - size = 0; - puint16 = binn_map_read(ptr, 99003, &type, &size); - CU_ASSERT(puint16 != NULL); - CU_ASSERT(type == BINN_UINT16); - CU_ASSERT(*puint16 == vuint16); - - type = 0; - size = 0; - pint32 = binn_map_read(ptr, 99004, &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - // in the second time the value must be the same... - type = 0; - size = 0; - pint32 = binn_map_read(ptr, 99004, &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - - type = 0; - size = 0; - puint32 = binn_map_read(ptr, 99005, &type, &size); - CU_ASSERT(puint32 != NULL); - CU_ASSERT(type == BINN_UINT32); - CU_ASSERT(*puint32 == vuint32); - - type = 0; - size = 0; - pint64 = binn_map_read(ptr, 99006, &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - // in the second time the value must be the same... - type = 0; - size = 0; - pint64 = binn_map_read(ptr, 99006, &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - - type = 0; - size = 0; - puint64 = binn_map_read(ptr, 99007, &type, &size); - CU_ASSERT(puint64 != NULL); - CU_ASSERT(type == BINN_UINT64); - CU_ASSERT(*puint64 == vuint64); - - type = 0; - size = 0; - pstr = binn_map_read(ptr, 99008, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "this is the string") == 0); - - type = 0; - size = 0; - p2 = binn_map_read(ptr, 99009, &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_BLOB); - CU_ASSERT(size == blobsize); - CU_ASSERT(memcmp(p2, pblob, blobsize) == 0); - - - ptr = binn_ptr(obj); - CU_ASSERT(ptr != NULL); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key0", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_NULL); - //CU_ASSERT(size > 0); - //CU_ASSERT(strcmp(pstr, "this is the value") == 0); - - type = 0; - size = 0; - p2 = binn_object_read(ptr, "key1", &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_UINT8); - CU_ASSERT(*p2 == vbyte); - - type = 0; - size = 0; - pint16 = binn_object_read(ptr, "key2", &type, &size); - CU_ASSERT(pint16 != NULL); - CU_ASSERT(type == BINN_INT16); - CU_ASSERT(*pint16 == vint16); - - type = 0; - size = 0; - puint16 = binn_object_read(ptr, "key3", &type, &size); - CU_ASSERT(puint16 != NULL); - CU_ASSERT(type == BINN_UINT16); - CU_ASSERT(*puint16 == vuint16); - - type = 0; - size = 0; - pint32 = binn_object_read(ptr, "key4", &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - // in the second time the value must be the same... - type = 0; - size = 0; - pint32 = binn_object_read(ptr, "key4", &type, &size); - CU_ASSERT(pint32 != NULL); - CU_ASSERT(type == BINN_INT32); - CU_ASSERT(*pint32 == vint32); - - type = 0; - size = 0; - puint32 = binn_object_read(ptr, "key5", &type, &size); - CU_ASSERT(puint32 != NULL); - CU_ASSERT(type == BINN_UINT32); - CU_ASSERT(*puint32 == vuint32); - - type = 0; - size = 0; - pint64 = binn_object_read(ptr, "key6", &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - // in the second time the value must be the same... - type = 0; - size = 0; - pint64 = binn_object_read(ptr, "key6", &type, &size); - CU_ASSERT(pint64 != NULL); - CU_ASSERT(type == BINN_INT64); - CU_ASSERT(*pint64 == vint64); - - type = 0; - size = 0; - puint64 = binn_object_read(ptr, "key7", &type, &size); - CU_ASSERT(puint64 != NULL); - CU_ASSERT(type == BINN_UINT64); - CU_ASSERT(*puint64 == vuint64); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key8", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "this is the string") == 0); - - type = 0; - size = 0; - p2 = binn_object_read(ptr, "key9", &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_BLOB); - CU_ASSERT(size == blobsize); - CU_ASSERT(memcmp(p2, pblob, blobsize) == 0); - - type = 0; - size = 0; - p2 = binn_object_read(ptr, "v2", &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size == fix_size - 1); - CU_ASSERT(strlen(p2) == fix_size - 1); - CU_ASSERT(p2[0] == 'A'); - CU_ASSERT(p2[1] == 'A'); - CU_ASSERT(p2[500] == 'A'); - CU_ASSERT(p2[fix_size - 1] == 0); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key00", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "after the big string") == 0); - - type = 0; - size = 0; - p2 = binn_object_read(ptr, "list", &type, &size); - CU_ASSERT(p2 != NULL); - CU_ASSERT(type == BINN_LIST); - CU_ASSERT(size > 0); - // - type = 0; - size = 0; - puint64 = binn_list_read(p2, 9, &type, &size); - CU_ASSERT(puint64 != NULL); - CU_ASSERT(type == BINN_UINT64); - CU_ASSERT(*puint64 == vuint64); - // - type = 0; - size = 0; - pstr = binn_list_read(p2, 10, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "this is the string") == 0); - // - type = 0; - size = 0; - pstr = binn_list_read(p2, 12, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_BLOB); // empty blob - CU_ASSERT(size == 0); - // - type = 0; - size = 0; - pstr = binn_list_read(p2, 13, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); // empty string - CU_ASSERT(size == 0); - CU_ASSERT(strcmp(pstr, "") == 0); - // - type = 0; - size = 0; - pstr = binn_list_read(p2, 14, &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "after the empty items") == 0); - - type = 0; - size = 0; - pstr = binn_object_read(ptr, "key10", &type, &size); - CU_ASSERT(pstr != NULL); - CU_ASSERT(type == BINN_STRING); - CU_ASSERT(size > 0); - CU_ASSERT(strcmp(pstr, "after the list") == 0); - - - // binn_ptr, IsValidBinnHeader, binn_is_valid... - // also with invalid/null pointers, with pointers containing invalid data... - - CU_ASSERT(binn_ptr(NULL) == NULL); - // pointers to invalid data - //CU_ASSERT(binn_ptr(&type) == NULL); - //CU_ASSERT(binn_ptr(&size) == NULL); - //CU_ASSERT(binn_ptr(&count) == NULL); - //CU_ASSERT(binn_is_valid_header(NULL) == FALSE); - - ptr = binn_ptr(obj); - CU_ASSERT(ptr != NULL); - // test the header - size = 0; - CU_ASSERT(binn_is_valid_header(ptr, &type, &count, &size, &header_size) == TRUE); - CU_ASSERT(type == BINN_OBJECT); - CU_ASSERT(count == 15); - CU_ASSERT(header_size >= MIN_BINN_SIZE && header_size <= MAX_BINN_HEADER); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == obj->size); - // test all the buffer - CU_ASSERT(binn_is_valid(ptr, &type, &count, &size) == TRUE); - CU_ASSERT(type == BINN_OBJECT); - CU_ASSERT(count == 15); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == obj->size); - - ptr = binn_ptr(map); - CU_ASSERT(ptr != NULL); - // test the header - size = 0; - CU_ASSERT(binn_is_valid_header(ptr, &type, &count, &size, &header_size) == TRUE); - CU_ASSERT(type == BINN_MAP); - CU_ASSERT(count == 11); - CU_ASSERT(header_size >= MIN_BINN_SIZE && header_size <= MAX_BINN_HEADER); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == map->size); - // test all the buffer - CU_ASSERT(binn_is_valid(ptr, &type, &count, &size) == TRUE); - CU_ASSERT(type == BINN_MAP); - CU_ASSERT(count == 11); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == map->size); - - ptr = binn_ptr(list); - CU_ASSERT(ptr != NULL); - // test the header - size = 0; - CU_ASSERT(binn_is_valid_header(ptr, &type, &count, &size, &header_size) == TRUE); - CU_ASSERT(type == BINN_LIST); - CU_ASSERT(count == 14); - CU_ASSERT(header_size >= MIN_BINN_SIZE && header_size <= MAX_BINN_HEADER); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == list->size); - // test all the buffer - CU_ASSERT(binn_is_valid(ptr, &type, &count, &size) == TRUE); - CU_ASSERT(type == BINN_LIST); - CU_ASSERT(count == 14); - CU_ASSERT(header_size >= MIN_BINN_SIZE && header_size <= MAX_BINN_HEADER); - CU_ASSERT(size > MIN_BINN_SIZE); - CU_ASSERT(size == list->size); - - - // binn_size - invalid and valid args -------------------------------------------- - - CU_ASSERT(binn_size(NULL) == 0); - - CU_ASSERT(binn_size(list) == list->size); - CU_ASSERT(binn_size(map) == map->size); - CU_ASSERT(binn_size(obj) == obj->size); - CU_ASSERT(binn_size(obj1) == obj1->size); - - - // destroy them all ------------------------------------------------------------------- - - binn_free(list); - binn_free(map); - binn_free(obj); - - printf("OK\n"); -} - -/*************************************************************************************/ - -void test_invalid_binn() { - - unsigned char buffers[][20] = { - { 0xE0 }, - { 0xE0, 0x7E}, - { 0xE0, 0x7E, 0x7F}, - { 0xE0, 0x7E, 0x7F, 0x12}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0x01}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0x7F}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0x01}, - { 0xE0, 0x7E, 0x7F, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0xFF}, - { 0xE0, 0x7E, 0xFF, 0x12}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0x01}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0x7F}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0x01}, - { 0xE0, 0x7E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x8E}, - { 0xE0, 0x8E, 0xFF}, - { 0xE0, 0x8E, 0xFF, 0x12}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0x01}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0x7F}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF, 0xFF}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0x01}, - { 0xE0, 0x8E, 0xFF, 0x12, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} - }; - - int count, size, i; - unsigned char *ptr; - - puts("testing invalid binn buffers..."); - - count = sizeof buffers / sizeof buffers[0]; - - for (i = 0; i < count; i++) { - ptr = buffers[i]; - size = strlen((char*) ptr); - printf("checking invalid binn #%d size: %d bytes\n", i, size); - CU_ASSERT(binn_is_valid_ex(ptr, NULL, NULL, &size) == FALSE); - } - - puts("OK"); -} - -int main() { - CU_pSuite pSuite = NULL; - if (CUE_SUCCESS != CU_initialize_registry()) { - return CU_get_error(); - } - pSuite = CU_add_suite("jbl_test_binn1", init_suite, clean_suite); - if (NULL == pSuite) { - CU_cleanup_registry(); - return CU_get_error(); - } - if ( (NULL == CU_add_test(pSuite, "test_int64", test_int64)) - || (NULL == CU_add_test(pSuite, "test_floating_point_numbers", test_floating_point_numbers)) - || (NULL == CU_add_test(pSuite, "test1", test1)) - || (NULL == CU_add_test(pSuite, "test2", test2)) - || (NULL == CU_add_test(pSuite, "test_invalid_binn", test_invalid_binn))) { - CU_cleanup_registry(); - return CU_get_error(); - } - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - int ret = CU_get_error() || CU_get_number_of_failures(); - CU_cleanup_registry(); - return ret; -} diff --git a/src/jbl/tests/jbl_test_binn2.c b/src/jbl/tests/jbl_test_binn2.c deleted file mode 100644 index adf88d727..000000000 --- a/src/jbl/tests/jbl_test_binn2.c +++ /dev/null @@ -1,2466 +0,0 @@ -#include "ejdb2.h" -#include "jbl.h" -#include "jbl_internal.h" -#include -#include -#include - -#define INT64_FORMAT PRId64 -#define UINT64_FORMAT PRIu64 -#define INT64_HEX_FORMAT PRIx64 - -typedef unsigned short int u16; -typedef unsigned int u32; -typedef unsigned long long int u64; - -int init_suite(void) { - int rc = ejdb_init(); - return rc; -} - -int clean_suite(void) { - return 0; -} - -#ifdef _MSC_VER -#define snprintf _snprintf -#endif - -int MY_DATE; -int MY_CURRENCY; - -char tmp[128]; - -void *memdup(const void *mem, size_t size) { - void *out = malloc(size); - - if (out != NULL) { - memcpy(out, mem, size); - } - - return out; -} - -char *i64toa(int64 val, char *buf) { - iwitoa(val, buf, 127); - return buf; -} - -#ifdef _MSC_VER -#define atoi64 _atoi64 -#else -int64 atoi64(char *str); - -#endif - -BOOL AlmostEqualFloats(float A, float B, int maxUlps); - -/*************************************************************************************/ - -int vint32; -unsigned int vuint32; -int64 vint64; -uint64 vuint64; -short vint16; -unsigned short vuint16; -signed char vint8; -unsigned char vuint8; -float vfloat32; -double vfloat64; -BOOL vbool; - -/*************************************************************************************/ - -char *stripchr(char *mainstr, int separator) { - char *ptr; - - if (mainstr == NULL) { - return NULL; - } - - ptr = strchr(mainstr, separator); - if (ptr == 0) { - return NULL; - } - ptr[0] = '\0'; - ptr++; - return ptr; -} - -/*************************************************************************************/ -// MY_DATE -// day: 1-31 -> 2^5 -> 5 bits -// month: 1-12 -> 2^4 -> 4 bits -// year: 16 - 9 bits = 7 bits -> 2^7=128 - from 1900 to 2028 - -unsigned short str_to_date(char *datestr) { - unsigned short date; - int day, month, year; - char *next; - - if (datestr == NULL) { - return 0; - } - strcpy(tmp, datestr); - datestr = tmp; - - next = stripchr(datestr, '-'); - year = atoi(datestr) - 1900; - - datestr = next; - next = stripchr(datestr, '-'); - month = atoi(datestr); - - day = atoi(next); - - date = (day << 11) | (month << 7) | year; - return date; -} - -/*************************************************************************************/ - -char *date_to_str(unsigned short date) { - int day, month, year; - //char *datestr; - - day = ((date & 0xf800) >> 11); - month = ((date & 0x0780) >> 7); - year = (date & 0x007f); - - sprintf(tmp, "%.4d-%.2d-%.2d", year + 1900, month, day); - - return tmp; -} - -/*************************************************************************************/ -// MY_CURRENCY -// 00000000.0000 <- fixed point - -#define CURRENCY_DECIMAL_DIGITS 4 -#define CURRENCY_DECIMAL_DIGITS_STR "0000" -#define CURRENCY_FACTOR 10000 - -int64 str_to_currency(char *str) { - char *next; - int size, i; - - if (str == NULL) { - return 0; - } - strcpy(tmp, str); - str = tmp; - - next = strchr(str, '.'); - if (next) { - size = strlen(next + 1); - memmove(next, next + 1, size + 1); // include the null terminator - if (size <= CURRENCY_DECIMAL_DIGITS) { - size = CURRENCY_DECIMAL_DIGITS - size; - for (i = 0; i < size; i++) strcat(str, "0"); - } else { - next[CURRENCY_DECIMAL_DIGITS] = 0; // puts a null terminator - } - } else { - strcat(str, CURRENCY_DECIMAL_DIGITS_STR); - } - - return atoi64(str); -} - -/*************************************************************************************/ - -char *currency_to_str(int64 value) { - char *str, *ptr; - int size, move, i; - - i64toa(value, tmp); - str = tmp; - - size = strlen(str); - if (size > CURRENCY_DECIMAL_DIGITS) { - ptr = str + size - CURRENCY_DECIMAL_DIGITS; - memmove(ptr + 1, ptr, CURRENCY_DECIMAL_DIGITS + 1); // include the null terminator - ptr[0] = '.'; // include the point - } else { - move = 2 + CURRENCY_DECIMAL_DIGITS - size; - memmove(str + move, str, size + 1); // include the null terminator - str[0] = '0'; // include the zero - str[1] = '.'; // include the point - for (i = 2; i < move; i++) str[i] = '0'; - } - - return str; -} - -/*************************************************************************************/ - -int64 float_to_currency(double value) { - char buf[128]; - - snprintf(buf, 127, "%.4f", value); - - return str_to_currency(buf); -} - -/*************************************************************************************/ - -double currency_to_float(int64 value) { - - currency_to_str(value); - - return atof(tmp); -} - -/*************************************************************************************/ - -int64 mul_currency(int64 value1, int64 value2) { - return value1 * value2 / CURRENCY_FACTOR; -} - -/*************************************************************************************/ - -int64 div_currency(int64 value1, int64 value2) { - return value1 * CURRENCY_FACTOR / value2; -} - -/*************************************************************************************/ - -//! this code may not work on processors that does not use the default float standard -// original name: AlmostEqual2sComplement -BOOL AlmostEqualFloats(float A, float B, int maxUlps) { - int aInt, bInt, intDiff; - // Make sure maxUlps is non-negative and small enough that the - // default NAN won't compare as equal to anything. - CU_ASSERT(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); - aInt = *(int*) &A; - bInt = *(int*) &B; - // Make aInt lexicographically ordered as a twos-complement int - if (aInt < 0) { - aInt = 0x80000000 - aInt; - } - if (bInt < 0) { - bInt = 0x80000000 - bInt; - } - intDiff = abs(aInt - bInt); - if (intDiff <= maxUlps) { - return TRUE; - } - return FALSE; -} - -/*************************************************************************************/ - -char *test_create_object_1(int *psize) { - binn *obj = INVALID_BINN, *list = INVALID_BINN; - - printf("creating object 1...\n"); - - obj = binn_object(); - CU_ASSERT(obj != NULL); - - vint32 = -12345; - CU_ASSERT(binn_object_set(obj, "int32", BINN_INT32, &vint32, 0) == TRUE); - vint16 = -258; - CU_ASSERT(binn_object_set(obj, "int16", BINN_INT16, &vint16, 0) == TRUE); - vint8 = -120; - CU_ASSERT(binn_object_set(obj, "int8", BINN_INT8, &vint8, 0) == TRUE); - vint64 = -1234567890123; - CU_ASSERT(binn_object_set(obj, "int64", BINN_INT64, &vint64, 0) == TRUE); - - vuint32 = 123456; - CU_ASSERT(binn_object_set(obj, "uint32", BINN_UINT32, &vuint32, 0) == TRUE); - vuint16 = 60500; - CU_ASSERT(binn_object_set(obj, "uint16", BINN_UINT16, &vuint16, 0) == TRUE); - vuint8 = 250; - CU_ASSERT(binn_object_set(obj, "uint8", BINN_UINT8, &vuint8, 0) == TRUE); - vuint64 = 1234567890123; - CU_ASSERT(binn_object_set(obj, "uint64", BINN_UINT64, &vuint64, 0) == TRUE); - - vfloat32 = -12.345; - CU_ASSERT(binn_object_set(obj, "float32", BINN_FLOAT32, &vfloat32, 0) == TRUE); - vfloat32 = -12.345; - CU_ASSERT(binn_object_set(obj, "single", BINN_SINGLE, &vfloat32, 0) == TRUE); - vfloat64 = -123456.7895; - CU_ASSERT(binn_object_set(obj, "float64", BINN_FLOAT64, &vfloat64, 0) == TRUE); - vfloat64 = -123456.7895; - CU_ASSERT(binn_object_set(obj, "double", BINN_DOUBLE, &vfloat64, 0) == TRUE); - - CU_ASSERT(binn_object_set(obj, "str", BINN_STRING, "the value", 0) == TRUE); - - vint32 = TRUE; - CU_ASSERT(binn_object_set(obj, "bool_true", BINN_BOOL, &vint32, 0) == TRUE); - vint32 = FALSE; - CU_ASSERT(binn_object_set(obj, "bool_false", BINN_BOOL, &vint32, 0) == TRUE); - - CU_ASSERT(binn_object_set(obj, "null", BINN_NULL, NULL, 0) == TRUE); - - - // add a list - - list = binn_list(); - CU_ASSERT(list != NULL); - - CU_ASSERT(binn_list_add(list, BINN_NULL, NULL, 0) == TRUE); - vint32 = 123; - CU_ASSERT(binn_list_add(list, BINN_INT32, &vint32, 0) == TRUE); - CU_ASSERT(binn_list_add(list, BINN_STRING, "this is a string", 0) == TRUE); - - CU_ASSERT(binn_object_set(obj, "list", BINN_LIST, binn_ptr(list), binn_size(list)) == TRUE); - - binn_free(list); - list = INVALID_BINN; - - - // return the values - - *psize = binn_size(obj); - return binn_release(obj); -} - -/*************************************************************************************/ - -char *test_create_object_2(int *psize) { - binn *obj = INVALID_BINN, *list = INVALID_BINN; - - printf("creating object 2...\n"); - - obj = binn_object(); - CU_ASSERT(obj != NULL); - - CU_ASSERT(binn_object_set_int32(obj, "int32", -12345) == TRUE); - CU_ASSERT(binn_object_set_int16(obj, "int16", -258) == TRUE); - CU_ASSERT(binn_object_set_int8(obj, "int8", -120) == TRUE); - CU_ASSERT(binn_object_set_int64(obj, "int64", -1234567890123) == TRUE); - - CU_ASSERT(binn_object_set_uint32(obj, "uint32", 123456) == TRUE); - CU_ASSERT(binn_object_set_int16(obj, "uint16", (short) 60500) == TRUE); - CU_ASSERT(binn_object_set_int8(obj, "uint8", (signed char) 250) == TRUE); - CU_ASSERT(binn_object_set_uint64(obj, "uint64", 1234567890123) == TRUE); - - CU_ASSERT(binn_object_set_float(obj, "float32", -12.345) == TRUE); - vfloat32 = -12.345; - CU_ASSERT(binn_object_set(obj, "single", BINN_SINGLE, &vfloat32, 0) == TRUE); - CU_ASSERT(binn_object_set_double(obj, "float64", -123456.7895) == TRUE); - vfloat64 = -123456.7895; - CU_ASSERT(binn_object_set(obj, "double", BINN_DOUBLE, &vfloat64, 0) == TRUE); - - CU_ASSERT(binn_object_set_str(obj, "str", "the value") == TRUE); - - CU_ASSERT(binn_object_set_bool(obj, "bool_true", TRUE) == TRUE); - CU_ASSERT(binn_object_set_bool(obj, "bool_false", FALSE) == TRUE); - - CU_ASSERT(binn_object_set_null(obj, "null") == TRUE); - - - // add a list - - list = binn_list(); - CU_ASSERT(list != NULL); - - CU_ASSERT(binn_list_add_null(list) == TRUE); - CU_ASSERT(binn_list_add_int32(list, 123) == TRUE); - CU_ASSERT(binn_list_add_str(list, "this is a string") == TRUE); - - CU_ASSERT(binn_object_set_list(obj, "list", list) == TRUE); - - binn_free(list); - list = INVALID_BINN; - - - // return the values - - *psize = binn_size(obj); - return binn_release(obj); -} - -/*************************************************************************************/ - -void test_binn_read(void *objptr) { - void *listptr; - char *ptr; - binn value = { 0 }; - - printf("OK\nreading:\n"); - - vint32 = 0; - CU_ASSERT(binn_object_get(objptr, "int32", BINN_INT32, &vint32, NULL) == TRUE); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == -12345); - - vint16 = 0; - CU_ASSERT(binn_object_get(objptr, "int16", BINN_INT16, &vint16, NULL) == TRUE); - printf("int16: %d\n", vint16); - CU_ASSERT(vint16 == -258); - - vint8 = 0; - CU_ASSERT(binn_object_get(objptr, "int8", BINN_INT8, &vint8, NULL) == TRUE); - printf("int8: %d\n", vint8); - CU_ASSERT(vint8 == -120); - - vint64 = 0; - CU_ASSERT(binn_object_get(objptr, "int64", BINN_INT64, &vint64, NULL) == TRUE); - printf("int64: %" INT64_FORMAT "\n", vint64); - CU_ASSERT(vint64 == -1234567890123); - - - vuint32 = 0; - CU_ASSERT(binn_object_get(objptr, "uint32", BINN_UINT32, &vuint32, NULL) == TRUE); - printf("uint32: %d\n", vuint32); - CU_ASSERT(vuint32 == 123456); - - vuint16 = 0; - CU_ASSERT(binn_object_get(objptr, "uint16", BINN_UINT16, &vuint16, NULL) == TRUE); - printf("uint16: %d\n", vuint16); - CU_ASSERT(vuint16 == 60500); - - vuint8 = 0; - CU_ASSERT(binn_object_get(objptr, "uint8", BINN_UINT8, &vuint8, NULL) == TRUE); - printf("uint8: %d\n", vuint8); - CU_ASSERT(vuint8 == 250); - - vuint64 = 0; - CU_ASSERT(binn_object_get(objptr, "uint64", BINN_UINT64, &vuint64, NULL) == TRUE); - printf("uint64: %" UINT64_FORMAT "\n", vuint64); - CU_ASSERT(vuint64 == 1234567890123); - - - vfloat32 = 0; - CU_ASSERT(binn_object_get(objptr, "float32", BINN_FLOAT32, &vfloat32, NULL) == TRUE); - printf("float32: %f\n", vfloat32); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - vfloat64 = 0; - CU_ASSERT(binn_object_get(objptr, "float64", BINN_FLOAT64, &vfloat64, NULL) == TRUE); - printf("float64: %f\n", vfloat64); - CU_ASSERT(vfloat64 - -123456.7895 < 0.01); - - vfloat32 = 0; - CU_ASSERT(binn_object_get(objptr, "single", BINN_SINGLE, &vfloat32, NULL) == TRUE); - printf("single: %f\n", vfloat32); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - vfloat64 = 0; - CU_ASSERT(binn_object_get(objptr, "double", BINN_DOUBLE, &vfloat64, NULL) == TRUE); - printf("double: %f\n", vfloat64); - CU_ASSERT(vfloat64 - -123456.7895 < 0.01); - - - ptr = 0; - CU_ASSERT(binn_object_get(objptr, "str", BINN_STRING, &ptr, NULL) == TRUE); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "the value") == 0); - - - vint32 = 999; - CU_ASSERT(binn_object_get(objptr, "bool_true", BINN_BOOL, &vint32, NULL) == TRUE); - printf("bool true: %d\n", vint32); - CU_ASSERT(vint32 == TRUE); - - vint32 = 999; - CU_ASSERT(binn_object_get(objptr, "bool_false", BINN_BOOL, &vint32, NULL) == TRUE); - printf("bool false: %d\n", vint32); - CU_ASSERT(vint32 == FALSE); - - - vint32 = 999; - CU_ASSERT(binn_object_get(objptr, "null", BINN_NULL, &vint32, NULL) == TRUE); - printf("null: %d\n", vint32); - //CU_ASSERT(vint32 == 0); - CU_ASSERT(binn_object_get(objptr, "null", BINN_NULL, NULL, NULL) == TRUE); - - - CU_ASSERT(binn_object_get(objptr, "list", BINN_LIST, &listptr, NULL) == TRUE); - printf("obj ptr: %p list ptr: %p\n", objptr, listptr); - CU_ASSERT(listptr != 0); - CU_ASSERT(listptr > objptr); - - vint32 = 0; - CU_ASSERT(binn_list_get(listptr, 2, BINN_INT32, &vint32, NULL) == TRUE); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == 123); - - ptr = 0; - CU_ASSERT(binn_list_get(listptr, 3, BINN_STRING, &ptr, NULL) == TRUE); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "this is a string") == 0); - - - // short read functions 1 - - vint32 = 0; - CU_ASSERT(binn_object_get_int32(objptr, "int32", &vint32) == TRUE); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == -12345); - - vint16 = 0; - CU_ASSERT(binn_object_get_int16(objptr, "int16", &vint16) == TRUE); - printf("int16: %d\n", vint16); - CU_ASSERT(vint16 == -258); - - vint8 = 0; - CU_ASSERT(binn_object_get_int8(objptr, "int8", &vint8) == TRUE); - printf("int8: %d\n", vint8); - CU_ASSERT(vint8 == -120); - - vint64 = 0; - CU_ASSERT(binn_object_get_int64(objptr, "int64", &vint64) == TRUE); - printf("int64: %" INT64_FORMAT "\n", vint64); - CU_ASSERT(vint64 == -1234567890123); - - - vuint32 = 0; - CU_ASSERT(binn_object_get_uint32(objptr, "uint32", &vuint32) == TRUE); - printf("uint32: %d\n", vuint32); - CU_ASSERT(vuint32 == 123456); - - vuint16 = 0; - CU_ASSERT(binn_object_get_uint16(objptr, "uint16", &vuint16) == TRUE); - printf("uint16: %d\n", vuint16); - CU_ASSERT(vuint16 == 60500); - - vuint8 = 0; - CU_ASSERT(binn_object_get_uint8(objptr, "uint8", &vuint8) == TRUE); - printf("uint8: %d\n", vuint8); - CU_ASSERT(vuint8 == 250); - - vuint64 = 0; - CU_ASSERT(binn_object_get_uint64(objptr, "uint64", &vuint64) == TRUE); - printf("uint64: %" UINT64_FORMAT "\n", vuint64); - CU_ASSERT(vuint64 == 1234567890123); - - - vfloat32 = 0; - CU_ASSERT(binn_object_get_float(objptr, "float32", &vfloat32) == TRUE); - printf("float32: %f\n", vfloat32); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - vfloat64 = 0; - CU_ASSERT(binn_object_get_double(objptr, "float64", &vfloat64) == TRUE); - printf("float64: %f\n", vfloat64); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - - ptr = 0; - CU_ASSERT(binn_object_get_str(objptr, "str", &ptr) == TRUE); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "the value") == 0); - - - vint32 = 999; - CU_ASSERT(binn_object_get_bool(objptr, "bool_true", &vint32) == TRUE); - printf("bool true: %d\n", vint32); - CU_ASSERT(vint32 == TRUE); - - vint32 = 999; - CU_ASSERT(binn_object_get_bool(objptr, "bool_false", &vint32) == TRUE); - printf("bool false: %d\n", vint32); - CU_ASSERT(vint32 == FALSE); - - - vbool = FALSE; - CU_ASSERT(binn_object_null(objptr, "null") == TRUE); - - CU_ASSERT(binn_object_null(objptr, "bool_true") == FALSE); - - - CU_ASSERT(binn_object_get_list(objptr, "list", &listptr) == TRUE); - printf("obj ptr: %p list ptr: %p\n", objptr, listptr); - CU_ASSERT(listptr != 0); - CU_ASSERT(listptr > objptr); - - vint32 = 0; - CU_ASSERT(binn_list_get_int32(listptr, 2, &vint32) == TRUE); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == 123); - - ptr = 0; - CU_ASSERT(binn_list_get_str(listptr, 3, &ptr) == TRUE); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "this is a string") == 0); - - - // short read functions 2 - - vint32 = binn_object_int32(objptr, "int32"); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == -12345); - - vint16 = binn_object_int16(objptr, "int16"); - printf("int16: %d\n", vint16); - CU_ASSERT(vint16 == -258); - - vint8 = binn_object_int8(objptr, "int8"); - printf("int8: %d\n", vint8); - CU_ASSERT(vint8 == -120); - - vint64 = binn_object_int64(objptr, "int64"); - printf("int64: %" INT64_FORMAT "\n", vint64); - CU_ASSERT(vint64 == -1234567890123); - - - vuint32 = binn_object_uint32(objptr, "uint32"); - printf("uint32: %d\n", vuint32); - CU_ASSERT(vuint32 == 123456); - - vuint16 = binn_object_uint16(objptr, "uint16"); - printf("uint16: %d\n", vuint16); - CU_ASSERT(vuint16 == 60500); - - vuint8 = binn_object_uint8(objptr, "uint8"); - printf("uint8: %d\n", vuint8); - CU_ASSERT(vuint8 == 250); - - vuint64 = binn_object_uint64(objptr, "uint64"); - printf("uint64: %" UINT64_FORMAT "\n", vuint64); - CU_ASSERT(vuint64 == 1234567890123); - - - vfloat32 = binn_object_float(objptr, "float32"); - printf("float32: %f\n", vfloat32); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - vfloat64 = binn_object_double(objptr, "float64"); - printf("float64: %f\n", vfloat64); - CU_ASSERT(AlmostEqualFloats(vfloat32, -12.345, 2) == TRUE); - - - ptr = binn_object_str(objptr, "str"); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "the value") == 0); - - - vint32 = binn_object_bool(objptr, "bool_true"); - printf("bool true: %d\n", vint32); - CU_ASSERT(vint32 == TRUE); - - vint32 = binn_object_bool(objptr, "bool_false"); - printf("bool false: %d\n", vint32); - CU_ASSERT(vint32 == FALSE); - - - CU_ASSERT(binn_object_null(objptr, "null") == TRUE); - CU_ASSERT(binn_object_null(objptr, "nonull") == FALSE); - - - listptr = binn_object_list(objptr, "list"); - printf("obj ptr: %p list ptr: %p\n", objptr, listptr); - CU_ASSERT(listptr != 0); - CU_ASSERT(listptr > objptr); - - vint32 = binn_list_int32(listptr, 2); - printf("int32: %d\n", vint32); - CU_ASSERT(vint32 == 123); - - ptr = binn_list_str(listptr, 3); - printf("ptr: (%p) '%s'\n", (void*) ptr, ptr); - CU_ASSERT(strcmp(ptr, "this is a string") == 0); - - - // read as value / binn - - CU_ASSERT(binn_object_get_value(objptr, "int32", &value) == TRUE); -#ifndef BINN_DISABLE_COMPRESS_INT - CU_ASSERT(value.type == BINN_INT16); - CU_ASSERT(value.vint16 == -12345); -#else - CU_ASSERT(value.type == BINN_INT32); - CU_ASSERT(value.vint32 == -12345); -#endif - - CU_ASSERT(binn_object_get_value(objptr, "int16", &value) == TRUE); - CU_ASSERT(value.type == BINN_INT16); - CU_ASSERT(value.vint16 == -258); - - CU_ASSERT(binn_object_get_value(objptr, "int8", &value) == TRUE); - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == -120); - - CU_ASSERT(binn_object_get_value(objptr, "int64", &value) == TRUE); - CU_ASSERT(value.type == BINN_INT64); - CU_ASSERT(value.vint64 == -1234567890123); - - - CU_ASSERT(binn_object_get_value(objptr, "uint32", &value) == TRUE); - CU_ASSERT(value.type == BINN_UINT32); - CU_ASSERT(value.vuint32 == 123456); - - CU_ASSERT(binn_object_get_value(objptr, "uint16", &value) == TRUE); - CU_ASSERT(value.type == BINN_UINT16); - CU_ASSERT(value.vuint16 == 60500); - - CU_ASSERT(binn_object_get_value(objptr, "uint8", &value) == TRUE); - CU_ASSERT(value.type == BINN_UINT8); - CU_ASSERT(value.vuint8 == 250); - - CU_ASSERT(binn_object_get_value(objptr, "uint64", &value) == TRUE); - CU_ASSERT(value.type == BINN_UINT64); - CU_ASSERT(value.vuint64 == 1234567890123); - - puts("reading... OK"); -} - -/*************************************************************************************/ - -void init_udts() { - binn *obj = INVALID_BINN; - unsigned short date; - uint64 value; - void *ptr; - - puts("testing UDTs..."); - - CU_ASSERT(strcmp(date_to_str(str_to_date("1950-08-15")), "1950-08-15") == 0); - CU_ASSERT(strcmp(date_to_str(str_to_date("1900-12-01")), "1900-12-01") == 0); - CU_ASSERT(strcmp(date_to_str(str_to_date("2000-10-31")), "2000-10-31") == 0); - CU_ASSERT(strcmp(date_to_str(str_to_date("2014-03-19")), "2014-03-19") == 0); - - printf("curr=%s\n", currency_to_str(str_to_currency("123.456"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123.45"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123.4"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123."))); - printf("curr=%s\n", currency_to_str(str_to_currency("123"))); - printf("curr=%s\n", currency_to_str(str_to_currency("1.2"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0.987"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0.98"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0.9"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0.0"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123.4567"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123.45678"))); - printf("curr=%s\n", currency_to_str(str_to_currency("123.456789"))); - printf("curr=%s\n", currency_to_str(str_to_currency("0.1234"))); - printf("curr=%s\n", currency_to_str(str_to_currency(".1234"))); - - CU_ASSERT(float_to_currency(2.5) == 25000); - CU_ASSERT(float_to_currency(5) == 50000); - CU_ASSERT(str_to_currency("1.1") == 11000); - CU_ASSERT(str_to_currency("12") == 120000); - CU_ASSERT(mul_currency(20000, 20000) == 40000); - CU_ASSERT(mul_currency(20000, 25000) == 50000); - CU_ASSERT(mul_currency(30000, 40000) == 120000); - CU_ASSERT(div_currency(80000, 20000) == 40000); - CU_ASSERT(div_currency(120000, 40000) == 30000); - CU_ASSERT(div_currency(100000, 40000) == 25000); - - printf("1.1 * 2.5 = %s\n", currency_to_str(mul_currency(str_to_currency("1.1"), float_to_currency(2.5)))); - printf("12 / 5 = %s\n", currency_to_str(div_currency(str_to_currency("12"), float_to_currency(5)))); - - - //CU_ASSERT(binn_register_type(MY_DATE, BINN_STORAGE_WORD) == TRUE); - //CU_ASSERT(binn_register_type(MY_CURRENCY, BINN_STORAGE_QWORD) == TRUE); - - MY_DATE = binn_create_type(BINN_STORAGE_WORD, 0x0a); - MY_CURRENCY = binn_create_type(BINN_STORAGE_QWORD, 0x0a); - - - obj = binn_object(); - CU_ASSERT(obj != NULL); - - date = str_to_date("1950-08-15"); - printf(" date 1: %d %s\n", date, date_to_str(date)); - CU_ASSERT(binn_object_set(obj, "date1", MY_DATE, &date, 0) == TRUE); - CU_ASSERT(binn_object_set(obj, "date1", MY_DATE, &date, 0) == FALSE); - - date = str_to_date("1999-12-31"); - printf(" date 2: %d %s\n", date, date_to_str(date)); - binn_object_set(obj, "date2", MY_DATE, &date, 0); - - - value = str_to_currency("123.456"); - printf(" curr 1: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - binn_object_set(obj, "curr1", MY_CURRENCY, &value, 0); - - value = str_to_currency("123.45"); - printf(" curr 2: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - binn_object_set(obj, "curr2", MY_CURRENCY, &value, 0); - - value = str_to_currency("12.5"); - printf(" curr 3: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - binn_object_set(obj, "curr3", MY_CURRENCY, &value, 0); - - value = str_to_currency("5"); - printf(" curr 4: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - binn_object_set(obj, "curr4", MY_CURRENCY, &value, 0); - - value = str_to_currency("0.75"); - printf(" curr 5: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - binn_object_set(obj, "curr5", MY_CURRENCY, &value, 0); - - - ptr = binn_ptr(obj); - - - CU_ASSERT(binn_object_get(ptr, "date1", MY_DATE, &date, NULL) == TRUE); - printf(" date 1: %d %s\n", date, date_to_str(date)); - - CU_ASSERT(binn_object_get(ptr, "date2", MY_DATE, &date, NULL) == TRUE); - printf(" date 2: %d %s\n", date, date_to_str(date)); - - - CU_ASSERT(binn_object_get(ptr, "curr1", MY_CURRENCY, &value, NULL) == TRUE); - printf(" curr 1: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - - CU_ASSERT(binn_object_get(ptr, "curr2", MY_CURRENCY, &value, NULL) == TRUE); - printf(" curr 2: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - - CU_ASSERT(binn_object_get(ptr, "curr3", MY_CURRENCY, &value, NULL) == TRUE); - printf(" curr 3: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - - CU_ASSERT(binn_object_get(ptr, "curr4", MY_CURRENCY, &value, NULL) == TRUE); - printf(" curr 4: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - - CU_ASSERT(binn_object_get(ptr, "curr5", MY_CURRENCY, &value, NULL) == TRUE); - printf(" curr 5: %" UINT64_FORMAT " %s\n", value, currency_to_str(value)); - - - binn_free(obj); - - puts("testing UDTs... OK"); -} - -/*************************************************************************************/ - -BOOL copy_int_value_tests(void *psource, void *pdest, int source_type, int dest_type); - -void test_int_conversion() { - - printf("testing integer conversion..."); - - // copy negative value to unsigned integer - - vint8 = -110; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint8, BINN_INT8, BINN_UINT8) == FALSE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vuint8 == 0); - - vint8 = -110; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint16, BINN_INT8, BINN_UINT16) == FALSE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vuint16 == 0); - - vint8 = -110; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint32, BINN_INT8, BINN_UINT32) == FALSE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vuint32 == 0); - - vint8 = -110; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint64, BINN_INT8, BINN_UINT64) == FALSE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vuint64 == 0); - - - vint16 = -123; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint8, BINN_INT16, BINN_UINT8) == FALSE); - CU_ASSERT(vint16 == -123); - CU_ASSERT(vuint8 == 0); - - vint16 = -123; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint16, BINN_INT16, BINN_UINT16) == FALSE); - CU_ASSERT(vint16 == -123); - CU_ASSERT(vuint16 == 0); - - vint16 = -32000; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint32, BINN_INT16, BINN_UINT32) == FALSE); - CU_ASSERT(vint16 == -32000); - CU_ASSERT(vuint32 == 0); - - vint16 = -32000; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint64, BINN_INT16, BINN_UINT64) == FALSE); - CU_ASSERT(vint16 == -32000); - CU_ASSERT(vuint64 == 0); - - - vint32 = -123; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint8, BINN_INT32, BINN_UINT8) == FALSE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vuint8 == 0); - - vint32 = -123; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint16, BINN_INT32, BINN_UINT16) == FALSE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vuint16 == 0); - - vint32 = -123; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint32, BINN_INT32, BINN_UINT32) == FALSE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vuint32 == 0); - - vint32 = -123; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint64, BINN_INT32, BINN_UINT64) == FALSE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vuint64 == 0); - - - vint64 = -123; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint8, BINN_INT64, BINN_UINT8) == FALSE); - CU_ASSERT(vint64 == -123); - CU_ASSERT(vuint8 == 0); - - vint64 = -123; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint16, BINN_INT64, BINN_UINT16) == FALSE); - CU_ASSERT(vint64 == -123); - CU_ASSERT(vuint16 == 0); - - vint64 = -123; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint32, BINN_INT64, BINN_UINT32) == FALSE); - CU_ASSERT(vint64 == -123); - CU_ASSERT(vuint32 == 0); - - vint64 = -123; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint64, BINN_INT64, BINN_UINT64) == FALSE); - CU_ASSERT(vint64 == -123); - CU_ASSERT(vuint64 == 0); - - - // copy big negative value to small signed integer - - vint16 = -32000; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vint8, BINN_INT16, BINN_INT8) == FALSE); - CU_ASSERT(vint16 == -32000); - CU_ASSERT(vint8 == 0); - - - vint32 = -250; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint8, BINN_INT32, BINN_INT8) == FALSE); - CU_ASSERT(vint32 == -250); - CU_ASSERT(vint8 == 0); - - vint32 = -35000; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint16, BINN_INT32, BINN_INT16) == FALSE); - CU_ASSERT(vint32 == -35000); - CU_ASSERT(vint16 == 0); - - - vint64 = -250; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint8, BINN_INT64, BINN_INT8) == FALSE); - CU_ASSERT(vint64 == -250); - CU_ASSERT(vint8 == 0); - - vint64 = -35000; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint16, BINN_INT64, BINN_INT16) == FALSE); - CU_ASSERT(vint64 == -35000); - CU_ASSERT(vint16 == 0); - - vint64 = -25470000000; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint32, BINN_INT64, BINN_INT32) == FALSE); - CU_ASSERT(vint64 == -25470000000); - CU_ASSERT(vint32 == 0); - - - // copy big positive value to small signed integer - - vint16 = 250; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vint8, BINN_INT16, BINN_INT8) == FALSE); - CU_ASSERT(vint16 == 250); - CU_ASSERT(vint8 == 0); - - - vint32 = 250; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint8, BINN_INT32, BINN_INT8) == FALSE); - CU_ASSERT(vint32 == 250); - CU_ASSERT(vint8 == 0); - - vint32 = 35000; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint16, BINN_INT32, BINN_INT16) == FALSE); - CU_ASSERT(vint32 == 35000); - CU_ASSERT(vint16 == 0); - - - vint64 = 250; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint8, BINN_INT64, BINN_INT8) == FALSE); - CU_ASSERT(vint64 == 250); - CU_ASSERT(vint8 == 0); - - vint64 = 35000; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint16, BINN_INT64, BINN_INT16) == FALSE); - CU_ASSERT(vint64 == 35000); - CU_ASSERT(vint16 == 0); - - vint64 = 25470000000; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint32, BINN_INT64, BINN_INT32) == FALSE); - CU_ASSERT(vint64 == 25470000000); - CU_ASSERT(vint32 == 0); - - - // copy big positive value to small unsigned integer - - vint16 = 300; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint8, BINN_INT16, BINN_UINT8) == FALSE); - CU_ASSERT(vint16 == 300); - CU_ASSERT(vuint8 == 0); - - - vint32 = 300; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint8, BINN_INT32, BINN_UINT8) == FALSE); - CU_ASSERT(vint32 == 300); - CU_ASSERT(vuint8 == 0); - - vint32 = 70000; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint16, BINN_INT32, BINN_UINT16) == FALSE); - CU_ASSERT(vint32 == 70000); - CU_ASSERT(vuint16 == 0); - - - vint64 = 300; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint8, BINN_INT64, BINN_UINT8) == FALSE); - CU_ASSERT(vint64 == 300); - CU_ASSERT(vuint8 == 0); - - vint64 = 70000; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint16, BINN_INT64, BINN_UINT16) == FALSE); - CU_ASSERT(vint64 == 70000); - CU_ASSERT(vuint16 == 0); - - vint64 = 25470000000; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint32, BINN_INT64, BINN_UINT32) == FALSE); - CU_ASSERT(vint64 == 25470000000); - CU_ASSERT(vuint32 == 0); - - - // valid numbers -------------------- - - // int8 - copy to signed variable - - vint8 = 123; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint16, BINN_INT8, BINN_INT16) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vint16 == 123); - - vint8 = -110; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint16, BINN_INT8, BINN_INT16) == TRUE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vint16 == -110); - - vint8 = 123; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint32, BINN_INT8, BINN_INT32) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vint32 == 123); - - vint8 = -110; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint32, BINN_INT8, BINN_INT32) == TRUE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vint32 == -110); - - vint8 = 123; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint64, BINN_INT8, BINN_INT64) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vint64 == 123); - - vint8 = -120; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint64, BINN_INT8, BINN_INT64) == TRUE); - CU_ASSERT(vint8 == -120); - CU_ASSERT(vint64 == -120); - - - // int8 - copy to unsigned variable - - vint8 = 123; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint16, BINN_INT8, BINN_UINT16) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vuint16 == 123); - - vint8 = 123; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint32, BINN_INT8, BINN_UINT32) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vuint32 == 123); - - vint8 = 123; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vuint64, BINN_INT8, BINN_UINT64) == TRUE); - CU_ASSERT(vint8 == 123); - CU_ASSERT(vuint64 == 123); - - - // unsigned int8 - copy to signed variable - - vuint8 = 123; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint16, BINN_UINT8, BINN_INT16) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vint16 == 123); - - vuint8 = 250; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint16, BINN_UINT8, BINN_INT16) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vint16 == 250); - - vuint8 = 123; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint32, BINN_UINT8, BINN_INT32) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vint32 == 123); - - vuint8 = 250; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint32, BINN_UINT8, BINN_INT32) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vint32 == 250); - - vuint8 = 123; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint64, BINN_UINT8, BINN_INT64) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vint64 == 123); - - vuint8 = 250; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vint64, BINN_UINT8, BINN_INT64) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vint64 == 250); - - - // unsigned int8 - copy to unsigned variable - - vuint8 = 123; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint16, BINN_UINT8, BINN_UINT16) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vuint16 == 123); - - vuint8 = 250; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint16, BINN_UINT8, BINN_UINT16) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vuint16 == 250); - - vuint8 = 123; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint32, BINN_UINT8, BINN_UINT32) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vuint32 == 123); - - vuint8 = 250; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint32, BINN_UINT8, BINN_UINT32) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vuint32 == 250); - - vuint8 = 123; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint64, BINN_UINT8, BINN_UINT64) == TRUE); - CU_ASSERT(vuint8 == 123); - CU_ASSERT(vuint64 == 123); - - vuint8 = 250; - vuint64 = 0; - CU_ASSERT(copy_int_value_tests(&vuint8, &vuint64, BINN_UINT8, BINN_UINT64) == TRUE); - CU_ASSERT(vuint8 == 250); - CU_ASSERT(vuint64 == 250); - - - vint16 = 250; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vuint8, BINN_INT16, BINN_UINT8) == TRUE); - CU_ASSERT(vint16 == 250); - CU_ASSERT(vuint8 == 250); - - - vint32 = 250; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint8, BINN_INT32, BINN_UINT8) == TRUE); - CU_ASSERT(vint32 == 250); - CU_ASSERT(vuint8 == 250); - - vint32 = 35000; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vuint16, BINN_INT32, BINN_UINT16) == TRUE); - CU_ASSERT(vint32 == 35000); - CU_ASSERT(vuint16 == 35000); - - - vint64 = 250; - vuint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint8, BINN_INT64, BINN_UINT8) == TRUE); - CU_ASSERT(vint64 == 250); - CU_ASSERT(vuint8 == 250); - - vint64 = 35000; - vuint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint16, BINN_INT64, BINN_UINT16) == TRUE); - CU_ASSERT(vint64 == 35000); - CU_ASSERT(vuint16 == 35000); - - vint64 = 2147000000; - vuint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vuint32, BINN_INT64, BINN_UINT32) == TRUE); - CU_ASSERT(vint64 == 2147000000); - CU_ASSERT(vuint32 == 2147000000); - - - // valid negative values - - - vint8 = -110; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint16, BINN_INT8, BINN_INT16) == TRUE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vint16 == -110); - - vint8 = -110; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint32, BINN_INT8, BINN_INT32) == TRUE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vint32 == -110); - - vint8 = -110; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint8, &vint64, BINN_INT8, BINN_INT64) == TRUE); - CU_ASSERT(vint8 == -110); - CU_ASSERT(vint64 == -110); - - - vint16 = -123; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vint8, BINN_INT16, BINN_INT8) == TRUE); - CU_ASSERT(vint16 == -123); - CU_ASSERT(vint8 == -123); - - vint16 = -32000; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vint32, BINN_INT16, BINN_INT32) == TRUE); - CU_ASSERT(vint16 == -32000); - CU_ASSERT(vint32 == -32000); - - vint16 = -32000; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint16, &vint64, BINN_INT16, BINN_INT64) == TRUE); - CU_ASSERT(vint16 == -32000); - CU_ASSERT(vint64 == -32000); - - - vint32 = -123; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint8, BINN_INT32, BINN_INT8) == TRUE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vint8 == -123); - - vint32 = -123; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint16, BINN_INT32, BINN_INT16) == TRUE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vint16 == -123); - - vint32 = -32000; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint16, BINN_INT32, BINN_INT16) == TRUE); - CU_ASSERT(vint32 == -32000); - CU_ASSERT(vint16 == -32000); - - vint32 = -123; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint64, BINN_INT32, BINN_INT64) == TRUE); - CU_ASSERT(vint32 == -123); - CU_ASSERT(vint64 == -123); - - vint32 = -2147000000; - vint64 = 0; - CU_ASSERT(copy_int_value_tests(&vint32, &vint64, BINN_INT32, BINN_INT64) == TRUE); - CU_ASSERT(vint32 == -2147000000); - CU_ASSERT(vint64 == -2147000000); - - - vint64 = -123; - vint8 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint8, BINN_INT64, BINN_INT8) == TRUE); - CU_ASSERT(vint64 == -123); - CU_ASSERT(vint8 == -123); - - vint64 = -250; - vint16 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint16, BINN_INT64, BINN_INT16) == TRUE); - CU_ASSERT(vint64 == -250); - CU_ASSERT(vint16 == -250); - - vint64 = -35000; - vint32 = 0; - CU_ASSERT(copy_int_value_tests(&vint64, &vint32, BINN_INT64, BINN_INT32) == TRUE); - CU_ASSERT(vint64 == -35000); - CU_ASSERT(vint32 == -35000); - - - puts("OK"); -} - -/*************************************************************************************/ - -void test_binn_int_conversion() { - binn *obj = INVALID_BINN; - void *ptr; - - printf("testing binn integer read conversion... "); - - obj = binn_object(); - CU_ASSERT(obj != NULL); - - CU_ASSERT(binn_object_set_int8(obj, "int8", -8) == TRUE); - CU_ASSERT(binn_object_set_int16(obj, "int16", -16) == TRUE); - CU_ASSERT(binn_object_set_int32(obj, "int32", -32) == TRUE); - CU_ASSERT(binn_object_set_int64(obj, "int64", -64) == TRUE); - - CU_ASSERT(binn_object_set_uint8(obj, "uint8", 111) == TRUE); - CU_ASSERT(binn_object_set_uint16(obj, "uint16", 112) == TRUE); - CU_ASSERT(binn_object_set_uint32(obj, "uint32", 113) == TRUE); - CU_ASSERT(binn_object_set_uint64(obj, "uint64", 114) == TRUE); - - ptr = binn_ptr(obj); - - CU_ASSERT(binn_object_int8(ptr, "int8") == -8); - CU_ASSERT(binn_object_int8(ptr, "int16") == -16); - CU_ASSERT(binn_object_int8(ptr, "int32") == -32); - CU_ASSERT(binn_object_int8(ptr, "int64") == -64); - - CU_ASSERT(binn_object_int16(ptr, "int8") == -8); - CU_ASSERT(binn_object_int16(ptr, "int16") == -16); - CU_ASSERT(binn_object_int16(ptr, "int32") == -32); - CU_ASSERT(binn_object_int16(ptr, "int64") == -64); - - CU_ASSERT(binn_object_int32(ptr, "int8") == -8); - CU_ASSERT(binn_object_int32(ptr, "int16") == -16); - CU_ASSERT(binn_object_int32(ptr, "int32") == -32); - CU_ASSERT(binn_object_int32(ptr, "int64") == -64); - - CU_ASSERT(binn_object_int64(ptr, "int8") == -8); - CU_ASSERT(binn_object_int64(ptr, "int16") == -16); - CU_ASSERT(binn_object_int64(ptr, "int32") == -32); - CU_ASSERT(binn_object_int64(ptr, "int64") == -64); - - - CU_ASSERT(binn_object_int8(ptr, "uint8") == 111); - CU_ASSERT(binn_object_int8(ptr, "uint16") == 112); - CU_ASSERT(binn_object_int8(ptr, "uint32") == 113); - CU_ASSERT(binn_object_int8(ptr, "uint64") == 114); - - CU_ASSERT(binn_object_int16(ptr, "uint8") == 111); - CU_ASSERT(binn_object_int16(ptr, "uint16") == 112); - CU_ASSERT(binn_object_int16(ptr, "uint32") == 113); - CU_ASSERT(binn_object_int16(ptr, "uint64") == 114); - - CU_ASSERT(binn_object_int32(ptr, "uint8") == 111); - CU_ASSERT(binn_object_int32(ptr, "uint16") == 112); - CU_ASSERT(binn_object_int32(ptr, "uint32") == 113); - CU_ASSERT(binn_object_int32(ptr, "uint64") == 114); - - CU_ASSERT(binn_object_int64(ptr, "uint8") == 111); - CU_ASSERT(binn_object_int64(ptr, "uint16") == 112); - CU_ASSERT(binn_object_int64(ptr, "uint32") == 113); - CU_ASSERT(binn_object_int64(ptr, "uint64") == 114); - - - binn_free(obj); - - puts("OK"); -} - -/*************************************************************************************/ - -void test_value_conversion() { - binn *value; - char *ptr, blob[64] = "test blob"; - void *pblob; - int size, vint32; - int64 vint64; - double vdouble; - BOOL vbool; - - printf("testing binn value conversion... "); - - /* test string values */ - - ptr = "static string"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - binn_free(value); - - ptr = "transient string"; - value = binn_string(ptr, BINN_TRANSIENT); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr != ptr); - CU_ASSERT(strcmp((char*) value->ptr, ptr) == 0); - CU_ASSERT(value->freefn != NULL); - binn_free(value); - - ptr = strdup("dynamic allocated string"); - value = binn_string(ptr, free); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - CU_ASSERT(value->freefn == &free); - binn_free(value); - - /* test blob values */ - - size = 64; - pblob = blob; - value = binn_blob(pblob, size, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_BLOB); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == pblob); - CU_ASSERT(value->freefn == NULL); - binn_free(value); - - size = 64; - pblob = blob; - value = binn_blob(pblob, size, BINN_TRANSIENT); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_BLOB); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr != pblob); - CU_ASSERT(memcmp(value->ptr, pblob, size) == 0); - CU_ASSERT(value->freefn != NULL); - binn_free(value); - - size = 64; - pblob = memdup(blob, size); - value = binn_blob(pblob, size, free); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_BLOB); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == pblob); - CU_ASSERT(value->freefn == &free); - binn_free(value); - - - /* test conversions */ - - ptr = "123"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_str(value) == ptr); - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == 123); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == 123); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, 123, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - binn_free(value); - - - ptr = "-456"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_str(value) == ptr); - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == -456); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == -456); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, -456, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - binn_free(value); - - - ptr = "-4.56"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_str(value) == ptr); - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == -4); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == -4); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, -4.56, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn == NULL); - // - binn_free(value); - - - // to boolean - - ptr = "yes"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_str(value) == ptr); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - binn_free(value); - - ptr = "no"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - binn_free(value); - - ptr = "on"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - binn_free(value); - - ptr = "off"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - binn_free(value); - - ptr = "true"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - binn_free(value); - - ptr = "false"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - binn_free(value); - - ptr = "1"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - binn_free(value); - - ptr = "0"; - value = binn_string(ptr, BINN_STATIC); - CU_ASSERT(value != NULL); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - binn_free(value); - - - // from int32 - - value = binn_int32(-345); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_INT32); - CU_ASSERT(value->vint32 == -345); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == -345); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == -345); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, -345, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_INT32); - CU_ASSERT(value->vint32 == -345); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "-345") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - value = binn_int32(0); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_INT32); - CU_ASSERT(value->vint32 == 0); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == 0); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == 0); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, 0, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - // check that the type is the same - CU_ASSERT(value->type == BINN_INT32); - CU_ASSERT(value->vint32 == 0); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "0") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - // from int64 - - value = binn_int64(-345678); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_INT64); - CU_ASSERT(value->vint64 == -345678); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == -345678); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == -345678); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, -345678, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_INT64); - CU_ASSERT(value->vint64 == -345678); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "-345678") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - // from double - - value = binn_double(-345.678); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_DOUBLE); - CU_ASSERT(value->vdouble == -345.678); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == -345); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == -345); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, -345.678, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_DOUBLE); - CU_ASSERT(value->vdouble == -345.678); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "-345.678") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - value = binn_double(0.0); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_DOUBLE); - CU_ASSERT(value->vdouble == 0.0); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == 0); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == 0); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, 0, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - // check that the type is the same - CU_ASSERT(value->type == BINN_DOUBLE); - CU_ASSERT(value->vdouble == 0.0); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "0") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - // from bool - - value = binn_bool(FALSE); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_BOOL); - CU_ASSERT(value->vbool == FALSE); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == 0); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == 0); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, 0, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == FALSE); - // check that the type is the same - CU_ASSERT(value->type == BINN_BOOL); - CU_ASSERT(value->vbool == FALSE); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "false") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - value = binn_bool(TRUE); - CU_ASSERT(value != NULL); - CU_ASSERT(value->type == BINN_BOOL); - CU_ASSERT(value->vbool == TRUE); - CU_ASSERT(value->freefn == NULL); - // - CU_ASSERT(binn_get_int32(value, &vint32) == TRUE); - CU_ASSERT(vint32 == 1); - CU_ASSERT(binn_get_int64(value, &vint64) == TRUE); - CU_ASSERT(vint64 == 1); - CU_ASSERT(binn_get_double(value, &vdouble) == TRUE); - CU_ASSERT(AlmostEqualFloats(vdouble, 1, 4) == TRUE); - CU_ASSERT(binn_get_bool(value, &vbool) == TRUE); - CU_ASSERT(vbool == TRUE); - // check that the type is the same - CU_ASSERT(value->type == BINN_BOOL); - CU_ASSERT(value->vbool == TRUE); - CU_ASSERT(value->freefn == NULL); - // convert the value to string - ptr = binn_get_str(value); - CU_ASSERT(ptr != NULL); - CU_ASSERT(strcmp(ptr, "true") == 0); - CU_ASSERT(value->type == BINN_STRING); - CU_ASSERT(value->ptr != NULL); - CU_ASSERT(value->ptr == ptr); - CU_ASSERT(value->freefn != NULL); - // - binn_free(value); - - - puts("OK"); -} - -/*************************************************************************************/ - -void test_value_copy() { - - printf("testing binn value copy... "); - - //TODO - - puts("TODO!!!"); -} - -/*************************************************************************************/ - -void test_virtual_types() { - binn *list = INVALID_BINN; - void *ptr; - int storage_type, extra_type; - BOOL value; - - printf("testing binn virtual types... "); - - CU_ASSERT(binn_get_type_info(BINN_BOOL, &storage_type, &extra_type) == TRUE); - CU_ASSERT(storage_type == BINN_STORAGE_DWORD); - CU_ASSERT(extra_type == 1); - - list = binn_list(); - CU_ASSERT(list != NULL); - - CU_ASSERT(binn_list_add_bool(list, TRUE) == TRUE); - CU_ASSERT(binn_list_add_bool(list, FALSE) == TRUE); - CU_ASSERT(binn_list_add_null(list) == TRUE); - - ptr = binn_ptr(list); - CU_ASSERT(ptr != 0); - - CU_ASSERT(binn_list_get_bool(ptr, 1, &value) == TRUE); - CU_ASSERT(value == TRUE); - - CU_ASSERT(binn_list_get_bool(ptr, 2, &value) == TRUE); - CU_ASSERT(value == FALSE); - - CU_ASSERT(binn_list_null(ptr, 3) == TRUE); - - // invalid values - CU_ASSERT(binn_list_null(ptr, 1) == FALSE); - CU_ASSERT(binn_list_null(ptr, 2) == FALSE); - CU_ASSERT(binn_list_get_bool(ptr, 3, &value) == FALSE); - - binn_free(list); - - puts("OK"); -} - -/*************************************************************************************/ - -void test_binn_iter() { - binn *list, *map, *obj; - binn *list2, *copy = NULL; - binn_iter iter, iter2; - binn value, value2; - int blob_size, id, id2, list2size; - void *ptr, *blob_ptr; - char key[256], key2[256]; - - blob_ptr = "key\0value\0\0"; - blob_size = 11; - - printf("testing binn sequential read"); - - // create the - - list = binn_list(); - list2 = binn_list(); - map = binn_map(); - obj = binn_object(); - - CU_ASSERT(list != NULL); - CU_ASSERT(list2 != NULL); - CU_ASSERT(map != NULL); - CU_ASSERT(obj != NULL); - - CU_ASSERT(binn_list_add_int32(list2, 250) == TRUE); - CU_ASSERT(binn_list_add_null(list2) == TRUE); - CU_ASSERT(binn_list_add_str(list2, "l1st2") == TRUE); - CU_ASSERT(binn_list_add_bool(list2, TRUE) == TRUE); - - list2size = binn_size(list2); - - CU_ASSERT(binn_list_add_int8(list, 111) == TRUE); - CU_ASSERT(binn_list_add_int32(list, 123456789) == TRUE); - CU_ASSERT(binn_list_add_int16(list, -123) == TRUE); - CU_ASSERT(binn_list_add_int64(list, 9876543210) == TRUE); - CU_ASSERT(binn_list_add_float(list, 1.25) == TRUE); - CU_ASSERT(binn_list_add_double(list, 25.987654321) == TRUE); - CU_ASSERT(binn_list_add_bool(list, TRUE) == TRUE); - CU_ASSERT(binn_list_add_bool(list, FALSE) == TRUE); - CU_ASSERT(binn_list_add_null(list) == TRUE); - CU_ASSERT(binn_list_add_str(list, "testing...") == TRUE); - CU_ASSERT(binn_list_add_blob(list, (char*) blob_ptr, blob_size) == TRUE); - CU_ASSERT(binn_list_add_list(list, list2) == TRUE); - - CU_ASSERT(binn_object_set_int8(obj, "a", 111) == TRUE); - CU_ASSERT(binn_object_set_int32(obj, "b", 123456789) == TRUE); - CU_ASSERT(binn_object_set_int16(obj, "c", -123) == TRUE); - CU_ASSERT(binn_object_set_int64(obj, "d", 9876543210) == TRUE); - CU_ASSERT(binn_object_set_float(obj, "e", 1.25) == TRUE); - CU_ASSERT(binn_object_set_double(obj, "f", 25.987654321) == TRUE); - CU_ASSERT(binn_object_set_bool(obj, "g", TRUE) == TRUE); - CU_ASSERT(binn_object_set_bool(obj, "h", FALSE) == TRUE); - CU_ASSERT(binn_object_set_null(obj, "i") == TRUE); - CU_ASSERT(binn_object_set_str(obj, "j", "testing...") == TRUE); - CU_ASSERT(binn_object_set_blob(obj, "k", (char*) blob_ptr, blob_size) == TRUE); - CU_ASSERT(binn_object_set_list(obj, "l", list2) == TRUE); - - CU_ASSERT(binn_map_set_int8(map, 55010, 111) == TRUE); - CU_ASSERT(binn_map_set_int32(map, 55020, 123456789) == TRUE); - CU_ASSERT(binn_map_set_int16(map, 55030, -123) == TRUE); - CU_ASSERT(binn_map_set_int64(map, 55040, 9876543210) == TRUE); - CU_ASSERT(binn_map_set_float(map, 55050, 1.25) == TRUE); - CU_ASSERT(binn_map_set_double(map, 55060, 25.987654321) == TRUE); - CU_ASSERT(binn_map_set_bool(map, 55070, TRUE) == TRUE); - CU_ASSERT(binn_map_set_bool(map, 55080, FALSE) == TRUE); - CU_ASSERT(binn_map_set_null(map, 55090) == TRUE); - CU_ASSERT(binn_map_set_str(map, 55100, "testing...") == TRUE); - CU_ASSERT(binn_map_set_blob(map, 55110, (char*) blob_ptr, blob_size) == TRUE); - CU_ASSERT(binn_map_set_list(map, 55120, list2) == TRUE); - - - // read list sequentially - using value - - /* - CU_ASSERT(binn_iter_init(&iter, binn_ptr(list), BINN_LIST)); - - while (binn_list_next(&iter, &value)) { - ... - } - */ - - ptr = binn_ptr(list); - CU_ASSERT(ptr != 0); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_LIST)); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 0); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 1); - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == 111); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 2); - - CU_ASSERT(value.type == BINN_UINT32); - CU_ASSERT(value.vint32 == 123456789); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 3); - - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == -123); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 4); - CU_ASSERT(value.type == BINN_INT64); - CU_ASSERT(value.vint64 == 9876543210); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 5); - CU_ASSERT(value.type == BINN_FLOAT32); - CU_ASSERT(AlmostEqualFloats(value.vfloat, 1.25, 2)); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 6); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.vdouble - 25.987654321 < 0.00000001); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 7); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == TRUE); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 8); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == FALSE); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 9); - CU_ASSERT(value.type == BINN_NULL); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 10); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(strcmp((char*) value.ptr, "testing...") == 0); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 11); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(memcmp(value.ptr, blob_ptr, blob_size) == 0); - - CU_ASSERT(binn_list_next(&iter, &value) == TRUE); - CU_ASSERT(iter.current == 12); - CU_ASSERT(value.type == BINN_LIST); - CU_ASSERT(value.size == list2size); - CU_ASSERT(value.count == 4); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(binn_list_int32(value.ptr, 1) == 250); - CU_ASSERT(binn_list_null(value.ptr, 2) == TRUE); - ptr = binn_list_str(value.ptr, 3); - CU_ASSERT(ptr != 0); - CU_ASSERT(strcmp((char*) ptr, "l1st2") == 0); - CU_ASSERT(binn_list_bool(value.ptr, 4) == TRUE); - - CU_ASSERT(binn_list_next(&iter, &value) == FALSE); - //CU_ASSERT(iter.current == 13); - //CU_ASSERT(iter.count == 12); - - CU_ASSERT(binn_list_next(&iter, &value) == FALSE); - //CU_ASSERT(iter.current == 13); // must keep the same position - //CU_ASSERT(iter.count == 12); - - - // read object sequentially - using value - - ptr = binn_ptr(obj); - CU_ASSERT(ptr != 0); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_OBJECT)); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 1); - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == 111); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "a") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 2); - CU_ASSERT(value.type == BINN_UINT32); - CU_ASSERT(value.vint32 == 123456789); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "b") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 3); - - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == -123); - - //printf("%s ", key); - CU_ASSERT(strcmp(key, "c") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 4); - CU_ASSERT(value.type == BINN_INT64); - CU_ASSERT(value.vint64 == 9876543210); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "d") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 5); - CU_ASSERT(value.type == BINN_FLOAT32); - CU_ASSERT(AlmostEqualFloats(value.vfloat, 1.25, 2)); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "e") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 6); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.vdouble - 25.987654321 < 0.00000001); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "f") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 7); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == TRUE); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "g") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 8); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == FALSE); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "h") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 9); - CU_ASSERT(value.type == BINN_NULL); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "i") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 10); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(strcmp((char*) value.ptr, "testing...") == 0); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "j") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 11); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(memcmp(value.ptr, blob_ptr, blob_size) == 0); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "k") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == TRUE); - CU_ASSERT(iter.current == 12); - CU_ASSERT(value.type == BINN_LIST); - CU_ASSERT(value.size == list2size); - CU_ASSERT(value.count == 4); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(binn_list_int32(value.ptr, 1) == 250); - CU_ASSERT(binn_list_null(value.ptr, 2) == TRUE); - ptr = binn_list_str(value.ptr, 3); - CU_ASSERT(ptr != 0); - CU_ASSERT(strcmp((char*) ptr, "l1st2") == 0); - CU_ASSERT(binn_list_bool(value.ptr, 4) == TRUE); - //printf("%s ", key); - CU_ASSERT(strcmp(key, "l") == 0); - - CU_ASSERT(binn_object_next(&iter, key, &value) == FALSE); - //CU_ASSERT(iter.current == 13); - //CU_ASSERT(iter.count == 12); - - CU_ASSERT(binn_object_next(&iter, key, &value) == FALSE); - //CU_ASSERT(iter.current == 13); // must keep the same position - //CU_ASSERT(iter.count == 12); - - - // read map sequentially - using value - - ptr = binn_ptr(map); - CU_ASSERT(ptr != 0); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_MAP)); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 0); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.pnext > (unsigned char*) ptr); - CU_ASSERT(iter.plimit > (unsigned char*) ptr); - CU_ASSERT(iter.count == 12); - CU_ASSERT(iter.current == 1); - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == 111); - CU_ASSERT(id == 55010); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 2); - - CU_ASSERT(value.type == BINN_UINT32); - - CU_ASSERT(value.vint32 == 123456789); - CU_ASSERT(id == 55020); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 3); - - CU_ASSERT(value.type == BINN_INT8); - CU_ASSERT(value.vint8 == -123); - - CU_ASSERT(id == 55030); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 4); - CU_ASSERT(value.type == BINN_INT64); - CU_ASSERT(value.vint64 == 9876543210); - CU_ASSERT(id == 55040); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 5); - CU_ASSERT(value.type == BINN_FLOAT32); - CU_ASSERT(AlmostEqualFloats(value.vfloat, 1.25, 2)); - CU_ASSERT(id == 55050); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 6); - CU_ASSERT(value.type == BINN_FLOAT64); - CU_ASSERT(value.vdouble - 25.987654321 < 0.00000001); - CU_ASSERT(id == 55060); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 7); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == TRUE); - CU_ASSERT(id == 55070); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 8); - CU_ASSERT(value.type == BINN_BOOL); - CU_ASSERT(value.vbool == FALSE); - CU_ASSERT(id == 55080); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 9); - CU_ASSERT(value.type == BINN_NULL); - CU_ASSERT(id == 55090); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 10); - CU_ASSERT(value.type == BINN_STRING); - CU_ASSERT(strcmp((char*) value.ptr, "testing...") == 0); - CU_ASSERT(id == 55100); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 11); - CU_ASSERT(value.type == BINN_BLOB); - CU_ASSERT(memcmp(value.ptr, blob_ptr, blob_size) == 0); - CU_ASSERT(id == 55110); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == TRUE); - CU_ASSERT(iter.current == 12); - CU_ASSERT(value.type == BINN_LIST); - CU_ASSERT(value.size == list2size); - CU_ASSERT(value.count == 4); - CU_ASSERT(value.ptr != 0); - CU_ASSERT(binn_list_int32(value.ptr, 1) == 250); - CU_ASSERT(binn_list_null(value.ptr, 2) == TRUE); - ptr = binn_list_str(value.ptr, 3); - CU_ASSERT(ptr != 0); - CU_ASSERT(strcmp((char*) ptr, "l1st2") == 0); - CU_ASSERT(binn_list_bool(value.ptr, 4) == TRUE); - CU_ASSERT(id == 55120); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == FALSE); - //CU_ASSERT(iter.current == 13); - //CU_ASSERT(iter.count == 12); - - CU_ASSERT(binn_map_next(&iter, &id, &value) == FALSE); - //CU_ASSERT(iter.current == 13); // must keep the same position - //CU_ASSERT(iter.count == 12); - - - // test binn copy - - copy = binn_copy(list); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(list)); - CU_ASSERT(binn_count(copy) == binn_count(list)); - CU_ASSERT(binn_size(copy) == binn_size(list)); - CU_ASSERT(binn_iter_init(&iter, list, BINN_LIST)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_LIST)); - while (binn_list_next(&iter, &value)) { - CU_ASSERT(binn_list_next(&iter2, &value2) == TRUE); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_list_add_str(copy, "testing...") == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(list)); - CU_ASSERT(binn_count(copy) == binn_count(list) + 1); - CU_ASSERT(binn_size(copy) > binn_size(list)); - binn_free(copy); - - copy = binn_copy(map); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(map)); - CU_ASSERT(binn_count(copy) == binn_count(map)); - CU_ASSERT(binn_size(copy) == binn_size(map)); - CU_ASSERT(binn_iter_init(&iter, map, BINN_MAP)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_MAP)); - while (binn_map_next(&iter, &id, &value)) { - CU_ASSERT(binn_map_next(&iter2, &id2, &value2) == TRUE); - CU_ASSERT(id == id2); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_map_set_int32(copy, 5600, 123) == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(map)); - CU_ASSERT(binn_count(copy) == binn_count(map) + 1); - CU_ASSERT(binn_size(copy) > binn_size(map)); - binn_free(copy); - - copy = binn_copy(obj); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(obj)); - CU_ASSERT(binn_count(copy) == binn_count(obj)); - CU_ASSERT(binn_size(copy) == binn_size(obj)); - CU_ASSERT(binn_iter_init(&iter, obj, BINN_OBJECT)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_OBJECT)); - while (binn_object_next(&iter, key, &value)) { - CU_ASSERT(binn_object_next(&iter2, key2, &value2) == TRUE); - CU_ASSERT(strcmp(key, key2) == 0); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_object_set_int32(copy, "another", 123) == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(obj)); - CU_ASSERT(binn_count(copy) == binn_count(obj) + 1); - CU_ASSERT(binn_size(copy) > binn_size(obj)); - binn_free(copy); - - - // test binn copy reading from buffer - - ptr = binn_ptr(list); - copy = binn_copy(ptr); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(list)); - CU_ASSERT(binn_count(copy) == binn_count(list)); - CU_ASSERT(binn_size(copy) == binn_size(list)); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_LIST)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_LIST)); - while (binn_list_next(&iter, &value)) { - CU_ASSERT(binn_list_next(&iter2, &value2) == TRUE); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_list_add_str(copy, "testing...") == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(list)); - CU_ASSERT(binn_count(copy) == binn_count(list) + 1); - CU_ASSERT(binn_size(copy) > binn_size(list)); - binn_free(copy); - - ptr = binn_ptr(map); - copy = binn_copy(ptr); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(map)); - CU_ASSERT(binn_count(copy) == binn_count(map)); - CU_ASSERT(binn_size(copy) == binn_size(map)); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_MAP)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_MAP)); - while (binn_map_next(&iter, &id, &value)) { - CU_ASSERT(binn_map_next(&iter2, &id2, &value2) == TRUE); - CU_ASSERT(id == id2); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_map_set_int32(copy, 5600, 123) == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(map)); - CU_ASSERT(binn_count(copy) == binn_count(map) + 1); - CU_ASSERT(binn_size(copy) > binn_size(map)); - binn_free(copy); - - ptr = binn_ptr(obj); - copy = binn_copy(ptr); - CU_ASSERT(copy != NULL); - CU_ASSERT(binn_type(copy) == binn_type(obj)); - CU_ASSERT(binn_count(copy) == binn_count(obj)); - CU_ASSERT(binn_size(copy) == binn_size(obj)); - CU_ASSERT(binn_iter_init(&iter, ptr, BINN_OBJECT)); - CU_ASSERT(binn_iter_init(&iter2, copy, BINN_OBJECT)); - while (binn_object_next(&iter, key, &value)) { - CU_ASSERT(binn_object_next(&iter2, key2, &value2) == TRUE); - CU_ASSERT(strcmp(key, key2) == 0); - CU_ASSERT(value.type == value2.type); - //CU_ASSERT(value.vint32 == value.vint32); - } - CU_ASSERT(binn_object_set_int32(copy, "another", 123) == TRUE); - CU_ASSERT(binn_type(copy) == binn_type(obj)); - CU_ASSERT(binn_count(copy) == binn_count(obj) + 1); - CU_ASSERT(binn_size(copy) > binn_size(obj)); - binn_free(copy); - - - binn_free(list); - binn_free(list2); - binn_free(map); - binn_free(obj); - - puts("OK"); -} - -/*************************************************************************************/ - -void test_binn2() { - char *obj1ptr, *obj2ptr; - int obj1size, obj2size; - - test_virtual_types(); - - test_int_conversion(); - test_binn_int_conversion(); - test_value_conversion(); - test_value_copy(); - - init_udts(); - - obj1ptr = test_create_object_1(&obj1size); - obj2ptr = test_create_object_2(&obj2size); - - CU_ASSERT(obj1ptr != NULL); - CU_ASSERT(obj2ptr != NULL); - - printf("obj1size=%d obj2size=%d\n", obj1size, obj2size); - CU_ASSERT(obj1size == obj2size); - - test_binn_read(obj1ptr); - - free(obj1ptr); - free(obj2ptr); - - test_binn_iter(); -} - -/*************************************************************************************/ - -int main() { - CU_pSuite pSuite = NULL; - if (CUE_SUCCESS != CU_initialize_registry()) { - return CU_get_error(); - } - pSuite = CU_add_suite("jbl_test_binn2", init_suite, clean_suite); - if (NULL == pSuite) { - CU_cleanup_registry(); - return CU_get_error(); - } - if ( - (NULL == CU_add_test(pSuite, "test_binn2", test_binn2))) { - CU_cleanup_registry(); - return CU_get_error(); - } - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - int ret = CU_get_error() || CU_get_number_of_failures(); - CU_cleanup_registry(); - return ret; -} diff --git a/src/jbr/README.md b/src/jbr/README.md index e706c8d45..18322418a 100644 --- a/src/jbr/README.md +++ b/src/jbr/README.md @@ -1,45 +1,45 @@ # HTTP REST/Websocket API endpoint EJDB engine provides the ability to start a separate HTTP/Websocket endpoint worker exposing network API for quering and data modifications. +SSL (TLS 1.2) is supported by `jbs` server. -The easiest way to expose database over the network is using the standalone `jbs` server. (Of course if you plan to avoid `C API` integration). +The easiest way to expose database over the network is use the standalone `jbs` server. (Of course if you want to avoid `C API` integration). ## jbs server ``` -jbs -h - -EJDB 2.0.0 standalone REST/Websocket server. http://ejdb.org - - --file <> Database file path. Default: db.jb - -f <> (same as --file) - --port ## HTTP port number listen to. Default: 9191 - -p ## (same as --port) - --bind <> Address server listen. Default: localhost - -b <> (same as --bind) - --access <> Server access token matched to 'X-Access-Token' HTTP header value - -a <> (same as --access) - --trunc Cleanup existing database file on open - -t (same as --trunc) - --wal Use write ahead logging (WAL). Must be set for data durability. - -w (same as --wal) - -Advanced options - --sbz ## Max sorting buffer size. If exceeded, an overflow temp file for data will be created. Default: 16777216, min: 1048576 - --dsz ## Initial size of buffer to process/store document on queries. Preferable average size of document. Default: 65536, min: 16384 - --bsz ## Max HTTP/WS API document body size. Default: 67108864, min: 524288 - -Use any of the following input formats: - -arg -arg= -arg - -Use the -h, -help or -? to get this information again. +Usage: + + ./jbs [options] + + -v, --version Print program version. + -f, --file=<> Database file path. Default: ejdb2.db + -p, --port=NUM HTTP server port numer. Default: 9191 + -l, --listen=<> Network address server will listen. Default: localhost + -k, --key=<> PEM private key file for TLS 1.2 HTTP server. + -c, --certs=<> PEM certificates file for TLS 1.2 HTTP server. + -a, --access=TOKEN|@FILE Access token to match 'X-Access-Token' HTTP header value. + -r, --access-read Allows unrestricted read-only data access. + -C, --cors Enable COSR response headers for HTTP server + -t, --trunc Cleanup/reset database file on open. + -w, --wal use the write ahead log (WAL). Used to provide data durability. + +Advanced options: + -S, --sbz=NUM Max sorting buffer size. If exceeded, an overflow temp file for data will be created. + Default: 16777216, min: 1048576 + -D, --dsz=NUM Initial size of buffer to process/store document on queries. Preferable average size of document. + Default: 65536, min: 16384 + -T, --trylock Exit with error if database is locked by another process. + If not set, current process will wait for lock release. + ``` ## HTTP API -Access to HTTP endpoint can be protected by a token specified with `--access` -command flag or by C API `EJDB_HTTP` options. If access token specified on server, client must provide `X-Access-Token` HTTP header value. If token is required and not provided by client the `401` HTTP code will be reported. If access token is not matched to the token provided the `403` HTTP code will be returned. -For any other errors server will respond with `500` error code. +HTTP endpoint may be protected by a token specified with `--access` flag or C API `EJDB_HTTP` struct. +If access token was set, client should provide `X-Access-Token` HTTP header. +If token is required but not provided by client `401` HTTP code will be reported. +If access token is not matched to the token provided by client server will respond with `403` HTTP code. ## REST API @@ -54,7 +54,7 @@ Replaces/store document under specific numeric `id` ### DELETE /{collection}/{id} Removes document identified by `id` from a `collection` * `200` on success. Empty body -* `404` if document not found +* `404` document not found ### PATCH /{collection}/{id} Patch a document identified by `id` by [rfc7396](https://tools.ietf.org/html/rfc7396), @@ -66,7 +66,7 @@ Retrieve document identified by `id` from a `collection`. * `200` on success. Body: JSON document text. * `content-type:application/json` * `content-length:` -* `404` if document not found +* `404` document not found ### POST / Query a collection by provided query as POST body. diff --git a/src/jbr/jbr.c b/src/jbr/jbr.c index ec5ef87a8..e5c620a51 100644 --- a/src/jbr/jbr.c +++ b/src/jbr/jbr.c @@ -1,673 +1,545 @@ #include "jbr.h" -#include -#include #include "ejdb2_internal.h" -#define FIO_INCLUDE_STR +#include +#include +#include -#include -#include -#include -#include +#include #include #define JBR_MAX_KEY_LEN 36 -#define JBR_HTTP_CHUNK_SIZE 4096 #define JBR_WS_STR_PREMATURE_END "Premature end of message" -static uint64_t k_header_x_access_token_hash; -static uint64_t k_header_x_hints_hash; -static uint64_t k_header_content_length_hash; -static uint64_t k_header_content_type_hash; - typedef enum { - JBR_GET = 1, - JBR_PUT, - JBR_PATCH, - JBR_DELETE, - JBR_POST, - JBR_HEAD, - JBR_OPTIONS, -} jbr_method_t; - -struct _JBR { - volatile bool terminated; - volatile iwrc rc; - pthread_t worker_thread; - pthread_barrier_t start_barrier; - const EJDB_HTTP *http; + _JBR_ERROR_START = (IW_ERROR_START + 15000UL + 3000), + JBR_ERROR_WS_INVALID_MESSAGE, /**< Invalid message recieved (JBR_ERROR_WS_INVALID_MESSAGE) */ + JBR_ERROR_WS_ACCESS_DENIED, /**< Access denied (JBR_ERROR_WS_ACCESS_DENIED) */ + _JBR_ERROR_END, +} jbr_ecode_t; + +struct jbr { + struct iwn_poller *poller; + pthread_t poller_thread; + const EJDB_HTTP *http; + struct iwn_wf_ctx *ctx; EJDB db; }; -typedef struct _JBRCTX { - JBR jbr; - http_s *req; - const char *collection; +struct rctx { + struct iwn_wf_req *req; + struct iwn_ws_sess *ws; + struct jbr *jbr; + struct iwn_vals vals; + pthread_mutex_t mtx; + pthread_cond_t cond; + EJDB_EXEC ux; + int64_t id; + pthread_t request_thread; + bool read_anon; + bool visitor_started; + bool visitor_finished; + char cname[EJDB_COLLECTION_NAME_MAX_LEN + 1]; +}; + +struct mctx { + struct rctx *ctx; IWXSTR *wbuf; int64_t id; - size_t collection_len; - jbr_method_t method; - bool read_anon; - bool data_sent; -} JBRCTX; - -#define JBR_RC_REPORT(code_, r_, rc_) \ - do { \ - if ((code_) >= 500) iwlog_ecode_error3(rc_); \ - const char *strerr = iwlog_ecode_explained(rc_); \ - _jbr_http_send(r_, code_, "text/plain", strerr, strerr ? strlen(strerr) : 0); \ - } while (0) - -IW_INLINE void _jbr_http_set_content_length(http_s *r, uintptr_t length) { - if (!fiobj_hash_get2(r->private_data.out_headers, k_header_content_length_hash)) { - fiobj_hash_set(r->private_data.out_headers, HTTP_HEADER_CONTENT_LENGTH, - fiobj_num_new(length)); + char cname[EJDB_COLLECTION_NAME_MAX_LEN + 1]; + char key[JBR_MAX_KEY_LEN + 1]; +}; + +#define JBR_RC_REPORT(ret_, r_, rc_) \ + do { \ + if ((ret_) >= 500) iwlog_ecode_error3(rc_); \ + const char *err = iwlog_ecode_explained(rc_); \ + if (!iwn_http_response_write(r_, ret_, "text/plain", err, -1)) { \ + ret_ = -1; \ + } else { \ + ret_ = 1; \ + } \ + } while (0) + +void jbr_shutdown_request(EJDB db) { + if (db->jbr) { + iwn_poller_shutdown_request(db->jbr->poller); } } -IW_INLINE void _jbr_http_set_content_type(http_s *r, const char *ctype) { - if (!fiobj_hash_get2(r->private_data.out_headers, k_header_content_type_hash)) { - fiobj_hash_set(r->private_data.out_headers, HTTP_HEADER_CONTENT_TYPE, - fiobj_str_new(ctype, strlen(ctype))); +void jbr_shutdown_wait(struct jbr *jbr) { + if (jbr) { + pthread_t t = jbr->poller_thread; + iwn_poller_shutdown_request(jbr->poller); + if (t && t != pthread_self()) { + jbr->poller_thread = 0; + pthread_join(t, 0); + } + free(jbr); } } -IW_INLINE void _jbr_http_set_header( - http_s *r, - char *name, size_t nlen, - char *val, size_t vlen) { - http_set_header2(r, (fio_str_info_s) { - .data = name, .len = nlen - }, (fio_str_info_s) { - .data = val, .len = vlen - }); +static void* _poller_worker(void *op) { + JBR jbr = op; + iwn_poller_poll(jbr->poller); + iwn_poller_destroy(&jbr->poller); + return 0; } -static iwrc _jbr_http_send(http_s *r, int status, const char *ctype, const char *body, int bodylen) { - if (!r || !r->private_data.out_headers) { - iwlog_ecode_error3(IW_ERROR_INVALID_ARGS); - return IW_ERROR_INVALID_ARGS; - } - r->status = status; - if (ctype) { - _jbr_http_set_content_type(r, ctype); - } - if (http_send_body(r, (char*) body, bodylen)) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; +static void _rctx_dispose(struct rctx *ctx) { + if (ctx) { + for (struct iwn_val *v = ctx->vals.first; v; ) { + struct iwn_val *n = v->next; + free(v->buf); + free(v); + v = n; + } + pthread_mutex_destroy(&ctx->mtx); + pthread_cond_destroy(&ctx->cond); + free(ctx); } - return 0; } -IW_INLINE iwrc _jbr_http_error_send(http_s *r, int status) { - return _jbr_http_send(r, status, 0, 0, 0); +static void _on_http_request_dispose(struct iwn_http_req *req) { + struct rctx *ctx = req->user_data; + _rctx_dispose(ctx); } -IW_INLINE iwrc _jbr_http_error_send2(http_s *r, int status, const char *ctype, const char *body, int bodylen) { - return _jbr_http_send(r, status, ctype, body, bodylen); -} +static int _on_get(struct rctx *ctx) { + JBL jbl = 0; + IWXSTR *xstr = 0; + int nbytes = 0, ret = 500; -static iwrc _jbr_flush_chunk(JBRCTX *rctx, bool finish) { - http_s *req = rctx->req; - IWXSTR *wbuf = rctx->wbuf; - char nbuf[JBNUMBUF_SIZE + 2]; // + \r\n - assert(wbuf); - if (!rctx->data_sent) { - req->status = 200; - _jbr_http_set_content_type(req, "application/json"); - _jbr_http_set_header(req, "transfer-encoding", 17, "chunked", 7); - if (http_write_headers(req) < 0) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; - } - rctx->data_sent = true; - } - if (!finish && (iwxstr_size(wbuf) < JBR_HTTP_CHUNK_SIZE)) { - return 0; - } - intptr_t uuid = http_uuid(req); - if (iwxstr_size(wbuf) > 0) { - int sz = snprintf(nbuf, JBNUMBUF_SIZE, "%zX\r\n", iwxstr_size(wbuf)); - if (fio_write(uuid, nbuf, sz) < 0) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; - } - if (fio_write(uuid, iwxstr_ptr(wbuf), iwxstr_size(wbuf)) < 0) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; - } - if (fio_write(uuid, "\r\n", 2) < 0) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; - } - iwxstr_clear(wbuf); - } - if (finish) { - if (fio_write(uuid, "0\r\n\r\n", 5) < 0) { - iwlog_ecode_error3(JBR_ERROR_SEND_RESPONSE); - return JBR_ERROR_SEND_RESPONSE; + iwrc rc = ejdb_get(ctx->jbr->db, ctx->cname, ctx->id, &jbl); + if (rc) { + if ((rc == IWKV_ERROR_NOTFOUND) || (rc == IW_ERROR_NOT_EXISTS)) { + return 404; } + goto finish; } - return 0; -} -static iwrc _jbr_query_visitor(EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { - JBRCTX *rctx = ux->opaque; - assert(rctx); - iwrc rc = 0; - IWXSTR *wbuf = rctx->wbuf; - if (!wbuf) { - wbuf = iwxstr_new2(512); - if (!wbuf) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - rctx->wbuf = wbuf; - } - if (ux->log) { - rc = iwxstr_cat(wbuf, iwxstr_ptr(ux->log), iwxstr_size(ux->log)); - RCRET(rc); - rc = iwxstr_cat(wbuf, "--------------------", 20); - RCRET(rc); - iwxstr_destroy(ux->log); - ux->log = 0; - } - rc = iwxstr_printf(wbuf, "\r\n%lld\t", doc->id); - RCRET(rc); - if (doc->node) { - rc = jbn_as_json(doc->node, jbl_xstr_json_printer, wbuf, 0); + if (ctx->req->flags & IWN_WF_HEAD) { + RCC(rc, finish, jbl_as_json(jbl, jbl_count_json_printer, &nbytes, JBL_PRINT_PRETTY)); + RCC(rc, finish, iwn_http_response_header_i64_set(ctx->req->http, "content-length", nbytes)); } else { - rc = jbl_as_json(doc->raw, jbl_xstr_json_printer, wbuf, 0); + RCA(xstr = iwxstr_new2((size_t) jbl->bn.size * 2), finish); + RCC(rc, finish, jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY)); + nbytes = iwxstr_size(xstr); } - RCRET(rc); - return _jbr_flush_chunk(rctx, false); -} -static void _jbr_on_query(JBRCTX *rctx) { - http_s *req = rctx->req; - fio_str_info_s data = fiobj_data_read(req->body, 0); - if (data.len < 1) { - _jbr_http_error_send(rctx->req, 400); - return; - } - EJDB_EXEC ux = { - .opaque = rctx, - .db = rctx->jbr->db, - .visitor = _jbr_query_visitor - }; + ret = iwn_http_response_write(ctx->req->http, 200, "application/json", + xstr ? iwxstr_ptr(xstr) : 0, xstr ? nbytes : 0) ? 1 : -1; - // Collection name must be encoded in query - iwrc rc = jql_create2(&ux.q, 0, data.data, JQL_SILENT_ON_PARSE_ERROR | JQL_KEEP_QUERY_ON_PARSE_ERROR); - RCGO(rc, finish); - if (rctx->read_anon && jql_has_apply(ux.q)) { - // We have not permitted data modification request - jql_destroy(&ux.q); - _jbr_http_error_send(rctx->req, 403); - return; - } - - FIOBJ h = fiobj_hash_get2(req->headers, k_header_x_hints_hash); - if (h) { - if (!fiobj_type_is(h, FIOBJ_T_STRING)) { - jql_destroy(&ux.q); - _jbr_http_error_send(req, 400); - return; - } - fio_str_info_s hv = fiobj_obj2cstr(h); - if (strstr(hv.data, "explain")) { - ux.log = iwxstr_new(); - if (!ux.log) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - goto finish; - } - } +finish: + if (rc) { + JBR_RC_REPORT(ret, ctx->req->http, rc); } + jbl_destroy(&jbl); + iwxstr_destroy(xstr); + return ret; +} - rc = ejdb_exec(&ux); +static int _on_post(struct rctx *ctx) { + if (ctx->read_anon) { + return 403; + } + if (ctx->req->body_len < 1) { + return 400; + } - if (!rc && rctx->wbuf) { - rc = iwxstr_cat(rctx->wbuf, "\r\n", 2); - RCGO(rc, finish); - rc = _jbr_flush_chunk(rctx, true); + JBL jbl; + int64_t id; + int ret = 500; + iwrc rc = jbl_from_json(&jbl, ctx->req->body); + if (rc) { + ret = 400; + goto finish; } + RCC(rc, finish, ejdb_put_new(ctx->jbr->db, ctx->cname, jbl, &id)); + ret = iwn_http_response_printf(ctx->req->http, 200, "text/plain", "%" PRId64, id) ? 1 : -1; finish: if (rc) { - iwrc rcs = rc; - iwrc_strip_code(&rcs); - switch (rcs) { - case JQL_ERROR_QUERY_PARSE: { - const char *err = jql_error(ux.q); - _jbr_http_error_send2(rctx->req, 400, "text/plain", err, err ? (int) strlen(err) : 0); - break; - } - case JQL_ERROR_NO_COLLECTION: - JBR_RC_REPORT(400, req, rc); - break; - default: - if (rctx->data_sent) { - // We cannot report error over HTTP - // because already sent some data to client - iwlog_ecode_error3(rc); - http_complete(req); - } else { - JBR_RC_REPORT(500, req, rc); - } - break; - } - } else if (rctx->data_sent) { - http_complete(req); - } else if (ux.log) { - iwxstr_cat(ux.log, "--------------------", 20); - if (jql_has_aggregate_count(ux.q)) { - iwxstr_printf(ux.log, "\n%lld", ux.cnt); - } - _jbr_http_send(req, 200, "text/plain", iwxstr_ptr(ux.log), iwxstr_size(ux.log)); - } else { - if (jql_has_aggregate_count(ux.q)) { - char nbuf[JBNUMBUF_SIZE]; - snprintf(nbuf, sizeof(nbuf), "%" PRId64, ux.cnt); - _jbr_http_send(req, 200, "text/plain", nbuf, (int) strlen(nbuf)); - } else { - _jbr_http_send(req, 200, 0, 0, 0); - } - } - if (ux.q) { - jql_destroy(&ux.q); - } - if (ux.log) { - iwxstr_destroy(ux.log); - } - if (rctx->wbuf) { - iwxstr_destroy(rctx->wbuf); - rctx->wbuf = 0; + JBR_RC_REPORT(ret, ctx->req->http, rc); } + jbl_destroy(&jbl); + return ret; } -static void _jbr_on_patch(JBRCTX *rctx) { - if (rctx->read_anon) { - _jbr_http_error_send(rctx->req, 403); - return; - } - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - fio_str_info_s data = fiobj_data_read(req->body, 0); - if (data.len < 1) { - _jbr_http_error_send(rctx->req, 400); - return; - } - iwrc rc = ejdb_patch(db, rctx->collection, data.data, rctx->id); - iwrc_strip_code(&rc); - switch (rc) { - case IWKV_ERROR_NOTFOUND: - case IW_ERROR_NOT_EXISTS: - _jbr_http_error_send(req, 404); - return; - case JBL_ERROR_PARSE_JSON: - case JBL_ERROR_PARSE_INVALID_CODEPOINT: - case JBL_ERROR_PARSE_INVALID_UTF8: - case JBL_ERROR_PARSE_UNQUOTED_STRING: - case JBL_ERROR_PATCH_TARGET_INVALID: - case JBL_ERROR_PATCH_NOVALUE: - case JBL_ERROR_PATCH_INVALID_OP: - case JBL_ERROR_PATCH_TEST_FAILED: - case JBL_ERROR_PATCH_INVALID_ARRAY_INDEX: - case JBL_ERROR_JSON_POINTER: - JBR_RC_REPORT(400, req, rc); - break; - default: - break; +static int _on_put(struct rctx *ctx) { + if (ctx->read_anon) { + return 403; } - if (rc) { - JBR_RC_REPORT(500, req, rc); - } else { - _jbr_http_send(req, 200, 0, 0, 0); + if (ctx->req->body_len < 1) { + return 400; } -} - -static void _jbr_on_delete(JBRCTX *rctx) { - if (rctx->read_anon) { - _jbr_http_error_send(rctx->req, 403); - return; - } - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - iwrc rc = ejdb_del(db, rctx->collection, rctx->id); - if ((rc == IWKV_ERROR_NOTFOUND) || (rc == IW_ERROR_NOT_EXISTS)) { - _jbr_http_error_send(req, 404); - return; - } else if (rc) { - JBR_RC_REPORT(500, req, rc); - return; - } - _jbr_http_send(req, 200, 0, 0, 0); -} -static void _jbr_on_put(JBRCTX *rctx) { - if (rctx->read_anon) { - _jbr_http_error_send(rctx->req, 403); - return; - } JBL jbl; - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - fio_str_info_s data = fiobj_data_read(req->body, 0); - if (data.len < 1) { - _jbr_http_error_send(rctx->req, 400); - return; - } - iwrc rc = jbl_from_json(&jbl, data.data); - if (rc) { - JBR_RC_REPORT(400, req, rc); - return; - } - rc = ejdb_put(db, rctx->collection, jbl, rctx->id); + int ret = 500; + iwrc rc = jbl_from_json(&jbl, ctx->req->body); if (rc) { - JBR_RC_REPORT(500, req, rc); + ret = 400; goto finish; } - _jbr_http_send(req, 200, 0, 0, 0); + RCC(rc, finish, ejdb_put(ctx->jbr->db, ctx->cname, jbl, ctx->id)); + ret = 200; finish: + if (rc) { + JBR_RC_REPORT(ret, ctx->req->http, rc); + } jbl_destroy(&jbl); + return ret; } -static void _jbr_on_post(JBRCTX *rctx) { - if (rctx->read_anon) { - _jbr_http_error_send(rctx->req, 403); - return; +static int _on_patch(struct rctx *ctx) { + if (ctx->read_anon) { + return 403; } - JBL jbl; - int64_t id; - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - fio_str_info_s data = fiobj_data_read(req->body, 0); - if (data.len < 1) { - _jbr_http_error_send(rctx->req, 400); - return; - } - iwrc rc = jbl_from_json(&jbl, data.data); + if (ctx->req->body_len < 1) { + return 400; + } + int ret = 200; + iwrc rc = ejdb_patch(ctx->jbr->db, ctx->cname, ctx->req->body, ctx->id); if (rc) { - JBR_RC_REPORT(400, req, rc); - return; + iwrc_strip_code(&rc); + switch (rc) { + case IWKV_ERROR_NOTFOUND: + case IW_ERROR_NOT_EXISTS: + rc = 0; + ret = 404; + break; + case JBL_ERROR_PARSE_JSON: + case JBL_ERROR_PARSE_INVALID_CODEPOINT: + case JBL_ERROR_PARSE_INVALID_UTF8: + case JBL_ERROR_PARSE_UNQUOTED_STRING: + case JBL_ERROR_PATCH_TARGET_INVALID: + case JBL_ERROR_PATCH_NOVALUE: + case JBL_ERROR_PATCH_INVALID_OP: + case JBL_ERROR_PATCH_TEST_FAILED: + case JBL_ERROR_PATCH_INVALID_ARRAY_INDEX: + case JBL_ERROR_JSON_POINTER: + ret = 400; + break; + default: + ret = 500; + break; + } } - rc = ejdb_put_new(db, rctx->collection, jbl, &id); if (rc) { - JBR_RC_REPORT(500, req, rc); - goto finish; + JBR_RC_REPORT(ret, ctx->req->http, rc); } + return ret; +} - char nbuf[JBNUMBUF_SIZE]; - int len = iwitoa(id, nbuf, sizeof(nbuf)); - _jbr_http_send(req, 200, "text/plain", nbuf, len); - -finish: - jbl_destroy(&jbl); +static int _on_delete(struct rctx *ctx) { + if (ctx->read_anon) { + return 403; + } + iwrc rc = ejdb_del(ctx->jbr->db, ctx->cname, ctx->id); + if (rc) { + if (rc == IWKV_ERROR_NOTFOUND || rc == IW_ERROR_NOT_EXISTS) { + return 404; + } else { + int ret = 500; + JBR_RC_REPORT(ret, ctx->req->http, rc); + return ret; + } + } + return 200; } -static void _jbr_on_get(JBRCTX *rctx) { - JBL jbl; +static int _on_options(struct rctx *ctx) { + iwrc rc; + JBL jbl = 0; IWXSTR *xstr = 0; - int nbytes = 0; - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - - iwrc rc = ejdb_get(db, rctx->collection, rctx->id, &jbl); - if ((rc == IWKV_ERROR_NOTFOUND) || (rc == IW_ERROR_NOT_EXISTS)) { - _jbr_http_error_send(req, 404); - return; - } else if (rc) { - JBR_RC_REPORT(500, req, rc); - return; - } - if (req->method == JBR_HEAD) { - rc = jbl_as_json(jbl, jbl_count_json_printer, &nbytes, JBL_PRINT_PRETTY); + int ret = 500; + + RCC(rc, finish, ejdb_get_meta(ctx->jbr->db, &jbl)); + RCA(xstr = iwxstr_new2((size_t) jbl->bn.size * 2), finish); + RCC(rc, finish, jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY)); + + if (ctx->jbr->http->read_anon) { + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Allow", "GET, HEAD, POST, OPTIONS", 24)); } else { - xstr = iwxstr_new2(jbl->bn.size * 2); - if (!xstr) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - goto finish; + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Allow", + "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS", 44)); + } + + if (ctx->jbr->http->cors) { + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Access-Control-Allow-Origin", "*", 1)); + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Access-Control-Allow-Headers", + "X-Requested-With, Content-Type, Accept, Origin, Authorization", 61)); + + if (ctx->jbr->http->read_anon) { + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Access-Control-Allow-Methods", + "GET, HEAD, POST, OPTIONS", 24)); + } else { + RCC(rc, finish, iwn_http_response_header_add(ctx->req->http, "Access-Control-Allow-Methods", + "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS", 44)); } - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY); } - RCGO(rc, finish); - _jbr_http_send(req, 200, "application/json", - xstr ? iwxstr_ptr(xstr) : 0, - xstr ? (int) iwxstr_size(xstr) : nbytes); + ret = iwn_http_response_write(ctx->req->http, 200, "application/json", iwxstr_ptr(xstr), iwxstr_size(xstr)) ? 1 : -1; + finish: if (rc) { - JBR_RC_REPORT(500, req, rc); + JBR_RC_REPORT(ret, ctx->req->http, rc); } jbl_destroy(&jbl); - if (xstr) { - iwxstr_destroy(xstr); - } + iwxstr_destroy(xstr); + return ret; } -static void _jbr_on_options(JBRCTX *rctx) { - JBL jbl; - EJDB db = rctx->jbr->db; - http_s *req = rctx->req; - const EJDB_HTTP *http = rctx->jbr->http; +static bool _query_chunk_write_next(struct iwn_http_req *req, bool *again) { + iwrc rc = 0; + struct iwn_val *val; + struct rctx *ctx = req->user_data; - iwrc rc = ejdb_get_meta(db, &jbl); - if (rc) { - JBR_RC_REPORT(500, req, rc); - return; + if (ctx->request_thread == pthread_self()) { + return iwn_poller_arm_events(req->poller_adapter->poller, req->poller_adapter->fd, IWN_POLLOUT) == 0; } - IWXSTR *xstr = iwxstr_new2(jbl->bn.size * 2); - if (!xstr) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - goto finish; + + pthread_mutex_lock(&ctx->mtx); +start: + val = ctx->vals.first; + if (val) { + ctx->vals.first = val->next; + if (ctx->vals.last == val) { + ctx->vals.last = 0; + } + } else if (!ctx->visitor_finished) { + pthread_cond_wait(&ctx->cond, &ctx->mtx); + goto start; } - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY); - RCGO(rc, finish); + pthread_mutex_unlock(&ctx->mtx); - if (http->read_anon) { - _jbr_http_set_header(req, "Allow", 5, "GET, HEAD, POST, OPTIONS", 24); + if (val) { + rc = iwn_http_response_chunk_write(req, val->buf, val->len, _query_chunk_write_next, again); + free(val->buf); + free(val); } else { - _jbr_http_set_header(req, "Allow", 5, "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS", 44); + rc = iwn_http_response_chunk_end(req); } - if (http->cors) { - _jbr_http_set_header(req, "Access-Control-Allow-Origin", 27, "*", 1); - _jbr_http_set_header(req, "Access-Control-Allow-Headers", 28, "X-Requested-With, Content-Type, Accept, Origin, Authorization", 61); + return rc == 0; +} - if (http->read_anon) { - _jbr_http_set_header(req, "Access-Control-Allow-Methods", 28, "GET, HEAD, POST, OPTIONS", 24); - } else { - _jbr_http_set_header(req, "Access-Control-Allow-Methods", 28, "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS", 44); - } - } +static iwrc _query_visitor(EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { + iwrc rc = 0; + struct rctx *ctx = ux->opaque; + IWXSTR *xstr = iwxstr_new(); + RCA(xstr, finish); - _jbr_http_send(req, 200, "application/json", - iwxstr_ptr(xstr), - iwxstr_size(xstr)); -finish: - if (rc) { - JBR_RC_REPORT(500, req, rc); + if (ux->log) { + RCC(rc, finish, iwxstr_cat(xstr, iwxstr_ptr(ux->log), iwxstr_size(ux->log))); + RCC(rc, finish, iwxstr_cat(xstr, "--------------------", 20)); + iwxstr_destroy(ux->log); + ux->log = 0; } - jbl_destroy(&jbl); - if (xstr) { + RCC(rc, finish, iwxstr_printf(xstr, "\r\n%" PRId64 "\t", doc->id)); + if (doc->node) { + RCC(rc, finish, jbn_as_json(doc->node, jbl_xstr_json_printer, xstr, 0)); + } else { + RCC(rc, finish, jbl_as_json(doc->raw, jbl_xstr_json_printer, xstr, 0)); + } + + if (ctx->visitor_started) { + size_t sz = iwxstr_size(xstr); + char *buf = iwxstr_destroy_keep_ptr(xstr); + pthread_mutex_lock(&ctx->mtx); + iwn_val_add_new(&ctx->vals, buf, sz); + pthread_cond_broadcast(&ctx->cond); + pthread_mutex_unlock(&ctx->mtx); + } else { + ctx->visitor_started = true; + RCC(rc, finish, iwn_http_response_chunk_write( + ctx->req->http, iwxstr_ptr(xstr), iwxstr_size(xstr), _query_chunk_write_next, 0)); iwxstr_destroy(xstr); } + + xstr = 0; + +finish: + iwxstr_destroy(xstr); + return rc; } -static bool _jbr_fill_ctx(http_s *req, JBRCTX *r) { - JBR jbr = req->udata; - memset(r, 0, sizeof(*r)); - r->req = req; - r->jbr = jbr; - fio_str_info_s method = fiobj_obj2cstr(req->method); - switch (method.len) { - case 3: - if (!strncmp("GET", method.data, method.len)) { - r->method = JBR_GET; - } else if (!strncmp("PUT", method.data, method.len)) { - r->method = JBR_PUT; - } - break; - case 4: - if (!strncmp("POST", method.data, method.len)) { - r->method = JBR_POST; - } else if (!strncmp("HEAD", method.data, method.len)) { - r->method = JBR_HEAD; - } - break; - case 5: - if (!strncmp("PATCH", method.data, method.len)) { - r->method = JBR_PATCH; - } - break; - case 6: - if (!strncmp("DELETE", method.data, method.len)) { - r->method = JBR_DELETE; - } - break; - case 7: - if (!strncmp("OPTIONS", method.data, method.len)) { - r->method = JBR_OPTIONS; - } - break; +static int _on_query(struct rctx *ctx) { + if (ctx->req->body_len < 1) { + return 400; } - if (!r->method) { - // Unknown method - return false; + iwrc rc = 0; + int ret = 500; + + ctx->ux.opaque = ctx; + ctx->ux.db = ctx->jbr->db; + ctx->ux.visitor = _query_visitor; + + RCC(rc, finish, + jql_create2(&ctx->ux.q, 0, ctx->req->body, JQL_SILENT_ON_PARSE_ERROR | JQL_KEEP_QUERY_ON_PARSE_ERROR)); + + if (ctx->read_anon && jql_has_apply(ctx->ux.q)) { + jql_destroy(&ctx->ux.q); + return 403; } - fio_str_info_s path = fiobj_obj2cstr(req->path); - if (!req->path || (path.len < 2)) { - return true; - } else if (r->method == JBR_OPTIONS) { - return false; + + struct iwn_val val = iwn_http_request_header_get(ctx->req->http, "x-hints", IW_LLEN("x-hints")); + if (val.len) { + char buf[val.len + 1]; + memcpy(buf, val.buf, val.len); + buf[val.len] = '\0'; + if (strstr(buf, "explain")) { + RCA(ctx->ux.log = iwxstr_new(), finish); + } } - char *c = strchr(path.data + 1, '/'); - if (!c) { - switch (r->method) { - case JBR_GET: - case JBR_HEAD: - case JBR_PUT: - case JBR_DELETE: - case JBR_PATCH: - return false; - default: - break; + rc = ejdb_exec(&ctx->ux); + + pthread_mutex_lock(&ctx->mtx); + ctx->visitor_finished = true; + pthread_cond_broadcast(&ctx->cond); + pthread_mutex_unlock(&ctx->mtx); + RCGO(rc, finish); + + if (!ctx->visitor_started) { + if (ctx->ux.log) { + iwxstr_cat(ctx->ux.log, "--------------------", 20); + if (jql_has_aggregate_count(ctx->ux.q)) { + iwxstr_printf(ctx->ux.log, "\n%" PRId64, ctx->ux.cnt); + } + ret = iwn_http_response_write(ctx->req->http, 200, "text/plain", + iwxstr_ptr(ctx->ux.log), iwxstr_size(ctx->ux.log)) + ? 1 : -1; + } else if (jql_has_aggregate_count(ctx->ux.q)) { + ret = iwn_http_response_printf(ctx->req->http, 200, "text/plain", "%" PRId64, ctx->ux.cnt) + ? 1 : -1; + } else { + ret = 200; } - r->collection = path.data + 1; - r->collection_len = path.len - 1; } else { - char *eptr; - char nbuf[JBNUMBUF_SIZE]; - r->collection = path.data + 1; - r->collection_len = c - r->collection; - int nlen = path.len - (c - path.data) - 1; - if (nlen < 1) { - goto finish; - } - if (nlen > JBNUMBUF_SIZE - 1) { - return false; - } - memcpy(nbuf, r->collection + r->collection_len + 1, nlen); - nbuf[nlen] = '\0'; - r->id = strtoll(nbuf, &eptr, 10); - if ((*eptr != '\0') || (r->id < 1) || (r->method == JBR_POST)) { - return false; - } + ret = 1; } finish: - return (r->collection_len <= EJDB_COLLECTION_NAME_MAX_LEN); + if (rc) { + iwrc rcs = rc; + iwrc_strip_code(&rcs); + switch (rcs) { + case JQL_ERROR_QUERY_PARSE: { + const char *err = jql_error(ctx->ux.q); + ret = iwn_http_response_write(ctx->req->http, 400, "text/plain", err, -1) ? 1 : -1; + break; + } + case JQL_ERROR_NO_COLLECTION: + ret = 400; + JBR_RC_REPORT(ret, ctx->req->http, rc); + break; + default: + JBR_RC_REPORT(ret, ctx->req->http, rc); + break; + } + } + jql_destroy(&ctx->ux.q); + iwxstr_destroy(ctx->ux.log); + return ret; } -static void _jbr_on_http_request(http_s *req) { - JBRCTX rctx; - JBR jbr = req->udata; - assert(jbr); - const EJDB_HTTP *http = jbr->http; - char cname[EJDB_COLLECTION_NAME_MAX_LEN + 1]; +static int _on_http_request(struct iwn_wf_req *req, void *op) { + struct jbr *jbr = op; + struct rctx *ctx = calloc(1, sizeof(*ctx)); + if (!ctx) { + return 500; + } + pthread_mutex_init(&ctx->mtx, 0); + pthread_cond_init(&ctx->cond, 0); + + ctx->req = req; + ctx->jbr = jbr; + ctx->request_thread = pthread_self(); + + uint32_t method = req->flags & IWN_WF_METHODS_ALL; + req->http->user_data = ctx; + req->http->on_request_dispose = _on_http_request_dispose; - if (http->cors) { - _jbr_http_set_header(req, "Access-Control-Allow-Origin", 27, "*", 1); + if ((req->flags & IWN_WF_OPTIONS) && req->path_unmatched[0] != '\0') { + return 400; } - if (!_jbr_fill_ctx(req, &rctx)) { - http_send_error(req, 400); // Bad request - return; + { + // Parse {collection name}/{id} + const char *cname = req->path_unmatched; + size_t len = strlen(cname); + char *c = strchr(req->path_unmatched, '/'); + if (!c) { + if ( len > EJDB_COLLECTION_NAME_MAX_LEN + || (method & (IWN_WF_GET | IWN_WF_HEAD | IWN_WF_PUT | IWN_WF_DELETE | IWN_WF_PATCH))) { + return 400; + } + } else { + len = c - cname; + if ( len > EJDB_COLLECTION_NAME_MAX_LEN + || method == IWN_WF_POST) { + return 400; + } + char *ep; + ctx->id = strtoll(c + 1, &ep, 10); + if (*ep != '\0' || ctx->id < 1) { + return 400; + } + } + memcpy(ctx->cname, cname, len); + ctx->cname[len] = '\0'; } - if (http->access_token) { - FIOBJ h = fiobj_hash_get2(req->headers, k_header_x_access_token_hash); - if (!h) { - if (http->read_anon) { - if ((rctx.method == JBR_GET) || (rctx.method == JBR_HEAD) || ((rctx.method == JBR_POST) && !rctx.collection)) { - rctx.read_anon = true; + + if (jbr->http->access_token) { + struct iwn_val val = iwn_http_request_header_get(req->http, "x-access-token", IW_LLEN("x-access-token")); + if (!val.len) { + if (jbr->http->read_anon) { + if ( (method & (IWN_WF_GET | IWN_WF_HEAD)) + || (method == IWN_WF_POST && ctx->cname[0] == '\0')) { + ctx->read_anon = true; goto process; } } - http_send_error(req, 401); - return; - } - if (!fiobj_type_is(h, FIOBJ_T_STRING)) { // header specified more than once - http_send_error(req, 400); - return; - } - fio_str_info_s hv = fiobj_obj2cstr(h); - if ((hv.len != http->access_token_len) || (memcmp(hv.data, http->access_token, http->access_token_len) != 0)) { // -V526 - http_send_error(req, 403); - return; + return 401; + } else { + if ( val.len != jbr->http->access_token_len + || strncmp(val.buf, jbr->http->access_token, val.len) != 0) { + return 403; + } } } process: - if (rctx.collection) { - // convert to `\0` terminated c-string - memcpy(cname, rctx.collection, rctx.collection_len); - cname[rctx.collection_len] = '\0'; - rctx.collection = cname; - switch (rctx.method) { - case JBR_GET: - case JBR_HEAD: - _jbr_on_get(&rctx); - break; - case JBR_POST: - _jbr_on_post(&rctx); - break; - case JBR_PUT: - _jbr_on_put(&rctx); - break; - case JBR_PATCH: - _jbr_on_patch(&rctx); - break; - case JBR_DELETE: - _jbr_on_delete(&rctx); - break; + if (jbr->http->cors && iwn_http_response_header_set(req->http, "access-control-allow-origin", "*", 1)) { + return 500; + } + if (ctx->cname[0] != '\0') { + switch (method) { + case IWN_WF_GET: + case IWN_WF_HEAD: + return _on_get(ctx); + case IWN_WF_POST: + return _on_post(ctx); + case IWN_WF_PUT: + return _on_put(ctx); + case IWN_WF_PATCH: + return _on_patch(ctx); + case IWN_WF_DELETE: + return _on_delete(ctx); default: - http_send_error(req, 400); - break; + return 400; } - } else if (rctx.method == JBR_POST) { - _jbr_on_query(&rctx); - } else if (rctx.method == JBR_OPTIONS) { - _jbr_on_options(&rctx); + } else if (method == IWN_WF_POST) { + return _on_query(ctx); + } else if (method == IWN_WF_OPTIONS) { + return _on_options(ctx); } else { - http_send_error(req, 400); + return 400; } } -static void _jbr_on_http_finish(struct http_settings_s *settings) { -} - -static void _jbr_on_pre_start(void *op) { - JBR jbr = op; - if (!jbr->http->blocking) { - pthread_barrier_wait(&jbr->start_barrier); - } -} - -//------------------ WS --------------------- - - -#define _WS_KEYPREFIX_BUFSZ (JBNUMBUF_SIZE + JBR_MAX_KEY_LEN + 2) - typedef enum { JBWS_NONE, JBWS_SET, @@ -681,293 +553,296 @@ typedef enum { JBWS_IDX, JBWS_NIDX, JBWS_REMOVE_COLL, -} jbwsop_t; - -typedef struct _JBWCTX { - bool read_anon; - EJDB db; - ws_s *ws; -} JBWCTX; - -IW_INLINE bool _jbr_ws_write_text(ws_s *ws, const char *data, int len) { - if (fio_is_closed(websocket_uuid(ws)) || (websocket_write(ws, (fio_str_info_s) { - .data = (char*) data, .len = len - }, 1) < 0)) { - iwlog_warn2("Websocket channel closed"); - return false; +} jbws_e; + +static int _on_ws_session_http(struct iwn_wf_req *req, struct iwn_ws_handler_spec *spec) { + struct jbr *jbr = spec->user_data; + struct rctx *ctx = calloc(1, sizeof(*ctx)); + if (!ctx) { + return 500; + } + pthread_mutex_init(&ctx->mtx, 0); + pthread_cond_init(&ctx->cond, 0); + ctx->req = req; + ctx->jbr = jbr; + req->http->user_data = ctx; + + if (jbr->http->access_token) { + struct iwn_val val = iwn_http_request_header_get(req->http, "x-access-token", IW_LLEN("x-access-token")); + if (val.len) { + if (val.len != jbr->http->access_token_len || strncmp(val.buf, jbr->http->access_token, val.len) != 0) { + return 403; + } + } else { + if (jbr->http->read_anon) { + ctx->read_anon = true; + } else { + return 401; + } + } } - return true; -} -IW_INLINE int _jbr_fill_prefix_buf(const char *key, int64_t id, char buf[static _WS_KEYPREFIX_BUFSZ]) { - int len = (int) strlen(key); - char *wp = buf; - memcpy(wp, key, len); // NOLINT(bugprone-not-null-terminated-result) - wp += len; - *wp++ = '\t'; - wp += iwitoa(id, wp, _WS_KEYPREFIX_BUFSZ - (wp - buf)); - return (int) (wp - buf); + return 0; } -static void _jbr_ws_on_open(ws_s *ws) { - JBWCTX *wctx = websocket_udata_get(ws); - if (wctx) { - wctx->ws = ws; - } +static void _on_ws_session_dispose(struct iwn_ws_sess *ws) { + _on_http_request_dispose(ws->req->http); } -static void _jbr_ws_on_close(intptr_t uuid, void *udata) { - JBWCTX *wctx = udata; - free(wctx); +static bool _on_ws_session_init(struct iwn_ws_sess *ws) { + struct rctx *ctx = ws->req->http->user_data; + ctx->ws = ws; + return true; } -static void _jbr_ws_send_error(JBWCTX *wctx, const char *key, const char *error, const char *extra) { - assert(wctx && key && error); - IWXSTR *xstr = iwxstr_new(); - if (!xstr) { - iwlog_ecode_error3(iwrc_set_errno(IW_ERROR_ALLOC, errno)); - return; +static bool _ws_error_send(struct iwn_ws_sess *ws, const char *key, const char *error, const char *extra) { + if (key == 0) { + return false; } - iwrc rc; if (extra) { - rc = iwxstr_printf(xstr, "%s ERROR: %s %s", key, error, extra); + return iwn_ws_server_printf(ws, "%s ERROR: %s %s", key, error, extra); } else { - rc = iwxstr_printf(xstr, "%s ERROR: %s", key, error); + return iwn_ws_server_printf(ws, "%s ERROR: %s", key, error); } - if (rc) { - iwlog_ecode_error3(rc); - } else { - _jbr_ws_write_text(wctx->ws, iwxstr_ptr(xstr), iwxstr_size(xstr)); - } - iwxstr_destroy(xstr); } -static void _jbr_ws_send_rc(JBWCTX *wctx, const char *key, iwrc rc, const char *extra) { +static bool _ws_rc_send(struct iwn_ws_sess *ws, const char *key, iwrc rc, const char *extra) { const char *error = iwlog_ecode_explained(rc); - if (error) { - _jbr_ws_send_error(wctx, key, error, extra); - } + return _ws_error_send(ws, key, error ? error : "unknown", extra); } -static void _jbr_ws_add_document(JBWCTX *wctx, const char *key, const char *coll, const char *json) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; - } - JBL jbl; - int64_t id; - iwrc rc = jbl_from_json(&jbl, json); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; - } - rc = ejdb_put_new(wctx->db, coll, jbl, &id); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); +static bool _ws_info(struct iwn_ws_sess *ws, struct mctx *mctx) { + iwrc rc; + JBL jbl = 0; + IWXSTR *xstr = 0; + bool ret = true; + struct rctx *ctx = mctx->ctx; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; goto finish; } - char pbuf[_WS_KEYPREFIX_BUFSZ]; - _jbr_fill_prefix_buf(key, id, pbuf); - _jbr_ws_write_text(wctx->ws, pbuf, (int) strlen(pbuf)); + RCC(rc, finish, ejdb_get_meta(ctx->jbr->db, &jbl)); + RCA(xstr = iwxstr_new2((size_t) jbl->bn.size * 2), finish); + RCC(rc, finish, iwxstr_printf(xstr, "%s\t", mctx->key)); + RCC(rc, finish, jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY)); + ret = iwn_ws_server_write(ws, iwxstr_ptr(xstr), iwxstr_size(xstr)); finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; + } jbl_destroy(&jbl); + iwxstr_destroy(xstr); + return ret; } -static void _jbr_ws_set_document(JBWCTX *wctx, const char *key, const char *coll, int64_t id, const char *json) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; +static bool _ws_coll_remove(struct iwn_ws_sess *ws, struct mctx *mctx) { + iwrc rc; + bool ret = true; + struct rctx *ctx = mctx->ctx; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; + goto finish; } - JBL jbl; - iwrc rc = jbl_from_json(&jbl, json); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; + RCC(rc, finish, ejdb_remove_collection(ctx->jbr->db, mctx->cname)); + ret = iwn_ws_server_write(ws, mctx->key, -1); + +finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } - rc = ejdb_put(wctx->db, coll, jbl, id); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); + return ret; +} + +static bool _ws_document_add(struct iwn_ws_sess *ws, struct mctx *mctx, const char *json) { + iwrc rc; + JBL jbl = 0; + int64_t id; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; goto finish; } - char pbuf[_WS_KEYPREFIX_BUFSZ]; - int len = _jbr_fill_prefix_buf(key, id, pbuf); - _jbr_ws_write_text(wctx->ws, pbuf, len); + RCC(rc, finish, jbl_from_json(&jbl, json)); + RCC(rc, finish, ejdb_put_new(ctx->jbr->db, mctx->cname, jbl, &id)); + ret = iwn_ws_server_printf(ws, "%s\t%" PRId64, mctx->key, id); finish: jbl_destroy(&jbl); + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; + } + return ret; } -static void _jbr_ws_get_document(JBWCTX *wctx, const char *key, const char *coll, int64_t id) { - JBL jbl; - iwrc rc = ejdb_get(wctx->db, coll, id, &jbl); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; - } - IWXSTR *xstr = iwxstr_new2(jbl->bn.size * 2); - if (!xstr) { - rc = iwrc_set_errno(rc, IW_ERROR_ALLOC); - iwlog_ecode_error3(rc); - _jbr_ws_send_rc(wctx, key, rc, 0); - return; - } - char pbuf[_WS_KEYPREFIX_BUFSZ]; - _jbr_fill_prefix_buf(key, id, pbuf); - rc = iwxstr_printf(xstr, "%s\t", pbuf); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - goto finish; +static bool _ws_document_get(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t id) { + iwrc rc; + JBL jbl = 0; + IWXSTR *xstr = 0; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + + RCC(rc, finish, ejdb_get(ctx->jbr->db, mctx->cname, id, &jbl)); + RCA(xstr = iwxstr_new2((size_t) jbl->bn.size * 2), finish); + RCC(rc, finish, iwxstr_printf(xstr, "%s\t%" PRId64 "\t", mctx->key, id)); + RCC(rc, finish, jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY)); + ret = iwn_ws_server_write(ws, iwxstr_ptr(xstr), iwxstr_size(xstr)); + +finish: + iwxstr_destroy(xstr); + jbl_destroy(&jbl); + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); + return ret; +} + +static bool _ws_document_set(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t id, const char *json) { + iwrc rc; + JBL jbl = 0; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; goto finish; } - _jbr_ws_write_text(wctx->ws, iwxstr_ptr(xstr), iwxstr_size(xstr)); + RCC(rc, finish, jbl_from_json(&jbl, json)); + RCC(rc, finish, ejdb_put(ctx->jbr->db, mctx->cname, jbl, id)); + ret = iwn_ws_server_printf(ctx->ws, "%s\t%" PRId64, mctx->key, id); finish: - iwxstr_destroy(xstr); jbl_destroy(&jbl); + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; + } + return ret; } -static void _jbr_ws_del_document(JBWCTX *wctx, const char *key, const char *coll, int64_t id) { - iwrc rc = ejdb_del(wctx->db, coll, id); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; +static bool _ws_document_del(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t id) { + iwrc rc; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; + goto finish; + } + RCC(rc, finish, ejdb_del(ctx->jbr->db, mctx->cname, id)); + ret = iwn_ws_server_printf(ctx->ws, "%s\t%" PRId64, mctx->key, id); + +finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } - char pbuf[_WS_KEYPREFIX_BUFSZ]; - int len = _jbr_fill_prefix_buf(key, id, pbuf); - _jbr_ws_write_text(wctx->ws, pbuf, len); + return ret; } -static void _jbr_ws_patch_document(JBWCTX *wctx, const char *key, const char *coll, int64_t id, const char *json) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; +static bool _ws_document_patch(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t id, const char *json) { + iwrc rc; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; + goto finish; } - iwrc rc = ejdb_patch(wctx->db, coll, json, id); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; + RCC(rc, finish, ejdb_patch(ctx->jbr->db, mctx->cname, json, id)); + ret = iwn_ws_server_printf(ctx->ws, "%s\t%" PRId64, mctx->key, id); + +finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } - char pbuf[_WS_KEYPREFIX_BUFSZ]; - int len = _jbr_fill_prefix_buf(key, id, pbuf); - _jbr_ws_write_text(wctx->ws, pbuf, len); + return ret; } -static void _jbr_ws_set_index(JBWCTX *wctx, const char *key, const char *coll, int64_t mode, const char *path) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; +static bool _ws_index_set(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t mode, const char *path) { + iwrc rc; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; + goto finish; } - iwrc rc = ejdb_ensure_index(wctx->db, coll, path, mode); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - } else { - _jbr_ws_write_text(wctx->ws, key, (int) strlen(key)); + RCC(rc, finish, ejdb_ensure_index(ctx->jbr->db, mctx->cname, path, mode)); + ret = iwn_ws_server_write(ws, mctx->key, -1); + +finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } + return ret; } -static void _jbr_ws_del_index(JBWCTX *wctx, const char *key, const char *coll, int64_t mode, const char *path) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; +static bool _ws_index_del(struct iwn_ws_sess *ws, struct mctx *mctx, int64_t mode, const char *path) { + iwrc rc; + bool ret = true; + struct rctx *ctx = ws->req->http->user_data; + if (ctx->read_anon) { + rc = JBR_ERROR_WS_ACCESS_DENIED; + goto finish; } - iwrc rc = ejdb_remove_index(wctx->db, coll, path, mode); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - } else { - _jbr_ws_write_text(wctx->ws, key, (int) strlen(key)); + RCC(rc, finish, ejdb_remove_index(ctx->jbr->db, mctx->cname, path, mode)); + ret = iwn_ws_server_write(ws, mctx->key, -1); + +finish: + if (rc && !_ws_rc_send(ws, mctx->key, rc, 0)) { + ret = false; } + return ret; } -typedef struct JBWQCTX { - JBWCTX *wctx; - IWXSTR *wbuf; - const char *key; -} JBWQCTX; - -static iwrc _jbr_ws_query_visitor(EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { +static iwrc _ws_query_visitor(EJDB_EXEC *ux, EJDB_DOC doc, int64_t *step) { iwrc rc = 0; - JBWQCTX *qctx = ux->opaque; - assert(qctx); - IWXSTR *wbuf = qctx->wbuf; - if (!wbuf) { - wbuf = iwxstr_new2(512); - if (!wbuf) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); - } - qctx->wbuf = wbuf; + struct mctx *mctx = ux->opaque; + if (!mctx->wbuf) { + RCA(mctx->wbuf = iwxstr_new2(512), finish); } else { - iwxstr_clear(wbuf); + iwxstr_clear(mctx->wbuf); } if (ux->log) { - rc = iwxstr_printf(wbuf, "%s\texplain\t%s", qctx->key, iwxstr_ptr(ux->log)); + iwn_ws_server_printf(mctx->ctx->ws, "%s\texplain\t%s", mctx->key, iwxstr_ptr(ux->log)); iwxstr_destroy(ux->log); ux->log = 0; - RCRET(rc); - _jbr_ws_write_text(qctx->wctx->ws, iwxstr_ptr(wbuf), iwxstr_size(wbuf)); - iwxstr_clear(wbuf); } - - rc = iwxstr_printf(wbuf, "%s\t%lld\t", qctx->key, doc->id); - RCRET(rc); - + RCC(rc, finish, iwxstr_printf(mctx->wbuf, "%s\t%" PRId64 "\t", mctx->key, doc->id)); if (doc->node) { - rc = jbn_as_json(doc->node, jbl_xstr_json_printer, wbuf, 0); + RCC(rc, finish, jbn_as_json(doc->node, jbl_xstr_json_printer, mctx->wbuf, 0)); } else { - rc = jbl_as_json(doc->raw, jbl_xstr_json_printer, wbuf, 0); + RCC(rc, finish, jbl_as_json(doc->raw, jbl_xstr_json_printer, mctx->wbuf, 0)); } - RCRET(rc); - if (!_jbr_ws_write_text(qctx->wctx->ws, iwxstr_ptr(wbuf), iwxstr_size(wbuf))) { + if (!iwn_ws_server_write(mctx->ctx->ws, iwxstr_ptr(mctx->wbuf), iwxstr_size(mctx->wbuf))) { *step = 0; } - return 0; + +finish: + return rc; } -static void _jbr_ws_query(JBWCTX *wctx, const char *key, const char *coll, const char *query, bool explain) { - JBWQCTX qctx = { - .wctx = wctx, - .key = key - }; +static bool _ws_query(struct iwn_ws_sess *ws, struct mctx *mctx, const char *query, bool explain) { + iwrc rc; + bool ret = false; + struct rctx *ctx = mctx->ctx; + EJDB_EXEC ux = { - .db = wctx->db, - .opaque = &qctx, - .visitor = _jbr_ws_query_visitor, + .db = ctx->jbr->db, + .opaque = mctx, + .visitor = _ws_query_visitor, }; - iwrc rc = jql_create2(&ux.q, coll, query, JQL_SILENT_ON_PARSE_ERROR | JQL_KEEP_QUERY_ON_PARSE_ERROR); - RCGO(rc, finish); - - if (wctx->read_anon && jql_has_apply(ux.q)) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); + RCC(rc, finish, + jql_create2(&ux.q, mctx->cname, query, JQL_SILENT_ON_PARSE_ERROR | JQL_KEEP_QUERY_ON_PARSE_ERROR)); + if (ctx->read_anon && jql_has_apply(ux.q)) { + rc = JBR_ERROR_WS_ACCESS_DENIED; goto finish; } - if (explain) { - ux.log = iwxstr_new(); - if (!ux.log) { - iwlog_ecode_error3(iwrc_set_errno(IW_ERROR_ALLOC, errno)); - goto finish; - } + RCA(ux.log = iwxstr_new(), finish); } - - rc = ejdb_exec(&ux); - - if (!rc) { - if (ux.log) { - IWXSTR *wbuf = iwxstr_new(); - if (!wbuf) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - goto finish; - } - if (!iwxstr_printf(wbuf, "%s\texplain\t%s", qctx.key, iwxstr_ptr(ux.log))) { - _jbr_ws_write_text(wctx->ws, iwxstr_ptr(wbuf), iwxstr_size(wbuf)); - } - iwxstr_destroy(wbuf); - } + RCC(rc, finish, ejdb_exec(&ux)); + if (ux.log) { + ret = iwn_ws_server_printf(mctx->ctx->ws, "%s\texplain\t%s", mctx->key, iwxstr_ptr(ux.log)); + } else { + ret = true; } finish: @@ -976,109 +851,46 @@ static void _jbr_ws_query(JBWCTX *wctx, const char *key, const char *coll, const iwrc_strip_code(&rcs); switch (rcs) { case JQL_ERROR_QUERY_PARSE: - _jbr_ws_send_error(wctx, key, jql_error(ux.q), 0); + ret = _ws_error_send(ws, mctx->key, jql_error(ux.q), 0); break; default: - _jbr_ws_send_rc(wctx, key, rc, 0); + ret = _ws_rc_send(ws, mctx->key, rc, 0); break; } } else { if (jql_has_aggregate_count(ux.q)) { - char pbuf[_WS_KEYPREFIX_BUFSZ]; - _jbr_fill_prefix_buf(key, ux.cnt, pbuf); - _jbr_ws_write_text(wctx->ws, pbuf, (int) strlen(pbuf)); + ret = iwn_ws_server_printf(ws, "%s\t%" PRId64, mctx->key, ux.cnt); + } else { + ret = iwn_ws_server_write(ws, mctx->key, -1); } - _jbr_ws_write_text(wctx->ws, key, (int) strlen(key)); - } - if (ux.q) { - jql_destroy(&ux.q); - } - if (ux.log) { - iwxstr_destroy(ux.log); - } - if (qctx.wbuf) { - iwxstr_destroy(qctx.wbuf); } + jql_destroy(&ux.q); + iwxstr_destroy(ux.log); + return ret; } -static void _jbr_ws_info(JBWCTX *wctx, const char *key) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; - } - JBL jbl; - iwrc rc = ejdb_get_meta(wctx->db, &jbl); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - return; - } - IWXSTR *xstr = iwxstr_new2(jbl->bn.size * 2); - if (!xstr) { - rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - RCGO(rc, finish); - } - rc = iwxstr_printf(xstr, "%s\t", key); - RCGO(rc, finish); - - rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, JBL_PRINT_PRETTY); - RCGO(rc, finish); - _jbr_ws_write_text(wctx->ws, iwxstr_ptr(xstr), iwxstr_size(xstr)); - -finish: - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - } - jbl_destroy(&jbl); - if (xstr) { - iwxstr_destroy(xstr); - } -} - -static void _jbr_ws_remove_coll(JBWCTX *wctx, const char *key, const char *coll) { - if (wctx->read_anon) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_ACCESS_DENIED, 0); - return; - } - iwrc rc = ejdb_remove_collection(wctx->db, coll); - if (rc) { - _jbr_ws_send_rc(wctx, key, rc, 0); - } else { - _jbr_ws_write_text(wctx->ws, key, (int) strlen(key)); - } -} - -static void _jbr_ws_on_message(ws_s *ws, fio_str_info_s msg, uint8_t is_text) { - if (!is_text) { // Do not serve binary requests - websocket_close(ws); - return; - } - if (!msg.data || (msg.len < 1)) { // Ignore empty messages, but keep connection - return; +static bool _on_ws_msg_impl(struct iwn_ws_sess *ws, struct mctx *mctx, const char *msg_, size_t len) { + if (len < 1) { + return true; } - JBWCTX *wctx = websocket_udata_get(ws); - assert(wctx); - wctx->ws = ws; - jbwsop_t wsop = JBWS_NONE; - char keybuf[JBR_MAX_KEY_LEN + 1]; - char cnamebuf[EJDB_COLLECTION_NAME_MAX_LEN + 1]; + int pos; + jbws_e wsop = JBWS_NONE; + const char *key = 0; + char *msg = (char*) msg_; // Discard const - char *data = msg.data, *key = 0; - int len = msg.len, pos; - - // Trim right - for (pos = len; pos > 0 && isspace(data[pos - 1]); --pos) ; - len = pos; - // Trim left - for (pos = 0; pos < len && isspace(data[pos]); ++pos) ; + // Trim left/right + for ( ; len > 0 && isspace(msg[len - 1]); --len); + for (pos = 0; pos < len && isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; if (len < 1) { - return; + return true; } - if ((len == 1) && (data[0] == '?')) { - const char *help - = "\n info" + + if (len == 1 && msg[0] == '?') { + static const char help[] + = " info" "\n get " "\n set " "\n add " @@ -1089,264 +901,202 @@ static void _jbr_ws_on_message(ws_s *ws, fio_str_info_s msg, uint8_t is_text) { "\n rmc " "\n query " "\n explain " - "\n " - "\n"; - _jbr_ws_write_text(ws, help, (int) strlen(help)); - return; + "\n "; + return iwn_ws_server_write(ws, help, sizeof(help) - 1); } // Fetch key, after we can do good errors reporting - for (pos = 0; pos < len && !isspace(data[pos]); ++pos) ; + for (pos = 0; pos < len && !isspace(msg[pos]); ++pos); if (pos > JBR_MAX_KEY_LEN) { - iwlog_warn("The key length: %d exceeded limit: %d", pos, JBR_MAX_KEY_LEN); - return; + return false; } - memcpy(keybuf, data, pos); - keybuf[pos] = '\0'; - key = keybuf; + memcpy(mctx->key, msg, pos); + mctx->key[pos] = '\0'; if (pos >= len) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); - return; + return _ws_rc_send(ws, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); } - // Space - for ( ; pos < len && isspace(data[pos]); ++pos) ; + for ( ; pos < len && isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; if (len < 1) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); - return; + return _ws_rc_send(ws, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); } // Fetch command - for (pos = 0; pos < len && !isspace(data[pos]); ++pos) ; + for (pos = 0; pos < len && !isspace(msg[pos]); ++pos); if (pos <= len) { - if (!strncmp("get", data, pos)) { + if (!strncmp("get", msg, pos)) { wsop = JBWS_GET; - } else if (!strncmp("add", data, pos)) { + } else if (!strncmp("add", msg, pos)) { wsop = JBWS_ADD; - } else if (!strncmp("set", data, pos)) { + } else if (!strncmp("set", msg, pos)) { wsop = JBWS_SET; - } else if (!strncmp("query", data, pos)) { + } else if (!strncmp("query", msg, pos)) { wsop = JBWS_QUERY; - } else if (!strncmp("del", data, pos)) { + } else if (!strncmp("del", msg, pos)) { wsop = JBWS_DEL; - } else if (!strncmp("patch", data, pos)) { + } else if (!strncmp("patch", msg, pos)) { wsop = JBWS_PATCH; - } else if (!strncmp("explain", data, pos)) { + } else if (!strncmp("explain", msg, pos)) { wsop = JBWS_EXPLAIN; - } else if (!strncmp("info", data, pos)) { + } else if (!strncmp("info", msg, pos)) { wsop = JBWS_INFO; - } else if (!strncmp("idx", data, pos)) { + } else if (!strncmp("idx", msg, pos)) { wsop = JBWS_IDX; - } else if (!strncmp("rmi", data, pos)) { + } else if (!strncmp("rmi", msg, pos)) { wsop = JBWS_NIDX; - } else if (!strncmp("rmc", data, pos)) { + } else if (!strncmp("rmc", msg, pos)) { wsop = JBWS_REMOVE_COLL; } } if (wsop > JBWS_NONE) { if (wsop == JBWS_INFO) { - _jbr_ws_info(wctx, key); - return; + return _ws_info(ws, mctx); } - for ( ; pos < len && isspace(data[pos]); ++pos) ; + for ( ; pos < len && isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; - char *coll = data; - for (pos = 0; pos < len && !isspace(data[pos]); ++pos) ; + const char *rp = msg; + for (pos = 0; pos < len && !isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; - if ((pos < 1) || (len < 1)) { + if (pos < 1 || len < 1) { if (wsop != JBWS_REMOVE_COLL) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); - return; + return _ws_rc_send(ws, mctx->key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); } } else if (pos > EJDB_COLLECTION_NAME_MAX_LEN) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, - "Collection name exceeds maximum length allowed: " - "EJDB_COLLECTION_NAME_MAX_LEN"); - return; + return _ws_rc_send(ws, key, JBR_ERROR_WS_INVALID_MESSAGE, + "Collection name exceeds maximum length allowed: " + "EJDB_COLLECTION_NAME_MAX_LEN"); } - memcpy(cnamebuf, coll, pos); - cnamebuf[pos] = '\0'; - coll = cnamebuf; + memcpy(mctx->cname, rp, pos); + mctx->cname[pos] = '\0'; if (wsop == JBWS_REMOVE_COLL) { - _jbr_ws_remove_coll(wctx, key, coll); - return; + return _ws_coll_remove(ws, mctx); } - for (pos = 0; pos < len && isspace(data[pos]); ++pos) ; + for (pos = 0; pos < len && isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; if (len < 1) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); - return; + return _ws_rc_send(ws, mctx->key, JBR_ERROR_WS_INVALID_MESSAGE, JBR_WS_STR_PREMATURE_END); } switch (wsop) { case JBWS_ADD: - data[len] = '\0'; - _jbr_ws_add_document(wctx, key, coll, data); - break; + msg[len] = '\0'; + return _ws_document_add(ws, mctx, msg); case JBWS_QUERY: case JBWS_EXPLAIN: - data[len] = '\0'; - _jbr_ws_query(wctx, key, coll, data, (wsop == JBWS_EXPLAIN)); - break; + msg[len] = '\0'; + return _ws_query(ws, mctx, msg, (wsop == JBWS_EXPLAIN)); default: { - char nbuf[JBNUMBUF_SIZE]; - for (pos = 0; pos < len && pos < JBNUMBUF_SIZE - 1 && isdigit(data[pos]); ++pos) { - nbuf[pos] = data[pos]; + char nbuf[IWNUMBUF_SIZE]; + for (pos = 0; pos < len && pos < IWNUMBUF_SIZE - 1 && isdigit(msg[pos]); ++pos) { + nbuf[pos] = msg[pos]; } nbuf[pos] = '\0'; - for ( ; pos < len && isspace(data[pos]); ++pos) ; + for ( ; pos < len && isspace(msg[pos]); ++pos); len -= pos; - data += pos; + msg += pos; int64_t id = iwatoi(nbuf); if (id < 1) { - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, "Invalid document id specified"); - return; + return _ws_rc_send(ws, mctx->key, JBR_ERROR_WS_INVALID_MESSAGE, "Invalid document id specified"); } + msg[len] = '\0'; switch (wsop) { case JBWS_GET: - _jbr_ws_get_document(wctx, key, coll, id); - break; + return _ws_document_get(ws, mctx, id); case JBWS_SET: - data[len] = '\0'; - _jbr_ws_set_document(wctx, key, coll, id, data); - break; + return _ws_document_set(ws, mctx, id, msg); case JBWS_DEL: - _jbr_ws_del_document(wctx, key, coll, id); - break; + return _ws_document_del(ws, mctx, id); case JBWS_PATCH: - data[len] = '\0'; - _jbr_ws_patch_document(wctx, key, coll, id, data); - break; + return _ws_document_patch(ws, mctx, id, msg); case JBWS_IDX: - data[len] = '\0'; - _jbr_ws_set_index(wctx, key, coll, id, data); - break; + return _ws_index_set(ws, mctx, id, msg); case JBWS_NIDX: - data[len] = '\0'; - _jbr_ws_del_index(wctx, key, coll, id, data); - break; + return _ws_index_del(ws, mctx, id, msg); default: - _jbr_ws_send_rc(wctx, key, JBR_ERROR_WS_INVALID_MESSAGE, 0); - return; + return _ws_rc_send(ws, mctx->key, JBR_ERROR_WS_INVALID_MESSAGE, 0); } } } } else { - data[len] = '\0'; - _jbr_ws_query(wctx, key, 0, data, false); + msg[len] = '\0'; + return _ws_query(ws, mctx, msg, false); } } -static void _jbr_on_http_upgrade(http_s *req, char *requested_protocol, size_t len) { - JBR jbr = req->udata; - assert(jbr); - const EJDB_HTTP *http = jbr->http; - fio_str_info_s path = fiobj_obj2cstr(req->path); +static bool _on_ws_msg(struct iwn_ws_sess *ws, const char *msg, size_t len, uint8_t frame) { + struct mctx mctx = { + .ctx = ws->req->http->user_data, + }; + bool ret = _on_ws_msg_impl(ws, &mctx, msg, len); + iwxstr_destroy(mctx.wbuf); + return ret; +} - if ( ((path.len != 1) || (path.data[0] != '/')) - || ((len != 9) || (requested_protocol[1] != 'e'))) { - http_send_error(req, 400); - return; - } - JBWCTX *wctx = calloc(1, sizeof(*wctx)); - if (!wctx) { - http_send_error(req, 500); - return; - } - wctx->db = jbr->db; +static iwrc _configure(struct jbr *jbr) { + iwrc rc; - if (http->access_token) { - FIOBJ h = fiobj_hash_get2(req->headers, k_header_x_access_token_hash); - if (!h) { - if (http->read_anon) { - wctx->read_anon = true; - } else { - free(wctx); - http_send_error(req, 401); - return; - } - } - if (!fiobj_type_is(h, FIOBJ_T_STRING)) { // header specified more than once - free(wctx); - http_send_error(req, 400); - return; - } - fio_str_info_s hv = fiobj_obj2cstr(h); - if ((hv.len != http->access_token_len) || (memcmp(hv.data, http->access_token, http->access_token_len) != 0)) { // -V526 - free(wctx); - http_send_error(req, 403); - return; - } - } - if (http_upgrade2ws(req, - .on_message = _jbr_ws_on_message, - .on_open = _jbr_ws_on_open, - .on_close = _jbr_ws_on_close, - .udata = wctx) < 0) { - free(wctx); - JBR_RC_REPORT(500, req, JBR_ERROR_WS_UPGRADE); - } -} + RCC(rc, finish, iwn_wf_create(&(struct iwn_wf_route) { + .handler = 0 + }, &jbr->ctx)); + + RCC(rc, finish, iwn_wf_route(iwn_ws_server_route_attach(&(struct iwn_wf_route) { + .ctx = jbr->ctx, + .pattern = "/", + .flags = IWN_WF_GET, + }, &(struct iwn_ws_handler_spec) { + .handler = _on_ws_msg, + .on_http_init = _on_ws_session_http, + .on_session_init = _on_ws_session_init, + .on_session_dispose = _on_ws_session_dispose, + .user_data = jbr + }), 0)); + + RCC(rc, finish, iwn_wf_route(&(struct iwn_wf_route) { + .ctx = jbr->ctx, + .pattern = "/", + .flags = IWN_WF_MATCH_PREFIX | IWN_WF_METHODS_ALL, + .handler = _on_http_request, + .user_data = jbr + }, 0)); -//---------------- Main --------------------- +finish: + return rc; +} -static void *_jbr_start_thread(void *op) { - JBR jbr = op; - char nbuf[JBNUMBUF_SIZE]; +static iwrc _start(struct jbr *jbr) { const EJDB_HTTP *http = jbr->http; - const char *bind = http->bind ? http->bind : "localhost"; - if (http->port < 1) { - jbr->rc = JBR_ERROR_PORT_INVALID; - if (!jbr->http->blocking) { - pthread_barrier_wait(&jbr->start_barrier); - } - return 0; + struct iwn_wf_server_spec spec = { + .poller = jbr->poller, + .listen = http->bind ? http->bind : "localhost", + .port = http->port > 0 ? http->port : 9292, + }; + if (http->ssl_private_key) { + spec.ssl.private_key = http->ssl_private_key; + spec.ssl.private_key_len = -1; } - iwitoa(http->port, nbuf, sizeof(nbuf)); - iwlog_info("HTTP/WS endpoint at %s:%s", bind, nbuf); - websocket_optimize4broadcasts(WEBSOCKET_OPTIMIZE_PUBSUB_TEXT, 1); - if (http_listen(nbuf, bind, - .udata = jbr, - .on_request = _jbr_on_http_request, - .on_upgrade = _jbr_on_http_upgrade, - .on_finish = _jbr_on_http_finish, - .max_body_size = http->max_body_size, - .ws_max_msg_size = http->max_body_size) == -1) { - jbr->rc = iwrc_set_errno(JBR_ERROR_HTTP_LISTEN, errno); - } - if (jbr->rc) { - if (!jbr->http->blocking) { - pthread_barrier_wait(&jbr->start_barrier); - } - return 0; + if (http->ssl_certs) { + spec.ssl.certs = http->ssl_certs; + spec.ssl.certs_len = -1; } - fio_state_callback_add(FIO_CALL_PRE_START, _jbr_on_pre_start, jbr); - fio_start(.threads = -2, .workers = 1, .is_no_signal_handlers = !jbr->http->blocking); // Will block current thread - // here - return 0; -} -static void _jbr_release(JBR *pjbr) { - JBR jbr = *pjbr; - free(jbr); - *pjbr = 0; + return iwn_wf_server(&spec, jbr->ctx); } -iwrc jbr_start(EJDB db, const EJDB_OPTS *opts, JBR *pjbr) { - iwrc rc; - *pjbr = 0; +iwrc jbr_start(EJDB db, const EJDB_OPTS *opts, struct jbr **jbrp) { + iwrc rc = 0; + *jbrp = 0; if (!opts->http.enabled) { return 0; } @@ -1355,71 +1105,40 @@ iwrc jbr_start(EJDB db, const EJDB_OPTS *opts, JBR *pjbr) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } jbr->db = db; - jbr->terminated = true; jbr->http = &opts->http; + *jbrp = jbr; + + uint16_t cores = iwp_num_cpu_cores(); + cores = MAX(2, cores == 0 ? 1 : cores - 1); + + RCC(rc, finish, _configure(jbr)); + RCC(rc, finish, iwn_poller_create(cores, cores / 2, &jbr->poller)); + RCC(rc, finish, _start(jbr)); if (!jbr->http->blocking) { - int rci = pthread_barrier_init(&jbr->start_barrier, 0, 2); - if (rci) { - free(jbr); - return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci); - } - rci = pthread_create(&jbr->worker_thread, 0, _jbr_start_thread, jbr); - if (rci) { - pthread_barrier_destroy(&jbr->start_barrier); - free(jbr); - return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci); - } - pthread_barrier_wait(&jbr->start_barrier); - pthread_barrier_destroy(&jbr->start_barrier); - jbr->terminated = false; - rc = jbr->rc; - if (rc) { - jbr_shutdown(pjbr); - return rc; - } - *pjbr = jbr; + pthread_create(&jbr->poller_thread, 0, _poller_worker, jbr); } else { - *pjbr = jbr; - jbr->terminated = false; - _jbr_start_thread(jbr); // Will block here - rc = jbr->rc; - jbr->terminated = true; - IWRC(jbr_shutdown(pjbr), rc); + iwn_poller_poll(jbr->poller); + iwn_poller_destroy(&jbr->poller); + *jbrp = 0; + free(jbr); } - return rc; -} -iwrc jbr_shutdown(JBR *pjbr) { - if (!*pjbr) { - return 0; - } - JBR jbr = *pjbr; - if (__sync_bool_compare_and_swap(&jbr->terminated, 0, 1)) { - fio_state_callback_remove(FIO_CALL_PRE_START, _jbr_on_pre_start, jbr); - fio_stop(); - if (!jbr->http->blocking) { - pthread_join(jbr->worker_thread, 0); - } +finish: + if (rc) { + *jbrp = 0; + iwn_wf_destroy(jbr->ctx); + iwn_poller_destroy(&jbr->poller); + free(jbr); } - _jbr_release(pjbr); - *pjbr = 0; - return 0; + return rc; } -static const char *_jbr_ecodefn(locale_t locale, uint32_t ecode) { +static const char* _jbr_ecodefn(locale_t locale, uint32_t ecode) { if (!((ecode > _JBR_ERROR_START) && (ecode < _JBR_ERROR_END))) { return 0; } switch (ecode) { - case JBR_ERROR_HTTP_LISTEN: - return "Failed to start HTTP network listener (JBR_ERROR_HTTP_LISTEN)"; - case JBR_ERROR_PORT_INVALID: - return "Invalid port specified (JBR_ERROR_PORT_INVALID)"; - case JBR_ERROR_SEND_RESPONSE: - return "Error sending response (JBR_ERROR_SEND_RESPONSE)"; - case JBR_ERROR_WS_UPGRADE: - return "Failed upgrading to websocket connection (JBR_ERROR_WS_UPGRADE)"; case JBR_ERROR_WS_INVALID_MESSAGE: return "Invalid message recieved (JBR_ERROR_WS_INVALID_MESSAGE)"; case JBR_ERROR_WS_ACCESS_DENIED: @@ -1428,14 +1147,10 @@ static const char *_jbr_ecodefn(locale_t locale, uint32_t ecode) { return 0; } -iwrc jbr_init() { +iwrc jbr_init(void) { static int _jbr_initialized = 0; if (!__sync_bool_compare_and_swap(&_jbr_initialized, 0, 1)) { return 0; } - k_header_x_access_token_hash = fiobj_hash_string("x-access-token", 14); - k_header_x_hints_hash = fiobj_hash_string("x-hints", 7); - k_header_content_length_hash = fiobj_hash_string("content-length", 14); - k_header_content_type_hash = fiobj_hash_string("content-type", 12); return iwlog_register_ecodefn(_jbr_ecodefn); } diff --git a/src/jbr/jbr.h b/src/jbr/jbr.h index b76355074..ac7b7ef81 100644 --- a/src/jbr/jbr.h +++ b/src/jbr/jbr.h @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,27 +30,18 @@ #include "ejdb2.h" -IW_EXTERN_C_START +IW_EXTERN_C_START; -typedef enum { - _JBR_ERROR_START = (IW_ERROR_START + 15000UL + 3000), - JBR_ERROR_HTTP_LISTEN, /**< Failed to start HTTP network listener (JBR_ERROR_HTTP_LISTEN) */ - JBR_ERROR_PORT_INVALID, /**< Invalid port specified (JBR_ERROR_PORT_INVALID) */ - JBR_ERROR_SEND_RESPONSE, /**< Error sending response (JBR_ERROR_SEND_RESPONSE) */ - JBR_ERROR_WS_UPGRADE, /**< Failed upgrading to websocket connection (JBR_ERROR_WS_UPGRADE) */ - JBR_ERROR_WS_INVALID_MESSAGE, /**< Invalid message recieved (JBR_ERROR_WS_INVALID_MESSAGE) */ - JBR_ERROR_WS_ACCESS_DENIED, /**< Access denied (JBR_ERROR_WS_ACCESS_DENIED) */ - _JBR_ERROR_END, -} jbr_ecode_t; +struct jbr; +typedef struct jbr*JBR; -struct _JBR; -typedef struct _JBR*JBR; +iwrc jbr_start(struct ejdb *db, const struct ejdb_opts *opts, struct jbr **out_jbr); -iwrc jbr_start(EJDB db, const EJDB_OPTS *opts, JBR *pjbr); +void jbr_shutdown_request(struct ejdb *db); -iwrc jbr_shutdown(JBR *pjbr); +void jbr_shutdown_wait(struct jbr *jbr); iwrc jbr_init(void); -IW_EXTERN_C_END +IW_EXTERN_C_END; #endif diff --git a/src/jbr/tests/jbr_test1.c b/src/jbr/tests/jbr_test1.c index 9ba68b733..0264f6727 100644 --- a/src/jbr/tests/jbr_test1.c +++ b/src/jbr/tests/jbr_test1.c @@ -32,16 +32,16 @@ static void jbr_test1_1() { uint32_t port = iwu_rand_range(20000) + 20000; EJDB_OPTS opts = { - .kv = { - .path = "jbr_test1_1.db", - .oflags = IWKV_TRUNC + .kv = { + .path = "jbr_test1_1.db", + .oflags = IWKV_TRUNC }, - .no_wal = true, - .http = { - .bind = "127.0.0.1", + .no_wal = true, + .http = { + .bind = "127.0.0.1", .blocking = false, - .enabled = true, - .port = port + .enabled = true, + .port = port } }; @@ -106,8 +106,8 @@ static void jbr_test1_1() { " \"foo\": \"bar\"\n" "}" ); - CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-type:application/json")); - CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-length:17")); + CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-type: application/json")); + CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-length: 17")); CU_ASSERT_EQUAL(iwxstr_size(xstr), 17); // PUT document under specific ID @@ -147,8 +147,8 @@ static void jbr_test1_1() { " \"foo\": \"b\\nar\"\n" "}" ); - CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-type:application/json")); - CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-length:19")); + CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-type: application/json")); + CU_ASSERT_PTR_NOT_NULL(strstr(iwxstr_ptr(hstr), "content-length: 19")); CU_ASSERT_EQUAL(iwxstr_size(xstr), 19); // Perform a query diff --git a/src/jbs/README.md b/src/jbs/README.md index f8a3af27b..a50352db7 100644 --- a/src/jbs/README.md +++ b/src/jbs/README.md @@ -1,31 +1,32 @@ -# Standalone REST/Websocket HTTP server +# REST/Websocket HTTP server. + +SSL (TLS 1.2) provided by fork of BearSSL library https://github.com/Softmotions/BearSSL ## jbs server -``` -jbs -h -EJDB 2.0.0 standalone REST/Websocket server. http://ejdb.org +``` +Usage: - --file <> Database file path. Default: db.jb - -f <> (same as --file) - --port ## HTTP port number listen to. Default: 9191 - -p ## (same as --port) - --bind <> Address server listen. Default: localhost - -b <> (same as --bind) - --access <> Server access token matched to 'X-Access-Token' HTTP header value - -a <> (same as --access) - --trunc Cleanup existing database file on open - -t (same as --trunc) - --wal Use write ahead logging (WAL). Must be set for data durability. - -w (same as --wal) + ./jbs [options] -Advanced options - --sbz ## Max sorting buffer size. If exceeded, an overflow temp file for data will be created. Default: 16777216, min: 1048576 - --dsz ## Initial size of buffer to process/store document on queries. Preferable average size of document. Default: 65536, min: 16384 - --bsz ## Max HTTP/WS API document body size. Default: 67108864, min: 524288 + -v, --version Print program version. + -f, --file=<> Database file path. Default: ejdb2.db + -p, --port=NUM HTTP server port numer. Default: 9191 + -l, --listen=<> Network address server will listen. Default: localhost + -k, --key=<> PEM private key file for TLS 1.2 HTTP server. + -c, --certs=<> PEM certificates file for TLS 1.2 HTTP server. + -a, --access=TOKEN|@FILE Access token to match 'X-Access-Token' HTTP header value. + -r, --access-read Allows unrestricted read-only data access. + -C, --cors Enable COSR response headers for HTTP server + -t, --trunc Cleanup/reset database file on open. + -w, --wal use the write ahead log (WAL). Used to provide data durability. -Use any of the following input formats: - -arg -arg= -arg +Advanced options: + -S, --sbz=NUM Max sorting buffer size. If exceeded, an overflow temp file for data will be created. + Default: 16777216, min: 1048576 + -D, --dsz=NUM Initial size of buffer to process/store document on queries. Preferable average size of document. + Default: 65536, min: 16384 + -T, --trylock Exit with error if database is locked by another process. + If not set, current process will wait for lock release. -Use the -h, -help or -? to get this information again. ``` diff --git a/src/jbs/jbs.c b/src/jbs/jbs.c index 6c3fe4d26..02693881f 100644 --- a/src/jbs/jbs.c +++ b/src/jbs/jbs.c @@ -1,105 +1,192 @@ -#include "ejdb2.h" +#include "jbr.h" #include "ejdb2cfg.h" -#include +#include +#include +#include + #include #include #include +#include +#include +#include -EJDB db; // -V707 -EJDB_OPTS opts; - -int main(int argc, char const *argv[]) { - iwrc rc = 0; - fio_cli_start(argc, argv, 0, 0, - "EJDB " EJDB2_VERSION " standalone HTTP REST/Websocket server. http://ejdb.org\n", - FIO_CLI_STRING("--file -f Database file path. Default: ejdb2.db"), - FIO_CLI_INT("--port -p HTTP port number listen to. Default: 9191"), - FIO_CLI_STRING("--bind -b Address server listen. Default: localhost"), - FIO_CLI_STRING("--access -a Server access token matched to 'X-Access-Token' HTTP header value.\n" - "If token prefixed by '@' it will be treated as file."), - FIO_CLI_BOOL("--trunc -t Cleanup existing database file on open"), - FIO_CLI_BOOL("--wal -w Use write ahead logging (WAL). Must be set for data durability."), - FIO_CLI_BOOL("--cors Enable Cross-Origin Resource Sharing (CORS)."), - FIO_CLI_PRINT_HEADER("Advanced options"), - FIO_CLI_INT( - "--sbz Max sorting buffer size. If exceeded, an overflow temp file for data will be created. " - "Default: 16777216, min: 1048576"), - FIO_CLI_INT("--dsz Initial size of buffer to process/store document on queries. " - "Preferable average size of document. " - "Default: 65536, min: 16384"), - FIO_CLI_INT("--bsz Max HTTP/WS API document body size. " "Default: 67108864, min: 524288"), - FIO_CLI_BOOL("--trylock Fail if database is locked by another process." - " If not set, current process will wait for lock release") - - ); - fio_cli_set_default("--file", "ejdb2.db"); - fio_cli_set_default("-f", "ejdb2.db"); - fio_cli_set_default("--port", "9191"); - fio_cli_set_default("-p", "9191"); - fio_cli_set_default("--sbz", "16777216"); - fio_cli_set_default("--dsz", "65536"); - fio_cli_set_default("--bsz", "67108864"); - - char access_token_buf[255]; - const char *access_token = fio_cli_get("-a"); - if (access_token && (*access_token == '@')) { - access_token = access_token + 1; - FILE *f = fopen(access_token, "r"); - if (!f) { - rc = iwrc_set_errno(IW_ERROR_IO_ERRNO, errno); - goto finish; - } - size_t n = fread(access_token_buf, 1, sizeof(access_token_buf), f); - if ((n == 0) || (n == sizeof(access_token_buf))) { - fclose(f); - rc = IW_ERROR_INVALID_VALUE; - iwlog_error("Invalid access token from %s", access_token); - goto finish; - } - access_token_buf[n] = '\0'; - for (int i = 0; i < n; ++i) { - if (isspace(access_token_buf[i])) { - access_token_buf[i] = '\0'; +struct env { + const char *program; + EJDB db; + EJDB_OPTS opts; + IWPOOL *pool; +} env; + +static int _usage(const char *err) { + if (err) { + fprintf(stderr, "\n%s\n", err); + } + fprintf(stderr, "\n\tEJDB " EJDB2_VERSION " HTTP REST/Websocket server. http://ejdb.org\n"); + fprintf(stderr, "\nUsage:\n\n %s [options]\n\n", env.program); + fprintf(stderr, "\t-v, --version Print program version.\n"); + fprintf(stderr, "\t-f, --file=<> Database file path. Default: ejdb2.db\n"); + fprintf(stderr, "\t-p, --port=NUM HTTP server port numer. Default: 9191\n"); + fprintf(stderr, "\t-l, --listen=<> Network address server will listen. Default: localhost\n"); + fprintf(stderr, "\t-k, --key=<> PEM private key file for TLS 1.2 HTTP server.\n"); + fprintf(stderr, "\t-c, --certs=<> PEM certificates file for TLS 1.2 HTTP server.\n"); + fprintf(stderr, "\t-a, --access=TOKEN|@FILE Access token to match 'X-Access-Token' HTTP header value.\n"); + fprintf(stderr, "\t-r, --access-read Allows unrestricted read-only data access.\n"); + fprintf(stderr, "\t-C, --cors Enable COSR response headers for HTTP server\n"); + fprintf(stderr, "\t-t, --trunc Cleanup/reset database file on open.\n"); + fprintf(stderr, "\t-w, --wal Write ahead log (WAL) in use. Used to provide data durability.\n"); + fprintf(stderr, "\nAdvanced options:\n"); + fprintf(stderr, + "\t-S, --sbz=NUM Max sort buffer size. If exceeded, an overflow temp file for data will be created." + "Default: 16777216, min: 1048576\n"); + fprintf(stderr, "\t-D, --dsz=NUM Initial size of buffer to process/store document on queries." + " Preferable average size of document. Default: 65536, min: 16384\n"); + fprintf(stderr, "\t-T, --trylock Exit with error if database is locked by another process." + " If not set, current process will wait for lock release."); + fprintf(stderr, "\n\n"); + return 1; +} + +static void _on_signal(int signo) { + if (env.db) { + // NOLINTNEXTLINE\w\w + jbr_shutdown_request(env.db); + } +} + +static void _version(void) { + fprintf(stdout, EJDB2_VERSION); +} + +int main(int argc, char *argv[]) { + signal(SIGPIPE, SIG_IGN); + signal(SIGHUP, SIG_IGN); + signal(SIGALRM, SIG_IGN); + signal(SIGUSR1, SIG_IGN); + signal(SIGUSR2, SIG_IGN); + if (signal(SIGTERM, _on_signal) == SIG_ERR) { + return EXIT_FAILURE; + } + if (signal(SIGINT, _on_signal) == SIG_ERR) { + return EXIT_FAILURE; + } + + IWPOOL *pool; + int ec = 0, ch; + + env.program = argc ? argv[0] : ""; + env.opts.http.enabled = true; + env.opts.http.blocking = true; + env.opts.no_wal = true; + + iwrc rc = ejdb_init(); + if (rc) { + iwlog_ecode_error3(rc); + return EXIT_FAILURE; + } + + RCA(pool = env.pool = iwpool_create_empty(), finish); + + static const struct option long_options[] = { + { "help", 0, 0, 'h' }, + { "version", 0, 0, 'v' }, + { "file", 1, 0, 'f' }, + { "port", 1, 0, 'p' }, + { "bind", 1, 0, 'b' }, // for backward compatibility + { "listen", 1, 0, 'l' }, + { "key", 1, 0, 'k' }, + { "certs", 1, 0, 'c' }, + { "access", 1, 0, 'a' }, + { "access-read", 0, 0, 'r' }, + { "cors", 0, 0, 'C' }, + { "trunc", 0, 0, 't' }, + { "wal", 0, 0, 'w' }, + { "sbz", 1, 0, 'S' }, + { "dsz", 1, 0, 'D' }, + { "trylock", 0, 0, 'T' } + }; + + while ((ch = getopt_long(argc, argv, "f:p:b:l:k:c:a:S:D:rCtwThv", long_options, 0)) != -1) { + switch (ch) { + case 'h': + ec = _usage(0); + goto finish; + case 'v': + _version(); + goto finish; + case 'f': + env.opts.kv.path = iwpool_strdup2(pool, optarg); + break; + case 'p': + env.opts.http.port = iwatoi(optarg); + break; + case 'b': + case 'l': + env.opts.http.bind = iwpool_strdup2(pool, optarg); + break; + case 'k': + env.opts.http.ssl_private_key = iwpool_strdup2(pool, optarg); + break; + case 'c': + env.opts.http.ssl_certs = iwpool_strdup2(pool, optarg); + break; + case 'a': + env.opts.http.access_token = iwpool_strdup2(pool, optarg); + env.opts.http.access_token_len = env.opts.http.access_token ? strlen(env.opts.http.access_token) : 0; + break; + case 'C': + env.opts.http.cors = true; + break; + case 't': + env.opts.kv.oflags |= IWKV_TRUNC; + break; + case 'w': + env.opts.no_wal = false; + break; + case 'S': + env.opts.sort_buffer_sz = iwatoi(optarg); break; - } + case 'D': + env.opts.document_buffer_sz = iwatoi(optarg); + break; + case 'T': + env.opts.kv.file_lock_fail_fast = true; + break; + case 'r': + env.opts.http.read_anon = true; + break; + default: + ec = _usage(0); + goto finish; } - fclose(f); - access_token = access_token_buf; - } else if (access_token && (strlen(access_token) >= sizeof(access_token_buf))) { - rc = IW_ERROR_INVALID_VALUE; - iwlog_error2("Invalid access token"); - goto finish; } - EJDB_OPTS ov = { - .kv = { - .path = fio_cli_get("-f"), - .oflags = fio_cli_get_i("-t") ? IWKV_TRUNC : 0, - .file_lock_fail_fast = fio_cli_get_bool("--trylock") - }, - .no_wal = !fio_cli_get_i("-w"), - .sort_buffer_sz = fio_cli_get_i("--sbz"), - .document_buffer_sz = fio_cli_get_i("--dsz"), - .http = { - .enabled = true, - .blocking = true, - .port = fio_cli_get_i("-p"), - .bind = fio_cli_get("-b"), - .access_token = access_token, - .max_body_size = fio_cli_get_i("--bsz"), - .cors = fio_cli_get_bool("--cors") - } - }; - memcpy(&opts, &ov, sizeof(ov)); + if (!env.opts.kv.path) { + env.opts.kv.path = "ejdb2.db"; + } + if (env.opts.http.port < 1) { + env.opts.http.port = 9191; + } + if (env.opts.sort_buffer_sz < 1) { + env.opts.sort_buffer_sz = 16777216; + } else if (env.opts.sort_buffer_sz < 1048576) { + env.opts.sort_buffer_sz = 1048576; + } + if (env.opts.document_buffer_sz < 1) { + env.opts.document_buffer_sz = 65536; + } else if (env.opts.document_buffer_sz < 16384) { + env.opts.document_buffer_sz = 16384; + } + + RCC(rc, finish, ejdb_open(&env.opts, &env.db)); + RCC(rc, finish, ejdb_close(&env.db)); - rc = ejdb_open(&opts, &db); - RCGO(rc, finish); - IWRC(ejdb_close(&db), rc); finish: - fio_cli_end(); if (rc) { iwlog_ecode_error3(rc); } - return rc ? 1 : 0; + iwpool_destroy(env.pool); + fflush(0); + return rc == 0 ? ec : 1; } diff --git a/src/jql/README.md b/src/jql/README.md index 6d23c86f3..28f6471d8 100644 --- a/src/jql/README.md +++ b/src/jql/README.md @@ -442,6 +442,8 @@ PROJECTIONS = PROJECTION [ {'+' | '-'} PROJECTION ] Projection allows to get only subset of JSON document excluding not needed data. +**Query placeholders API is supported in projections.** + Lets add one more document to our collection: ```sh diff --git a/src/jql/inc/jqpx.c b/src/jql/inc/jqpx.c index 0a66fb974..f19287a28 100644 --- a/src/jql/inc/jqpx.c +++ b/src/jql/inc/jqpx.c @@ -1,15 +1,16 @@ #include "jqp.h" -#include "utf8proc.h" -#include "jbl_internal.h" + +#include +#include #include #include #define MAX_ORDER_BY_CLAUSES 64 -#define JQRC(yy_, rc_) do { \ - iwrc __rc = (rc_); \ - if (__rc) _jqp_fatal(yy_, __rc); \ +#define JQRC(yy_, rc_) do { \ + iwrc __rc = (rc_); \ + if (__rc) _jqp_fatal(yy_, __rc); \ } while (0) static void _jqp_debug(yycontext *yy, const char *text) { @@ -17,32 +18,32 @@ static void _jqp_debug(yycontext *yy, const char *text) { } static void _jqp_fatal(yycontext *yy, iwrc rc) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->rc = rc; longjmp(aux->fatal_jmp, 1); } -static void *_jqp_malloc(struct _yycontext *yy, size_t size) { +static void* _jqp_malloc(struct _yycontext *yy, size_t size) { void *ret = malloc(size); if (!ret) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); longjmp(aux->fatal_jmp, 1); } return ret; } -static void *_jqp_realloc(struct _yycontext *yy, void *ptr, size_t size) { +static void* _jqp_realloc(struct _yycontext *yy, void *ptr, size_t size) { void *ret = realloc(ptr, size); if (!ret) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); longjmp(aux->fatal_jmp, 1); } return ret; } -static iwrc _jqp_aux_set_input(JQP_AUX *aux, const char *input) { +static iwrc _jqp_aux_set_input(struct jqp_aux *aux, const char *input) { size_t len = strlen(input) + 1; char *buf = iwpool_alloc(len, aux->pool); if (!buf) { @@ -55,24 +56,24 @@ static iwrc _jqp_aux_set_input(JQP_AUX *aux, const char *input) { //----------------- -IW_INLINE char *_jqp_strdup(struct _yycontext *yy, const char *text) { +IW_INLINE char* _jqp_strdup(struct _yycontext *yy, const char *text) { iwrc rc = 0; char *ret = iwpool_strdup(yy->aux->pool, text, &rc); JQRC(yy, rc); return ret; } -static JQPUNIT *_jqp_unit(yycontext *yy) { - JQPUNIT *ret = iwpool_calloc(sizeof(JQPUNIT), yy->aux->pool); +static union jqp_unit* _jqp_unit(yycontext *yy) { + union jqp_unit *ret = iwpool_calloc(sizeof(union jqp_unit), yy->aux->pool); if (!ret) { JQRC(yy, iwrc_set_errno(IW_ERROR_ALLOC, errno)); } return ret; } -static JQP_STACK *_jqp_push(yycontext *yy) { - JQP_AUX *aux = yy->aux; - JQP_STACK *stack; +static struct jqp_stack* _jqp_push(yycontext *yy) { + struct jqp_aux *aux = yy->aux; + struct jqp_stack *stack; if (aux->stackn < (sizeof(aux->stackpool) / sizeof(aux->stackpool[0]))) { stack = &aux->stackpool[aux->stackn++]; } else { @@ -94,9 +95,9 @@ static JQP_STACK *_jqp_push(yycontext *yy) { return aux->stack; } -static JQP_STACK _jqp_pop(yycontext *yy) { - JQP_AUX *aux = yy->aux; - JQP_STACK *stack = aux->stack, ret; +static struct jqp_stack _jqp_pop(yycontext *yy) { + struct jqp_aux *aux = yy->aux; + struct jqp_stack *stack = aux->stack, ret; if (!stack || (aux->stackn < 1)) { iwlog_error2("Unbalanced stack"); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -114,14 +115,14 @@ static JQP_STACK _jqp_pop(yycontext *yy) { return ret; } -static void _jqp_unit_push(yycontext *yy, JQPUNIT *unit) { - JQP_STACK *stack = _jqp_push(yy); +static void _jqp_unit_push(yycontext *yy, union jqp_unit *unit) { + struct jqp_stack *stack = _jqp_push(yy); stack->type = STACK_UNIT; stack->unit = unit; } -static JQPUNIT *_jqp_unit_pop(yycontext *yy) { - JQP_STACK stack = _jqp_pop(yy); +static union jqp_unit* _jqp_unit_pop(yycontext *yy) { + struct jqp_stack stack = _jqp_pop(yy); if (stack.type != STACK_UNIT) { iwlog_error("Unexpected type: %d", stack.type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -130,12 +131,12 @@ static JQPUNIT *_jqp_unit_pop(yycontext *yy) { } static void _jqp_string_push(yycontext *yy, char *str, bool dup) { - JQP_STACK *stack = _jqp_push(yy); + struct jqp_stack *stack = _jqp_push(yy); stack->type = STACK_STRING; stack->str = str; if (dup) { iwrc rc = 0; - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; stack->str = iwpool_strdup(aux->pool, stack->str, &rc); if (rc) { JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -143,8 +144,8 @@ static void _jqp_string_push(yycontext *yy, char *str, bool dup) { } } -static char *_jqp_string_pop(yycontext *yy) { - JQP_STACK stack = _jqp_pop(yy); +static char* _jqp_string_pop(yycontext *yy) { + struct jqp_stack stack = _jqp_pop(yy); if (stack.type != STACK_STRING) { iwlog_error("Unexpected type: %d", stack.type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -152,16 +153,16 @@ static char *_jqp_string_pop(yycontext *yy) { return stack.str; } -static JQPUNIT *_jqp_string(yycontext *yy, jqp_string_flavours_t flavour, const char *text) { - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_string(yycontext *yy, jqp_string_flavours_t flavour, const char *text) { + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_STRING_TYPE; unit->string.flavour |= flavour; unit->string.value = _jqp_strdup(yy, text); return unit; } -static JQPUNIT *_jqp_number(yycontext *yy, jqp_int_flavours_t flavour, const char *text) { - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_number(yycontext *yy, jqp_int_flavours_t flavour, const char *text) { + union jqp_unit *unit = _jqp_unit(yy); char *eptr; int64_t ival = strtoll(text, &eptr, 0); if ((eptr == text) || (errno == ERANGE)) { @@ -184,8 +185,8 @@ static JQPUNIT *_jqp_number(yycontext *yy, jqp_int_flavours_t flavour, const cha return unit; } -static JQPUNIT *_jqp_json_number(yycontext *yy, const char *text) { - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_json_number(yycontext *yy, const char *text) { + union jqp_unit *unit = _jqp_unit(yy); char *eptr; unit->type = JQP_JSON_TYPE; int64_t ival = strtoll(text, &eptr, 0); @@ -207,15 +208,15 @@ static JQPUNIT *_jqp_json_number(yycontext *yy, const char *text) { return unit; } -static JQPUNIT *_jqp_placeholder(yycontext *yy, const char *text) { - JQP_AUX *aux = yy->aux; - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_placeholder(yycontext *yy, const char *text) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_STRING_TYPE; unit->string.flavour |= JQP_STR_PLACEHOLDER; if (text[0] == '?') { - char nbuf[JBNUMBUF_SIZE + 1]; + char nbuf[IWNUMBUF_SIZE + 1]; nbuf[0] = '?'; - int len = iwitoa(aux->num_placeholders++, nbuf + 1, JBNUMBUF_SIZE); + int len = iwitoa(aux->num_placeholders++, nbuf + 1, IWNUMBUF_SIZE); nbuf[len + 1] = '\0'; unit->string.value = _jqp_strdup(yy, nbuf); } else { @@ -345,9 +346,9 @@ static int _jqp_unescape_json_string(const char *p, char *d, int dlen, iwrc *rcp return 0; } -static JQPUNIT *_jqp_unescaped_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text) { - JQP_AUX *aux = yy->aux; - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_unescaped_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_STRING_TYPE; unit->string.flavour |= flv; int len = _jqp_unescape_json_string(text, 0, 0, &aux->rc); @@ -367,9 +368,9 @@ static JQPUNIT *_jqp_unescaped_string(struct _yycontext *yy, jqp_string_flavours return unit; } -static JQPUNIT *_jqp_json_string(struct _yycontext *yy, const char *text) { - JQP_AUX *aux = yy->aux; - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_json_string(struct _yycontext *yy, const char *text) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_JSON_TYPE; unit->json.jn.type = JBV_STR; int len = _jqp_unescape_json_string(text, 0, 0, &aux->rc); @@ -390,7 +391,7 @@ static JQPUNIT *_jqp_json_string(struct _yycontext *yy, const char *text) { return unit; } -static JQPUNIT *_jqp_json_pair(yycontext *yy, JQPUNIT *key, JQPUNIT *val) { +static union jqp_unit* _jqp_json_pair(yycontext *yy, union jqp_unit *key, union jqp_unit *val) { if ((key->type != JQP_JSON_TYPE) || (val->type != JQP_JSON_TYPE) || (key->json.jn.type != JBV_STR)) { iwlog_error2("Invalid arguments"); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -400,14 +401,14 @@ static JQPUNIT *_jqp_json_pair(yycontext *yy, JQPUNIT *key, JQPUNIT *val) { return val; } -static JQPUNIT *_jqp_json_collect(yycontext *yy, jbl_type_t type, JQPUNIT *until) { - JQP_AUX *aux = yy->aux; - JQPUNIT *ret = _jqp_unit(yy); +static union jqp_unit* _jqp_json_collect(yycontext *yy, jbl_type_t type, union jqp_unit *until) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *ret = _jqp_unit(yy); ret->type = JQP_JSON_TYPE; - JBL_NODE jn = &ret->json.jn; + struct jbl_node *jn = &ret->json.jn; jn->type = type; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit == until) { _jqp_pop(yy); break; @@ -416,7 +417,7 @@ static JQPUNIT *_jqp_json_collect(yycontext *yy, jbl_type_t type, JQPUNIT *until iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); } - JBL_NODE ju = &unit->json.jn; + struct jbl_node *ju = &unit->json.jn; if (!jn->child) { jn->child = ju; } else { @@ -430,8 +431,8 @@ static JQPUNIT *_jqp_json_collect(yycontext *yy, jbl_type_t type, JQPUNIT *until return ret; } -static JQPUNIT *_jqp_json_true_false_null(yycontext *yy, const char *text) { - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_json_true_false_null(yycontext *yy, const char *text) { + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_JSON_TYPE; int len = strlen(text); if (!strncmp("null", text, len)) { @@ -457,9 +458,9 @@ static void _jqp_op_negate_reset(yycontext *yy) { yy->aux->negate = false; } -static JQPUNIT *_jqp_unit_op(yycontext *yy, const char *text) { - JQP_AUX *aux = yy->aux; - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_unit_op(yycontext *yy, const char *text) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_OP_TYPE; unit->op.negate = aux->negate; aux->negate = false; @@ -495,9 +496,9 @@ static JQPUNIT *_jqp_unit_op(yycontext *yy, const char *text) { return unit; } -static JQPUNIT *_jqp_unit_join(yycontext *yy, const char *text) { - JQP_AUX *aux = yy->aux; - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_unit_join(yycontext *yy, const char *text) { + struct jqp_aux *aux = yy->aux; + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_JOIN_TYPE; unit->join.negate = aux->negate; aux->negate = false; @@ -509,7 +510,7 @@ static JQPUNIT *_jqp_unit_join(yycontext *yy, const char *text) { return unit; } -static JQPUNIT *_jqp_expr(yycontext *yy, JQPUNIT *left, JQPUNIT *op, JQPUNIT *right) { +static union jqp_unit* _jqp_expr(yycontext *yy, union jqp_unit *left, union jqp_unit *op, union jqp_unit *right) { if (!left || !op || !right) { iwlog_error2("Invalid arguments"); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -518,7 +519,7 @@ static JQPUNIT *_jqp_expr(yycontext *yy, JQPUNIT *left, JQPUNIT *op, JQPUNIT *ri iwlog_error("Unexpected type: %d", op->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); } - JQPUNIT *unit = _jqp_unit(yy); + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_EXPR_TYPE; unit->expr.left = left; unit->expr.op = &op->op; @@ -526,11 +527,11 @@ static JQPUNIT *_jqp_expr(yycontext *yy, JQPUNIT *left, JQPUNIT *op, JQPUNIT *ri return unit; } -static JQPUNIT *_jqp_pop_expr_chain(yycontext *yy, JQPUNIT *until) { - JQPUNIT *expr = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_expr_chain(yycontext *yy, union jqp_unit *until) { + union jqp_unit *expr = 0; + struct jqp_aux *aux = yy->aux; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type == JQP_EXPR_TYPE) { if (expr) { unit->expr.next = &expr->expr; @@ -550,25 +551,25 @@ static JQPUNIT *_jqp_pop_expr_chain(yycontext *yy, JQPUNIT *until) { return expr; } -static JQPUNIT *_jqp_projection(struct _yycontext *yy, JQPUNIT *value, uint8_t flags) { +static union jqp_unit* _jqp_projection(struct _yycontext *yy, union jqp_unit *value, uint8_t flags) { if (value->type != JQP_STRING_TYPE) { iwlog_error("Unexpected type: %d", value->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); } - JQPUNIT *unit = _jqp_unit(yy); + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_PROJECTION_TYPE; unit->projection.value = &value->string; unit->projection.flags |= flags; return unit; } -static JQPUNIT *_jqp_pop_projection_nodes(yycontext *yy, JQPUNIT *until) { - JQPUNIT *first = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_projection_nodes(yycontext *yy, union jqp_unit *until) { + union jqp_unit *first = 0; + struct jqp_aux *aux = yy->aux; uint8_t flags = 0; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type != JQP_STRING_TYPE) { iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -576,7 +577,7 @@ static JQPUNIT *_jqp_pop_projection_nodes(yycontext *yy, JQPUNIT *until) { if (first) { unit->string.next = &first->string; } else if (unit->string.flavour & JQP_STR_PROJFIELD) { - for (JQP_STRING *s = &unit->string; s; s = s->subnext) { + for (struct jqp_string *s = &unit->string; s; s = s->subnext) { if (s->flavour & JQP_STR_PROJOIN) { flags |= JQP_PROJECTION_FLAG_JOINS; } else { @@ -586,6 +587,8 @@ static JQPUNIT *_jqp_pop_projection_nodes(yycontext *yy, JQPUNIT *until) { } else if (strchr(unit->string.value, '<')) { // JOIN Projection? unit->string.flavour |= JQP_STR_PROJOIN; flags |= JQP_PROJECTION_FLAG_JOINS; + } else { + unit->string.flavour |= JQP_STR_PROJPATH; } first = unit; _jqp_pop(yy); @@ -599,8 +602,8 @@ static JQPUNIT *_jqp_pop_projection_nodes(yycontext *yy, JQPUNIT *until) { return _jqp_projection(yy, first, flags); } -static JQPUNIT *_jqp_push_joined_projection(struct _yycontext *yy, JQPUNIT *p) { - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_push_joined_projection(struct _yycontext *yy, union jqp_unit *p) { + struct jqp_aux *aux = yy->aux; if (!aux->stack || (aux->stack->type != STACK_STRING)) { iwlog_error2("Invalid stack state"); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -614,11 +617,11 @@ static JQPUNIT *_jqp_push_joined_projection(struct _yycontext *yy, JQPUNIT *p) { return p; } -static JQPUNIT *_jqp_pop_joined_projections(yycontext *yy, JQPUNIT *until) { - JQPUNIT *first = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_joined_projections(yycontext *yy, union jqp_unit *until) { + union jqp_unit *first = 0; + struct jqp_aux *aux = yy->aux; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type != JQP_PROJECTION_TYPE) { iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -635,11 +638,11 @@ static JQPUNIT *_jqp_pop_joined_projections(yycontext *yy, JQPUNIT *until) { return first; } -static JQPUNIT *_jqp_pop_projfields_chain(yycontext *yy, JQPUNIT *until) { - JQPUNIT *field = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_projfields_chain(yycontext *yy, union jqp_unit *until) { + union jqp_unit *field = 0; + struct jqp_aux *aux = yy->aux; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type != JQP_STRING_TYPE) { iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -660,11 +663,11 @@ static JQPUNIT *_jqp_pop_projfields_chain(yycontext *yy, JQPUNIT *until) { return field; } -static JQPUNIT *_jqp_pop_ordernodes(yycontext *yy, JQPUNIT *until) { - JQPUNIT *first = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_ordernodes(yycontext *yy, union jqp_unit *until) { + union jqp_unit *first = 0; + struct jqp_aux *aux = yy->aux; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type != JQP_STRING_TYPE) { iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -681,8 +684,8 @@ static JQPUNIT *_jqp_pop_ordernodes(yycontext *yy, JQPUNIT *until) { return until; } -static JQPUNIT *_jqp_node(yycontext *yy, JQPUNIT *value) { - JQPUNIT *unit = _jqp_unit(yy); +static union jqp_unit* _jqp_node(yycontext *yy, union jqp_unit *value) { + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_NODE_TYPE; unit->node.value = value; if (value->type == JQP_EXPR_TYPE) { @@ -704,11 +707,11 @@ static JQPUNIT *_jqp_node(yycontext *yy, JQPUNIT *value) { return unit; } -static JQPUNIT *_jqp_pop_node_chain(yycontext *yy, JQPUNIT *until) { - JQPUNIT *filter, *first = 0; - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_pop_node_chain(yycontext *yy, union jqp_unit *until) { + union jqp_unit *filter, *first = 0; + struct jqp_aux *aux = yy->aux; while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type != JQP_NODE_TYPE) { iwlog_error("Unexpected type: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -741,16 +744,16 @@ static JQPUNIT *_jqp_pop_node_chain(yycontext *yy, JQPUNIT *until) { return filter; } -static JQPUNIT *_jqp_pop_filter_factor_chain(yycontext *yy, JQPUNIT *until) { - JQP_EXPR_NODE *factor = 0; - JQP_AUX *aux = yy->aux; - JQPUNIT *exprnode = _jqp_unit(yy); +static union jqp_unit* _jqp_pop_filter_factor_chain(yycontext *yy, union jqp_unit *until) { + struct jqp_expr_node *factor = 0; + struct jqp_aux *aux = yy->aux; + union jqp_unit *exprnode = _jqp_unit(yy); while (aux->stack && aux->stack->type == STACK_UNIT) { - JQPUNIT *unit = aux->stack->unit; + union jqp_unit *unit = aux->stack->unit; if (unit->type == JQP_JOIN_TYPE) { factor->join = &unit->join; // -V522 } else if ((unit->type == JQP_EXPR_NODE_TYPE) || (unit->type == JQP_FILTER_TYPE)) { - JQP_EXPR_NODE *node = (JQP_EXPR_NODE*) unit; + struct jqp_expr_node *node = (struct jqp_expr_node*) unit; if (factor) { node->next = factor; } @@ -769,21 +772,21 @@ static JQPUNIT *_jqp_pop_filter_factor_chain(yycontext *yy, JQPUNIT *until) { return exprnode; } -static void _jqp_set_filters_expr(yycontext *yy, JQPUNIT *expr) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_filters_expr(yycontext *yy, union jqp_unit *expr) { + struct jqp_aux *aux = yy->aux; if (expr->type != JQP_EXPR_NODE_TYPE) { iwlog_error("Unexpected type: %d", expr->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); } - JQPUNIT *query = _jqp_unit(yy); + union jqp_unit *query = _jqp_unit(yy); query->type = JQP_QUERY_TYPE; query->query.aux = aux; aux->expr = &expr->exprnode; aux->query = &query->query; } -static JQPUNIT *_jqp_create_filterexpr_pk(yycontext *yy, JQPUNIT *argument) { - JQP_AUX *aux = yy->aux; +static union jqp_unit* _jqp_create_filterexpr_pk(yycontext *yy, union jqp_unit *argument) { + struct jqp_aux *aux = yy->aux; const char *anchor = 0; // Looking for optional if ( aux->stack @@ -795,17 +798,17 @@ static JQPUNIT *_jqp_create_filterexpr_pk(yycontext *yy, JQPUNIT *argument) { aux->first_anchor = anchor; } } - JQPUNIT *unit = _jqp_unit(yy); + union jqp_unit *unit = _jqp_unit(yy); unit->type = JQP_EXPR_NODE_TYPE; - JQP_EXPR_NODE_PK *exprnode_pk = &unit->exprnode_pk; + struct jqp_expr_node_pk *exprnode_pk = &unit->exprnode_pk; exprnode_pk->flags = JQP_EXPR_NODE_FLAG_PK; exprnode_pk->anchor = anchor; exprnode_pk->argument = argument; return unit; } -static void _jqp_set_apply(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_apply(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; if (!unit || !aux->query) { iwlog_error2("Invalid arguments"); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -823,18 +826,18 @@ static void _jqp_set_apply(yycontext *yy, JQPUNIT *unit) { } static void _jqp_set_apply_delete(yycontext *yy) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->qmode |= JQP_QRY_APPLY_DEL; } -static void _jqp_set_apply_upsert(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_apply_upsert(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; aux->qmode |= JQP_QRY_APPLY_UPSERT; _jqp_set_apply(yy, unit); } -static void _jqp_add_orderby(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_add_orderby(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; if (unit->type != JQP_STRING_TYPE) { iwlog_error("Unexpected type for order by: %d", unit->type); JQRC(yy, JQL_ERROR_QUERY_PARSE); @@ -846,8 +849,8 @@ static void _jqp_add_orderby(yycontext *yy, JQPUNIT *unit) { } } -static void _jqp_set_skip(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_skip(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; if ((unit->type != JQP_INTEGER_TYPE) && !( (unit->type == JQP_STRING_TYPE) && (unit->string.flavour & JQP_STR_PLACEHOLDER))) { iwlog_error("Unexpected type for skip: %d", unit->type); @@ -859,8 +862,8 @@ static void _jqp_set_skip(yycontext *yy, JQPUNIT *unit) { aux->skip = unit; } -static void _jqp_set_limit(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_limit(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; if ((unit->type != JQP_INTEGER_TYPE) && !( (unit->type == JQP_STRING_TYPE) && (unit->string.flavour & JQP_STR_PLACEHOLDER))) { iwlog_error("Unexpected type for limit: %d", unit->type); @@ -873,30 +876,30 @@ static void _jqp_set_limit(yycontext *yy, JQPUNIT *unit) { } static void _jqp_set_aggregate_count(yycontext *yy) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->qmode |= JQP_QRY_COUNT; aux->projection = 0; // No projections in aggregate mode } static void _jqp_set_noidx(yycontext *yy) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->qmode |= JQP_QRY_NOIDX; } static void _jqp_set_inverse(yycontext *yy) { - JQP_AUX *aux = yy->aux; + struct jqp_aux *aux = yy->aux; aux->qmode |= (JQP_QRY_NOIDX | JQP_QRY_INVERSE); } -static void _jqp_set_projection(yycontext *yy, JQPUNIT *unit) { - JQP_AUX *aux = yy->aux; +static void _jqp_set_projection(yycontext *yy, union jqp_unit *unit) { + struct jqp_aux *aux = yy->aux; if (!unit || !aux->query) { iwlog_error2("Invalid arguments"); JQRC(yy, JQL_ERROR_QUERY_PARSE); } if (unit->type == JQP_PROJECTION_TYPE) { - JQP_PROJECTION *proj = &unit->projection; - for (JQP_PROJECTION *p = proj; p; p = p->next) { + struct jqp_projection *proj = &unit->projection; + for (struct jqp_projection *p = proj; p; p = p->next) { if (p->value->flavour & JQP_STR_PROJALIAS) { if (p->flags & JQP_PROJECTION_FLAG_EXCLUDE) { aux->has_exclude_all_projection = true; @@ -918,10 +921,11 @@ static void _jqp_set_projection(yycontext *yy, JQPUNIT *unit) { static void _jqp_finish(yycontext *yy) { iwrc rc = 0; int cnt = 0; - IWXSTR *xstr = 0; - JQP_AUX *aux = yy->aux; - JQP_STRING *orderby = aux->orderby; + struct iwxstr *xstr = 0; + struct jqp_aux *aux = yy->aux; + struct jqp_string *orderby = aux->orderby; + for ( ; orderby; ++cnt, orderby = orderby->next) { if (cnt >= MAX_ORDER_BY_CLAUSES) { rc = JQL_ERROR_ORDERBY_MAX_LIMIT; @@ -930,7 +934,7 @@ static void _jqp_finish(yycontext *yy) { } aux->orderby_num = cnt; if (cnt) { - aux->orderby_ptrs = iwpool_alloc(cnt * sizeof(JBL_PTR), aux->pool); + aux->orderby_ptrs = iwpool_alloc(cnt * sizeof(struct jbl_ptr*), aux->pool); if (!aux->orderby_ptrs) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); goto finish; @@ -944,14 +948,14 @@ static void _jqp_finish(yycontext *yy) { orderby = aux->orderby; for ( ; orderby; orderby = orderby->next) { iwxstr_clear(xstr); - for (JQP_STRING *on = orderby; on; on = on->subnext) { + for (struct jqp_string *on = orderby; on; on = on->subnext) { rc = iwxstr_cat(xstr, "/", 1); RCGO(rc, finish); iwxstr_cat(xstr, on->value, strlen(on->value)); } rc = jbl_ptr_alloc_pool(iwxstr_ptr(xstr), &aux->orderby_ptrs[cnt], aux->pool); RCGO(rc, finish); - JBL_PTR ptr = aux->orderby_ptrs[cnt]; + struct jbl_ptr *ptr = aux->orderby_ptrs[cnt]; ptr->op = (uint64_t) ((orderby->flavour & JQP_STR_NEGATE) != 0); // asc/desc cnt++; } @@ -967,13 +971,13 @@ static void _jqp_finish(yycontext *yy) { } } -iwrc jqp_aux_create(JQP_AUX **auxp, const char *input) { +iwrc jqp_aux_create(struct jqp_aux **auxp, const char *input) { iwrc rc = 0; *auxp = calloc(1, sizeof(**auxp)); if (!*auxp) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } - JQP_AUX *aux = *auxp; + struct jqp_aux *aux = *auxp; aux->xerr = iwxstr_new(); if (!aux->xerr) { rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); @@ -993,8 +997,8 @@ iwrc jqp_aux_create(JQP_AUX **auxp, const char *input) { return rc; } -void jqp_aux_destroy(JQP_AUX **auxp) { - JQP_AUX *aux = *auxp; +void jqp_aux_destroy(struct jqp_aux **auxp) { + struct jqp_aux *aux = *auxp; if (aux) { *auxp = 0; if (aux->pool) { @@ -1007,13 +1011,13 @@ void jqp_aux_destroy(JQP_AUX **auxp) { } } -IW_INLINE iwrc _iwxstr_cat2(IWXSTR *xstr, const char *buf) { +IW_INLINE iwrc _iwxstr_cat2(struct iwxstr *xstr, const char *buf) { return iwxstr_cat(xstr, buf, strlen(buf)); } static void yyerror(yycontext *yy) { - JQP_AUX *aux = yy->aux; - IWXSTR *xerr = aux->xerr; + struct jqp_aux *aux = yy->aux; + struct iwxstr *xerr = aux->xerr; if (yy->__pos && yy->__text[0]) { _iwxstr_cat2(xerr, "near token: '"); _iwxstr_cat2(xerr, yy->__text); @@ -1031,7 +1035,7 @@ static void yyerror(yycontext *yy) { _iwxstr_cat2(xerr, " <--- \n"); } -iwrc jqp_parse(JQP_AUX *aux) { +iwrc jqp_parse(struct jqp_aux *aux) { yycontext yy = { 0 }; yy.aux = aux; if (setjmp(aux->fatal_jmp)) { @@ -1057,34 +1061,44 @@ iwrc jqp_parse(JQP_AUX *aux) { return aux->rc; } -#define PT(data_, size_, ch_, count_) do { \ - rc = pt(data_, size_, ch_, count_, op); \ - RCRET(rc); \ +#define PT(data_, size_, ch_, count_) do { \ + rc = pt(data_, size_, ch_, count_, op); \ + RCRET(rc); \ } while (0) -static iwrc _jqp_print_projection_nodes(const JQP_STRING *p, jbl_json_printer pt, void *op) { +IW_INLINE iwrc _print_placeholder(const char *value, jbl_json_printer pt, void *op); + +static iwrc _jqp_print_projection_nodes(const struct jqp_string *p, jbl_json_printer pt, void *op) { iwrc rc = 0; - for (const JQP_STRING *s = p; s; s = s->next) { + for (const struct jqp_string *s = p; s; s = s->next) { if (!(s->flavour & JQP_STR_PROJALIAS)) { PT(0, 0, '/', 1); } if (s->flavour & JQP_STR_PROJFIELD) { PT(0, 0, '{', 1); - for (const JQP_STRING *pf = s; pf; pf = pf->subnext) { - PT(pf->value, -1, 0, 0); + for (const struct jqp_string *pf = s; pf; pf = pf->subnext) { + if (pf->flavour & JQP_STR_PLACEHOLDER) { + RCR(_print_placeholder(pf->value, pt, op)); + } else { + PT(pf->value, -1, 0, 0); + } if (pf->subnext) { PT(0, 0, ',', 1); } } PT(0, 0, '}', 1); } else { - PT(s->value, -1, 0, 0); + if (s->flavour & JQP_STR_PLACEHOLDER) { + RCR(_print_placeholder(s->value, pt, op)); + } else { + PT(s->value, -1, 0, 0); + } } } return rc; } -static iwrc _jqp_print_projection(const JQP_PROJECTION *p, jbl_json_printer pt, void *op) { +static iwrc _jqp_print_projection(const struct jqp_projection *p, jbl_json_printer pt, void *op) { iwrc rc = 0; PT(0, 0, '|', 1); for (int i = 0; p; p = p->next, ++i) { @@ -1104,7 +1118,7 @@ static iwrc _jqp_print_projection(const JQP_PROJECTION *p, jbl_json_printer pt, return rc; } -static iwrc _jqp_print_apply(const JQP_QUERY *q, jbl_json_printer pt, void *op) { +static iwrc _jqp_print_apply(const struct jqp_query *q, jbl_json_printer pt, void *op) { iwrc rc = 0; if (q->aux->qmode & JQP_QRY_APPLY_DEL) { PT("| del ", 6, 0, 0); @@ -1192,7 +1206,7 @@ IW_INLINE iwrc _print_placeholder(const char *value, jbl_json_printer pt, void * return rc; } -iwrc jqp_print_filter_node_expr(const JQP_EXPR *e, jbl_json_printer pt, void *op) { +iwrc jqp_print_filter_node_expr(const struct jqp_expr *e, jbl_json_printer pt, void *op) { iwrc rc = 0; if (e->left->type == JQP_EXPR_TYPE) { PT(0, 0, '[', 1); @@ -1229,16 +1243,16 @@ iwrc jqp_print_filter_node_expr(const JQP_EXPR *e, jbl_json_printer pt, void *op return rc; } -static iwrc _jqp_print_filter_node(const JQP_NODE *n, jbl_json_printer pt, void *op) { +static iwrc _jqp_print_filter_node(const struct jqp_node *n, jbl_json_printer pt, void *op) { iwrc rc = 0; - JQPUNIT *u = n->value; + union jqp_unit *u = n->value; PT(0, 0, '/', 1); if (u->type == JQP_STRING_TYPE) { PT(u->string.value, -1, 0, 0); return rc; } else if (u->type == JQP_EXPR_TYPE) { PT(0, 0, '[', 1); - for (JQP_EXPR *e = &u->expr; e; e = e->next) { + for (struct jqp_expr *e = &u->expr; e; e = e->next) { if (e->join) { rc = _jqp_print_join(e->join->value, e->join->negate, pt, op); RCRET(rc); @@ -1255,16 +1269,16 @@ static iwrc _jqp_print_filter_node(const JQP_NODE *n, jbl_json_printer pt, void } static iwrc _jqp_print_filter( - const JQP_QUERY *q, - const JQP_FILTER *f, - jbl_json_printer pt, - void *op) { + const struct jqp_query *q, + const struct jqp_filter *f, + jbl_json_printer pt, + void *op) { iwrc rc = 0; if (f->anchor) { PT(0, 0, '@', 1); PT(f->anchor, -1, 0, 0); } - for (JQP_NODE *n = f->node; n; n = n->next) { + for (struct jqp_node *n = f->node; n; n = n->next) { rc = _jqp_print_filter_node(n, pt, op); RCRET(rc); } @@ -1272,10 +1286,10 @@ static iwrc _jqp_print_filter( } static iwrc _jqp_print_expression_node( - const JQP_QUERY *q, - const JQP_EXPR_NODE *en, - jbl_json_printer pt, - void *op) { + const struct jqp_query *q, + const struct jqp_expr_node *en, + jbl_json_printer pt, + void *op) { iwrc rc = 0; bool inbraces = (en != q->aux->expr && en->type == JQP_EXPR_NODE_TYPE); if (inbraces) { @@ -1284,7 +1298,7 @@ static iwrc _jqp_print_expression_node( // Primary key expression if (en->flags & JQP_EXPR_NODE_FLAG_PK) { - JQP_EXPR_NODE_PK *pk = (void*) en; + struct jqp_expr_node_pk *pk = (void*) en; if (pk->anchor) { PT(0, 0, '@', 1); PT(pk->anchor, -1, 0, 0); @@ -1320,7 +1334,7 @@ static iwrc _jqp_print_expression_node( rc = _jqp_print_expression_node(q, en, pt, op); RCRET(rc); } else if (en->type == JQP_FILTER_TYPE) { - rc = _jqp_print_filter(q, (const JQP_FILTER*) en, pt, op); // -V1027 + rc = _jqp_print_filter(q, (const struct jqp_filter*) en, pt, op); // -V1027 } else { iwlog_ecode_error3(IW_ERROR_ASSERTION); return IW_ERROR_ASSERTION; @@ -1332,12 +1346,12 @@ static iwrc _jqp_print_expression_node( return rc; } -static iwrc _jqp_print_opts(const JQP_QUERY *q, jbl_json_printer pt, void *op) { +static iwrc _jqp_print_opts(const struct jqp_query *q, jbl_json_printer pt, void *op) { iwrc rc = 0; int c = 0; - JQP_AUX *aux = q->aux; + struct jqp_aux *aux = q->aux; PT(0, 0, '|', 1); - JQP_STRING *ob = aux->orderby; + struct jqp_string *ob = aux->orderby; while (ob) { if (c++ > 0) { PT("\n ", 2, 0, 0); @@ -1352,7 +1366,7 @@ static iwrc _jqp_print_opts(const JQP_QUERY *q, jbl_json_printer pt, void *op) { RCRET(rc); } else { // print orderby subnext chain - JQP_STRING *n = ob; + struct jqp_string *n = ob; do { PT(0, 0, '/', 1); PT(n->value, -1, 0, 0); @@ -1375,8 +1389,8 @@ static iwrc _jqp_print_opts(const JQP_QUERY *q, jbl_json_printer pt, void *op) { PT(aux->skip->string.value, -1, 0, 0); } } else if (aux->skip->type == JQP_INTEGER_TYPE) { - char nbuf[JBNUMBUF_SIZE]; - iwitoa(aux->skip->intval.value, nbuf, JBNUMBUF_SIZE); + char nbuf[IWNUMBUF_SIZE]; + iwitoa(aux->skip->intval.value, nbuf, IWNUMBUF_SIZE); PT(nbuf, -1, 0, 0); } } @@ -1390,19 +1404,19 @@ static iwrc _jqp_print_opts(const JQP_QUERY *q, jbl_json_printer pt, void *op) { PT(aux->limit->string.value, -1, 0, 0); } } else if (aux->limit->type == JQP_INTEGER_TYPE) { - char nbuf[JBNUMBUF_SIZE]; - iwitoa(aux->limit->intval.value, nbuf, JBNUMBUF_SIZE); + char nbuf[IWNUMBUF_SIZE]; + iwitoa(aux->limit->intval.value, nbuf, IWNUMBUF_SIZE); PT(nbuf, -1, 0, 0); } } return rc; } -iwrc jqp_print_query(const JQP_QUERY *q, jbl_json_printer pt, void *op) { +iwrc jqp_print_query(const struct jqp_query *q, jbl_json_printer pt, void *op) { if (!q || !pt) { return IW_ERROR_INVALID_ARGS; } - JQP_AUX *aux = q->aux; + struct jqp_aux *aux = q->aux; iwrc rc = _jqp_print_expression_node(q, aux->expr, pt, op); RCRET(rc); if (aux->apply_placeholder || aux->apply) { diff --git a/src/jql/jql.c b/src/jql/jql.c index bcf507a04..bbd8a7646 100644 --- a/src/jql/jql.c +++ b/src/jql/jql.c @@ -1,17 +1,24 @@ -#include "convert.h" #include "ejdb2_internal.h" -#include "jbl_internal.h" #include "jql_internal.h" #include "jqp.h" -#include "lwre.h" + +#ifdef _WIN32 +#include +#define strndup(c__, s__) xstrndup(c__, s__) +#endif + +#include #include +#include + +#define IWRE_UNUSED_PTR ((void*) (intptr_t) -1) /** Query matching context */ typedef struct MCTX { int lvl; binn *bv; const char *key; - struct _JQL *q; + struct jql *q; JQP_AUX *aux; JBL_VCTX *vctx; } MCTX; @@ -41,8 +48,12 @@ IW_INLINE void _jql_jqval_destroy(JQP_STRING *pv) { ptr = (void*) qv->vstr; break; case JQVAL_RE: - ptr = (void*) qv->vre->expression; - lwre_free(qv->vre); + if (qv->vre != IWRE_UNUSED_PTR) { + ptr = (void*) iwre_pattern_get(qv->vre); + iwre_destroy(qv->vre); + } else { + ptr = 0; + } break; case JQVAL_JBLNODE: ptr = qv->vnode; @@ -51,11 +62,13 @@ IW_INLINE void _jql_jqval_destroy(JQP_STRING *pv) { ptr = 0; break; } - if (ptr && qv->freefn) { - qv->freefn(ptr, qv->freefn_op); + if (--qv->refs <= 0) { + if (ptr && qv->freefn) { + qv->freefn(ptr, qv->freefn_op); + } + free(qv); } pv->opaque = 0; - free(qv); } } @@ -75,40 +88,67 @@ JQVAL* jql_find_placeholder(JQL q, const char *name) { static iwrc _jql_set_placeholder(JQL q, const char *placeholder, int index, JQVAL *val) { JQP_AUX *aux = q->aux; + iwrc rc = JQL_ERROR_INVALID_PLACEHOLDER; if (!placeholder) { // Index - char nbuf[JBNUMBUF_SIZE]; - iwitoa(index, nbuf, JBNUMBUF_SIZE); + char nbuf[IWNUMBUF_SIZE]; + iwitoa(index, nbuf, IWNUMBUF_SIZE); for (JQP_STRING *pv = aux->start_placeholder; pv; pv = pv->placeholder_next) { if ((pv->value[0] == '?') && !strcmp(pv->value + 1, nbuf)) { + if ((pv->flavour & (JQP_STR_PROJFIELD | JQP_STR_PROJPATH)) && val->type != JQVAL_STR) { + return JQL_ERROR_INVALID_PLACEHOLDER_VALUE_TYPE; + } _jql_jqval_destroy(pv); pv->opaque = val; + val->refs++; return 0; } } } else { for (JQP_STRING *pv = aux->start_placeholder; pv; pv = pv->placeholder_next) { if (!strcmp(pv->value, placeholder)) { + if ((pv->flavour & (JQP_STR_PROJFIELD | JQP_STR_PROJPATH)) && val->type != JQVAL_STR) { + rc = JQL_ERROR_INVALID_PLACEHOLDER_VALUE_TYPE; + goto finish; + } _jql_jqval_destroy(pv); pv->opaque = val; - return 0; + val->refs++; + rc = 0; + } + } + } +finish: + if (rc) { + val->refs = 0; + for (JQP_STRING *pv = aux->start_placeholder; pv; pv = pv->placeholder_next) { + if (pv->opaque == val) { + pv->opaque = 0; } } } - return JQL_ERROR_INVALID_PLACEHOLDER; + return rc; } iwrc jql_set_json2( JQL q, const char *placeholder, int index, JBL_NODE val, - void (*freefn) (void*, void*), void *op) { + void (*freefn)(void*, void*), void *op) { JQVAL *qv = malloc(sizeof(*qv)); if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = freefn; qv->freefn_op = op; qv->type = JQVAL_JBLNODE; qv->vnode = val; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + if (freefn) { + freefn(val, op); + } + free(qv); + } + return rc; } iwrc jql_set_json(JQL q, const char *placeholder, int index, JBL_NODE val) { @@ -124,10 +164,11 @@ iwrc jql_set_json_jbl(JQL q, const char *placeholder, int index, JBL jbl) { if (!pool) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + iwrc rc; JBL_NODE n; - iwrc rc = jbl_to_node(jbl, &n, true, pool); - RCGO(rc, finish); + RCC(rc, finish, jbl_to_node(jbl, &n, true, pool)); rc = jql_set_json2(q, placeholder, index, n, _jql_free_iwpool, pool); + finish: if (rc) { iwpool_destroy(pool); @@ -140,11 +181,16 @@ iwrc jql_set_i64(JQL q, const char *placeholder, int index, int64_t val) { if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = 0; qv->freefn_op = 0; qv->type = JQVAL_I64; qv->vi64 = val; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + free(qv); + } + return rc; } iwrc jql_set_f64(JQL q, const char *placeholder, int index, double val) { @@ -152,61 +198,113 @@ iwrc jql_set_f64(JQL q, const char *placeholder, int index, double val) { if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = 0; qv->freefn_op = 0; qv->type = JQVAL_F64; qv->vf64 = val; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + free(qv); + } + return rc; } iwrc jql_set_str2( JQL q, const char *placeholder, int index, const char *val, - void (*freefn) (void*, void*), void *op) { + void (*freefn)(void*, void*), void *op) { + if (val == 0) { + if (freefn) { + freefn((void*) val, op); + } + return jql_set_null(q, placeholder, index); + } + JQVAL *qv = malloc(sizeof(*qv)); if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = freefn; qv->freefn_op = op; qv->type = JQVAL_STR; qv->vstr = val; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + if (freefn) { + freefn((void*) val, op); + } + free(qv); + } + return rc; } iwrc jql_set_str(JQL q, const char *placeholder, int index, const char *val) { return jql_set_str2(q, placeholder, index, val, 0, 0); } +static void _freefn_str(void *v, void *op) { + free(v); +} + +iwrc jql_set_str3(JQL q, const char *placeholder, int index, const char *val_, size_t val_len) { + char *val = strndup(val_, val_len); + if (!val) { + return iwrc_set_errno(IW_ERROR_ALLOC, errno); + } + return jql_set_str2(q, placeholder, index, val, _freefn_str, 0); +} + iwrc jql_set_bool(JQL q, const char *placeholder, int index, bool val) { JQVAL *qv = malloc(sizeof(*qv)); if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = 0; qv->freefn_op = 0; qv->type = JQVAL_BOOL; qv->vbool = val; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + free(qv); + } + return rc; } iwrc jql_set_regexp2( JQL q, const char *placeholder, int index, const char *expr, - void (*freefn) (void*, void*), void *op) { - struct re *rx = lwre_new(expr); + void (*freefn)(void*, void*), void *op) { + iwrc rc = 0; + JQVAL *qv = 0; + struct iwre *rx = (expr && *expr != '\0') ? iwre_create(expr) : IWRE_UNUSED_PTR; if (!rx) { - return iwrc_set_errno(IW_ERROR_ALLOC, errno); + rc = JQL_ERROR_REGEXP_INVALID; + goto finish; } - JQVAL *qv = malloc(sizeof(*qv)); - if (!qv) { - iwrc rc = iwrc_set_errno(IW_ERROR_ALLOC, errno); - lwre_free(rx); - return rc; + RCA(qv = malloc(sizeof(*qv)), finish); + qv->refs = 0; + if (rx != IWRE_UNUSED_PTR) { + qv->freefn = freefn; + qv->freefn_op = op; } - qv->freefn = freefn; - qv->freefn_op = op; qv->type = JQVAL_RE; qv->vre = rx; - return _jql_set_placeholder(q, placeholder, index, qv); + rc = _jql_set_placeholder(q, placeholder, index, qv); + +finish: + if (rc) { + if (freefn) { + freefn((void*) expr, op); + } + if (rx != IWRE_UNUSED_PTR) { + iwre_destroy(rx); + } + free(qv); + } else if (rx == IWRE_UNUSED_PTR && freefn) { + freefn((void*) expr, op); + } + return rc; } iwrc jql_set_regexp(JQL q, const char *placeholder, int index, const char *expr) { @@ -218,12 +316,18 @@ iwrc jql_set_null(JQL q, const char *placeholder, int index) { if (!qv) { return iwrc_set_errno(IW_ERROR_ALLOC, errno); } + qv->refs = 0; qv->freefn = 0; qv->freefn_op = 0; qv->type = JQVAL_NULL; - return _jql_set_placeholder(q, placeholder, index, qv); + iwrc rc = _jql_set_placeholder(q, placeholder, index, qv); + if (rc) { + free(qv); + } + return rc; } +// NOLINTNEXTLINE(misc-no-recursion) static bool _jql_need_deeper_match(JQP_EXPR_NODE *en, int lvl) { for (en = en->chain; en; en = en->next) { if (en->type == JQP_EXPR_NODE_TYPE) { @@ -240,6 +344,7 @@ static bool _jql_need_deeper_match(JQP_EXPR_NODE *en, int lvl) { return false; } +// NOLINTNEXTLINE(misc-no-recursion) static void _jql_reset_expression_node(JQP_EXPR_NODE *en, JQP_AUX *aux, bool reset_match_cache) { MENCTX *ectx = en->opaque; ectx->matched = false; @@ -262,6 +367,7 @@ static void _jql_reset_expression_node(JQP_EXPR_NODE *en, JQP_AUX *aux, bool res } } +// NOLINTNEXTLINE(misc-no-recursion) static iwrc _jql_init_expression_node(JQP_EXPR_NODE *en, JQP_AUX *aux) { en->opaque = iwpool_calloc(sizeof(MENCTX), aux->pool); if (!en->opaque) { @@ -310,16 +416,13 @@ iwrc jql_create2(JQL *qptr, const char *coll, const char *query, jql_create_mode aux->mode = mode; q->aux = aux; - rc = jqp_parse(aux); - RCGO(rc, finish); + RCC(rc, finish, jqp_parse(aux)); - if (coll) { + if (coll && *coll != '\0') { // Get a copy of collection name - coll = iwpool_strdup(aux->pool, coll, &rc); - RCGO(rc, finish); + q->coll = iwpool_strdup2(aux->pool, coll); } - q->coll = coll; q->qp = aux->query; if (!q->coll) { @@ -352,7 +455,7 @@ iwrc jql_create(JQL *qptr, const char *coll, const char *query) { } size_t jql_estimate_allocated_size(JQL q) { - size_t ret = sizeof(struct _JQL); + size_t ret = sizeof(struct jql); if (q->aux && q->aux->pool) { ret += iwpool_allocated_size(q->aux->pool); } @@ -387,8 +490,8 @@ void jql_destroy(JQL *qptr) { } for (JQP_OP *op = aux->start_op; op; op = op->next) { if (op->opaque) { - if (op->value == JQP_OP_RE) { - lwre_free(op->opaque); + if (op->value == JQP_OP_RE && op->opaque != IWRE_UNUSED_PTR) { + iwre_destroy(op->opaque); } } } @@ -537,14 +640,14 @@ static int _jql_cmp_jqval_pair(const JQVAL *left, const JQVAL *right, iwrc *rcp) case JQVAL_BOOL: return !strcmp(lv->vstr, "true") - rv->vbool; case JQVAL_I64: { - char nbuf[JBNUMBUF_SIZE]; - iwitoa(rv->vi64, nbuf, JBNUMBUF_SIZE); + char nbuf[IWNUMBUF_SIZE]; + iwitoa(rv->vi64, nbuf, IWNUMBUF_SIZE); return strcmp(lv->vstr, nbuf); } case JQVAL_F64: { size_t osz; - char nbuf[JBNUMBUF_SIZE]; - jbi_ftoa(rv->vf64, nbuf, &osz); + char nbuf[IWNUMBUF_SIZE]; + iwjson_ftoa(rv->vf64, nbuf, &osz); return strcmp(lv->vstr, nbuf); } case JQVAL_NULL: @@ -577,7 +680,7 @@ static int _jql_cmp_jqval_pair(const JQVAL *left, const JQVAL *right, iwrc *rcp) case JQVAL_F64: return lv->vf64 > rv->vf64 ? 1 : lv->vf64 < rv->vf64 ? -1 : 0; case JQVAL_I64: - return lv->vf64 > (double) rv->vi64 ? 1 : lv->vf64 < rv->vf64 ? -1 : 0; + return lv->vf64 > (double) rv->vi64 ? 1 : lv->vf64 < (double) rv->vi64 ? -1 : 0; case JQVAL_STR: { double rval = (double) iwatof(rv->vstr); return lv->vf64 > rval ? 1 : lv->vf64 < rval ? -1 : 0; @@ -600,7 +703,7 @@ static int _jql_cmp_jqval_pair(const JQVAL *left, const JQVAL *right, iwrc *rcp) return lv->vbool - (rv->vf64 != 0.0); // -V550 case JQVAL_STR: { if (strcmp(rv->vstr, "true") == 0) { - return lv->vbool - 1; + return lv->vbool - 1; } else if (strcmp(rv->vstr, "false") == 0) { return lv->vbool; } else { @@ -632,7 +735,7 @@ static int _jql_cmp_jqval_pair(const JQVAL *left, const JQVAL *right, iwrc *rcp) return 0; } JBL_NODE lnode; - IWPOOL *pool = iwpool_create(rv->vbinn->size * 2); + IWPOOL *pool = iwpool_create((size_t) (rv->vbinn->size) * 2); if (!pool) { *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); return 0; @@ -661,15 +764,12 @@ static bool _jql_match_regexp( JQP_AUX *aux, JQVAL *left, JQP_OP *jqop, JQVAL *right, iwrc *rcp) { - struct re *rx; - char nbuf[JBNUMBUF_SIZE]; - static_assert(JBNUMBUF_SIZE >= IWFTOA_BUFSIZE, "JBNUMBUF_SIZE >= IWFTOA_BUFSIZE"); + struct iwre *rx; + char nbuf[IWNUMBUF_SIZE]; JQVAL sleft, sright; // Stack allocated left/right converted values JQVAL *lv = left, *rv = right; char *input = 0; - size_t rci, match_end = 0; const char *expr = 0; - bool match_start = false; if (lv->type == JQVAL_JBLNODE) { _jql_node_to_jqval(lv->vnode, &sleft); @@ -697,7 +797,7 @@ static bool _jql_match_regexp( expr = rv->vstr; break; case JQVAL_I64: { - iwitoa(rv->vi64, nbuf, JBNUMBUF_SIZE); + iwitoa(rv->vi64, nbuf, IWNUMBUF_SIZE); expr = iwpool_strdup(aux->pool, nbuf, rcp); if (*rcp) { return false; @@ -706,7 +806,7 @@ static bool _jql_match_regexp( } case JQVAL_F64: { size_t osz; - jbi_ftoa(rv->vf64, nbuf, &osz); + iwjson_ftoa(rv->vf64, nbuf, &osz); expr = iwpool_strdup(aux->pool, nbuf, rcp); if (*rcp) { return false; @@ -721,43 +821,29 @@ static bool _jql_match_regexp( return false; } - assert(expr); - if (expr[0] == '^') { - expr += 1; - match_start = true; - } - rci = strlen(expr); - if (rci && (expr[rci - 1] == '$')) { - char *aexpr = iwpool_alloc(rci, aux->pool); - if (!aexpr) { - *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); + if (IW_UNLIKELY(*expr == '\0')) { + rx = IWRE_UNUSED_PTR; + } else { + rx = iwre_create(expr); + if (!rx) { + *rcp = JQL_ERROR_REGEXP_INVALID; return false; } - match_end = rci - 1; - memcpy(aexpr, expr, match_end); - aexpr[rci - 1] = '\0'; - expr = aexpr; - } - rx = lwre_new(expr); - if (!rx) { - *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return false; } jqop->opaque = rx; } - assert(rx); switch (lv->type) { case JQVAL_STR: input = (char*) lv->vstr; break; case JQVAL_I64: - iwitoa(lv->vi64, nbuf, JBNUMBUF_SIZE); + iwitoa(lv->vi64, nbuf, IWNUMBUF_SIZE); input = nbuf; break; case JQVAL_F64: { size_t osz; - jbi_ftoa(lv->vf64, nbuf, &osz); + iwjson_ftoa(lv->vf64, nbuf, &osz); input = nbuf; } break; @@ -769,44 +855,18 @@ static bool _jql_match_regexp( return false; } - assert(input); - int mret = lwre_match(rx, input); - switch (mret) { - case RE_ERROR_NOMATCH: - return false; - case RE_ERROR_NOMEM: - *rcp = iwrc_set_errno(IW_ERROR_ALLOC, errno); - return false; - case RE_ERROR_CHARSET: - *rcp = JQL_ERROR_REGEXP_CHARSET; - return false; - case RE_ERROR_SUBEXP: - *rcp = JQL_ERROR_REGEXP_SUBEXP; - return false; - case RE_ERROR_SUBMATCH: - *rcp = JQL_ERROR_REGEXP_SUBMATCH; - return false; - case RE_ERROR_ENGINE: - *rcp = JQL_ERROR_REGEXP_ENGINE; - iwlog_ecode_error3(JQL_ERROR_REGEXP_ENGINE); - return false; - } - if (mret > 0) { - if (match_start && (rx->position - mret != input)) { - return false; - } - if (match_end && (rx->position != input + match_end)) { - return false; - } - return true; + if (IW_UNLIKELY(rx == IWRE_UNUSED_PTR)) { + return *input == '\0'; + } else { + const char *mpairs[IWRE_MAX_MATCHES]; + int mret = iwre_match(rx, input, mpairs, IWRE_MAX_MATCHES); + return mret > 0; } - return false; } static bool _jql_match_in( JQVAL *left, JQP_OP *jqop, JQVAL *right, iwrc *rcp) { - JQVAL sleft; // Stack allocated left/right converted values JQVAL *lv = left, *rv = right; if ((rv->type != JQVAL_JBLNODE) && (rv->vnode->type != JBV_ARRAY)) { @@ -822,7 +882,7 @@ static bool _jql_match_in( } for (JBL_NODE n = rv->vnode->child; n; n = n->next) { JQVAL qv = { - .type = JQVAL_JBLNODE, + .type = JQVAL_JBLNODE, .vnode = n }; if (!_jql_cmp_jqval_pair(lv, &qv, rcp)) { @@ -841,7 +901,6 @@ static bool _jql_match_in( static bool _jql_match_ni( JQVAL *left, JQP_OP *jqop, JQVAL *right, iwrc *rcp) { - JQVAL sleft; // Stack allocated left/right converted values JQVAL *lv = left, *rv = right; binn bv; @@ -867,7 +926,7 @@ static bool _jql_match_ni( } while (binn_list_next(&iter, &bv)) { JQVAL qv = { - .type = JQVAL_BINN, + .type = JQVAL_BINN, .vbinn = &bv }; if (!_jql_cmp_jqval_pair(&qv, lv, rcp)) { @@ -885,11 +944,10 @@ static bool _jql_match_ni( static bool _jql_match_starts( JQVAL *left, JQP_OP *jqop, JQVAL *right, iwrc *rcp) { - JQVAL sleft; // Stack allocated left/right converted values JQVAL *lv = left, *rv = right; - char nbuf[JBNUMBUF_SIZE]; - char nbuf2[JBNUMBUF_SIZE]; + char nbuf[IWNUMBUF_SIZE]; + char nbuf2[IWNUMBUF_SIZE]; char *input = 0, *prefix = 0; if (lv->type == JQVAL_JBLNODE) { @@ -904,12 +962,12 @@ static bool _jql_match_starts( input = (char*) lv->vstr; break; case JQVAL_I64: - iwitoa(lv->vi64, nbuf, JBNUMBUF_SIZE); + iwitoa(lv->vi64, nbuf, IWNUMBUF_SIZE); input = nbuf; break; case JQVAL_F64: { size_t osz; - jbi_ftoa(lv->vf64, nbuf, &osz); + iwjson_ftoa(lv->vf64, nbuf, &osz); input = nbuf; break; } @@ -925,12 +983,12 @@ static bool _jql_match_starts( prefix = (char*) rv->vstr; break; case JQVAL_I64: - iwitoa(rv->vi64, nbuf2, JBNUMBUF_SIZE); + iwitoa(rv->vi64, nbuf2, IWNUMBUF_SIZE); prefix = nbuf2; break; case JQVAL_F64: { size_t osz; - jbi_ftoa(rv->vf64, nbuf2, &osz); + iwjson_ftoa(rv->vf64, nbuf2, &osz); prefix = nbuf2; break; } @@ -1049,7 +1107,7 @@ static JQVAL* _jql_unit_to_jqval(JQP_AUX *aux, JQPUNIT *unit, iwrc *rcp) { return 0; } unit->json.opaque = qv; - struct _JBL_NODE *jn = &unit->json.jn; + struct jbl_node *jn = &unit->json.jn; switch (jn->type) { case JBV_BOOL: qv->type = JQVAL_BOOL; @@ -1245,6 +1303,7 @@ IW_INLINE bool _jql_match_node_field(MCTX *mctx, JQP_NODE *n, iwrc *rcp) { return (strcmp(n->value->string.value, mctx->key) == 0); } +// NOLINTNEXTLINE(misc-no-recursion) IW_INLINE JQP_NODE* _jql_match_node_anys(MCTX *mctx, JQP_NODE *n, bool *res, iwrc *rcp) { if (n->start < 0) { n->start = mctx->lvl; @@ -1264,6 +1323,7 @@ IW_INLINE JQP_NODE* _jql_match_node_anys(MCTX *mctx, JQP_NODE *n, bool *res, iwr return n; } +// NOLINTNEXTLINE(misc-no-recursion) static JQP_NODE* _jql_match_node(MCTX *mctx, JQP_NODE *n, bool *res, iwrc *rcp) { switch (n->ntype) { case JQP_NODE_FIELD: @@ -1321,6 +1381,7 @@ static bool _jql_match_filter(JQP_FILTER *f, MCTX *mctx, iwrc *rcp) { return fctx->matched; } +// NOLINTNEXTLINE(misc-no-recursion) static bool _jql_match_expression_node(JQP_EXPR_NODE *en, MCTX *mctx, iwrc *rcp) { MENCTX *enctx = en->opaque; if (enctx->matched) { @@ -1356,7 +1417,7 @@ static bool _jql_match_expression_node(JQP_EXPR_NODE *en, MCTX *mctx, iwrc *rcp) } static jbl_visitor_cmd_t _jql_match_visitor(int lvl, binn *bv, const char *key, int idx, JBL_VCTX *vctx, iwrc *rcp) { - char nbuf[JBNUMBUF_SIZE]; + char nbuf[IWNUMBUF_SIZE]; const char *nkey = key; JQL q = vctx->op; if (!nkey) { @@ -1364,12 +1425,12 @@ static jbl_visitor_cmd_t _jql_match_visitor(int lvl, binn *bv, const char *key, nkey = nbuf; } MCTX mctx = { - .lvl = lvl, - .bv = bv, - .key = nkey, + .lvl = lvl, + .bv = bv, + .key = nkey, .vctx = vctx, - .q = q, - .aux = q->aux + .q = q, + .aux = q->aux }; q->matched = _jql_match_expression_node(mctx.aux->expr, &mctx, rcp); if (*rcp || q->matched) { @@ -1459,7 +1520,7 @@ bool jql_has_aggregate_count(JQL q) { iwrc jql_get_skip(JQL q, int64_t *out) { iwrc rc = 0; *out = 0; - struct JQP_AUX *aux = q->aux; + struct jqp_aux *aux = q->aux; JQPUNIT *skip = aux->skip; if (!skip) { return 0; @@ -1476,7 +1537,7 @@ iwrc jql_get_skip(JQL q, int64_t *out) { iwrc jql_get_limit(JQL q, int64_t *out) { iwrc rc = 0; *out = 0; - struct JQP_AUX *aux = q->aux; + struct jqp_aux *aux = q->aux; JQPUNIT *limit = aux->limit; if (!limit) { return 0; @@ -1523,11 +1584,11 @@ static bool _jql_proj_matched( } if (proj->pos + 1 == lvl) { JQP_STRING *ps = proj->value; - for (int i = 0; i < lvl; ps = ps->next, ++i); // -V529 + for (int i = 0; i < lvl; ps = ps->next, ++i); // -V529 assert(ps); if (ps->flavour & JQP_STR_PROJFIELD) { for (JQP_STRING *sn = ps; sn; sn = sn->subnext) { - const char *pv = sn->value; + const char *pv = IW_UNLIKELY(sn->flavour & JQP_STR_PLACEHOLDER) ? ((JQVAL*) sn->opaque)->vstr : sn->value; int pvlen = (int) strlen(pv); if ((pvlen == keylen) && !strncmp(key, pv, keylen)) { proj->pos = lvl; @@ -1535,7 +1596,7 @@ static bool _jql_proj_matched( } } } else { - const char *pv = ps->value; + const char *pv = IW_UNLIKELY(ps->flavour & JQP_STR_PLACEHOLDER) ? ((JQVAL*) ps->opaque)->vstr : ps->value; int pvlen = (int) strlen(pv); if (((pvlen == keylen) && !strncmp(key, pv, keylen)) || ((pv[0] == '*') && (pv[1] == '\0'))) { proj->pos = lvl; @@ -1552,7 +1613,6 @@ static bool _jql_proj_join_matched( JBN_VCTX *vctx, JQP_PROJECTION *proj, JBL *out, iwrc *rcp) { - PROJ_CTX *pctx = vctx->op; if (proj->cnt != lvl + 1) { return _jql_proj_matched(lvl, n, key, keylen, vctx, proj, rcp); @@ -1563,12 +1623,12 @@ static bool _jql_proj_join_matched( const char *pv, *spos; bool ret = false; JQP_STRING *ps = proj->value; - for (int i = 0; i < lvl; ps = ps->next, ++i); // -V529 + for (int i = 0; i < lvl; ps = ps->next, ++i); // -V529 assert(ps); if (ps->flavour & JQP_STR_PROJFIELD) { for (JQP_STRING *sn = ps; sn; sn = sn->subnext) { - pv = sn->value; + pv = IW_UNLIKELY(sn->flavour & JQP_STR_PLACEHOLDER) ? ((JQVAL*) sn->opaque)->vstr : sn->value; spos = strchr(pv, '<'); if (!spos) { if ((strlen(pv) == keylen) && !strncmp(key, pv, keylen)) { @@ -1582,7 +1642,7 @@ static bool _jql_proj_join_matched( } } } else { - pv = ps->value; + pv = IW_UNLIKELY(ps->flavour & JQP_STR_PLACEHOLDER) ? ((JQVAL*) ps->opaque)->vstr : ps->value; spos = strchr(pv, '<'); assert(spos); ret = !strncmp(key, pv, spos - pv); @@ -1601,7 +1661,7 @@ static bool _jql_proj_join_matched( // Unable to convert current node value as int number return false; } - IWSTREE *cache = exec_ctx->proj_joined_nodes_cache; + IWHMAP *cache = exec_ctx->proj_joined_nodes_cache; IWPOOL *pool = exec_ctx->ux->pool; if (!pool) { pool = exec_ctx->proj_joined_nodes_pool; @@ -1609,25 +1669,24 @@ static bool _jql_proj_join_matched( pool = iwpool_create(512); RCGA(pool, finish); exec_ctx->proj_joined_nodes_pool = pool; - } else if (cache && (iwpool_used_size(pool) > 10 * 1024 * 1024)) { // 10Mb + } else if (cache && (iwpool_used_size(pool) > 10UL * 1024 * 1024)) { // 10Mb exec_ctx->proj_joined_nodes_cache = 0; - iwstree_destroy(cache); + iwhmap_destroy(exec_ctx->proj_joined_nodes_cache); cache = 0; iwpool_destroy(pool); - pool = iwpool_create(1024 * 1024); // 1Mb + pool = iwpool_create(1024UL * 1024); // 1Mb RCGA(pool, finish); } } if (!cache) { - cache = iwstree_create(jb_proj_node_cache_cmp, jb_proj_node_kvfree); - RCGA(cache, finish); + RCB(finish, cache = iwhmap_create(jb_proj_node_cache_cmp, jb_proj_node_hash, jb_proj_node_kvfree)); exec_ctx->proj_joined_nodes_cache = cache; } - struct _JBDOCREF ref = { - .id = id, + struct jbdocref ref = { + .id = id, .coll = coll }; - nn = iwstree_get(cache, &ref); + nn = iwhmap_get(cache, &ref); if (!nn) { rc = jb_collection_join_resolver(id, coll, &jbl, exec_ctx); if (rc) { @@ -1639,11 +1698,11 @@ static bool _jql_proj_join_matched( } goto finish; } - RCHECK(rc, finish, jbl_to_node(jbl, &nn, true, pool)); - struct _JBDOCREF *refkey = malloc(sizeof(*refkey)); + RCC(rc, finish, jbl_to_node(jbl, &nn, true, pool)); + struct jbdocref *refkey = malloc(sizeof(*refkey)); RCGA(refkey, finish); *refkey = ref; - RCHECK(rc, finish, iwstree_put(cache, refkey, nn)); + RCC(rc, finish, iwhmap_put(cache, refkey, nn)); } jbn_apply_from(n, nn); proj->pos = lvl; @@ -1658,13 +1717,13 @@ static bool _jql_proj_join_matched( static jbn_visitor_cmd_t _jql_proj_visitor(int lvl, JBL_NODE n, const char *key, int klidx, JBN_VCTX *vctx, iwrc *rc) { PROJ_CTX *pctx = vctx->op; const char *keyptr; - char buf[JBNUMBUF_SIZE]; + char buf[IWNUMBUF_SIZE]; if (key) { keyptr = key; } else if (lvl < 0) { return 0; } else { - iwitoa(klidx, buf, JBNUMBUF_SIZE); + iwitoa(klidx, buf, IWNUMBUF_SIZE); keyptr = buf; klidx = (int) strlen(keyptr); } @@ -1704,6 +1763,7 @@ static jbn_visitor_cmd_t _jql_proj_keep_visitor( } static iwrc _jql_project(JBL_NODE root, JQL q, IWPOOL *pool, JBEXEC *exec_ctx) { + iwrc rc; JQP_AUX *aux = q->aux; if (aux->has_exclude_all_projection) { jbn_data(root); @@ -1711,9 +1771,9 @@ static iwrc _jql_project(JBL_NODE root, JQL q, IWPOOL *pool, JBEXEC *exec_ctx) { } JQP_PROJECTION *proj = aux->projection; PROJ_CTX pctx = { - .q = q, - .proj = proj, - .pool = pool, + .q = q, + .proj = proj, + .pool = pool, .exec_ctx = exec_ctx, }; if (!pool) { @@ -1724,17 +1784,22 @@ static iwrc _jql_project(JBL_NODE root, JQL q, IWPOOL *pool, JBEXEC *exec_ctx) { p->pos = -1; p->cnt = 0; for (JQP_STRING *s = p->value; s; s = s->next) { + if (s->flavour & JQP_STR_PLACEHOLDER) { + if (s->opaque == 0 || ((JQVAL*) s->opaque)->type != JQVAL_STR) { + return JQL_ERROR_INVALID_PLACEHOLDER_VALUE_TYPE; + } + } p->cnt++; } } JBN_VCTX vctx = { .root = root, - .op = &pctx + .op = &pctx }; - iwrc rc = jbn_visit(root, 0, &vctx, _jql_proj_visitor); - RCGO(rc, finish); + + RCC(rc, finish, jbn_visit(root, 0, &vctx, _jql_proj_visitor)); if (aux->has_keep_projections) { // We have keep projections - RCHECK(rc, finish, jbn_visit(root, 0, &vctx, _jql_proj_keep_visitor)); + RCC(rc, finish, jbn_visit(root, 0, &vctx, _jql_proj_keep_visitor)); } finish: @@ -1803,14 +1868,6 @@ static const char* _ecodefn(locale_t locale, uint32_t ecode) { return "Found unset placeholder (JQL_ERROR_UNSET_PLACEHOLDER)"; case JQL_ERROR_REGEXP_INVALID: return "Invalid regular expression (JQL_ERROR_REGEXP_INVALID)"; - case JQL_ERROR_REGEXP_CHARSET: - return "Invalid regular expression: expected ']' at end of character set (JQL_ERROR_REGEXP_CHARSET)"; - case JQL_ERROR_REGEXP_SUBEXP: - return "Invalid regular expression: expected ')' at end of subexpression (JQL_ERROR_REGEXP_SUBEXP)"; - case JQL_ERROR_REGEXP_SUBMATCH: - return "Invalid regular expression: expected '}' at end of submatch (JQL_ERROR_REGEXP_SUBMATCH)"; - case JQL_ERROR_REGEXP_ENGINE: - return "Illegal instruction in compiled regular expression (please report this bug) (JQL_ERROR_REGEXP_ENGINE)"; case JQL_ERROR_SKIP_ALREADY_SET: return "Skip clause already specified (JQL_ERROR_SKIP_ALREADY_SET)"; case JQL_ERROR_LIMIT_ALREADY_SET: diff --git a/src/jql/jql.h b/src/jql/jql.h index e3cf1c39b..e56d83c03 100644 --- a/src/jql/jql.h +++ b/src/jql/jql.h @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,13 +37,13 @@ * */ -#include "jbl.h" -#include +#include +#include -IW_EXTERN_C_START +IW_EXTERN_C_START; -struct _JQL; -typedef struct _JQL*JQL; +struct jql; +typedef struct jql*JQL; typedef enum { _JQL_ERROR_START = (IW_ERROR_START + 15000UL + 2000), @@ -51,18 +51,6 @@ typedef enum { JQL_ERROR_INVALID_PLACEHOLDER, /**< Invalid placeholder position (JQL_ERROR_INVALID_PLACEHOLDER) */ JQL_ERROR_UNSET_PLACEHOLDER, /**< Found unset placeholder (JQL_ERROR_UNSET_PLACEHOLDER) */ JQL_ERROR_REGEXP_INVALID, /**< Invalid regular expression (JQL_ERROR_REGEXP_INVALID) */ - JQL_ERROR_REGEXP_CHARSET, - /**< Invalid regular expression: expected ']' at end of character set - (JQL_ERROR_REGEXP_CHARSET) */ - JQL_ERROR_REGEXP_SUBEXP, - /**< Invalid regular expression: expected ')' at end of subexpression - (JQL_ERROR_REGEXP_SUBEXP) */ - JQL_ERROR_REGEXP_SUBMATCH, - /**< Invalid regular expression: expected '}' at end of submatch - (JQL_ERROR_REGEXP_SUBMATCH) */ - JQL_ERROR_REGEXP_ENGINE, - /**< Illegal instruction in compiled regular expression (please report this - bug) (JQL_ERROR_REGEXP_ENGINE) */ JQL_ERROR_SKIP_ALREADY_SET, /**< Skip clause already specified (JQL_ERROR_SKIP_ALREADY_SET) */ JQL_ERROR_LIMIT_ALREADY_SET, /**< Limit clause already specified (JQL_ERROR_SKIP_ALREADY_SET) */ JQL_ERROR_ORDERBY_MAX_LIMIT, @@ -91,11 +79,11 @@ typedef uint8_t jql_create_mode_t; * @param coll Optional collection name used to execute query * @param query Query text */ -IW_EXPORT WUR iwrc jql_create(JQL *qptr, const char *coll, const char *query); +IW_EXPORT WUR iwrc jql_create(struct jql * *qptr, const char *coll, const char *query); -IW_EXPORT WUR iwrc jql_create2(JQL *qptr, const char *coll, const char *query, jql_create_mode_t mode); +IW_EXPORT WUR iwrc jql_create2(struct jql * *qptr, const char *coll, const char *query, jql_create_mode_t mode); -IW_EXPORT const char *jql_collection(JQL q); +IW_EXPORT const char* jql_collection(struct jql *q); /** * @brief Bind JSON node data to query placeholder. @@ -103,17 +91,17 @@ IW_EXPORT const char *jql_collection(JQL q); * Caller is responsible to maintain `val` availability during execution of query. * @see jql_set_json2() */ -IW_EXPORT WUR iwrc jql_set_json(JQL q, const char *placeholder, int index, JBL_NODE val); +IW_EXPORT WUR iwrc jql_set_json(struct jql *q, const char *placeholder, int index, struct jbl_node *val); IW_EXPORT WUR iwrc jql_set_json2( - JQL q, const char *placeholder, int index, JBL_NODE val, + struct jql *q, const char *placeholder, int index, struct jbl_node *val, void (*freefn)(void*, void*), void *op); -IW_EXPORT WUR iwrc jql_set_json_jbl(JQL q, const char *placeholder, int index, JBL jbl); +IW_EXPORT WUR iwrc jql_set_json_jbl(struct jql *q, const char *placeholder, int index, JBL jbl); -IW_EXPORT WUR iwrc jql_set_i64(JQL q, const char *placeholder, int index, int64_t val); +IW_EXPORT WUR iwrc jql_set_i64(struct jql *q, const char *placeholder, int index, int64_t val); -IW_EXPORT WUR iwrc jql_set_f64(JQL q, const char *placeholder, int index, double val); +IW_EXPORT WUR iwrc jql_set_f64(struct jql *q, const char *placeholder, int index, double val); /** * @brief Bind string data to query placeholder. @@ -121,14 +109,19 @@ IW_EXPORT WUR iwrc jql_set_f64(JQL q, const char *placeholder, int index, double * Caller is responsible to maintain `val` availability during execution of query. * @see jql_set_str2() */ -IW_EXPORT WUR iwrc jql_set_str(JQL q, const char *placeholder, int index, const char *val); +IW_EXPORT WUR iwrc jql_set_str(struct jql *q, const char *placeholder, int index, const char *val); IW_EXPORT WUR iwrc jql_set_str2( - JQL q, const char *placeholder, int index, const char *val, + struct jql *q, const char *placeholder, int index, const char *val, void (*freefn)(void*, void*), void *op); -IW_EXPORT WUR iwrc jql_set_bool(JQL q, const char *placeholder, int index, bool val); +IW_EXPORT WUR iwrc jql_set_str3(struct jql *q, const char *placeholder, int index, const char *val, size_t val_len); +/* + * @brief Bind string data to query placeholder. + * @note Unlike `jql_set_str()` data is copied into query context. + */ +IW_EXPORT WUR iwrc jql_set_bool(struct jql *q, const char *placeholder, int index, bool val); /** * @brief Bind regexp data string to query placeholder. @@ -136,49 +129,54 @@ IW_EXPORT WUR iwrc jql_set_bool(JQL q, const char *placeholder, int index, bool * Caller is responsible to maintain `val` availability during execution of query. * @see jql_set_regexp2() */ -IW_EXPORT WUR iwrc jql_set_regexp(JQL q, const char *placeholder, int index, const char *expr); +IW_EXPORT WUR iwrc jql_set_regexp(struct jql *q, const char *placeholder, int index, const char *expr); IW_EXPORT WUR iwrc jql_set_regexp2( - JQL q, const char *placeholder, int index, const char *expr, + struct jql *q, const char *placeholder, int index, const char *expr, void (*freefn)(void*, void*), void *op); -IW_EXPORT WUR iwrc jql_set_null(JQL q, const char *placeholder, int index); +IW_EXPORT WUR iwrc jql_set_null(struct jql *q, const char *placeholder, int index); -IW_EXPORT WUR iwrc jql_matched(JQL q, JBL jbl, bool *out); +IW_EXPORT WUR iwrc jql_matched(struct jql *q, JBL jbl, bool *out); -IW_EXPORT const char *jql_first_anchor(JQL q); +IW_EXPORT const char* jql_first_anchor(struct jql *q); -IW_EXPORT const char *jql_error(JQL q); +IW_EXPORT const char* jql_error(struct jql *q); -IW_EXPORT bool jql_has_apply(JQL q); +IW_EXPORT bool jql_has_apply(struct jql *q); -IW_EXPORT bool jql_has_apply_upsert(JQL q); +IW_EXPORT bool jql_has_apply_upsert(struct jql *q); -IW_EXPORT bool jql_has_apply_delete(JQL q); +IW_EXPORT bool jql_has_apply_delete(struct jql *q); -IW_EXPORT bool jql_has_projection(JQL q); +IW_EXPORT bool jql_has_projection(struct jql *q); -IW_EXPORT bool jql_has_orderby(JQL q); +IW_EXPORT bool jql_has_orderby(struct jql *q); -IW_EXPORT bool jql_has_aggregate_count(JQL q); +IW_EXPORT bool jql_has_aggregate_count(struct jql *q); -IW_EXPORT iwrc jql_get_skip(JQL q, int64_t *out); +IW_EXPORT iwrc jql_get_skip(struct jql *q, int64_t *out); -IW_EXPORT iwrc jql_get_limit(JQL q, int64_t *out); +IW_EXPORT iwrc jql_get_limit(struct jql *q, int64_t *out); -IW_EXPORT WUR iwrc jql_apply(JQL q, JBL_NODE root, IWPOOL *pool); +IW_EXPORT WUR iwrc jql_apply(struct jql *q, struct jbl_node *root, struct iwpool *pool); -IW_EXPORT WUR iwrc jql_project(JQL q, JBL_NODE root, IWPOOL *pool, void *exec_ctx); +IW_EXPORT WUR iwrc jql_project(struct jql *q, struct jbl_node *root, struct iwpool *pool, void *exec_ctx); -IW_EXPORT WUR iwrc jql_apply_and_project(JQL q, JBL jbl, JBL_NODE *out, void *exec_ctx, IWPOOL *pool); +IW_EXPORT WUR iwrc jql_apply_and_project( + struct jql *q, + struct jbl *jbl, + struct jbl_node **out, + void *exec_ctx, + struct iwpool *pool); -IW_EXPORT void jql_reset(JQL q, bool reset_match_cache, bool reset_placeholders); +IW_EXPORT void jql_reset(struct jql *q, bool reset_match_cache, bool reset_placeholders); -IW_EXPORT void jql_destroy(JQL *qptr); +IW_EXPORT void jql_destroy(struct jql * *qptr); -IW_EXPORT size_t jql_estimate_allocated_size(JQL q); +IW_EXPORT size_t jql_estimate_allocated_size(struct jql *q); IW_EXPORT WUR iwrc jql_init(void); -IW_EXTERN_C_END +IW_EXTERN_C_END; #endif diff --git a/src/jql/jql_internal.h b/src/jql/jql_internal.h index bb5fd3ee8..687cbfc52 100644 --- a/src/jql/jql_internal.h +++ b/src/jql/jql_internal.h @@ -3,12 +3,15 @@ #define JQL_INTERNAL_H #include "jqp.h" -#include "binn.h" + +#include +#include + #include /** Query object */ -struct _JQL { +struct jql { bool dirty; bool matched; JQP_QUERY *qp; @@ -30,24 +33,25 @@ typedef enum { } jqval_type_t; /** Placeholder value */ -typedef struct { +typedef struct jqval { jqval_type_t type; void (*freefn)(void*, void*); void *freefn_op; + int refs; union { JBL_NODE vnode; binn *vbinn; int64_t vi64; double vf64; const char *vstr; - bool vbool; - struct re *vre; + struct iwre *vre; + bool vbool; }; } JQVAL; -JQVAL *jql_find_placeholder(JQL q, const char *name); +JQVAL* jql_find_placeholder(JQL q, const char *name); -JQVAL *jql_unit_to_jqval(JQP_AUX *aux, JQPUNIT *unit, iwrc *rcp); +JQVAL* jql_unit_to_jqval(JQP_AUX *aux, JQPUNIT *unit, iwrc *rcp); bool jql_jqval_as_int(JQVAL *jqval, int64_t *out); diff --git a/src/jql/jqp.c b/src/jql/jqp.c index 17abc3e74..850ede223 100644 --- a/src/jql/jqp.c +++ b/src/jql/jqp.c @@ -7,33 +7,33 @@ #line 1 "./jqp.leg" #include "jqp.h" -#include "jbl.h" +#include #define YY_CTX_LOCAL 1 #define YY_CTX_MEMBERS \ - JQP_AUX *aux; + JQP_AUX *aux; struct _yycontext; static void _jqp_finish(struct _yycontext *yy); static void _jqp_debug(struct _yycontext *yy, const char *text); -static void *_jqp_malloc(struct _yycontext *yy, size_t size); -static void *_jqp_realloc(struct _yycontext *yy, void *ptr, size_t size); -static JQPUNIT *_jqp_unit(struct _yycontext *yy); +static void* _jqp_malloc(struct _yycontext *yy, size_t size); +static void* _jqp_realloc(struct _yycontext *yy, void *ptr, size_t size); +static JQPUNIT* _jqp_unit(struct _yycontext *yy); static void _jqp_op_negate(struct _yycontext *yy); static void _jqp_op_negate_reset(struct _yycontext *yy); -static JQPUNIT *_jqp_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text); -static JQPUNIT *_jqp_unescaped_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text); -static JQPUNIT *_jqp_number(struct _yycontext *yy, jqp_int_flavours_t flv, const char *text); -static JQPUNIT *_jqp_placeholder(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_unit_op(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_unit_join(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_expr(struct _yycontext *yy, JQPUNIT *left, JQPUNIT *op, JQPUNIT *right); -static JQPUNIT *_jqp_node(struct _yycontext *yy, JQPUNIT *value); -static JQPUNIT *_jqp_projection(struct _yycontext *yy, JQPUNIT *value, uint8_t flags); +static JQPUNIT* _jqp_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text); +static JQPUNIT* _jqp_unescaped_string(struct _yycontext *yy, jqp_string_flavours_t flv, const char *text); +static JQPUNIT* _jqp_number(struct _yycontext *yy, jqp_int_flavours_t flv, const char *text); +static JQPUNIT* _jqp_placeholder(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_unit_op(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_unit_join(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_expr(struct _yycontext *yy, JQPUNIT *left, JQPUNIT *op, JQPUNIT *right); +static JQPUNIT* _jqp_node(struct _yycontext *yy, JQPUNIT *value); +static JQPUNIT* _jqp_projection(struct _yycontext *yy, JQPUNIT *value, uint8_t flags); static void _jqp_set_skip(struct _yycontext *yy, JQPUNIT *unit); static void _jqp_set_limit(struct _yycontext *yy, JQPUNIT *unit); static void _jqp_add_orderby(struct _yycontext *yy, JQPUNIT *unit); @@ -41,93 +41,93 @@ static void _jqp_set_aggregate_count(struct _yycontext *yy); static void _jqp_set_noidx(struct _yycontext *yy); static void _jqp_set_inverse(struct _yycontext *yy); -static JQPUNIT *_jqp_json_string(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_json_number(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_json_true_false_null(struct _yycontext *yy, const char *text); -static JQPUNIT *_jqp_json_pair(struct _yycontext *yy, JQPUNIT *key, JQPUNIT *val); -static JQPUNIT *_jqp_json_collect(struct _yycontext *yy, jbl_type_t type, JQPUNIT *until); +static JQPUNIT* _jqp_json_string(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_json_number(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_json_true_false_null(struct _yycontext *yy, const char *text); +static JQPUNIT* _jqp_json_pair(struct _yycontext *yy, JQPUNIT *key, JQPUNIT *val); +static JQPUNIT* _jqp_json_collect(struct _yycontext *yy, jbl_type_t type, JQPUNIT *until); -static JQP_STACK *_jqp_push(struct _yycontext *yy); +static JQP_STACK* _jqp_push(struct _yycontext *yy); static void _jqp_unit_push(struct _yycontext *yy, JQPUNIT *unit); -static JQPUNIT *_jqp_unit_pop(struct _yycontext *yy); +static JQPUNIT* _jqp_unit_pop(struct _yycontext *yy); static void _jqp_string_push(struct _yycontext *yy, char *str, bool dup); -static char *_jqp_string_pop(struct _yycontext *yy); +static char* _jqp_string_pop(struct _yycontext *yy); -static JQPUNIT *_jqp_pop_filter_factor_chain(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_pop_expr_chain(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_pop_node_chain(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_pop_projfields_chain(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_pop_projection_nodes(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_pop_ordernodes(struct _yycontext *yy, JQPUNIT *until); -static JQPUNIT *_jqp_push_joined_projection(struct _yycontext *yy, JQPUNIT *p); -static JQPUNIT *_jqp_pop_joined_projections(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_filter_factor_chain(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_expr_chain(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_node_chain(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_projfields_chain(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_projection_nodes(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_pop_ordernodes(struct _yycontext *yy, JQPUNIT *until); +static JQPUNIT* _jqp_push_joined_projection(struct _yycontext *yy, JQPUNIT *p); +static JQPUNIT* _jqp_pop_joined_projections(struct _yycontext *yy, JQPUNIT *until); static void _jqp_set_filters_expr(struct _yycontext *yy, JQPUNIT *expr); -static JQPUNIT *_jqp_create_filterexpr_pk(struct _yycontext *yy, JQPUNIT *argument); +static JQPUNIT* _jqp_create_filterexpr_pk(struct _yycontext *yy, JQPUNIT *argument); static void _jqp_set_apply(struct _yycontext *yy, JQPUNIT *unit); static void _jqp_set_apply_delete(struct _yycontext *yy); static void _jqp_set_apply_upsert(struct _yycontext *yy, JQPUNIT *unit); static void _jqp_set_projection(struct _yycontext *yy, JQPUNIT *unit); #define YYSTYPE JQPUNIT* -#define YY_MALLOC(yy_, sz_) _jqp_malloc(yy_, sz_) +#define YY_MALLOC(yy_, sz_) _jqp_malloc(yy_, sz_) #define YY_REALLOC(yy_, ptr_, sz_) _jqp_realloc(yy_, ptr_, sz_) -#define YY_INPUT(yy_, buf_, result_, max_size_) \ - { \ - JQP_AUX *aux = (yy_)->aux; \ - if (aux->rc || *(aux->buf + aux->pos) == '\0') { \ - result_ = 0; \ - } else { \ - char ch = *(aux->buf + aux->pos++); \ - result_ = 1; \ - *(buf_)= ch; \ - } \ - } +#define YY_INPUT(yy_, buf_, result_, max_size_) \ + { \ + JQP_AUX *aux = (yy_)->aux; \ + if (aux->rc || *(aux->buf + aux->pos) == '\0') { \ + result_ = 0; \ + } else { \ + char ch = *(aux->buf + aux->pos++); \ + result_ = 1; \ + *(buf_) = ch; \ + } \ + } #ifndef YY_MALLOC -#define YY_MALLOC(C, N) malloc(N) +#define YY_MALLOC(C, N) malloc(N) #endif #ifndef YY_REALLOC -#define YY_REALLOC(C, P, N) realloc(P, N) +#define YY_REALLOC(C, P, N) realloc(P, N) #endif #ifndef YY_FREE -#define YY_FREE(C, P) free(P) +#define YY_FREE(C, P) free(P) #endif #ifndef YY_LOCAL -#define YY_LOCAL(T) static T +#define YY_LOCAL(T) static T #endif #ifndef YY_ACTION -#define YY_ACTION(T) static T +#define YY_ACTION(T) static T #endif #ifndef YY_RULE -#define YY_RULE(T) static T +#define YY_RULE(T) static T #endif #ifndef YY_PARSE -#define YY_PARSE(T) T +#define YY_PARSE(T) T #endif #ifndef YYPARSE -#define YYPARSE yyparse +#define YYPARSE yyparse #endif #ifndef YYPARSEFROM -#define YYPARSEFROM yyparsefrom +#define YYPARSEFROM yyparsefrom #endif #ifndef YYRELEASE -#define YYRELEASE yyrelease +#define YYRELEASE yyrelease #endif #ifndef YY_BEGIN -#define YY_BEGIN ( yy->__begin= yy->__pos, 1) +#define YY_BEGIN (yy->__begin = yy->__pos, 1) #endif #ifndef YY_END -#define YY_END ( yy->__end= yy->__pos, 1) +#define YY_END (yy->__end = yy->__pos, 1) #endif #ifdef YY_DEBUG -# define yyprintf(args) fprintf args +# define yyprintf(args) fprintf args #else # define yyprintf(args) #endif #ifndef YYSTYPE -#define YYSTYPE int +#define YYSTYPE int #endif #ifndef YY_STACK_SIZE #define YY_STACK_SIZE 128 @@ -141,294 +141,287 @@ static void _jqp_set_projection(struct _yycontext *yy, JQPUNIT *unit); typedef struct _yycontext yycontext; typedef void (*yyaction)(yycontext *yy, char *yytext, int yyleng); -typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; +typedef struct _yythunk { + int begin, end; + yyaction action; + struct _yythunk *next; +} yythunk; struct _yycontext { - char *__buf; - int __buflen; - int __pos; - int __limit; - char *__text; - int __textlen; - int __begin; - int __end; - int __textmax; - yythunk *__thunks; - int __thunkslen; - int __thunkpos; - YYSTYPE __; - YYSTYPE *__val; - YYSTYPE *__vals; - int __valslen; + char *__buf; + int __buflen; + int __pos; + int __limit; + char *__text; + int __textlen; + int __begin; + int __end; + int __textmax; + yythunk *__thunks; + int __thunkslen; + int __thunkpos; + YYSTYPE __; + YYSTYPE *__val; + YYSTYPE *__vals; + int __valslen; #ifdef YY_CTX_MEMBERS YY_CTX_MEMBERS #endif }; #ifdef YY_CTX_LOCAL -#define YY_CTX_PARAM_ yycontext *yyctx, -#define YY_CTX_PARAM yycontext *yyctx -#define YY_CTX_ARG_ yyctx, -#define YY_CTX_ARG yyctx +#define YY_CTX_PARAM_ yycontext *yyctx, +#define YY_CTX_PARAM yycontext *yyctx +#define YY_CTX_ARG_ yyctx, +#define YY_CTX_ARG yyctx #ifndef YY_INPUT -#define YY_INPUT(yy, buf, result, max_size) \ - { \ - int yyc= getchar(); \ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ - yyprintf((stderr, "<%c>", yyc)); \ - } +#define YY_INPUT(yy, buf, result, max_size) \ + { \ + int yyc = getchar(); \ + result = (EOF == yyc) ? 0 : (*(buf) = yyc, 1); \ + yyprintf((stderr, "<%c>", yyc)); \ + } #endif #else #define YY_CTX_PARAM_ #define YY_CTX_PARAM #define YY_CTX_ARG_ #define YY_CTX_ARG -yycontext _yyctx= { 0, 0 }; -yycontext *yyctx= &_yyctx; +yycontext _yyctx = { 0, 0 }; +yycontext *yyctx = &_yyctx; #ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - { \ - int yyc= getchar(); \ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ - yyprintf((stderr, "<%c>", yyc)); \ - } +#define YY_INPUT(buf, result, max_size) \ + { \ + int yyc = getchar(); \ + result = (EOF == yyc) ? 0 : (*(buf) = yyc, 1); \ + yyprintf((stderr, "<%c>", yyc)); \ + } #endif #endif -YY_LOCAL(int) yyrefill(yycontext *yy) -{ +YY_LOCAL(int) yyrefill(yycontext * yy) { int yyn; - while (yy->__buflen - yy->__pos < 512) - { - yy->__buflen *= 2; - yy->__buf= (char *)YY_REALLOC(yy, yy->__buf, yy->__buflen); - } + while (yy->__buflen - yy->__pos < 512) { + yy->__buflen *= 2; + yy->__buf = (char*) YY_REALLOC(yy, yy->__buf, yy->__buflen); + } #ifdef YY_CTX_LOCAL YY_INPUT(yy, (yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos)); #else YY_INPUT((yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos)); #endif - if (!yyn) return 0; + if (!yyn) { + return 0; + } yy->__limit += yyn; return 1; } -YY_LOCAL(int) yymatchDot(yycontext *yy) -{ - if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; +YY_LOCAL(int) yymatchDot(yycontext * yy) { + if (yy->__pos >= yy->__limit && !yyrefill(yy)) { + return 0; + } ++yy->__pos; return 1; } -YY_LOCAL(int) yymatchChar(yycontext *yy, int c) -{ - if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; - if ((unsigned char)yy->__buf[yy->__pos] == c) - { - ++yy->__pos; - yyprintf((stderr, " ok yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos)); - return 1; - } - yyprintf((stderr, " fail yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos)); +YY_LOCAL(int) yymatchChar(yycontext * yy, int c) { + if (yy->__pos >= yy->__limit && !yyrefill(yy)) { + return 0; + } + if ((unsigned char) yy->__buf[yy->__pos] == c) { + ++yy->__pos; + yyprintf((stderr, " ok yymatchChar(yy, %c) @ %s\n", c, yy->__buf + yy->__pos)); + return 1; + } + yyprintf((stderr, " fail yymatchChar(yy, %c) @ %s\n", c, yy->__buf + yy->__pos)); return 0; } -YY_LOCAL(int) yymatchString(yycontext *yy, const char *s) -{ - int yysav= yy->__pos; - while (*s) - { - if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; - if (yy->__buf[yy->__pos] != *s) - { - yy->__pos= yysav; - return 0; - } - ++s; - ++yy->__pos; +YY_LOCAL(int) yymatchString(yycontext * yy, const char *s) { + int yysav = yy->__pos; + while (*s) { + if (yy->__pos >= yy->__limit && !yyrefill(yy)) { + return 0; + } + if (yy->__buf[yy->__pos] != *s) { + yy->__pos = yysav; + return 0; } + ++s; + ++yy->__pos; + } return 1; } -YY_LOCAL(int) yymatchClass(yycontext *yy, unsigned char *bits) -{ +YY_LOCAL(int) yymatchClass(yycontext * yy, unsigned char *bits) { int c; - if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; - c= (unsigned char)yy->__buf[yy->__pos]; - if (bits[c >> 3] & (1 << (c & 7))) - { - ++yy->__pos; - yyprintf((stderr, " ok yymatchClass @ %s\n", yy->__buf+yy->__pos)); - return 1; - } - yyprintf((stderr, " fail yymatchClass @ %s\n", yy->__buf+yy->__pos)); + if (yy->__pos >= yy->__limit && !yyrefill(yy)) { + return 0; + } + c = (unsigned char) yy->__buf[yy->__pos]; + if (bits[c >> 3] & (1 << (c & 7))) { + ++yy->__pos; + yyprintf((stderr, " ok yymatchClass @ %s\n", yy->__buf + yy->__pos)); + return 1; + } + yyprintf((stderr, " fail yymatchClass @ %s\n", yy->__buf + yy->__pos)); return 0; } -YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end) -{ - while (yy->__thunkpos >= yy->__thunkslen) - { - yy->__thunkslen *= 2; - yy->__thunks= (yythunk *)YY_REALLOC(yy, yy->__thunks, sizeof(yythunk) * yy->__thunkslen); - } - yy->__thunks[yy->__thunkpos].begin= begin; - yy->__thunks[yy->__thunkpos].end= end; - yy->__thunks[yy->__thunkpos].action= action; +YY_LOCAL(void) yyDo(yycontext * yy, yyaction action, int begin, int end) { + while (yy->__thunkpos >= yy->__thunkslen) { + yy->__thunkslen *= 2; + yy->__thunks = (yythunk*) YY_REALLOC(yy, yy->__thunks, sizeof(yythunk) * yy->__thunkslen); + } + yy->__thunks[yy->__thunkpos].begin = begin; + yy->__thunks[yy->__thunkpos].end = end; + yy->__thunks[yy->__thunkpos].action = action; ++yy->__thunkpos; } -YY_LOCAL(int) yyText(yycontext *yy, int begin, int end) -{ - int yyleng= end - begin; - if (yyleng <= 0) - yyleng= 0; - else - { - while (yy->__textlen < (yyleng + 1)) - { - yy->__textlen *= 2; - yy->__text= (char *)YY_REALLOC(yy, yy->__text, yy->__textlen); - } - memcpy(yy->__text, yy->__buf + begin, yyleng); - } - yy->__text[yyleng]= '\0'; +YY_LOCAL(int) yyText(yycontext * yy, int begin, int end) { + int yyleng = end - begin; + if (yyleng <= 0) { + yyleng = 0; + } else { + while (yy->__textlen < (yyleng + 1)) { + yy->__textlen *= 2; + yy->__text = (char*) YY_REALLOC(yy, yy->__text, yy->__textlen); + } + memcpy(yy->__text, yy->__buf + begin, yyleng); + } + yy->__text[yyleng] = '\0'; return yyleng; } -YY_LOCAL(void) yyDone(yycontext *yy) -{ +YY_LOCAL(void) yyDone(yycontext * yy) { int pos; - for (pos= 0; pos < yy->__thunkpos; ++pos) - { - yythunk *thunk= &yy->__thunks[pos]; - int yyleng= thunk->end ? yyText(yy, thunk->begin, thunk->end) : thunk->begin; - yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yy->__text)); - thunk->action(yy, yy->__text, yyleng); - } - yy->__thunkpos= 0; + for (pos = 0; pos < yy->__thunkpos; ++pos) { + yythunk *thunk = &yy->__thunks[pos]; + int yyleng = thunk->end ? yyText(yy, thunk->begin, thunk->end) : thunk->begin; + yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yy->__text)); + thunk->action(yy, yy->__text, yyleng); + } + yy->__thunkpos = 0; } -YY_LOCAL(void) yyCommit(yycontext *yy) -{ - if ((yy->__limit -= yy->__pos)) - { - memmove(yy->__buf, yy->__buf + yy->__pos, yy->__limit); - } +YY_LOCAL(void) yyCommit(yycontext * yy) { + if ((yy->__limit -= yy->__pos)) { + memmove(yy->__buf, yy->__buf + yy->__pos, yy->__limit); + } yy->__begin -= yy->__pos; yy->__end -= yy->__pos; - yy->__pos= yy->__thunkpos= 0; + yy->__pos = yy->__thunkpos = 0; } -YY_LOCAL(int) yyAccept(yycontext *yy, int tp0) -{ - if (tp0) - { - fprintf(stderr, "accept denied at %d\n", tp0); - return 0; - } - else - { - yyDone(yy); - yyCommit(yy); - } +YY_LOCAL(int) yyAccept(yycontext * yy, int tp0) { + if (tp0) { + fprintf(stderr, "accept denied at %d\n", tp0); + return 0; + } else { + yyDone(yy); + yyCommit(yy); + } return 1; } -YY_LOCAL(void) yyPush(yycontext *yy, char *text, int count) -{ +YY_LOCAL(void) yyPush(yycontext * yy, char *text, int count) { yy->__val += count; - while (yy->__valslen <= yy->__val - yy->__vals) - { - long offset= yy->__val - yy->__vals; - yy->__valslen *= 2; - yy->__vals= (YYSTYPE *)YY_REALLOC(yy, yy->__vals, sizeof(YYSTYPE) * yy->__valslen); - yy->__val= yy->__vals + offset; - } + while (yy->__valslen <= yy->__val - yy->__vals) { + long offset = yy->__val - yy->__vals; + yy->__valslen *= 2; + yy->__vals = (YYSTYPE*) YY_REALLOC(yy, yy->__vals, sizeof(YYSTYPE) * yy->__valslen); + yy->__val = yy->__vals + offset; + } +} +YY_LOCAL(void) yyPop(yycontext * yy, char *text, int count) { + yy->__val -= count; +} +YY_LOCAL(void) yySet(yycontext * yy, char *text, int count) { + yy->__val[count] = yy->__; } -YY_LOCAL(void) yyPop(yycontext *yy, char *text, int count) { yy->__val -= count; } -YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]= yy->__; } #endif /* YY_PART */ -#define YYACCEPT yyAccept(yy, yythunkpos0) +#define YYACCEPT yyAccept(yy, yythunkpos0) -YY_RULE(int) yy_EOL(yycontext *yy); /* 63 */ -YY_RULE(int) yy_SPACE(yycontext *yy); /* 62 */ -YY_RULE(int) yy_NUME(yycontext *yy); /* 61 */ -YY_RULE(int) yy_NUMF(yycontext *yy); /* 60 */ -YY_RULE(int) yy_NUMJ(yycontext *yy); /* 59 */ -YY_RULE(int) yy_STRJ(yycontext *yy); /* 58 */ -YY_RULE(int) yy_SARRJ(yycontext *yy); /* 57 */ -YY_RULE(int) yy_PAIRJ(yycontext *yy); /* 56 */ -YY_RULE(int) yy_SOBJJ(yycontext *yy); /* 55 */ -YY_RULE(int) yy_CHJ(yycontext *yy); /* 54 */ -YY_RULE(int) yy_CHP(yycontext *yy); /* 53 */ -YY_RULE(int) yy_VALJ(yycontext *yy); /* 52 */ -YY_RULE(int) yy_NEXPRLEFT(yycontext *yy); /* 51 */ -YY_RULE(int) yy_STRSTAR(yycontext *yy); /* 50 */ -YY_RULE(int) yy_DBLSTAR(yycontext *yy); /* 49 */ -YY_RULE(int) yy_NEXRIGHT(yycontext *yy); /* 48 */ -YY_RULE(int) yy_NEXOP(yycontext *yy); /* 47 */ -YY_RULE(int) yy_NEXLEFT(yycontext *yy); /* 46 */ -YY_RULE(int) yy_NEXJOIN(yycontext *yy); /* 45 */ -YY_RULE(int) yy_NEXPAIR(yycontext *yy); /* 44 */ -YY_RULE(int) yy_STRP(yycontext *yy); /* 43 */ -YY_RULE(int) yy_NEXPR(yycontext *yy); /* 42 */ -YY_RULE(int) yy_NODE(yycontext *yy); /* 41 */ -YY_RULE(int) yy_FILTER(yycontext *yy); /* 40 */ -YY_RULE(int) yy_FILTERFACTOR(yycontext *yy); /* 39 */ -YY_RULE(int) yy_HEX(yycontext *yy); /* 38 */ -YY_RULE(int) yy_PCHP(yycontext *yy); /* 37 */ -YY_RULE(int) yy_PSTRP(yycontext *yy); /* 36 */ -YY_RULE(int) yy_STRN(yycontext *yy); /* 35 */ -YY_RULE(int) yy_PROJFIELDS(yycontext *yy); /* 34 */ -YY_RULE(int) yy_PROJNODE(yycontext *yy); /* 33 */ -YY_RULE(int) yy_PROJALL(yycontext *yy); /* 32 */ -YY_RULE(int) yy_PROJPROP(yycontext *yy); /* 31 */ -YY_RULE(int) yy_ORDERNODE(yycontext *yy); /* 30 */ -YY_RULE(int) yy_ORDERNODES(yycontext *yy); /* 29 */ -YY_RULE(int) yy_NUMI(yycontext *yy); /* 28 */ -YY_RULE(int) yy_INVERSE(yycontext *yy); /* 27 */ -YY_RULE(int) yy_NOIDX(yycontext *yy); /* 26 */ -YY_RULE(int) yy_COUNT(yycontext *yy); /* 25 */ -YY_RULE(int) yy_ORDERBY(yycontext *yy); /* 24 */ -YY_RULE(int) yy_LIMIT(yycontext *yy); /* 23 */ -YY_RULE(int) yy_SKIP(yycontext *yy); /* 22 */ -YY_RULE(int) yy_OPT(yycontext *yy); /* 21 */ -YY_RULE(int) yy_PROJOIN(yycontext *yy); /* 20 */ -YY_RULE(int) yy_PROJNODES(yycontext *yy); /* 19 */ -YY_RULE(int) yy_ARRJ(yycontext *yy); /* 18 */ -YY_RULE(int) yy_OBJJ(yycontext *yy); /* 17 */ -YY_RULE(int) yy___(yycontext *yy); /* 16 */ -YY_RULE(int) yy_FILTERJOIN(yycontext *yy); /* 15 */ -YY_RULE(int) yy_NUMPK_ARR(yycontext *yy); /* 14 */ -YY_RULE(int) yy_NUMPK(yycontext *yy); /* 13 */ -YY_RULE(int) yy_PLACEHOLDER(yycontext *yy); /* 12 */ -YY_RULE(int) yy_FILTERANCHOR(yycontext *yy); /* 11 */ -YY_RULE(int) yy_FILTEREXPR(yycontext *yy); /* 10 */ -YY_RULE(int) yy_FILTEREXPR_PK(yycontext *yy); /* 9 */ -YY_RULE(int) yy_EOF(yycontext *yy); /* 8 */ -YY_RULE(int) yy_OPTS(yycontext *yy); /* 7 */ -YY_RULE(int) yy_PROJECTION(yycontext *yy); /* 6 */ -YY_RULE(int) yy_UPSERT(yycontext *yy); /* 5 */ -YY_RULE(int) yy_APPLY(yycontext *yy); /* 4 */ -YY_RULE(int) yy__(yycontext *yy); /* 3 */ -YY_RULE(int) yy_QEXPR(yycontext *yy); /* 2 */ -YY_RULE(int) yy_QUERY(yycontext *yy); /* 1 */ +YY_RULE(int) yy_EOL(yycontext * yy); /* 63 */ +YY_RULE(int) yy_SPACE(yycontext * yy); /* 62 */ +YY_RULE(int) yy_NUME(yycontext * yy); /* 61 */ +YY_RULE(int) yy_NUMF(yycontext * yy); /* 60 */ +YY_RULE(int) yy_NUMJ(yycontext * yy); /* 59 */ +YY_RULE(int) yy_STRJ(yycontext * yy); /* 58 */ +YY_RULE(int) yy_SARRJ(yycontext * yy); /* 57 */ +YY_RULE(int) yy_PAIRJ(yycontext * yy); /* 56 */ +YY_RULE(int) yy_SOBJJ(yycontext * yy); /* 55 */ +YY_RULE(int) yy_CHJ(yycontext * yy); /* 54 */ +YY_RULE(int) yy_CHP(yycontext * yy); /* 53 */ +YY_RULE(int) yy_VALJ(yycontext * yy); /* 52 */ +YY_RULE(int) yy_NEXPRLEFT(yycontext * yy); /* 51 */ +YY_RULE(int) yy_STRSTAR(yycontext * yy); /* 50 */ +YY_RULE(int) yy_DBLSTAR(yycontext * yy); /* 49 */ +YY_RULE(int) yy_NEXRIGHT(yycontext * yy); /* 48 */ +YY_RULE(int) yy_NEXOP(yycontext * yy); /* 47 */ +YY_RULE(int) yy_NEXLEFT(yycontext * yy); /* 46 */ +YY_RULE(int) yy_NEXJOIN(yycontext * yy); /* 45 */ +YY_RULE(int) yy_NEXPAIR(yycontext * yy); /* 44 */ +YY_RULE(int) yy_STRP(yycontext * yy); /* 43 */ +YY_RULE(int) yy_NEXPR(yycontext * yy); /* 42 */ +YY_RULE(int) yy_NODE(yycontext * yy); /* 41 */ +YY_RULE(int) yy_FILTER(yycontext * yy); /* 40 */ +YY_RULE(int) yy_FILTERFACTOR(yycontext * yy); /* 39 */ +YY_RULE(int) yy_HEX(yycontext * yy); /* 38 */ +YY_RULE(int) yy_PCHP(yycontext * yy); /* 37 */ +YY_RULE(int) yy_PSTRP(yycontext * yy); /* 36 */ +YY_RULE(int) yy_STRN(yycontext * yy); /* 35 */ +YY_RULE(int) yy_PROJFIELDS(yycontext * yy); /* 34 */ +YY_RULE(int) yy_PROJNODE(yycontext * yy); /* 33 */ +YY_RULE(int) yy_PROJALL(yycontext * yy); /* 32 */ +YY_RULE(int) yy_PROJPROP(yycontext * yy); /* 31 */ +YY_RULE(int) yy_ORDERNODE(yycontext * yy); /* 30 */ +YY_RULE(int) yy_ORDERNODES(yycontext * yy); /* 29 */ +YY_RULE(int) yy_NUMI(yycontext * yy); /* 28 */ +YY_RULE(int) yy_INVERSE(yycontext * yy); /* 27 */ +YY_RULE(int) yy_NOIDX(yycontext * yy); /* 26 */ +YY_RULE(int) yy_COUNT(yycontext * yy); /* 25 */ +YY_RULE(int) yy_ORDERBY(yycontext * yy); /* 24 */ +YY_RULE(int) yy_LIMIT(yycontext * yy); /* 23 */ +YY_RULE(int) yy_SKIP(yycontext * yy); /* 22 */ +YY_RULE(int) yy_OPT(yycontext * yy); /* 21 */ +YY_RULE(int) yy_PROJOIN(yycontext * yy); /* 20 */ +YY_RULE(int) yy_PROJNODES(yycontext * yy); /* 19 */ +YY_RULE(int) yy_ARRJ(yycontext * yy); /* 18 */ +YY_RULE(int) yy_OBJJ(yycontext * yy); /* 17 */ +YY_RULE(int) yy___(yycontext * yy); /* 16 */ +YY_RULE(int) yy_FILTERJOIN(yycontext * yy); /* 15 */ +YY_RULE(int) yy_NUMPK_ARR(yycontext * yy); /* 14 */ +YY_RULE(int) yy_NUMPK(yycontext * yy); /* 13 */ +YY_RULE(int) yy_PLACEHOLDER(yycontext * yy); /* 12 */ +YY_RULE(int) yy_FILTERANCHOR(yycontext * yy); /* 11 */ +YY_RULE(int) yy_FILTEREXPR(yycontext * yy); /* 10 */ +YY_RULE(int) yy_FILTEREXPR_PK(yycontext * yy); /* 9 */ +YY_RULE(int) yy_EOF(yycontext * yy); /* 8 */ +YY_RULE(int) yy_OPTS(yycontext * yy); /* 7 */ +YY_RULE(int) yy_PROJECTION(yycontext * yy); /* 6 */ +YY_RULE(int) yy_UPSERT(yycontext * yy); /* 5 */ +YY_RULE(int) yy_APPLY(yycontext * yy); /* 4 */ +YY_RULE(int) yy__(yycontext * yy); /* 3 */ +YY_RULE(int) yy_QEXPR(yycontext * yy); /* 2 */ +YY_RULE(int) yy_QUERY(yycontext * yy); /* 1 */ -YY_ACTION(void) yy_4_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_NUMPK_ARR(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_NUMPK_ARR\n")); { #line 235 - __ = _jqp_json_collect(yy, JBV_ARRAY, s); ; + __ = _jqp_json_collect(yy, JBV_ARRAY, s); + ; } #undef yythunkpos #undef yypos @@ -437,18 +430,18 @@ YY_ACTION(void) yy_4_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_3_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_NUMPK_ARR(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_NUMPK_ARR\n")); { #line 234 - _jqp_unit_push(yy, v); ; + _jqp_unit_push(yy, v); + ; } #undef yythunkpos #undef yypos @@ -457,18 +450,18 @@ YY_ACTION(void) yy_3_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_2_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_NUMPK_ARR(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_NUMPK_ARR\n")); { #line 234 - _jqp_unit_push(yy, fv); ; + _jqp_unit_push(yy, fv); + ; } #undef yythunkpos #undef yypos @@ -477,18 +470,18 @@ YY_ACTION(void) yy_2_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_1_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NUMPK_ARR(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NUMPK_ARR\n")); { #line 233 - _jqp_unit_push(yy, s); ; + _jqp_unit_push(yy, s); + ; } #undef yythunkpos #undef yypos @@ -497,101 +490,101 @@ YY_ACTION(void) yy_1_NUMPK_ARR(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_1_NUMPK(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NUMPK(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NUMPK\n")); { #line 231 - __ = _jqp_json_number(yy, yytext); ; + __ = _jqp_json_number(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_NUMJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NUMJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NUMJ\n")); { #line 229 - __ = _jqp_json_number(yy, yytext); ; + __ = _jqp_json_number(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_STRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_STRJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_STRJ\n")); { #line 214 - __ = _jqp_json_string(yy, yytext); ; + __ = _jqp_json_string(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_3_VALJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_VALJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_VALJ\n")); { #line 212 - __ = _jqp_json_true_false_null(yy, "null"); ; + __ = _jqp_json_true_false_null(yy, "null"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_2_VALJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_VALJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_VALJ\n")); { #line 211 - __ = _jqp_json_true_false_null(yy, "false"); ; + __ = _jqp_json_true_false_null(yy, "false"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_VALJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_VALJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_VALJ\n")); { #line 210 - __ = _jqp_json_true_false_null(yy, "true"); ; + __ = _jqp_json_true_false_null(yy, "true"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_PAIRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define s yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PAIRJ(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define s yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PAIRJ\n")); { #line 204 - __ = _jqp_json_pair(yy, s, v); ; + __ = _jqp_json_pair(yy, s, v); + ; } #undef yythunkpos #undef yypos @@ -599,46 +592,46 @@ YY_ACTION(void) yy_1_PAIRJ(yycontext *yy, char *yytext, int yyleng) #undef v #undef s } -YY_ACTION(void) yy_1_SARRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_SARRJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_SARRJ\n")); { #line 202 - __ = _jqp_unit(yy); ; + __ = _jqp_unit(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_SOBJJ(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_SOBJJ(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_SOBJJ\n")); { #line 200 - __ = _jqp_unit(yy); ; + __ = _jqp_unit(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_4_ARRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_ARRJ(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_ARRJ\n")); { #line 198 - __ = _jqp_json_collect(yy, JBV_ARRAY, s); ; + __ = _jqp_json_collect(yy, JBV_ARRAY, s); + ; } #undef yythunkpos #undef yypos @@ -647,18 +640,18 @@ YY_ACTION(void) yy_4_ARRJ(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_3_ARRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_ARRJ(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_ARRJ\n")); { #line 197 - _jqp_unit_push(yy, v); ; + _jqp_unit_push(yy, v); + ; } #undef yythunkpos #undef yypos @@ -667,18 +660,18 @@ YY_ACTION(void) yy_3_ARRJ(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_2_ARRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_ARRJ(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_ARRJ\n")); { #line 197 - _jqp_unit_push(yy, fv); ; + _jqp_unit_push(yy, fv); + ; } #undef yythunkpos #undef yypos @@ -687,18 +680,18 @@ YY_ACTION(void) yy_2_ARRJ(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_1_ARRJ(yycontext *yy, char *yytext, int yyleng) -{ -#define v yy->__val[-1] -#define fv yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_ARRJ(yycontext * yy, char *yytext, int yyleng) { +#define v yy->__val[-1] +#define fv yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_ARRJ\n")); { #line 196 - _jqp_unit_push(yy, s); ; + _jqp_unit_push(yy, s); + ; } #undef yythunkpos #undef yypos @@ -707,18 +700,18 @@ YY_ACTION(void) yy_1_ARRJ(yycontext *yy, char *yytext, int yyleng) #undef fv #undef s } -YY_ACTION(void) yy_4_OBJJ(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define fp yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_OBJJ(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define fp yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_OBJJ\n")); { #line 194 - __ = _jqp_json_collect(yy, JBV_OBJECT, s); ; + __ = _jqp_json_collect(yy, JBV_OBJECT, s); + ; } #undef yythunkpos #undef yypos @@ -727,18 +720,18 @@ YY_ACTION(void) yy_4_OBJJ(yycontext *yy, char *yytext, int yyleng) #undef fp #undef s } -YY_ACTION(void) yy_3_OBJJ(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define fp yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_OBJJ(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define fp yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_OBJJ\n")); { #line 193 - _jqp_unit_push(yy, p); ; + _jqp_unit_push(yy, p); + ; } #undef yythunkpos #undef yypos @@ -747,18 +740,18 @@ YY_ACTION(void) yy_3_OBJJ(yycontext *yy, char *yytext, int yyleng) #undef fp #undef s } -YY_ACTION(void) yy_2_OBJJ(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define fp yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_OBJJ(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define fp yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_OBJJ\n")); { #line 193 - _jqp_unit_push(yy, fp); ; + _jqp_unit_push(yy, fp); + ; } #undef yythunkpos #undef yypos @@ -767,18 +760,18 @@ YY_ACTION(void) yy_2_OBJJ(yycontext *yy, char *yytext, int yyleng) #undef fp #undef s } -YY_ACTION(void) yy_1_OBJJ(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define fp yy->__val[-2] -#define s yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_OBJJ(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define fp yy->__val[-2] +#define s yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_OBJJ\n")); { #line 192 - _jqp_unit_push(yy, s); ; + _jqp_unit_push(yy, s); + ; } #undef yythunkpos #undef yypos @@ -787,214 +780,214 @@ YY_ACTION(void) yy_1_OBJJ(yycontext *yy, char *yytext, int yyleng) #undef fp #undef s } -YY_ACTION(void) yy_1_STRN(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_STRN(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_STRN\n")); { #line 190 - __ = _jqp_unescaped_string(yy, JQP_STR_QUOTED, yytext); ; + __ = _jqp_unescaped_string(yy, JQP_STR_QUOTED, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_STRSTAR(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_STRSTAR(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_STRSTAR\n")); { #line 188 - __ = _jqp_unescaped_string(yy, JQP_STR_STAR, "*"); ; + __ = _jqp_unescaped_string(yy, JQP_STR_STAR, "*"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_DBLSTAR(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_DBLSTAR(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_DBLSTAR\n")); { #line 186 - __ = _jqp_unescaped_string(yy, JQP_STR_DBL_STAR, "**"); ; + __ = _jqp_unescaped_string(yy, JQP_STR_DBL_STAR, "**"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_STRP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_STRP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_STRP\n")); { #line 184 - __ = _jqp_unescaped_string(yy, 0, yytext); ; + __ = _jqp_unescaped_string(yy, 0, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_9_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_9_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_9_NEXOP\n")); { #line 182 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_8_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_8_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_8_NEXOP\n")); { #line 181 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_7_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_7_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_7_NEXOP\n")); { #line 180 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_6_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_6_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_6_NEXOP\n")); { #line 179 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_5_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_5_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_5_NEXOP\n")); { #line 179 - _jqp_op_negate(yy); ; + _jqp_op_negate(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_4_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_NEXOP\n")); { #line 178 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_3_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_NEXOP\n")); { #line 177 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_2_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_NEXOP\n")); { #line 176 - __ = _jqp_unit_op(yy, yytext); ; + __ = _jqp_unit_op(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_NEXOP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NEXOP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NEXOP\n")); { #line 176 - _jqp_op_negate(yy); ; + _jqp_op_negate(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_PLACEHOLDER(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PLACEHOLDER(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PLACEHOLDER\n")); { #line 174 - __ = _jqp_placeholder(yy, yytext); ; + __ = _jqp_placeholder(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_NEXPRLEFT(yycontext *yy, char *yytext, int yyleng) -{ -#define r yy->__val[-1] -#define o yy->__val[-2] -#define l yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NEXPRLEFT(yycontext * yy, char *yytext, int yyleng) { +#define r yy->__val[-1] +#define o yy->__val[-2] +#define l yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NEXPRLEFT\n")); { #line 170 - __ = _jqp_expr(yy, l, o, r); ; + __ = _jqp_expr(yy, l, o, r); + ; } #undef yythunkpos #undef yypos @@ -1003,18 +996,18 @@ YY_ACTION(void) yy_1_NEXPRLEFT(yycontext *yy, char *yytext, int yyleng) #undef o #undef l } -YY_ACTION(void) yy_1_NEXPAIR(yycontext *yy, char *yytext, int yyleng) -{ -#define r yy->__val[-1] -#define o yy->__val[-2] -#define l yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NEXPAIR(yycontext * yy, char *yytext, int yyleng) { +#define r yy->__val[-1] +#define o yy->__val[-2] +#define l yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NEXPAIR\n")); { #line 166 - __ = _jqp_expr(yy, l, o, r); ; + __ = _jqp_expr(yy, l, o, r); + ; } #undef yythunkpos #undef yypos @@ -1023,46 +1016,46 @@ YY_ACTION(void) yy_1_NEXPAIR(yycontext *yy, char *yytext, int yyleng) #undef o #undef l } -YY_ACTION(void) yy_2_NEXJOIN(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_NEXJOIN(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_NEXJOIN\n")); { #line 164 - __ = _jqp_unit_join(yy, yytext); ; + __ = _jqp_unit_join(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_NEXJOIN(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NEXJOIN(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NEXJOIN\n")); { #line 164 - _jqp_op_negate(yy); ; + _jqp_op_negate(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_4_NEXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define np yy->__val[-1] -#define j yy->__val[-2] -#define n yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_NEXPR(yycontext * yy, char *yytext, int yyleng) { +#define np yy->__val[-1] +#define j yy->__val[-2] +#define n yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_NEXPR\n")); { #line 162 - __ = _jqp_pop_expr_chain(yy, n); ; + __ = _jqp_pop_expr_chain(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1071,18 +1064,18 @@ YY_ACTION(void) yy_4_NEXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef n } -YY_ACTION(void) yy_3_NEXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define np yy->__val[-1] -#define j yy->__val[-2] -#define n yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_NEXPR(yycontext * yy, char *yytext, int yyleng) { +#define np yy->__val[-1] +#define j yy->__val[-2] +#define n yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_NEXPR\n")); { #line 161 - _jqp_unit_push(yy, np); ; + _jqp_unit_push(yy, np); + ; } #undef yythunkpos #undef yypos @@ -1091,18 +1084,18 @@ YY_ACTION(void) yy_3_NEXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef n } -YY_ACTION(void) yy_2_NEXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define np yy->__val[-1] -#define j yy->__val[-2] -#define n yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_NEXPR(yycontext * yy, char *yytext, int yyleng) { +#define np yy->__val[-1] +#define j yy->__val[-2] +#define n yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_NEXPR\n")); { #line 161 - _jqp_unit_push(yy, j); ; + _jqp_unit_push(yy, j); + ; } #undef yythunkpos #undef yypos @@ -1111,18 +1104,18 @@ YY_ACTION(void) yy_2_NEXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef n } -YY_ACTION(void) yy_1_NEXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define np yy->__val[-1] -#define j yy->__val[-2] -#define n yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NEXPR(yycontext * yy, char *yytext, int yyleng) { +#define np yy->__val[-1] +#define j yy->__val[-2] +#define n yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NEXPR\n")); { #line 160 - _jqp_unit_push(yy, n); ; + _jqp_unit_push(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1131,48 +1124,48 @@ YY_ACTION(void) yy_1_NEXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef n } -YY_ACTION(void) yy_1_NODE(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NODE(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NODE\n")); { #line 158 - __ = _jqp_node(yy, n); ; + __ = _jqp_node(yy, n); + ; } #undef yythunkpos #undef yypos #undef yy #undef n } -YY_ACTION(void) yy_1_FILTERANCHOR(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_FILTERANCHOR(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_FILTERANCHOR\n")); { #line 155 - __ = _jqp_string(yy, JQP_STR_ANCHOR, yytext); ; + __ = _jqp_string(yy, JQP_STR_ANCHOR, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_4_FILTER(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define fn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_FILTER(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define fn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_FILTER\n")); { #line 153 - __ = _jqp_pop_node_chain(yy, fn); ; + __ = _jqp_pop_node_chain(yy, fn); + ; } #undef yythunkpos #undef yypos @@ -1181,18 +1174,18 @@ YY_ACTION(void) yy_4_FILTER(yycontext *yy, char *yytext, int yyleng) #undef fn #undef a } -YY_ACTION(void) yy_3_FILTER(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define fn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_FILTER(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define fn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_FILTER\n")); { #line 153 - _jqp_unit_push(yy, n); ; + _jqp_unit_push(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1201,18 +1194,18 @@ YY_ACTION(void) yy_3_FILTER(yycontext *yy, char *yytext, int yyleng) #undef fn #undef a } -YY_ACTION(void) yy_2_FILTER(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define fn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_FILTER(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define fn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_FILTER\n")); { #line 153 - _jqp_unit_push(yy, fn); ; + _jqp_unit_push(yy, fn); + ; } #undef yythunkpos #undef yypos @@ -1221,18 +1214,18 @@ YY_ACTION(void) yy_2_FILTER(yycontext *yy, char *yytext, int yyleng) #undef fn #undef a } -YY_ACTION(void) yy_1_FILTER(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define fn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_FILTER(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define fn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_FILTER\n")); { #line 153 - _jqp_unit_push(yy, a); ; + _jqp_unit_push(yy, a); + ; } #undef yythunkpos #undef yypos @@ -1241,18 +1234,18 @@ YY_ACTION(void) yy_1_FILTER(yycontext *yy, char *yytext, int yyleng) #undef fn #undef a } -YY_ACTION(void) yy_4_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define f yy->__val[-1] -#define j yy->__val[-2] -#define ff yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_FILTEREXPR(yycontext * yy, char *yytext, int yyleng) { +#define f yy->__val[-1] +#define j yy->__val[-2] +#define ff yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_FILTEREXPR\n")); { #line 151 - __ = _jqp_pop_filter_factor_chain(yy, ff); ; + __ = _jqp_pop_filter_factor_chain(yy, ff); + ; } #undef yythunkpos #undef yypos @@ -1261,18 +1254,18 @@ YY_ACTION(void) yy_4_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef ff } -YY_ACTION(void) yy_3_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define f yy->__val[-1] -#define j yy->__val[-2] -#define ff yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_FILTEREXPR(yycontext * yy, char *yytext, int yyleng) { +#define f yy->__val[-1] +#define j yy->__val[-2] +#define ff yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_FILTEREXPR\n")); { #line 151 - _jqp_unit_push(yy, f); ; + _jqp_unit_push(yy, f); + ; } #undef yythunkpos #undef yypos @@ -1281,18 +1274,18 @@ YY_ACTION(void) yy_3_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef ff } -YY_ACTION(void) yy_2_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define f yy->__val[-1] -#define j yy->__val[-2] -#define ff yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_FILTEREXPR(yycontext * yy, char *yytext, int yyleng) { +#define f yy->__val[-1] +#define j yy->__val[-2] +#define ff yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_FILTEREXPR\n")); { #line 151 - _jqp_unit_push(yy, j); ; + _jqp_unit_push(yy, j); + ; } #undef yythunkpos #undef yypos @@ -1301,18 +1294,18 @@ YY_ACTION(void) yy_2_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef ff } -YY_ACTION(void) yy_1_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) -{ -#define f yy->__val[-1] -#define j yy->__val[-2] -#define ff yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_FILTEREXPR(yycontext * yy, char *yytext, int yyleng) { +#define f yy->__val[-1] +#define j yy->__val[-2] +#define ff yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_FILTEREXPR\n")); { #line 150 - _jqp_unit_push(yy, ff); ; + _jqp_unit_push(yy, ff); + ; } #undef yythunkpos #undef yypos @@ -1321,31 +1314,31 @@ YY_ACTION(void) yy_1_FILTEREXPR(yycontext *yy, char *yytext, int yyleng) #undef j #undef ff } -YY_ACTION(void) yy_1_PSTRP(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PSTRP(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PSTRP\n")); { #line 140 - __ = _jqp_string(yy, 0, yytext); ; + __ = _jqp_string(yy, 0, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_3_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define sp yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_PROJFIELDS(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define sp yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_PROJFIELDS\n")); { #line 134 - __ = _jqp_pop_projfields_chain(yy, sp); ; + __ = _jqp_pop_projfields_chain(yy, sp); + ; } #undef yythunkpos #undef yypos @@ -1353,17 +1346,17 @@ YY_ACTION(void) yy_3_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) #undef p #undef sp } -YY_ACTION(void) yy_2_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define sp yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_PROJFIELDS(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define sp yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_PROJFIELDS\n")); { #line 133 - _jqp_unit_push(yy, p); ; + _jqp_unit_push(yy, p); + ; } #undef yythunkpos #undef yypos @@ -1371,17 +1364,17 @@ YY_ACTION(void) yy_2_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) #undef p #undef sp } -YY_ACTION(void) yy_1_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define sp yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PROJFIELDS(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define sp yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PROJFIELDS\n")); { #line 133 - _jqp_unit_push(yy, sp); ; + _jqp_unit_push(yy, sp); + ; } #undef yythunkpos #undef yypos @@ -1389,32 +1382,32 @@ YY_ACTION(void) yy_1_PROJFIELDS(yycontext *yy, char *yytext, int yyleng) #undef p #undef sp } -YY_ACTION(void) yy_1_PROJALL(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PROJALL(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PROJALL\n")); { #line 129 - __ = _jqp_string(yy, JQP_STR_PROJALIAS, "all"); ; + __ = _jqp_string(yy, JQP_STR_PROJALIAS, "all"); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_4_PROJNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_PROJNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_PROJNODES\n")); { #line 127 - __ = _jqp_pop_projection_nodes(yy, sn); ; + __ = _jqp_pop_projection_nodes(yy, sn); + ; } #undef yythunkpos #undef yypos @@ -1423,18 +1416,18 @@ YY_ACTION(void) yy_4_PROJNODES(yycontext *yy, char *yytext, int yyleng) #undef sn #undef a } -YY_ACTION(void) yy_3_PROJNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_PROJNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_PROJNODES\n")); { #line 127 - _jqp_unit_push(yy, n);; + _jqp_unit_push(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1443,18 +1436,18 @@ YY_ACTION(void) yy_3_PROJNODES(yycontext *yy, char *yytext, int yyleng) #undef sn #undef a } -YY_ACTION(void) yy_2_PROJNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_PROJNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_PROJNODES\n")); { #line 127 - _jqp_unit_push(yy, sn); ; + _jqp_unit_push(yy, sn); + ; } #undef yythunkpos #undef yypos @@ -1463,18 +1456,18 @@ YY_ACTION(void) yy_2_PROJNODES(yycontext *yy, char *yytext, int yyleng) #undef sn #undef a } -YY_ACTION(void) yy_1_PROJNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define a yy->__val[-3] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PROJNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define a yy->__val[-3] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PROJNODES\n")); { #line 126 - __ = _jqp_projection(yy, a, 0); ; + __ = _jqp_projection(yy, a, 0); + ; } #undef yythunkpos #undef yypos @@ -1483,17 +1476,16 @@ YY_ACTION(void) yy_1_PROJNODES(yycontext *yy, char *yytext, int yyleng) #undef sn #undef a } -YY_ACTION(void) yy_3_ORDERNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_ORDERNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_ORDERNODES\n")); { #line 122 - __ = _jqp_pop_ordernodes(yy, sn) ; + __ = _jqp_pop_ordernodes(yy, sn); } #undef yythunkpos #undef yypos @@ -1501,17 +1493,17 @@ YY_ACTION(void) yy_3_ORDERNODES(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_2_ORDERNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_ORDERNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_ORDERNODES\n")); { #line 122 - _jqp_unit_push(yy, n); ; + _jqp_unit_push(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1519,17 +1511,17 @@ YY_ACTION(void) yy_2_ORDERNODES(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_1_ORDERNODES(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_ORDERNODES(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_ORDERNODES\n")); { #line 122 - _jqp_unit_push(yy, sn); ; + _jqp_unit_push(yy, sn); + ; } #undef yythunkpos #undef yypos @@ -1537,187 +1529,189 @@ YY_ACTION(void) yy_1_ORDERNODES(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_2_ORDERBY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_ORDERBY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_ORDERBY\n")); { #line 120 - p->string.flavour |= (yy->aux->negate ? JQP_STR_NEGATE : 0); _jqp_op_negate_reset(yy); _jqp_add_orderby(yy, p); ; + p->string.flavour |= (yy->aux->negate ? JQP_STR_NEGATE : 0); + _jqp_op_negate_reset(yy); + _jqp_add_orderby(yy, p); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_1_ORDERBY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_ORDERBY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_ORDERBY\n")); { #line 118 - _jqp_op_negate(yy); ; + _jqp_op_negate(yy); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_1_INVERSE(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_INVERSE(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_INVERSE\n")); { #line 116 - _jqp_set_inverse(yy); ; + _jqp_set_inverse(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_NOIDX(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_NOIDX(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_NOIDX\n")); { #line 114 - _jqp_set_noidx(yy); ; + _jqp_set_noidx(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_COUNT(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_COUNT(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_COUNT\n")); { #line 112 - _jqp_set_aggregate_count(yy); ; + _jqp_set_aggregate_count(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_3_LIMIT(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_LIMIT(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_LIMIT\n")); { #line 110 - _jqp_set_limit(yy, __); ; + _jqp_set_limit(yy, __); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_2_LIMIT(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_LIMIT(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_LIMIT\n")); { #line 110 - __ = p; ; + __ = p; + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_1_LIMIT(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_LIMIT(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_LIMIT\n")); { #line 110 - __ = _jqp_number(yy, JQP_INT_LIMIT, yytext); ; + __ = _jqp_number(yy, JQP_INT_LIMIT, yytext); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_3_SKIP(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_SKIP(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_SKIP\n")); { #line 108 - _jqp_set_skip(yy, __); ; + _jqp_set_skip(yy, __); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_2_SKIP(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_SKIP(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_SKIP\n")); { #line 108 - __ = p; ; + __ = p; + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_1_SKIP(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_SKIP(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_SKIP\n")); { #line 108 - __ = _jqp_number(yy, JQP_INT_SKIP, yytext); ; + __ = _jqp_number(yy, JQP_INT_SKIP, yytext); + ; } #undef yythunkpos #undef yypos #undef yy #undef p } -YY_ACTION(void) yy_4_PROJECTION(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_PROJECTION(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_PROJECTION\n")); { #line 102 - __ = _jqp_pop_joined_projections(yy, sn); ; + __ = _jqp_pop_joined_projections(yy, sn); + ; } #undef yythunkpos #undef yypos @@ -1725,17 +1719,17 @@ YY_ACTION(void) yy_4_PROJECTION(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_3_PROJECTION(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_PROJECTION(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_PROJECTION\n")); { #line 101 - _jqp_push_joined_projection(yy, n); ; + _jqp_push_joined_projection(yy, n); + ; } #undef yythunkpos #undef yypos @@ -1743,17 +1737,17 @@ YY_ACTION(void) yy_3_PROJECTION(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_2_PROJECTION(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_PROJECTION(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_PROJECTION\n")); { #line 101 - _jqp_string_push(yy, yytext, true); ; + _jqp_string_push(yy, yytext, true); + ; } #undef yythunkpos #undef yypos @@ -1761,17 +1755,17 @@ YY_ACTION(void) yy_2_PROJECTION(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_1_PROJECTION(yycontext *yy, char *yytext, int yyleng) -{ -#define n yy->__val[-1] -#define sn yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_PROJECTION(yycontext * yy, char *yytext, int yyleng) { +#define n yy->__val[-1] +#define sn yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_PROJECTION\n")); { #line 100 - _jqp_unit_push(yy, sn); ; + _jqp_unit_push(yy, sn); + ; } #undef yythunkpos #undef yypos @@ -1779,45 +1773,44 @@ YY_ACTION(void) yy_1_PROJECTION(yycontext *yy, char *yytext, int yyleng) #undef n #undef sn } -YY_ACTION(void) yy_2_FILTERJOIN(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_FILTERJOIN(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_FILTERJOIN\n")); { #line 94 - __ = _jqp_unit_join(yy, yytext); ; + __ = _jqp_unit_join(yy, yytext); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_FILTERJOIN(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_FILTERJOIN(yycontext * yy, char *yytext, int yyleng) { +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_FILTERJOIN\n")); { #line 94 - _jqp_op_negate(yy); ; + _jqp_op_negate(yy); + ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_2_FILTEREXPR_PK(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define a yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_FILTEREXPR_PK(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define a yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_FILTEREXPR_PK\n")); { #line 92 - __ = _jqp_create_filterexpr_pk(yy, p) ; + __ = _jqp_create_filterexpr_pk(yy, p); } #undef yythunkpos #undef yypos @@ -1825,17 +1818,17 @@ YY_ACTION(void) yy_2_FILTEREXPR_PK(yycontext *yy, char *yytext, int yyleng) #undef p #undef a } -YY_ACTION(void) yy_1_FILTEREXPR_PK(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define a yy->__val[-2] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_FILTEREXPR_PK(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define a yy->__val[-2] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_FILTEREXPR_PK\n")); { #line 90 - _jqp_unit_push(yy, a); ; + _jqp_unit_push(yy, a); + ; } #undef yythunkpos #undef yypos @@ -1843,19 +1836,19 @@ YY_ACTION(void) yy_1_FILTEREXPR_PK(yycontext *yy, char *yytext, int yyleng) #undef p #undef a } -YY_ACTION(void) yy_6_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_6_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_6_QUERY\n")); { #line 86 - _jqp_finish(yy); ; + _jqp_finish(yy); + ; } #undef yythunkpos #undef yypos @@ -1865,19 +1858,19 @@ YY_ACTION(void) yy_6_QUERY(yycontext *yy, char *yytext, int yyleng) #undef a #undef s } -YY_ACTION(void) yy_5_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_5_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_5_QUERY\n")); { #line 84 - _jqp_set_projection(yy, p); ; + _jqp_set_projection(yy, p); + ; } #undef yythunkpos #undef yypos @@ -1887,19 +1880,19 @@ YY_ACTION(void) yy_5_QUERY(yycontext *yy, char *yytext, int yyleng) #undef a #undef s } -YY_ACTION(void) yy_4_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_4_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_4_QUERY\n")); { #line 83 - _jqp_set_apply_upsert(yy, u); ; + _jqp_set_apply_upsert(yy, u); + ; } #undef yythunkpos #undef yypos @@ -1909,19 +1902,19 @@ YY_ACTION(void) yy_4_QUERY(yycontext *yy, char *yytext, int yyleng) #undef a #undef s } -YY_ACTION(void) yy_3_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_3_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_3_QUERY\n")); { #line 83 - _jqp_set_apply_delete(yy); ; + _jqp_set_apply_delete(yy); + ; } #undef yythunkpos #undef yypos @@ -1931,19 +1924,19 @@ YY_ACTION(void) yy_3_QUERY(yycontext *yy, char *yytext, int yyleng) #undef a #undef s } -YY_ACTION(void) yy_2_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_2_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_2_QUERY\n")); { #line 83 - _jqp_set_apply(yy, a); ; + _jqp_set_apply(yy, a); + ; } #undef yythunkpos #undef yypos @@ -1953,19 +1946,19 @@ YY_ACTION(void) yy_2_QUERY(yycontext *yy, char *yytext, int yyleng) #undef a #undef s } -YY_ACTION(void) yy_1_QUERY(yycontext *yy, char *yytext, int yyleng) -{ -#define p yy->__val[-1] -#define u yy->__val[-2] -#define a yy->__val[-3] -#define s yy->__val[-4] -#define __ yy->__ -#define yypos yy->__pos +YY_ACTION(void) yy_1_QUERY(yycontext * yy, char *yytext, int yyleng) { +#define p yy->__val[-1] +#define u yy->__val[-2] +#define a yy->__val[-3] +#define s yy->__val[-4] +#define __ yy->__ +#define yypos yy->__pos #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_QUERY\n")); { #line 82 - _jqp_set_filters_expr(yy, s); ; + _jqp_set_filters_expr(yy, s); + ; } #undef yythunkpos #undef yypos @@ -1976,1142 +1969,3149 @@ YY_ACTION(void) yy_1_QUERY(yycontext *yy, char *yytext, int yyleng) #undef s } -YY_RULE(int) yy_EOL(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_EOL(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "EOL")); - { int yypos2= yy->__pos, yythunkpos2= yy->__thunkpos; if (!yymatchString(yy, "\r\n")) goto l3; goto l2; - l3:; yy->__pos= yypos2; yy->__thunkpos= yythunkpos2; if (!yymatchChar(yy, '\n')) goto l4; goto l2; - l4:; yy->__pos= yypos2; yy->__thunkpos= yythunkpos2; if (!yymatchChar(yy, '\r')) goto l1; + { + int yypos2 = yy->__pos, yythunkpos2 = yy->__thunkpos; + if (!yymatchString(yy, "\r\n")) { + goto l3; + } + goto l2; +l3: + ; + yy->__pos = yypos2; + yy->__thunkpos = yythunkpos2; + if (!yymatchChar(yy, '\n')) { + goto l4; + } + goto l2; +l4: + ; + yy->__pos = yypos2; + yy->__thunkpos = yythunkpos2; + if (!yymatchChar(yy, '\r')) { + goto l1; + } } - l2:; - yyprintf((stderr, " ok %s @ %s\n", "EOL", yy->__buf+yy->__pos)); +l2: + ; + yyprintf((stderr, " ok %s @ %s\n", "EOL", yy->__buf + yy->__pos)); return 1; - l1:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EOL", yy->__buf+yy->__pos)); +l1: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EOL", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_SPACE(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_SPACE(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "SPACE")); - { int yypos6= yy->__pos, yythunkpos6= yy->__thunkpos; if (!yymatchChar(yy, ' ')) goto l7; goto l6; - l7:; yy->__pos= yypos6; yy->__thunkpos= yythunkpos6; if (!yymatchChar(yy, '\t')) goto l8; goto l6; - l8:; yy->__pos= yypos6; yy->__thunkpos= yythunkpos6; if (!yy_EOL(yy)) goto l5; + { + int yypos6 = yy->__pos, yythunkpos6 = yy->__thunkpos; + if (!yymatchChar(yy, ' ')) { + goto l7; + } + goto l6; +l7: + ; + yy->__pos = yypos6; + yy->__thunkpos = yythunkpos6; + if (!yymatchChar(yy, '\t')) { + goto l8; + } + goto l6; +l8: + ; + yy->__pos = yypos6; + yy->__thunkpos = yythunkpos6; + if (!yy_EOL(yy)) { + goto l5; + } } - l6:; - yyprintf((stderr, " ok %s @ %s\n", "SPACE", yy->__buf+yy->__pos)); +l6: + ; + yyprintf((stderr, " ok %s @ %s\n", "SPACE", yy->__buf + yy->__pos)); return 1; - l5:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SPACE", yy->__buf+yy->__pos)); +l5: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SPACE", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUME(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NUME")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\040\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l9; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\001\370\377\377\377\377\377\077\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l9; - l10:; - { int yypos11= yy->__pos, yythunkpos11= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\001\370\377\377\377\377\377\077\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l11; goto l10; - l11:; yy->__pos= yypos11; yy->__thunkpos= yythunkpos11; +YY_RULE(int) yy_NUME(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NUME")); + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\000\000\040\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l9; } - yyprintf((stderr, " ok %s @ %s\n", "NUME", yy->__buf+yy->__pos)); + { + int yypos10 = yy->__pos, yythunkpos10 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\050\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l10; + } + goto l11; +l10: + ; + yy->__pos = yypos10; + yy->__thunkpos = yythunkpos10; + } +l11: + ; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l9; + } +l12: + ; + { + int yypos13 = yy->__pos, yythunkpos13 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l13; + } + goto l12; +l13: + ; + yy->__pos = yypos13; + yy->__thunkpos = yythunkpos13; + } + yyprintf((stderr, " ok %s @ %s\n", "NUME", yy->__buf + yy->__pos)); return 1; - l9:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUME", yy->__buf+yy->__pos)); +l9: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUME", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUMF(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NUMF")); if (!yymatchChar(yy, '.')) goto l12; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l12; - l13:; - { int yypos14= yy->__pos, yythunkpos14= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l14; goto l13; - l14:; yy->__pos= yypos14; yy->__thunkpos= yythunkpos14; +YY_RULE(int) yy_NUMF(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NUMF")); + if (!yymatchChar(yy, '.')) { + goto l14; + } + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l14; } - yyprintf((stderr, " ok %s @ %s\n", "NUMF", yy->__buf+yy->__pos)); +l15: + ; + { + int yypos16 = yy->__pos, yythunkpos16 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l16; + } + goto l15; +l16: + ; + yy->__pos = yypos16; + yy->__thunkpos = yythunkpos16; + } + yyprintf((stderr, " ok %s @ %s\n", "NUMF", yy->__buf + yy->__pos)); return 1; - l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUMF", yy->__buf+yy->__pos)); +l14: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUMF", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUMJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NUMJ")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_NUMJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NUMJ")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l15; + if (!(YY_BEGIN)) { + goto l17; + } #undef yytext #undef yyleng } - { int yypos16= yy->__pos, yythunkpos16= yy->__thunkpos; if (!yymatchChar(yy, '-')) goto l16; goto l17; - l16:; yy->__pos= yypos16; yy->__thunkpos= yythunkpos16; - } - l17:; if (!yy_NUMI(yy)) goto l15; - { int yypos18= yy->__pos, yythunkpos18= yy->__thunkpos; if (!yy_NUMF(yy)) goto l18; goto l19; - l18:; yy->__pos= yypos18; yy->__thunkpos= yythunkpos18; + { + int yypos18 = yy->__pos, yythunkpos18 = yy->__thunkpos; + if (!yymatchChar(yy, '-')) { + goto l18; + } + goto l19; +l18: + ; + yy->__pos = yypos18; + yy->__thunkpos = yythunkpos18; } - l19:; - { int yypos20= yy->__pos, yythunkpos20= yy->__thunkpos; if (!yy_NUME(yy)) goto l20; goto l21; - l20:; yy->__pos= yypos20; yy->__thunkpos= yythunkpos20; +l19: + ; + if (!yy_NUMI(yy)) { + goto l17; } - l21:; yyText(yy, yy->__begin, yy->__end); { + { + int yypos20 = yy->__pos, yythunkpos20 = yy->__thunkpos; + if (!yy_NUMF(yy)) { + goto l20; + } + goto l21; +l20: + ; + yy->__pos = yypos20; + yy->__thunkpos = yythunkpos20; + } +l21: + ; + { + int yypos22 = yy->__pos, yythunkpos22 = yy->__thunkpos; + if (!yy_NUME(yy)) { + goto l22; + } + goto l23; +l22: + ; + yy->__pos = yypos22; + yy->__thunkpos = yythunkpos22; + } +l23: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l15; + if (!(YY_END)) { + goto l17; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_NUMJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NUMJ", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "NUMJ", yy->__buf + yy->__pos)); return 1; - l15:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUMJ", yy->__buf+yy->__pos)); +l17: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUMJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_STRJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "STRJ")); if (!yymatchChar(yy, '"')) goto l22; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_STRJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "STRJ")); + if (!yymatchChar(yy, '"')) { + goto l24; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l22; + if (!(YY_BEGIN)) { + goto l24; + } #undef yytext #undef yyleng } - l23:; - { int yypos24= yy->__pos, yythunkpos24= yy->__thunkpos; if (!yy_CHJ(yy)) goto l24; goto l23; - l24:; yy->__pos= yypos24; yy->__thunkpos= yythunkpos24; - } yyText(yy, yy->__begin, yy->__end); { +l25: + ; + { + int yypos26 = yy->__pos, yythunkpos26 = yy->__thunkpos; + if (!yy_CHJ(yy)) { + goto l26; + } + goto l25; +l26: + ; + yy->__pos = yypos26; + yy->__thunkpos = yythunkpos26; + } yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l22; + if (!(YY_END)) { + goto l24; + } #undef yytext #undef yyleng - } if (!yymatchChar(yy, '"')) goto l22; yyDo(yy, yy_1_STRJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "STRJ", yy->__buf+yy->__pos)); + } if (!yymatchChar(yy, '"')) { + goto l24; + } + yyDo(yy, yy_1_STRJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "STRJ", yy->__buf + yy->__pos)); return 1; - l22:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STRJ", yy->__buf+yy->__pos)); +l24: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STRJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_SARRJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "SARRJ")); if (!yymatchChar(yy, '[')) goto l25; yyDo(yy, yy_1_SARRJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "SARRJ", yy->__buf+yy->__pos)); +YY_RULE(int) yy_SARRJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "SARRJ")); + if (!yymatchChar(yy, '[')) { + goto l27; + } + yyDo(yy, yy_1_SARRJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "SARRJ", yy->__buf + yy->__pos)); return 1; - l25:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SARRJ", yy->__buf+yy->__pos)); +l27: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SARRJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PAIRJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "PAIRJ")); if (!yy_STRJ(yy)) goto l26; yyDo(yy, yySet, -2, 0); if (!yy__(yy)) goto l26; if (!yymatchChar(yy, ':')) goto l26; if (!yy__(yy)) goto l26; if (!yy_VALJ(yy)) goto l26; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_PAIRJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PAIRJ", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); +YY_RULE(int) yy_PAIRJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 2, 0); + yyprintf((stderr, "%s\n", "PAIRJ")); + if (!yy_STRJ(yy)) { + goto l28; + } + yyDo(yy, yySet, -2, 0); + if (!yy__(yy)) { + goto l28; + } + if (!yymatchChar(yy, ':')) { + goto l28; + } + if (!yy__(yy)) { + goto l28; + } + if (!yy_VALJ(yy)) { + goto l28; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_1_PAIRJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "PAIRJ", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 2, 0); return 1; - l26:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PAIRJ", yy->__buf+yy->__pos)); +l28: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PAIRJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_SOBJJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "SOBJJ")); if (!yymatchChar(yy, '{')) goto l27; yyDo(yy, yy_1_SOBJJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "SOBJJ", yy->__buf+yy->__pos)); +YY_RULE(int) yy_SOBJJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "SOBJJ")); + if (!yymatchChar(yy, '{')) { + goto l29; + } + yyDo(yy, yy_1_SOBJJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "SOBJJ", yy->__buf + yy->__pos)); return 1; - l27:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SOBJJ", yy->__buf+yy->__pos)); +l29: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SOBJJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_CHJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_CHJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "CHJ")); - { int yypos29= yy->__pos, yythunkpos29= yy->__thunkpos; if (!yymatchChar(yy, '\\')) goto l30; if (!yymatchChar(yy, '"')) goto l30; goto l29; - l30:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; if (!yymatchChar(yy, '\\')) goto l31; if (!yymatchChar(yy, '\\')) goto l31; goto l29; - l31:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; if (!yymatchChar(yy, '\\')) goto l32; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l32; goto l29; - l32:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; if (!yymatchChar(yy, '\\')) goto l33; if (!yymatchChar(yy, 'u')) goto l33; if (!yy_HEX(yy)) goto l33; if (!yy_HEX(yy)) goto l33; if (!yy_HEX(yy)) goto l33; if (!yy_HEX(yy)) goto l33; goto l29; - l33:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; - { int yypos34= yy->__pos, yythunkpos34= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l34; goto l28; - l34:; yy->__pos= yypos34; yy->__thunkpos= yythunkpos34; - } if (!yymatchDot(yy)) goto l28; + { + int yypos31 = yy->__pos, yythunkpos31 = yy->__thunkpos; + if (!yymatchChar(yy, '\\')) { + goto l32; + } + if (!yymatchChar(yy, '"')) { + goto l32; + } + goto l31; +l32: + ; + yy->__pos = yypos31; + yy->__thunkpos = yythunkpos31; + if (!yymatchChar(yy, '\\')) { + goto l33; + } + if (!yymatchChar(yy, '\\')) { + goto l33; + } + goto l31; +l33: + ; + yy->__pos = yypos31; + yy->__thunkpos = yythunkpos31; + if (!yymatchChar(yy, '\\')) { + goto l34; + } + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l34; + } + goto l31; +l34: + ; + yy->__pos = yypos31; + yy->__thunkpos = yythunkpos31; + if (!yymatchChar(yy, '\\')) { + goto l35; + } + if (!yymatchChar(yy, 'u')) { + goto l35; + } + if (!yy_HEX(yy)) { + goto l35; + } + if (!yy_HEX(yy)) { + goto l35; + } + if (!yy_HEX(yy)) { + goto l35; + } + if (!yy_HEX(yy)) { + goto l35; + } + goto l31; +l35: + ; + yy->__pos = yypos31; + yy->__thunkpos = yythunkpos31; + { + int yypos36 = yy->__pos, yythunkpos36 = yy->__thunkpos; + if (!yymatchChar(yy, '"')) { + goto l36; + } + goto l30; +l36: + ; + yy->__pos = yypos36; + yy->__thunkpos = yythunkpos36; + } if (!yymatchDot(yy)) { + goto l30; + } } - l29:; - yyprintf((stderr, " ok %s @ %s\n", "CHJ", yy->__buf+yy->__pos)); +l31: + ; + yyprintf((stderr, " ok %s @ %s\n", "CHJ", yy->__buf + yy->__pos)); return 1; - l28:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CHJ", yy->__buf+yy->__pos)); +l30: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "CHJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_CHP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_CHP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "CHP")); - { int yypos36= yy->__pos, yythunkpos36= yy->__thunkpos; if (!yymatchChar(yy, '\\')) goto l37; if (!yymatchChar(yy, '\\')) goto l37; goto l36; - l37:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; if (!yymatchChar(yy, '\\')) goto l38; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l38; goto l36; - l38:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; if (!yymatchChar(yy, '\\')) goto l39; if (!yymatchChar(yy, 'u')) goto l39; if (!yy_HEX(yy)) goto l39; if (!yy_HEX(yy)) goto l39; if (!yy_HEX(yy)) goto l39; if (!yy_HEX(yy)) goto l39; goto l36; - l39:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; - { int yypos40= yy->__pos, yythunkpos40= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\046\000\000\007\203\000\160\000\000\000\050\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l40; goto l35; - l40:; yy->__pos= yypos40; yy->__thunkpos= yythunkpos40; - } if (!yymatchDot(yy)) goto l35; + { + int yypos38 = yy->__pos, yythunkpos38 = yy->__thunkpos; + if (!yymatchChar(yy, '\\')) { + goto l39; + } + if (!yymatchChar(yy, '\\')) { + goto l39; + } + goto l38; +l39: + ; + yy->__pos = yypos38; + yy->__thunkpos = yythunkpos38; + if (!yymatchChar(yy, '\\')) { + goto l40; + } + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l40; + } + goto l38; +l40: + ; + yy->__pos = yypos38; + yy->__thunkpos = yythunkpos38; + if (!yymatchChar(yy, '\\')) { + goto l41; + } + if (!yymatchChar(yy, 'u')) { + goto l41; + } + if (!yy_HEX(yy)) { + goto l41; + } + if (!yy_HEX(yy)) { + goto l41; + } + if (!yy_HEX(yy)) { + goto l41; + } + if (!yy_HEX(yy)) { + goto l41; + } + goto l38; +l41: + ; + yy->__pos = yypos38; + yy->__thunkpos = yythunkpos38; + { + int yypos42 = yy->__pos, yythunkpos42 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\046\000\000\007\203\000\160\000\000\000\050\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l42; + } + goto l37; +l42: + ; + yy->__pos = yypos42; + yy->__thunkpos = yythunkpos42; + } if (!yymatchDot(yy)) { + goto l37; + } } - l36:; - yyprintf((stderr, " ok %s @ %s\n", "CHP", yy->__buf+yy->__pos)); +l38: + ; + yyprintf((stderr, " ok %s @ %s\n", "CHP", yy->__buf + yy->__pos)); return 1; - l35:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CHP", yy->__buf+yy->__pos)); +l37: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "CHP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_VALJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_VALJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "VALJ")); - { int yypos42= yy->__pos, yythunkpos42= yy->__thunkpos; if (!yy_STRJ(yy)) goto l43; goto l42; - l43:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yy_NUMJ(yy)) goto l44; goto l42; - l44:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yy_OBJJ(yy)) goto l45; goto l42; - l45:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yy_ARRJ(yy)) goto l46; goto l42; - l46:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yymatchString(yy, "true")) goto l47; yyDo(yy, yy_1_VALJ, yy->__begin, yy->__end); goto l42; - l47:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yymatchString(yy, "false")) goto l48; yyDo(yy, yy_2_VALJ, yy->__begin, yy->__end); goto l42; - l48:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; if (!yymatchString(yy, "null")) goto l41; yyDo(yy, yy_3_VALJ, yy->__begin, yy->__end); + { + int yypos44 = yy->__pos, yythunkpos44 = yy->__thunkpos; + if (!yy_STRJ(yy)) { + goto l45; + } + goto l44; +l45: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yy_NUMJ(yy)) { + goto l46; + } + goto l44; +l46: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yy_OBJJ(yy)) { + goto l47; + } + goto l44; +l47: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yy_ARRJ(yy)) { + goto l48; + } + goto l44; +l48: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yymatchString(yy, "true")) { + goto l49; + } + yyDo(yy, yy_1_VALJ, yy->__begin, yy->__end); + goto l44; +l49: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yymatchString(yy, "false")) { + goto l50; + } + yyDo(yy, yy_2_VALJ, yy->__begin, yy->__end); + goto l44; +l50: + ; + yy->__pos = yypos44; + yy->__thunkpos = yythunkpos44; + if (!yymatchString(yy, "null")) { + goto l43; + } + yyDo(yy, yy_3_VALJ, yy->__begin, yy->__end); } - l42:; - yyprintf((stderr, " ok %s @ %s\n", "VALJ", yy->__buf+yy->__pos)); +l44: + ; + yyprintf((stderr, " ok %s @ %s\n", "VALJ", yy->__buf + yy->__pos)); return 1; - l41:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "VALJ", yy->__buf+yy->__pos)); +l43: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "VALJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXPRLEFT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "NEXPRLEFT")); if (!yymatchChar(yy, '[')) goto l49; if (!yy__(yy)) goto l49; if (!yy_STRSTAR(yy)) goto l49; yyDo(yy, yySet, -3, 0); if (!yy__(yy)) goto l49; if (!yy_NEXOP(yy)) goto l49; yyDo(yy, yySet, -2, 0); if (!yy__(yy)) goto l49; if (!yy_NEXRIGHT(yy)) goto l49; yyDo(yy, yySet, -1, 0); if (!yy__(yy)) goto l49; if (!yymatchChar(yy, ']')) goto l49; yyDo(yy, yy_1_NEXPRLEFT, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NEXPRLEFT", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); +YY_RULE(int) yy_NEXPRLEFT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "NEXPRLEFT")); + if (!yymatchChar(yy, '[')) { + goto l51; + } + if (!yy__(yy)) { + goto l51; + } + if (!yy_STRSTAR(yy)) { + goto l51; + } + yyDo(yy, yySet, -3, 0); + if (!yy__(yy)) { + goto l51; + } + if (!yy_NEXOP(yy)) { + goto l51; + } + yyDo(yy, yySet, -2, 0); + if (!yy__(yy)) { + goto l51; + } + if (!yy_NEXRIGHT(yy)) { + goto l51; + } + yyDo(yy, yySet, -1, 0); + if (!yy__(yy)) { + goto l51; + } + if (!yymatchChar(yy, ']')) { + goto l51; + } + yyDo(yy, yy_1_NEXPRLEFT, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NEXPRLEFT", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l49:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXPRLEFT", yy->__buf+yy->__pos)); +l51: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXPRLEFT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_STRSTAR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "STRSTAR")); if (!yymatchChar(yy, '*')) goto l50; yyDo(yy, yy_1_STRSTAR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "STRSTAR", yy->__buf+yy->__pos)); +YY_RULE(int) yy_STRSTAR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "STRSTAR")); + if (!yymatchChar(yy, '*')) { + goto l52; + } + yyDo(yy, yy_1_STRSTAR, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "STRSTAR", yy->__buf + yy->__pos)); return 1; - l50:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STRSTAR", yy->__buf+yy->__pos)); +l52: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STRSTAR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_DBLSTAR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "DBLSTAR")); if (!yymatchString(yy, "**")) goto l51; yyDo(yy, yy_1_DBLSTAR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "DBLSTAR", yy->__buf+yy->__pos)); +YY_RULE(int) yy_DBLSTAR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "DBLSTAR")); + if (!yymatchString(yy, "**")) { + goto l53; + } + yyDo(yy, yy_1_DBLSTAR, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "DBLSTAR", yy->__buf + yy->__pos)); return 1; - l51:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "DBLSTAR", yy->__buf+yy->__pos)); +l53: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "DBLSTAR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXRIGHT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_NEXRIGHT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "NEXRIGHT")); - { int yypos53= yy->__pos, yythunkpos53= yy->__thunkpos; if (!yy_PLACEHOLDER(yy)) goto l54; goto l53; - l54:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_VALJ(yy)) goto l55; goto l53; - l55:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_STRP(yy)) goto l52; + { + int yypos55 = yy->__pos, yythunkpos55 = yy->__thunkpos; + if (!yy_PLACEHOLDER(yy)) { + goto l56; + } + goto l55; +l56: + ; + yy->__pos = yypos55; + yy->__thunkpos = yythunkpos55; + if (!yy_VALJ(yy)) { + goto l57; + } + goto l55; +l57: + ; + yy->__pos = yypos55; + yy->__thunkpos = yythunkpos55; + if (!yy_STRP(yy)) { + goto l54; + } } - l53:; - yyprintf((stderr, " ok %s @ %s\n", "NEXRIGHT", yy->__buf+yy->__pos)); +l55: + ; + yyprintf((stderr, " ok %s @ %s\n", "NEXRIGHT", yy->__buf + yy->__pos)); return 1; - l52:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXRIGHT", yy->__buf+yy->__pos)); +l54: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXRIGHT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXOP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_NEXOP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "NEXOP")); - { int yypos57= yy->__pos, yythunkpos57= yy->__thunkpos; - { int yypos59= yy->__pos, yythunkpos59= yy->__thunkpos; if (!yymatchString(yy, "not")) goto l59; if (!yy___(yy)) goto l59; yyDo(yy, yy_1_NEXOP, yy->__begin, yy->__end); goto l60; - l59:; yy->__pos= yypos59; yy->__thunkpos= yythunkpos59; - } - l60:; yyText(yy, yy->__begin, yy->__end); { + { + int yypos59 = yy->__pos, yythunkpos59 = yy->__thunkpos; + { + int yypos61 = yy->__pos, yythunkpos61 = yy->__thunkpos; + if (!yymatchString(yy, "not")) { + goto l61; + } + if (!yy___(yy)) { + goto l61; + } + yyDo(yy, yy_1_NEXOP, yy->__begin, yy->__end); + goto l62; +l61: + ; + yy->__pos = yypos61; + yy->__thunkpos = yythunkpos61; + } +l62: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l58; + if (!(YY_BEGIN)) { + goto l60; + } #undef yytext #undef yyleng - } - { int yypos61= yy->__pos, yythunkpos61= yy->__thunkpos; if (!yymatchString(yy, "in")) goto l62; goto l61; - l62:; yy->__pos= yypos61; yy->__thunkpos= yythunkpos61; if (!yymatchString(yy, "ni")) goto l63; goto l61; - l63:; yy->__pos= yypos61; yy->__thunkpos= yythunkpos61; if (!yymatchString(yy, "re")) goto l58; - } - l61:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos63 = yy->__pos, yythunkpos63 = yy->__thunkpos; + if (!yymatchString(yy, "in")) { + goto l64; + } + goto l63; +l64: + ; + yy->__pos = yypos63; + yy->__thunkpos = yythunkpos63; + if (!yymatchString(yy, "ni")) { + goto l65; + } + goto l63; +l65: + ; + yy->__pos = yypos63; + yy->__thunkpos = yythunkpos63; + if (!yymatchString(yy, "re")) { + goto l60; + } + } +l63: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l58; + if (!(YY_END)) { + goto l60; + } #undef yytext #undef yyleng - } yyDo(yy, yy_2_NEXOP, yy->__begin, yy->__end); goto l57; - l58:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_2_NEXOP, yy->__begin, yy->__end); + goto l59; +l60: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l64; + if (!(YY_BEGIN)) { + goto l66; + } #undef yytext #undef yyleng - } - { int yypos65= yy->__pos, yythunkpos65= yy->__thunkpos; if (!yymatchString(yy, ">=")) goto l66; goto l65; - l66:; yy->__pos= yypos65; yy->__thunkpos= yythunkpos65; if (!yymatchString(yy, "gte")) goto l64; - } - l65:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos67 = yy->__pos, yythunkpos67 = yy->__thunkpos; + if (!yymatchString(yy, ">=")) { + goto l68; + } + goto l67; +l68: + ; + yy->__pos = yypos67; + yy->__thunkpos = yythunkpos67; + if (!yymatchString(yy, "gte")) { + goto l66; + } + } +l67: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l64; + if (!(YY_END)) { + goto l66; + } #undef yytext #undef yyleng - } yyDo(yy, yy_3_NEXOP, yy->__begin, yy->__end); goto l57; - l64:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_3_NEXOP, yy->__begin, yy->__end); + goto l59; +l66: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l67; + if (!(YY_BEGIN)) { + goto l69; + } #undef yytext #undef yyleng - } - { int yypos68= yy->__pos, yythunkpos68= yy->__thunkpos; if (!yymatchString(yy, "<=")) goto l69; goto l68; - l69:; yy->__pos= yypos68; yy->__thunkpos= yythunkpos68; if (!yymatchString(yy, "lte")) goto l67; - } - l68:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos70 = yy->__pos, yythunkpos70 = yy->__thunkpos; + if (!yymatchString(yy, "<=")) { + goto l71; + } + goto l70; +l71: + ; + yy->__pos = yypos70; + yy->__thunkpos = yythunkpos70; + if (!yymatchString(yy, "lte")) { + goto l69; + } + } +l70: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l67; + if (!(YY_END)) { + goto l69; + } #undef yytext #undef yyleng - } yyDo(yy, yy_4_NEXOP, yy->__begin, yy->__end); goto l57; - l67:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; - { int yypos71= yy->__pos, yythunkpos71= yy->__thunkpos; if (!yymatchChar(yy, '!')) goto l71; if (!yy__(yy)) goto l71; yyDo(yy, yy_5_NEXOP, yy->__begin, yy->__end); goto l72; - l71:; yy->__pos= yypos71; yy->__thunkpos= yythunkpos71; - } - l72:; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_4_NEXOP, yy->__begin, yy->__end); + goto l59; +l69: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + { + int yypos73 = yy->__pos, yythunkpos73 = yy->__thunkpos; + if (!yymatchChar(yy, '!')) { + goto l73; + } + if (!yy__(yy)) { + goto l73; + } + yyDo(yy, yy_5_NEXOP, yy->__begin, yy->__end); + goto l74; +l73: + ; + yy->__pos = yypos73; + yy->__thunkpos = yythunkpos73; + } +l74: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l70; + if (!(YY_BEGIN)) { + goto l72; + } #undef yytext #undef yyleng - } - { int yypos73= yy->__pos, yythunkpos73= yy->__thunkpos; if (!yymatchChar(yy, '=')) goto l74; goto l73; - l74:; yy->__pos= yypos73; yy->__thunkpos= yythunkpos73; if (!yymatchString(yy, "eq")) goto l75; goto l73; - l75:; yy->__pos= yypos73; yy->__thunkpos= yythunkpos73; if (!yymatchChar(yy, '~')) goto l70; - } - l73:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos75 = yy->__pos, yythunkpos75 = yy->__thunkpos; + if (!yymatchChar(yy, '=')) { + goto l76; + } + goto l75; +l76: + ; + yy->__pos = yypos75; + yy->__thunkpos = yythunkpos75; + if (!yymatchString(yy, "eq")) { + goto l77; + } + goto l75; +l77: + ; + yy->__pos = yypos75; + yy->__thunkpos = yythunkpos75; + if (!yymatchChar(yy, '~')) { + goto l72; + } + } +l75: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l70; + if (!(YY_END)) { + goto l72; + } #undef yytext #undef yyleng - } yyDo(yy, yy_6_NEXOP, yy->__begin, yy->__end); goto l57; - l70:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_6_NEXOP, yy->__begin, yy->__end); + goto l59; +l72: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l76; + if (!(YY_BEGIN)) { + goto l78; + } #undef yytext #undef yyleng - } - { int yypos77= yy->__pos, yythunkpos77= yy->__thunkpos; if (!yymatchChar(yy, '>')) goto l78; goto l77; - l78:; yy->__pos= yypos77; yy->__thunkpos= yythunkpos77; if (!yymatchString(yy, "gt")) goto l76; - } - l77:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos79 = yy->__pos, yythunkpos79 = yy->__thunkpos; + if (!yymatchChar(yy, '>')) { + goto l80; + } + goto l79; +l80: + ; + yy->__pos = yypos79; + yy->__thunkpos = yythunkpos79; + if (!yymatchString(yy, "gt")) { + goto l78; + } + } +l79: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l76; + if (!(YY_END)) { + goto l78; + } #undef yytext #undef yyleng - } yyDo(yy, yy_7_NEXOP, yy->__begin, yy->__end); goto l57; - l76:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_7_NEXOP, yy->__begin, yy->__end); + goto l59; +l78: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l79; + if (!(YY_BEGIN)) { + goto l81; + } #undef yytext #undef yyleng - } - { int yypos80= yy->__pos, yythunkpos80= yy->__thunkpos; if (!yymatchChar(yy, '<')) goto l81; goto l80; - l81:; yy->__pos= yypos80; yy->__thunkpos= yythunkpos80; if (!yymatchString(yy, "lt")) goto l79; - } - l80:; yyText(yy, yy->__begin, yy->__end); { + } + { + int yypos82 = yy->__pos, yythunkpos82 = yy->__thunkpos; + if (!yymatchChar(yy, '<')) { + goto l83; + } + goto l82; +l83: + ; + yy->__pos = yypos82; + yy->__thunkpos = yythunkpos82; + if (!yymatchString(yy, "lt")) { + goto l81; + } + } +l82: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l79; + if (!(YY_END)) { + goto l81; + } #undef yytext #undef yyleng - } yyDo(yy, yy_8_NEXOP, yy->__begin, yy->__end); goto l57; - l79:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; yyText(yy, yy->__begin, yy->__end); { + } yyDo(yy, yy_8_NEXOP, yy->__begin, yy->__end); + goto l59; +l81: + ; + yy->__pos = yypos59; + yy->__thunkpos = yythunkpos59; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l56; + if (!(YY_BEGIN)) { + goto l58; + } #undef yytext #undef yyleng - } if (!yymatchChar(yy, '~')) goto l56; yyText(yy, yy->__begin, yy->__end); { + } if (!yymatchChar(yy, '~')) { + goto l58; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l56; + if (!(YY_END)) { + goto l58; + } #undef yytext #undef yyleng - } yyDo(yy, yy_9_NEXOP, yy->__begin, yy->__end); + } yyDo(yy, yy_9_NEXOP, yy->__begin, yy->__end); } - l57:; - yyprintf((stderr, " ok %s @ %s\n", "NEXOP", yy->__buf+yy->__pos)); +l59: + ; + yyprintf((stderr, " ok %s @ %s\n", "NEXOP", yy->__buf + yy->__pos)); return 1; - l56:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXOP", yy->__buf+yy->__pos)); +l58: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXOP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXLEFT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_NEXLEFT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "NEXLEFT")); - { int yypos83= yy->__pos, yythunkpos83= yy->__thunkpos; if (!yy_DBLSTAR(yy)) goto l84; goto l83; - l84:; yy->__pos= yypos83; yy->__thunkpos= yythunkpos83; if (!yy_STRSTAR(yy)) goto l85; goto l83; - l85:; yy->__pos= yypos83; yy->__thunkpos= yythunkpos83; if (!yy_STRN(yy)) goto l86; goto l83; - l86:; yy->__pos= yypos83; yy->__thunkpos= yythunkpos83; if (!yy_NEXPRLEFT(yy)) goto l87; goto l83; - l87:; yy->__pos= yypos83; yy->__thunkpos= yythunkpos83; if (!yy_STRP(yy)) goto l82; + { + int yypos85 = yy->__pos, yythunkpos85 = yy->__thunkpos; + if (!yy_DBLSTAR(yy)) { + goto l86; + } + goto l85; +l86: + ; + yy->__pos = yypos85; + yy->__thunkpos = yythunkpos85; + if (!yy_STRSTAR(yy)) { + goto l87; + } + goto l85; +l87: + ; + yy->__pos = yypos85; + yy->__thunkpos = yythunkpos85; + if (!yy_STRN(yy)) { + goto l88; + } + goto l85; +l88: + ; + yy->__pos = yypos85; + yy->__thunkpos = yythunkpos85; + if (!yy_NEXPRLEFT(yy)) { + goto l89; + } + goto l85; +l89: + ; + yy->__pos = yypos85; + yy->__thunkpos = yythunkpos85; + if (!yy_STRP(yy)) { + goto l84; + } } - l83:; - yyprintf((stderr, " ok %s @ %s\n", "NEXLEFT", yy->__buf+yy->__pos)); +l85: + ; + yyprintf((stderr, " ok %s @ %s\n", "NEXLEFT", yy->__buf + yy->__pos)); return 1; - l82:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXLEFT", yy->__buf+yy->__pos)); +l84: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXLEFT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXJOIN(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NEXJOIN")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_NEXJOIN(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NEXJOIN")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l88; + if (!(YY_BEGIN)) { + goto l90; + } #undef yytext #undef yyleng } - { int yypos89= yy->__pos, yythunkpos89= yy->__thunkpos; if (!yymatchString(yy, "and")) goto l90; goto l89; - l90:; yy->__pos= yypos89; yy->__thunkpos= yythunkpos89; if (!yymatchString(yy, "or")) goto l88; + { + int yypos91 = yy->__pos, yythunkpos91 = yy->__thunkpos; + if (!yymatchString(yy, "and")) { + goto l92; + } + goto l91; +l92: + ; + yy->__pos = yypos91; + yy->__thunkpos = yythunkpos91; + if (!yymatchString(yy, "or")) { + goto l90; + } } - l89:; yyText(yy, yy->__begin, yy->__end); { +l91: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l88; + if (!(YY_END)) { + goto l90; + } #undef yytext #undef yyleng } - { int yypos91= yy->__pos, yythunkpos91= yy->__thunkpos; if (!yy___(yy)) goto l91; if (!yymatchString(yy, "not")) goto l91; yyDo(yy, yy_1_NEXJOIN, yy->__begin, yy->__end); goto l92; - l91:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; - } - l92:; yyDo(yy, yy_2_NEXJOIN, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NEXJOIN", yy->__buf+yy->__pos)); + { + int yypos93 = yy->__pos, yythunkpos93 = yy->__thunkpos; + if (!yy___(yy)) { + goto l93; + } + if (!yymatchString(yy, "not")) { + goto l93; + } + yyDo(yy, yy_1_NEXJOIN, yy->__begin, yy->__end); + goto l94; +l93: + ; + yy->__pos = yypos93; + yy->__thunkpos = yythunkpos93; + } +l94: + ; + yyDo(yy, yy_2_NEXJOIN, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NEXJOIN", yy->__buf + yy->__pos)); return 1; - l88:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXJOIN", yy->__buf+yy->__pos)); +l90: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXJOIN", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXPAIR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "NEXPAIR")); if (!yy_NEXLEFT(yy)) goto l93; yyDo(yy, yySet, -3, 0); if (!yy__(yy)) goto l93; if (!yy_NEXOP(yy)) goto l93; yyDo(yy, yySet, -2, 0); if (!yy__(yy)) goto l93; if (!yy_NEXRIGHT(yy)) goto l93; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_NEXPAIR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NEXPAIR", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); +YY_RULE(int) yy_NEXPAIR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "NEXPAIR")); + if (!yy_NEXLEFT(yy)) { + goto l95; + } + yyDo(yy, yySet, -3, 0); + if (!yy__(yy)) { + goto l95; + } + if (!yy_NEXOP(yy)) { + goto l95; + } + yyDo(yy, yySet, -2, 0); + if (!yy__(yy)) { + goto l95; + } + if (!yy_NEXRIGHT(yy)) { + goto l95; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_1_NEXPAIR, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NEXPAIR", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l93:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXPAIR", yy->__buf+yy->__pos)); +l95: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXPAIR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_STRP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "STRP")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_STRP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "STRP")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l94; + if (!(YY_BEGIN)) { + goto l96; + } #undef yytext #undef yyleng - } if (!yy_CHP(yy)) goto l94; - l95:; - { int yypos96= yy->__pos, yythunkpos96= yy->__thunkpos; if (!yy_CHP(yy)) goto l96; goto l95; - l96:; yy->__pos= yypos96; yy->__thunkpos= yythunkpos96; - } yyText(yy, yy->__begin, yy->__end); { + } if (!yy_CHP(yy)) { + goto l96; + } +l97: + ; + { + int yypos98 = yy->__pos, yythunkpos98 = yy->__thunkpos; + if (!yy_CHP(yy)) { + goto l98; + } + goto l97; +l98: + ; + yy->__pos = yypos98; + yy->__thunkpos = yythunkpos98; + } yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l94; + if (!(YY_END)) { + goto l96; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_STRP, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "STRP", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "STRP", yy->__buf + yy->__pos)); return 1; - l94:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STRP", yy->__buf+yy->__pos)); +l96: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STRP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NEXPR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "NEXPR")); if (!yymatchChar(yy, '[')) goto l97; if (!yy__(yy)) goto l97; if (!yy_NEXPAIR(yy)) goto l97; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_NEXPR, yy->__begin, yy->__end); - l98:; - { int yypos99= yy->__pos, yythunkpos99= yy->__thunkpos; if (!yy___(yy)) goto l99; if (!yy_NEXJOIN(yy)) goto l99; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_NEXPR, yy->__begin, yy->__end); if (!yy___(yy)) goto l99; if (!yy_NEXPAIR(yy)) goto l99; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_NEXPR, yy->__begin, yy->__end); goto l98; - l99:; yy->__pos= yypos99; yy->__thunkpos= yythunkpos99; - } if (!yy__(yy)) goto l97; if (!yymatchChar(yy, ']')) goto l97; yyDo(yy, yy_4_NEXPR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NEXPR", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); +YY_RULE(int) yy_NEXPR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "NEXPR")); + if (!yymatchChar(yy, '[')) { + goto l99; + } + if (!yy__(yy)) { + goto l99; + } + if (!yy_NEXPAIR(yy)) { + goto l99; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_NEXPR, yy->__begin, yy->__end); +l100: + ; + { + int yypos101 = yy->__pos, yythunkpos101 = yy->__thunkpos; + if (!yy___(yy)) { + goto l101; + } + if (!yy_NEXJOIN(yy)) { + goto l101; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_NEXPR, yy->__begin, yy->__end); + if (!yy___(yy)) { + goto l101; + } + if (!yy_NEXPAIR(yy)) { + goto l101; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_NEXPR, yy->__begin, yy->__end); + goto l100; +l101: + ; + yy->__pos = yypos101; + yy->__thunkpos = yythunkpos101; + } if (!yy__(yy)) { + goto l99; + } + if (!yymatchChar(yy, ']')) { + goto l99; + } + yyDo(yy, yy_4_NEXPR, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NEXPR", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l97:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NEXPR", yy->__buf+yy->__pos)); +l99: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NEXPR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NODE(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "NODE")); if (!yymatchChar(yy, '/')) goto l100; - { int yypos101= yy->__pos, yythunkpos101= yy->__thunkpos; if (!yy_STRN(yy)) goto l102; yyDo(yy, yySet, -1, 0); goto l101; - l102:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_NEXPR(yy)) goto l103; yyDo(yy, yySet, -1, 0); goto l101; - l103:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_STRP(yy)) goto l100; yyDo(yy, yySet, -1, 0); +YY_RULE(int) yy_NODE(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 1, 0); + yyprintf((stderr, "%s\n", "NODE")); + if (!yymatchChar(yy, '/')) { + goto l102; + } + { + int yypos103 = yy->__pos, yythunkpos103 = yy->__thunkpos; + if (!yy_STRN(yy)) { + goto l104; + } + yyDo(yy, yySet, -1, 0); + goto l103; +l104: + ; + yy->__pos = yypos103; + yy->__thunkpos = yythunkpos103; + if (!yy_NEXPR(yy)) { + goto l105; + } + yyDo(yy, yySet, -1, 0); + goto l103; +l105: + ; + yy->__pos = yypos103; + yy->__thunkpos = yythunkpos103; + if (!yy_STRP(yy)) { + goto l102; + } + yyDo(yy, yySet, -1, 0); } - l101:; yyDo(yy, yy_1_NODE, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NODE", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 1, 0); +l103: + ; + yyDo(yy, yy_1_NODE, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NODE", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 1, 0); return 1; - l100:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NODE", yy->__buf+yy->__pos)); +l102: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NODE", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTER(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); +YY_RULE(int) yy_FILTER(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); yyprintf((stderr, "%s\n", "FILTER")); - { int yypos105= yy->__pos, yythunkpos105= yy->__thunkpos; if (!yy_FILTERANCHOR(yy)) goto l105; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_FILTER, yy->__begin, yy->__end); goto l106; - l105:; yy->__pos= yypos105; yy->__thunkpos= yythunkpos105; - } - l106:; if (!yy_NODE(yy)) goto l104; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_FILTER, yy->__begin, yy->__end); - l107:; - { int yypos108= yy->__pos, yythunkpos108= yy->__thunkpos; if (!yy_NODE(yy)) goto l108; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_FILTER, yy->__begin, yy->__end); goto l107; - l108:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; + { + int yypos107 = yy->__pos, yythunkpos107 = yy->__thunkpos; + if (!yy_FILTERANCHOR(yy)) { + goto l107; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_FILTER, yy->__begin, yy->__end); + goto l108; +l107: + ; + yy->__pos = yypos107; + yy->__thunkpos = yythunkpos107; + } +l108: + ; + if (!yy_NODE(yy)) { + goto l106; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_FILTER, yy->__begin, yy->__end); +l109: + ; + { + int yypos110 = yy->__pos, yythunkpos110 = yy->__thunkpos; + if (!yy_NODE(yy)) { + goto l110; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_FILTER, yy->__begin, yy->__end); + goto l109; +l110: + ; + yy->__pos = yypos110; + yy->__thunkpos = yythunkpos110; } yyDo(yy, yy_4_FILTER, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "FILTER", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + yyprintf((stderr, " ok %s @ %s\n", "FILTER", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l104:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTER", yy->__buf+yy->__pos)); +l106: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTER", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTERFACTOR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_FILTERFACTOR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "FILTERFACTOR")); - { int yypos110= yy->__pos, yythunkpos110= yy->__thunkpos; if (!yy_FILTER(yy)) goto l111; goto l110; - l111:; yy->__pos= yypos110; yy->__thunkpos= yythunkpos110; if (!yymatchChar(yy, '(')) goto l109; if (!yy_FILTEREXPR(yy)) goto l109; if (!yymatchChar(yy, ')')) goto l109; + { + int yypos112 = yy->__pos, yythunkpos112 = yy->__thunkpos; + if (!yy_FILTER(yy)) { + goto l113; + } + goto l112; +l113: + ; + yy->__pos = yypos112; + yy->__thunkpos = yythunkpos112; + if (!yymatchChar(yy, '(')) { + goto l111; + } + if (!yy_FILTEREXPR(yy)) { + goto l111; + } + if (!yymatchChar(yy, ')')) { + goto l111; + } } - l110:; - yyprintf((stderr, " ok %s @ %s\n", "FILTERFACTOR", yy->__buf+yy->__pos)); +l112: + ; + yyprintf((stderr, " ok %s @ %s\n", "FILTERFACTOR", yy->__buf + yy->__pos)); return 1; - l109:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTERFACTOR", yy->__buf+yy->__pos)); +l111: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTERFACTOR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_HEX(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "HEX")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l112; - yyprintf((stderr, " ok %s @ %s\n", "HEX", yy->__buf+yy->__pos)); +YY_RULE(int) yy_HEX(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "HEX")); + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l114; + } + yyprintf((stderr, " ok %s @ %s\n", "HEX", yy->__buf + yy->__pos)); return 1; - l112:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "HEX", yy->__buf+yy->__pos)); +l114: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "HEX", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PCHP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_PCHP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "PCHP")); - { int yypos114= yy->__pos, yythunkpos114= yy->__thunkpos; if (!yymatchChar(yy, '\\')) goto l115; if (!yymatchChar(yy, '\\')) goto l115; goto l114; - l115:; yy->__pos= yypos114; yy->__thunkpos= yythunkpos114; if (!yymatchChar(yy, '\\')) goto l116; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l116; goto l114; - l116:; yy->__pos= yypos114; yy->__thunkpos= yythunkpos114; if (!yymatchChar(yy, '\\')) goto l117; if (!yymatchChar(yy, 'u')) goto l117; if (!yy_HEX(yy)) goto l117; if (!yy_HEX(yy)) goto l117; if (!yy_HEX(yy)) goto l117; if (!yy_HEX(yy)) goto l117; goto l114; - l117:; yy->__pos= yypos114; yy->__thunkpos= yythunkpos114; - { int yypos118= yy->__pos, yythunkpos118= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\046\000\000\005\220\000\000\000\000\000\000\000\000\000\050\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l118; goto l113; - l118:; yy->__pos= yypos118; yy->__thunkpos= yythunkpos118; - } if (!yymatchDot(yy)) goto l113; + { + int yypos116 = yy->__pos, yythunkpos116 = yy->__thunkpos; + if (!yymatchChar(yy, '\\')) { + goto l117; + } + if (!yymatchChar(yy, '\\')) { + goto l117; + } + goto l116; +l117: + ; + yy->__pos = yypos116; + yy->__thunkpos = yythunkpos116; + if (!yymatchChar(yy, '\\')) { + goto l118; + } + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\000\000\000\000\000\000\104\100\024\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l118; + } + goto l116; +l118: + ; + yy->__pos = yypos116; + yy->__thunkpos = yythunkpos116; + if (!yymatchChar(yy, '\\')) { + goto l119; + } + if (!yymatchChar(yy, 'u')) { + goto l119; + } + if (!yy_HEX(yy)) { + goto l119; + } + if (!yy_HEX(yy)) { + goto l119; + } + if (!yy_HEX(yy)) { + goto l119; + } + if (!yy_HEX(yy)) { + goto l119; + } + goto l116; +l119: + ; + yy->__pos = yypos116; + yy->__thunkpos = yythunkpos116; + { + int yypos120 = yy->__pos, yythunkpos120 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\046\000\000\005\220\000\000\000\000\000\000\000\000\000\050\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l120; + } + goto l115; +l120: + ; + yy->__pos = yypos120; + yy->__thunkpos = yythunkpos120; + } if (!yymatchDot(yy)) { + goto l115; + } } - l114:; - yyprintf((stderr, " ok %s @ %s\n", "PCHP", yy->__buf+yy->__pos)); +l116: + ; + yyprintf((stderr, " ok %s @ %s\n", "PCHP", yy->__buf + yy->__pos)); return 1; - l113:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PCHP", yy->__buf+yy->__pos)); +l115: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PCHP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PSTRP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "PSTRP")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_PSTRP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "PSTRP")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l119; + if (!(YY_BEGIN)) { + goto l121; + } #undef yytext #undef yyleng - } if (!yy_PCHP(yy)) goto l119; - l120:; - { int yypos121= yy->__pos, yythunkpos121= yy->__thunkpos; if (!yy_PCHP(yy)) goto l121; goto l120; - l121:; yy->__pos= yypos121; yy->__thunkpos= yythunkpos121; - } yyText(yy, yy->__begin, yy->__end); { + } if (!yy_PCHP(yy)) { + goto l121; + } +l122: + ; + { + int yypos123 = yy->__pos, yythunkpos123 = yy->__thunkpos; + if (!yy_PCHP(yy)) { + goto l123; + } + goto l122; +l123: + ; + yy->__pos = yypos123; + yy->__thunkpos = yythunkpos123; + } yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l119; + if (!(YY_END)) { + goto l121; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_PSTRP, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PSTRP", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "PSTRP", yy->__buf + yy->__pos)); return 1; - l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PSTRP", yy->__buf+yy->__pos)); +l121: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PSTRP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_STRN(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "STRN")); if (!yymatchChar(yy, '"')) goto l122; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_STRN(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "STRN")); + if (!yymatchChar(yy, '"')) { + goto l124; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l122; + if (!(YY_BEGIN)) { + goto l124; + } #undef yytext #undef yyleng - } if (!yy_CHJ(yy)) goto l122; - l123:; - { int yypos124= yy->__pos, yythunkpos124= yy->__thunkpos; if (!yy_CHJ(yy)) goto l124; goto l123; - l124:; yy->__pos= yypos124; yy->__thunkpos= yythunkpos124; - } yyText(yy, yy->__begin, yy->__end); { + } if (!yy_CHJ(yy)) { + goto l124; + } +l125: + ; + { + int yypos126 = yy->__pos, yythunkpos126 = yy->__thunkpos; + if (!yy_CHJ(yy)) { + goto l126; + } + goto l125; +l126: + ; + yy->__pos = yypos126; + yy->__thunkpos = yythunkpos126; + } yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l122; + if (!(YY_END)) { + goto l124; + } #undef yytext #undef yyleng - } if (!yymatchChar(yy, '"')) goto l122; yyDo(yy, yy_1_STRN, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "STRN", yy->__buf+yy->__pos)); + } if (!yymatchChar(yy, '"')) { + goto l124; + } + yyDo(yy, yy_1_STRN, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "STRN", yy->__buf + yy->__pos)); return 1; - l122:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STRN", yy->__buf+yy->__pos)); +l124: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STRN", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJFIELDS(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "PROJFIELDS")); if (!yymatchChar(yy, '{')) goto l125; if (!yy__(yy)) goto l125; if (!yy_PROJPROP(yy)) goto l125; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_1_PROJFIELDS, yy->__begin, yy->__end); - l126:; - { int yypos127= yy->__pos, yythunkpos127= yy->__thunkpos; if (!yy__(yy)) goto l127; if (!yymatchChar(yy, ',')) goto l127; if (!yy__(yy)) goto l127; if (!yy_PROJPROP(yy)) goto l127; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_2_PROJFIELDS, yy->__begin, yy->__end); goto l126; - l127:; yy->__pos= yypos127; yy->__thunkpos= yythunkpos127; - } if (!yy__(yy)) goto l125; if (!yymatchChar(yy, '}')) goto l125; yyDo(yy, yy_3_PROJFIELDS, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PROJFIELDS", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); +YY_RULE(int) yy_PROJFIELDS(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 2, 0); + yyprintf((stderr, "%s\n", "PROJFIELDS")); + if (!yymatchChar(yy, '{')) { + goto l127; + } + if (!yy__(yy)) { + goto l127; + } + if (!yy_PROJPROP(yy)) { + goto l127; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_1_PROJFIELDS, yy->__begin, yy->__end); +l128: + ; + { + int yypos129 = yy->__pos, yythunkpos129 = yy->__thunkpos; + if (!yy__(yy)) { + goto l129; + } + if (!yymatchChar(yy, ',')) { + goto l129; + } + if (!yy__(yy)) { + goto l129; + } + if (!yy_PROJPROP(yy)) { + goto l129; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_2_PROJFIELDS, yy->__begin, yy->__end); + goto l128; +l129: + ; + yy->__pos = yypos129; + yy->__thunkpos = yythunkpos129; + } if (!yy__(yy)) { + goto l127; + } + if (!yymatchChar(yy, '}')) { + goto l127; + } + yyDo(yy, yy_3_PROJFIELDS, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "PROJFIELDS", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 2, 0); return 1; - l125:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJFIELDS", yy->__buf+yy->__pos)); +l127: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJFIELDS", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJNODE(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "PROJNODE")); if (!yymatchChar(yy, '/')) goto l128; - { int yypos129= yy->__pos, yythunkpos129= yy->__thunkpos; if (!yy_PROJFIELDS(yy)) goto l130; goto l129; - l130:; yy->__pos= yypos129; yy->__thunkpos= yythunkpos129; if (!yy_PROJPROP(yy)) goto l128; +YY_RULE(int) yy_PROJNODE(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "PROJNODE")); + if (!yymatchChar(yy, '/')) { + goto l130; + } + { + int yypos131 = yy->__pos, yythunkpos131 = yy->__thunkpos; + if (!yy_PROJFIELDS(yy)) { + goto l132; + } + goto l131; +l132: + ; + yy->__pos = yypos131; + yy->__thunkpos = yythunkpos131; + if (!yy_PROJPROP(yy)) { + goto l130; + } } - l129:; - yyprintf((stderr, " ok %s @ %s\n", "PROJNODE", yy->__buf+yy->__pos)); +l131: + ; + yyprintf((stderr, " ok %s @ %s\n", "PROJNODE", yy->__buf + yy->__pos)); return 1; - l128:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJNODE", yy->__buf+yy->__pos)); +l130: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJNODE", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJALL(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "PROJALL")); if (!yymatchString(yy, "all")) goto l131; yyDo(yy, yy_1_PROJALL, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PROJALL", yy->__buf+yy->__pos)); +YY_RULE(int) yy_PROJALL(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "PROJALL")); + if (!yymatchString(yy, "all")) { + goto l133; + } + yyDo(yy, yy_1_PROJALL, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "PROJALL", yy->__buf + yy->__pos)); return 1; - l131:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJALL", yy->__buf+yy->__pos)); +l133: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJALL", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJPROP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_PROJPROP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "PROJPROP")); - { int yypos133= yy->__pos, yythunkpos133= yy->__thunkpos; if (!yy_STRN(yy)) goto l134; goto l133; - l134:; yy->__pos= yypos133; yy->__thunkpos= yythunkpos133; if (!yy_PSTRP(yy)) goto l132; + { + int yypos135 = yy->__pos, yythunkpos135 = yy->__thunkpos; + if (!yy_STRN(yy)) { + goto l136; + } + goto l135; +l136: + ; + yy->__pos = yypos135; + yy->__thunkpos = yythunkpos135; + if (!yy_PLACEHOLDER(yy)) { + goto l137; + } + goto l135; +l137: + ; + yy->__pos = yypos135; + yy->__thunkpos = yythunkpos135; + if (!yy_PSTRP(yy)) { + goto l134; + } } - l133:; - yyprintf((stderr, " ok %s @ %s\n", "PROJPROP", yy->__buf+yy->__pos)); +l135: + ; + yyprintf((stderr, " ok %s @ %s\n", "PROJPROP", yy->__buf + yy->__pos)); return 1; - l132:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJPROP", yy->__buf+yy->__pos)); +l134: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJPROP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_ORDERNODE(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "ORDERNODE")); if (!yymatchChar(yy, '/')) goto l135; if (!yy_PROJPROP(yy)) goto l135; - yyprintf((stderr, " ok %s @ %s\n", "ORDERNODE", yy->__buf+yy->__pos)); +YY_RULE(int) yy_ORDERNODE(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "ORDERNODE")); + if (!yymatchChar(yy, '/')) { + goto l138; + } + if (!yy_PROJPROP(yy)) { + goto l138; + } + yyprintf((stderr, " ok %s @ %s\n", "ORDERNODE", yy->__buf + yy->__pos)); return 1; - l135:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ORDERNODE", yy->__buf+yy->__pos)); +l138: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "ORDERNODE", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_ORDERNODES(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "ORDERNODES")); if (!yy_ORDERNODE(yy)) goto l136; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_1_ORDERNODES, yy->__begin, yy->__end); - l137:; - { int yypos138= yy->__pos, yythunkpos138= yy->__thunkpos; if (!yy_ORDERNODE(yy)) goto l138; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_2_ORDERNODES, yy->__begin, yy->__end); goto l137; - l138:; yy->__pos= yypos138; yy->__thunkpos= yythunkpos138; +YY_RULE(int) yy_ORDERNODES(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 2, 0); + yyprintf((stderr, "%s\n", "ORDERNODES")); + if (!yy_ORDERNODE(yy)) { + goto l139; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_1_ORDERNODES, yy->__begin, yy->__end); +l140: + ; + { + int yypos141 = yy->__pos, yythunkpos141 = yy->__thunkpos; + if (!yy_ORDERNODE(yy)) { + goto l141; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_2_ORDERNODES, yy->__begin, yy->__end); + goto l140; +l141: + ; + yy->__pos = yypos141; + yy->__thunkpos = yythunkpos141; } yyDo(yy, yy_3_ORDERNODES, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "ORDERNODES", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); + yyprintf((stderr, " ok %s @ %s\n", "ORDERNODES", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 2, 0); return 1; - l136:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ORDERNODES", yy->__buf+yy->__pos)); +l139: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "ORDERNODES", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUMI(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_NUMI(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "NUMI")); - { int yypos140= yy->__pos, yythunkpos140= yy->__thunkpos; if (!yymatchChar(yy, '0')) goto l141; goto l140; - l141:; yy->__pos= yypos140; yy->__thunkpos= yythunkpos140; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\376\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l139; - l142:; - { int yypos143= yy->__pos, yythunkpos143= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l143; goto l142; - l143:; yy->__pos= yypos143; yy->__thunkpos= yythunkpos143; - } + { + int yypos143 = yy->__pos, yythunkpos143 = yy->__thunkpos; + if (!yymatchChar(yy, '0')) { + goto l144; + } + goto l143; +l144: + ; + yy->__pos = yypos143; + yy->__thunkpos = yythunkpos143; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\376\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l142; + } +l145: + ; + { + int yypos146 = yy->__pos, yythunkpos146 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l146; + } + goto l145; +l146: + ; + yy->__pos = yypos146; + yy->__thunkpos = yythunkpos146; + } } - l140:; - yyprintf((stderr, " ok %s @ %s\n", "NUMI", yy->__buf+yy->__pos)); +l143: + ; + yyprintf((stderr, " ok %s @ %s\n", "NUMI", yy->__buf + yy->__pos)); return 1; - l139:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUMI", yy->__buf+yy->__pos)); +l142: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUMI", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_INVERSE(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "INVERSE")); if (!yymatchString(yy, "inverse")) goto l144; yyDo(yy, yy_1_INVERSE, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "INVERSE", yy->__buf+yy->__pos)); +YY_RULE(int) yy_INVERSE(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "INVERSE")); + if (!yymatchString(yy, "inverse")) { + goto l147; + } + yyDo(yy, yy_1_INVERSE, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "INVERSE", yy->__buf + yy->__pos)); return 1; - l144:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "INVERSE", yy->__buf+yy->__pos)); +l147: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "INVERSE", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NOIDX(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NOIDX")); if (!yymatchString(yy, "noidx")) goto l145; yyDo(yy, yy_1_NOIDX, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NOIDX", yy->__buf+yy->__pos)); +YY_RULE(int) yy_NOIDX(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NOIDX")); + if (!yymatchString(yy, "noidx")) { + goto l148; + } + yyDo(yy, yy_1_NOIDX, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NOIDX", yy->__buf + yy->__pos)); return 1; - l145:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NOIDX", yy->__buf+yy->__pos)); +l148: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NOIDX", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_COUNT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "COUNT")); if (!yymatchString(yy, "count")) goto l146; yyDo(yy, yy_1_COUNT, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "COUNT", yy->__buf+yy->__pos)); +YY_RULE(int) yy_COUNT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "COUNT")); + if (!yymatchString(yy, "count")) { + goto l149; + } + yyDo(yy, yy_1_COUNT, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "COUNT", yy->__buf + yy->__pos)); return 1; - l146:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "COUNT", yy->__buf+yy->__pos)); +l149: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "COUNT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_ORDERBY(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 1, 0); +YY_RULE(int) yy_ORDERBY(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 1, 0); yyprintf((stderr, "%s\n", "ORDERBY")); - { int yypos148= yy->__pos, yythunkpos148= yy->__thunkpos; if (!yymatchString(yy, "asc")) goto l149; goto l148; - l149:; yy->__pos= yypos148; yy->__thunkpos= yythunkpos148; if (!yymatchString(yy, "desc")) goto l147; yyDo(yy, yy_1_ORDERBY, yy->__begin, yy->__end); + { + int yypos151 = yy->__pos, yythunkpos151 = yy->__thunkpos; + if (!yymatchString(yy, "asc")) { + goto l152; + } + goto l151; +l152: + ; + yy->__pos = yypos151; + yy->__thunkpos = yythunkpos151; + if (!yymatchString(yy, "desc")) { + goto l150; + } + yyDo(yy, yy_1_ORDERBY, yy->__begin, yy->__end); } - l148:; if (!yy___(yy)) goto l147; - { int yypos150= yy->__pos, yythunkpos150= yy->__thunkpos; if (!yy_ORDERNODES(yy)) goto l151; yyDo(yy, yySet, -1, 0); goto l150; - l151:; yy->__pos= yypos150; yy->__thunkpos= yythunkpos150; if (!yy_PLACEHOLDER(yy)) goto l147; yyDo(yy, yySet, -1, 0); +l151: + ; + if (!yy___(yy)) { + goto l150; } - l150:; yyDo(yy, yy_2_ORDERBY, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "ORDERBY", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 1, 0); + { + int yypos153 = yy->__pos, yythunkpos153 = yy->__thunkpos; + if (!yy_ORDERNODES(yy)) { + goto l154; + } + yyDo(yy, yySet, -1, 0); + goto l153; +l154: + ; + yy->__pos = yypos153; + yy->__thunkpos = yythunkpos153; + if (!yy_PLACEHOLDER(yy)) { + goto l150; + } + yyDo(yy, yySet, -1, 0); + } +l153: + ; + yyDo(yy, yy_2_ORDERBY, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "ORDERBY", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 1, 0); return 1; - l147:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ORDERBY", yy->__buf+yy->__pos)); +l150: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "ORDERBY", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_LIMIT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "LIMIT")); if (!yymatchString(yy, "limit")) goto l152; if (!yy___(yy)) goto l152; - { int yypos153= yy->__pos, yythunkpos153= yy->__thunkpos; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_LIMIT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 1, 0); + yyprintf((stderr, "%s\n", "LIMIT")); + if (!yymatchString(yy, "limit")) { + goto l155; + } + if (!yy___(yy)) { + goto l155; + } + { + int yypos156 = yy->__pos, yythunkpos156 = yy->__thunkpos; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l154; + if (!(YY_BEGIN)) { + goto l157; + } #undef yytext #undef yyleng - } if (!yy_NUMI(yy)) goto l154; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_NUMI(yy)) { + goto l157; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l154; + if (!(YY_END)) { + goto l157; + } #undef yytext #undef yyleng - } yyDo(yy, yy_1_LIMIT, yy->__begin, yy->__end); goto l153; - l154:; yy->__pos= yypos153; yy->__thunkpos= yythunkpos153; if (!yy_PLACEHOLDER(yy)) goto l152; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_2_LIMIT, yy->__begin, yy->__end); - } - l153:; yyDo(yy, yy_3_LIMIT, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "LIMIT", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 1, 0); + } yyDo(yy, yy_1_LIMIT, yy->__begin, yy->__end); + goto l156; +l157: + ; + yy->__pos = yypos156; + yy->__thunkpos = yythunkpos156; + if (!yy_PLACEHOLDER(yy)) { + goto l155; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_2_LIMIT, yy->__begin, yy->__end); + } +l156: + ; + yyDo(yy, yy_3_LIMIT, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "LIMIT", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 1, 0); return 1; - l152:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "LIMIT", yy->__buf+yy->__pos)); +l155: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "LIMIT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_SKIP(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 1, 0); - yyprintf((stderr, "%s\n", "SKIP")); if (!yymatchString(yy, "skip")) goto l155; if (!yy___(yy)) goto l155; - { int yypos156= yy->__pos, yythunkpos156= yy->__thunkpos; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_SKIP(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 1, 0); + yyprintf((stderr, "%s\n", "SKIP")); + if (!yymatchString(yy, "skip")) { + goto l158; + } + if (!yy___(yy)) { + goto l158; + } + { + int yypos159 = yy->__pos, yythunkpos159 = yy->__thunkpos; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l157; + if (!(YY_BEGIN)) { + goto l160; + } #undef yytext #undef yyleng - } if (!yy_NUMI(yy)) goto l157; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_NUMI(yy)) { + goto l160; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l157; + if (!(YY_END)) { + goto l160; + } #undef yytext #undef yyleng - } yyDo(yy, yy_1_SKIP, yy->__begin, yy->__end); goto l156; - l157:; yy->__pos= yypos156; yy->__thunkpos= yythunkpos156; if (!yy_PLACEHOLDER(yy)) goto l155; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_2_SKIP, yy->__begin, yy->__end); - } - l156:; yyDo(yy, yy_3_SKIP, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "SKIP", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 1, 0); + } yyDo(yy, yy_1_SKIP, yy->__begin, yy->__end); + goto l159; +l160: + ; + yy->__pos = yypos159; + yy->__thunkpos = yythunkpos159; + if (!yy_PLACEHOLDER(yy)) { + goto l158; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_2_SKIP, yy->__begin, yy->__end); + } +l159: + ; + yyDo(yy, yy_3_SKIP, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "SKIP", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 1, 0); return 1; - l155:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SKIP", yy->__buf+yy->__pos)); +l158: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SKIP", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_OPT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_OPT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "OPT")); - { int yypos159= yy->__pos, yythunkpos159= yy->__thunkpos; if (!yy_SKIP(yy)) goto l160; goto l159; - l160:; yy->__pos= yypos159; yy->__thunkpos= yythunkpos159; if (!yy_LIMIT(yy)) goto l161; goto l159; - l161:; yy->__pos= yypos159; yy->__thunkpos= yythunkpos159; if (!yy_ORDERBY(yy)) goto l162; goto l159; - l162:; yy->__pos= yypos159; yy->__thunkpos= yythunkpos159; if (!yy_COUNT(yy)) goto l163; goto l159; - l163:; yy->__pos= yypos159; yy->__thunkpos= yythunkpos159; if (!yy_NOIDX(yy)) goto l164; goto l159; - l164:; yy->__pos= yypos159; yy->__thunkpos= yythunkpos159; if (!yy_INVERSE(yy)) goto l158; + { + int yypos162 = yy->__pos, yythunkpos162 = yy->__thunkpos; + if (!yy_SKIP(yy)) { + goto l163; + } + goto l162; +l163: + ; + yy->__pos = yypos162; + yy->__thunkpos = yythunkpos162; + if (!yy_LIMIT(yy)) { + goto l164; + } + goto l162; +l164: + ; + yy->__pos = yypos162; + yy->__thunkpos = yythunkpos162; + if (!yy_ORDERBY(yy)) { + goto l165; + } + goto l162; +l165: + ; + yy->__pos = yypos162; + yy->__thunkpos = yythunkpos162; + if (!yy_COUNT(yy)) { + goto l166; + } + goto l162; +l166: + ; + yy->__pos = yypos162; + yy->__thunkpos = yythunkpos162; + if (!yy_NOIDX(yy)) { + goto l167; + } + goto l162; +l167: + ; + yy->__pos = yypos162; + yy->__thunkpos = yythunkpos162; + if (!yy_INVERSE(yy)) { + goto l161; + } } - l159:; - yyprintf((stderr, " ok %s @ %s\n", "OPT", yy->__buf+yy->__pos)); +l162: + ; + yyprintf((stderr, " ok %s @ %s\n", "OPT", yy->__buf + yy->__pos)); return 1; - l158:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OPT", yy->__buf+yy->__pos)); +l161: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OPT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJOIN(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_PROJOIN(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "PROJOIN")); - { int yypos166= yy->__pos, yythunkpos166= yy->__thunkpos; if (!yymatchChar(yy, '+')) goto l167; goto l166; - l167:; yy->__pos= yypos166; yy->__thunkpos= yythunkpos166; if (!yymatchChar(yy, '-')) goto l165; + { + int yypos169 = yy->__pos, yythunkpos169 = yy->__thunkpos; + if (!yymatchChar(yy, '+')) { + goto l170; + } + goto l169; +l170: + ; + yy->__pos = yypos169; + yy->__thunkpos = yythunkpos169; + if (!yymatchChar(yy, '-')) { + goto l168; + } } - l166:; - yyprintf((stderr, " ok %s @ %s\n", "PROJOIN", yy->__buf+yy->__pos)); +l169: + ; + yyprintf((stderr, " ok %s @ %s\n", "PROJOIN", yy->__buf + yy->__pos)); return 1; - l165:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJOIN", yy->__buf+yy->__pos)); +l168: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJOIN", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJNODES(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); +YY_RULE(int) yy_PROJNODES(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); yyprintf((stderr, "%s\n", "PROJNODES")); - { int yypos169= yy->__pos, yythunkpos169= yy->__thunkpos; if (!yy_PROJALL(yy)) goto l170; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_PROJNODES, yy->__begin, yy->__end); goto l169; - l170:; yy->__pos= yypos169; yy->__thunkpos= yythunkpos169; if (!yy_PROJNODE(yy)) goto l168; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_PROJNODES, yy->__begin, yy->__end); - l171:; - { int yypos172= yy->__pos, yythunkpos172= yy->__thunkpos; if (!yy_PROJNODE(yy)) goto l172; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_PROJNODES, yy->__begin, yy->__end); goto l171; - l172:; yy->__pos= yypos172; yy->__thunkpos= yythunkpos172; - } yyDo(yy, yy_4_PROJNODES, yy->__begin, yy->__end); - } - l169:; - yyprintf((stderr, " ok %s @ %s\n", "PROJNODES", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + { + int yypos172 = yy->__pos, yythunkpos172 = yy->__thunkpos; + if (!yy_PROJALL(yy)) { + goto l173; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_PROJNODES, yy->__begin, yy->__end); + goto l172; +l173: + ; + yy->__pos = yypos172; + yy->__thunkpos = yythunkpos172; + if (!yy_PROJNODE(yy)) { + goto l171; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_PROJNODES, yy->__begin, yy->__end); +l174: + ; + { + int yypos175 = yy->__pos, yythunkpos175 = yy->__thunkpos; + if (!yy_PROJNODE(yy)) { + goto l175; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_PROJNODES, yy->__begin, yy->__end); + goto l174; +l175: + ; + yy->__pos = yypos175; + yy->__thunkpos = yythunkpos175; + } yyDo(yy, yy_4_PROJNODES, yy->__begin, yy->__end); + } +l172: + ; + yyprintf((stderr, " ok %s @ %s\n", "PROJNODES", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l168:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJNODES", yy->__buf+yy->__pos)); +l171: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJNODES", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_ARRJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "ARRJ")); if (!yy_SARRJ(yy)) goto l173; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_ARRJ, yy->__begin, yy->__end); if (!yy__(yy)) goto l173; - { int yypos174= yy->__pos, yythunkpos174= yy->__thunkpos; if (!yy_VALJ(yy)) goto l174; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_ARRJ, yy->__begin, yy->__end); - l176:; - { int yypos177= yy->__pos, yythunkpos177= yy->__thunkpos; if (!yy__(yy)) goto l177; if (!yymatchChar(yy, ',')) goto l177; if (!yy__(yy)) goto l177; if (!yy_VALJ(yy)) goto l177; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_ARRJ, yy->__begin, yy->__end); goto l176; - l177:; yy->__pos= yypos177; yy->__thunkpos= yythunkpos177; - } goto l175; - l174:; yy->__pos= yypos174; yy->__thunkpos= yythunkpos174; +YY_RULE(int) yy_ARRJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "ARRJ")); + if (!yy_SARRJ(yy)) { + goto l176; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_ARRJ, yy->__begin, yy->__end); + if (!yy__(yy)) { + goto l176; } - l175:; if (!yy__(yy)) goto l173; if (!yymatchChar(yy, ']')) goto l173; yyDo(yy, yy_4_ARRJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "ARRJ", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + { + int yypos177 = yy->__pos, yythunkpos177 = yy->__thunkpos; + if (!yy_VALJ(yy)) { + goto l177; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_ARRJ, yy->__begin, yy->__end); +l179: + ; + { + int yypos180 = yy->__pos, yythunkpos180 = yy->__thunkpos; + if (!yy__(yy)) { + goto l180; + } + if (!yymatchChar(yy, ',')) { + goto l180; + } + if (!yy__(yy)) { + goto l180; + } + if (!yy_VALJ(yy)) { + goto l180; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_ARRJ, yy->__begin, yy->__end); + goto l179; +l180: + ; + yy->__pos = yypos180; + yy->__thunkpos = yythunkpos180; + } goto l178; +l177: + ; + yy->__pos = yypos177; + yy->__thunkpos = yythunkpos177; + } +l178: + ; + if (!yy__(yy)) { + goto l176; + } + if (!yymatchChar(yy, ']')) { + goto l176; + } + yyDo(yy, yy_4_ARRJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "ARRJ", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l173:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "ARRJ", yy->__buf+yy->__pos)); +l176: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "ARRJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_OBJJ(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "OBJJ")); if (!yy_SOBJJ(yy)) goto l178; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_OBJJ, yy->__begin, yy->__end); if (!yy__(yy)) goto l178; - { int yypos179= yy->__pos, yythunkpos179= yy->__thunkpos; if (!yy_PAIRJ(yy)) goto l179; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_OBJJ, yy->__begin, yy->__end); - l181:; - { int yypos182= yy->__pos, yythunkpos182= yy->__thunkpos; if (!yy__(yy)) goto l182; if (!yymatchChar(yy, ',')) goto l182; if (!yy__(yy)) goto l182; if (!yy_PAIRJ(yy)) goto l182; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_OBJJ, yy->__begin, yy->__end); goto l181; - l182:; yy->__pos= yypos182; yy->__thunkpos= yythunkpos182; - } goto l180; - l179:; yy->__pos= yypos179; yy->__thunkpos= yythunkpos179; +YY_RULE(int) yy_OBJJ(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "OBJJ")); + if (!yy_SOBJJ(yy)) { + goto l181; } - l180:; if (!yy__(yy)) goto l178; if (!yymatchChar(yy, '}')) goto l178; yyDo(yy, yy_4_OBJJ, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "OBJJ", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_OBJJ, yy->__begin, yy->__end); + if (!yy__(yy)) { + goto l181; + } + { + int yypos182 = yy->__pos, yythunkpos182 = yy->__thunkpos; + if (!yy_PAIRJ(yy)) { + goto l182; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_OBJJ, yy->__begin, yy->__end); +l184: + ; + { + int yypos185 = yy->__pos, yythunkpos185 = yy->__thunkpos; + if (!yy__(yy)) { + goto l185; + } + if (!yymatchChar(yy, ',')) { + goto l185; + } + if (!yy__(yy)) { + goto l185; + } + if (!yy_PAIRJ(yy)) { + goto l185; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_OBJJ, yy->__begin, yy->__end); + goto l184; +l185: + ; + yy->__pos = yypos185; + yy->__thunkpos = yythunkpos185; + } goto l183; +l182: + ; + yy->__pos = yypos182; + yy->__thunkpos = yythunkpos182; + } +l183: + ; + if (!yy__(yy)) { + goto l181; + } + if (!yymatchChar(yy, '}')) { + goto l181; + } + yyDo(yy, yy_4_OBJJ, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "OBJJ", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l178:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OBJJ", yy->__buf+yy->__pos)); +l181: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OBJJ", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy___(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "__")); if (!yy_SPACE(yy)) goto l183; - l184:; - { int yypos185= yy->__pos, yythunkpos185= yy->__thunkpos; if (!yy_SPACE(yy)) goto l185; goto l184; - l185:; yy->__pos= yypos185; yy->__thunkpos= yythunkpos185; +YY_RULE(int) yy___(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "__")); + if (!yy_SPACE(yy)) { + goto l186; } - yyprintf((stderr, " ok %s @ %s\n", "__", yy->__buf+yy->__pos)); +l187: + ; + { + int yypos188 = yy->__pos, yythunkpos188 = yy->__thunkpos; + if (!yy_SPACE(yy)) { + goto l188; + } + goto l187; +l188: + ; + yy->__pos = yypos188; + yy->__thunkpos = yythunkpos188; + } + yyprintf((stderr, " ok %s @ %s\n", "__", yy->__buf + yy->__pos)); return 1; - l183:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "__", yy->__buf+yy->__pos)); +l186: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "__", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTERJOIN(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "FILTERJOIN")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_FILTERJOIN(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "FILTERJOIN")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l186; + if (!(YY_BEGIN)) { + goto l189; + } #undef yytext #undef yyleng } - { int yypos187= yy->__pos, yythunkpos187= yy->__thunkpos; if (!yymatchString(yy, "and")) goto l188; goto l187; - l188:; yy->__pos= yypos187; yy->__thunkpos= yythunkpos187; if (!yymatchString(yy, "or")) goto l186; + { + int yypos190 = yy->__pos, yythunkpos190 = yy->__thunkpos; + if (!yymatchString(yy, "and")) { + goto l191; + } + goto l190; +l191: + ; + yy->__pos = yypos190; + yy->__thunkpos = yythunkpos190; + if (!yymatchString(yy, "or")) { + goto l189; + } } - l187:; yyText(yy, yy->__begin, yy->__end); { +l190: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l186; + if (!(YY_END)) { + goto l189; + } #undef yytext #undef yyleng } - { int yypos189= yy->__pos, yythunkpos189= yy->__thunkpos; if (!yy___(yy)) goto l189; if (!yymatchString(yy, "not")) goto l189; yyDo(yy, yy_1_FILTERJOIN, yy->__begin, yy->__end); goto l190; - l189:; yy->__pos= yypos189; yy->__thunkpos= yythunkpos189; - } - l190:; yyDo(yy, yy_2_FILTERJOIN, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "FILTERJOIN", yy->__buf+yy->__pos)); + { + int yypos192 = yy->__pos, yythunkpos192 = yy->__thunkpos; + if (!yy___(yy)) { + goto l192; + } + if (!yymatchString(yy, "not")) { + goto l192; + } + yyDo(yy, yy_1_FILTERJOIN, yy->__begin, yy->__end); + goto l193; +l192: + ; + yy->__pos = yypos192; + yy->__thunkpos = yythunkpos192; + } +l193: + ; + yyDo(yy, yy_2_FILTERJOIN, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "FILTERJOIN", yy->__buf + yy->__pos)); return 1; - l186:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTERJOIN", yy->__buf+yy->__pos)); +l189: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTERJOIN", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUMPK_ARR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "NUMPK_ARR")); if (!yy_SARRJ(yy)) goto l191; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_NUMPK_ARR, yy->__begin, yy->__end); if (!yy__(yy)) goto l191; - { int yypos192= yy->__pos, yythunkpos192= yy->__thunkpos; if (!yy_NUMPK(yy)) goto l192; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_NUMPK_ARR, yy->__begin, yy->__end); - l194:; - { int yypos195= yy->__pos, yythunkpos195= yy->__thunkpos; if (!yy__(yy)) goto l195; if (!yymatchChar(yy, ',')) goto l195; if (!yy__(yy)) goto l195; if (!yy_NUMPK(yy)) goto l195; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_NUMPK_ARR, yy->__begin, yy->__end); goto l194; - l195:; yy->__pos= yypos195; yy->__thunkpos= yythunkpos195; - } goto l193; - l192:; yy->__pos= yypos192; yy->__thunkpos= yythunkpos192; +YY_RULE(int) yy_NUMPK_ARR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "NUMPK_ARR")); + if (!yy_SARRJ(yy)) { + goto l194; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_NUMPK_ARR, yy->__begin, yy->__end); + if (!yy__(yy)) { + goto l194; } - l193:; if (!yy__(yy)) goto l191; if (!yymatchChar(yy, ']')) goto l191; yyDo(yy, yy_4_NUMPK_ARR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NUMPK_ARR", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + { + int yypos195 = yy->__pos, yythunkpos195 = yy->__thunkpos; + if (!yy_NUMPK(yy)) { + goto l195; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_NUMPK_ARR, yy->__begin, yy->__end); +l197: + ; + { + int yypos198 = yy->__pos, yythunkpos198 = yy->__thunkpos; + if (!yy__(yy)) { + goto l198; + } + if (!yymatchChar(yy, ',')) { + goto l198; + } + if (!yy__(yy)) { + goto l198; + } + if (!yy_NUMPK(yy)) { + goto l198; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_NUMPK_ARR, yy->__begin, yy->__end); + goto l197; +l198: + ; + yy->__pos = yypos198; + yy->__thunkpos = yythunkpos198; + } goto l196; +l195: + ; + yy->__pos = yypos195; + yy->__thunkpos = yythunkpos195; + } +l196: + ; + if (!yy__(yy)) { + goto l194; + } + if (!yymatchChar(yy, ']')) { + goto l194; + } + yyDo(yy, yy_4_NUMPK_ARR, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "NUMPK_ARR", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l191:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUMPK_ARR", yy->__buf+yy->__pos)); +l194: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUMPK_ARR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_NUMPK(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "NUMPK")); yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_NUMPK(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "NUMPK")); + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l196; + if (!(YY_BEGIN)) { + goto l199; + } #undef yytext #undef yyleng - } if (!yy_NUMI(yy)) goto l196; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_NUMI(yy)) { + goto l199; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l196; + if (!(YY_END)) { + goto l199; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_NUMPK, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "NUMPK", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "NUMPK", yy->__buf + yy->__pos)); return 1; - l196:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NUMPK", yy->__buf+yy->__pos)); +l199: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NUMPK", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PLACEHOLDER(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "PLACEHOLDER")); if (!yymatchChar(yy, ':')) goto l197; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_PLACEHOLDER(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "PLACEHOLDER")); + if (!yymatchChar(yy, ':')) { + goto l200; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l197; + if (!(YY_BEGIN)) { + goto l200; + } #undef yytext #undef yyleng } - { int yypos198= yy->__pos, yythunkpos198= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l199; - l200:; - { int yypos201= yy->__pos, yythunkpos201= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l201; goto l200; - l201:; yy->__pos= yypos201; yy->__thunkpos= yythunkpos201; - } goto l198; - l199:; yy->__pos= yypos198; yy->__thunkpos= yythunkpos198; if (!yymatchChar(yy, '?')) goto l197; + { + int yypos201 = yy->__pos, yythunkpos201 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l202; + } +l203: + ; + { + int yypos204 = yy->__pos, yythunkpos204 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\000\377\003\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l204; + } + goto l203; +l204: + ; + yy->__pos = yypos204; + yy->__thunkpos = yythunkpos204; + } goto l201; +l202: + ; + yy->__pos = yypos201; + yy->__thunkpos = yythunkpos201; + if (!yymatchChar(yy, '?')) { + goto l200; + } } - l198:; yyText(yy, yy->__begin, yy->__end); { +l201: + ; + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l197; + if (!(YY_END)) { + goto l200; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_PLACEHOLDER, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PLACEHOLDER", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "PLACEHOLDER", yy->__buf + yy->__pos)); return 1; - l197:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PLACEHOLDER", yy->__buf+yy->__pos)); +l200: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PLACEHOLDER", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTERANCHOR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "FILTERANCHOR")); if (!yymatchChar(yy, '@')) goto l202; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_FILTERANCHOR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "FILTERANCHOR")); + if (!yymatchChar(yy, '@')) { + goto l205; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l202; + if (!(YY_BEGIN)) { + goto l205; + } #undef yytext #undef yyleng - } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l202; - l203:; - { int yypos204= yy->__pos, yythunkpos204= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l204; goto l203; - l204:; yy->__pos= yypos204; yy->__thunkpos= yythunkpos204; - } yyText(yy, yy->__begin, yy->__end); { + } if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l205; + } +l206: + ; + { + int yypos207 = yy->__pos, yythunkpos207 = yy->__thunkpos; + if (!yymatchClass(yy, + (unsigned char*) + "\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) + { + goto l207; + } + goto l206; +l207: + ; + yy->__pos = yypos207; + yy->__thunkpos = yythunkpos207; + } yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l202; + if (!(YY_END)) { + goto l205; + } #undef yytext #undef yyleng } yyDo(yy, yy_1_FILTERANCHOR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "FILTERANCHOR", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "FILTERANCHOR", yy->__buf + yy->__pos)); return 1; - l202:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTERANCHOR", yy->__buf+yy->__pos)); +l205: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTERANCHOR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTEREXPR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 3, 0); - yyprintf((stderr, "%s\n", "FILTEREXPR")); if (!yy_FILTERFACTOR(yy)) goto l205; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_1_FILTEREXPR, yy->__begin, yy->__end); - l206:; - { int yypos207= yy->__pos, yythunkpos207= yy->__thunkpos; if (!yy___(yy)) goto l207; if (!yy_FILTERJOIN(yy)) goto l207; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_FILTEREXPR, yy->__begin, yy->__end); if (!yy___(yy)) goto l207; if (!yy_FILTERFACTOR(yy)) goto l207; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_FILTEREXPR, yy->__begin, yy->__end); goto l206; - l207:; yy->__pos= yypos207; yy->__thunkpos= yythunkpos207; +YY_RULE(int) yy_FILTEREXPR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 3, 0); + yyprintf((stderr, "%s\n", "FILTEREXPR")); + if (!yy_FILTERFACTOR(yy)) { + goto l208; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_1_FILTEREXPR, yy->__begin, yy->__end); +l209: + ; + { + int yypos210 = yy->__pos, yythunkpos210 = yy->__thunkpos; + if (!yy___(yy)) { + goto l210; + } + if (!yy_FILTERJOIN(yy)) { + goto l210; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_2_FILTEREXPR, yy->__begin, yy->__end); + if (!yy___(yy)) { + goto l210; + } + if (!yy_FILTERFACTOR(yy)) { + goto l210; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_FILTEREXPR, yy->__begin, yy->__end); + goto l209; +l210: + ; + yy->__pos = yypos210; + yy->__thunkpos = yythunkpos210; } yyDo(yy, yy_4_FILTEREXPR, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "FILTEREXPR", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 3, 0); + yyprintf((stderr, " ok %s @ %s\n", "FILTEREXPR", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 3, 0); return 1; - l205:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTEREXPR", yy->__buf+yy->__pos)); +l208: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTEREXPR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_FILTEREXPR_PK(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); +YY_RULE(int) yy_FILTEREXPR_PK(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 2, 0); yyprintf((stderr, "%s\n", "FILTEREXPR_PK")); - { int yypos209= yy->__pos, yythunkpos209= yy->__thunkpos; if (!yy_FILTERANCHOR(yy)) goto l209; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_1_FILTEREXPR_PK, yy->__begin, yy->__end); goto l210; - l209:; yy->__pos= yypos209; yy->__thunkpos= yythunkpos209; + { + int yypos212 = yy->__pos, yythunkpos212 = yy->__thunkpos; + if (!yy_FILTERANCHOR(yy)) { + goto l212; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_1_FILTEREXPR_PK, yy->__begin, yy->__end); + goto l213; +l212: + ; + yy->__pos = yypos212; + yy->__thunkpos = yythunkpos212; + } +l213: + ; + if (!yymatchChar(yy, '/')) { + goto l211; } - l210:; if (!yymatchChar(yy, '/')) goto l208; if (!yy__(yy)) goto l208; if (!yymatchChar(yy, '=')) goto l208; if (!yy__(yy)) goto l208; - { int yypos211= yy->__pos, yythunkpos211= yy->__thunkpos; if (!yy_PLACEHOLDER(yy)) goto l212; yyDo(yy, yySet, -1, 0); goto l211; - l212:; yy->__pos= yypos211; yy->__thunkpos= yythunkpos211; if (!yy_NUMPK(yy)) goto l213; yyDo(yy, yySet, -1, 0); goto l211; - l213:; yy->__pos= yypos211; yy->__thunkpos= yythunkpos211; if (!yy_NUMPK_ARR(yy)) goto l208; yyDo(yy, yySet, -1, 0); + if (!yy__(yy)) { + goto l211; } - l211:; yyDo(yy, yy_2_FILTEREXPR_PK, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "FILTEREXPR_PK", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); + if (!yymatchChar(yy, '=')) { + goto l211; + } + if (!yy__(yy)) { + goto l211; + } + { + int yypos214 = yy->__pos, yythunkpos214 = yy->__thunkpos; + if (!yy_PLACEHOLDER(yy)) { + goto l215; + } + yyDo(yy, yySet, -1, 0); + goto l214; +l215: + ; + yy->__pos = yypos214; + yy->__thunkpos = yythunkpos214; + if (!yy_NUMPK(yy)) { + goto l216; + } + yyDo(yy, yySet, -1, 0); + goto l214; +l216: + ; + yy->__pos = yypos214; + yy->__thunkpos = yythunkpos214; + if (!yy_NUMPK_ARR(yy)) { + goto l211; + } + yyDo(yy, yySet, -1, 0); + } +l214: + ; + yyDo(yy, yy_2_FILTEREXPR_PK, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "FILTEREXPR_PK", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 2, 0); return 1; - l208:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "FILTEREXPR_PK", yy->__buf+yy->__pos)); +l211: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "FILTEREXPR_PK", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_EOF(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_EOF(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "EOF")); - { int yypos215= yy->__pos, yythunkpos215= yy->__thunkpos; if (!yymatchDot(yy)) goto l215; goto l214; - l215:; yy->__pos= yypos215; yy->__thunkpos= yythunkpos215; + { + int yypos218 = yy->__pos, yythunkpos218 = yy->__thunkpos; + if (!yymatchDot(yy)) { + goto l218; + } + goto l217; +l218: + ; + yy->__pos = yypos218; + yy->__thunkpos = yythunkpos218; } - yyprintf((stderr, " ok %s @ %s\n", "EOF", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "EOF", yy->__buf + yy->__pos)); return 1; - l214:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EOF", yy->__buf+yy->__pos)); +l217: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EOF", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_OPTS(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "OPTS")); if (!yymatchChar(yy, '|')) goto l216; if (!yy__(yy)) goto l216; if (!yy_OPT(yy)) goto l216; - l217:; - { int yypos218= yy->__pos, yythunkpos218= yy->__thunkpos; if (!yy___(yy)) goto l218; if (!yy_OPT(yy)) goto l218; goto l217; - l218:; yy->__pos= yypos218; yy->__thunkpos= yythunkpos218; +YY_RULE(int) yy_OPTS(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "OPTS")); + if (!yymatchChar(yy, '|')) { + goto l219; + } + if (!yy__(yy)) { + goto l219; + } + if (!yy_OPT(yy)) { + goto l219; } - yyprintf((stderr, " ok %s @ %s\n", "OPTS", yy->__buf+yy->__pos)); +l220: + ; + { + int yypos221 = yy->__pos, yythunkpos221 = yy->__thunkpos; + if (!yy___(yy)) { + goto l221; + } + if (!yy_OPT(yy)) { + goto l221; + } + goto l220; +l221: + ; + yy->__pos = yypos221; + yy->__thunkpos = yythunkpos221; + } + yyprintf((stderr, " ok %s @ %s\n", "OPTS", yy->__buf + yy->__pos)); return 1; - l216:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OPTS", yy->__buf+yy->__pos)); +l219: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OPTS", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_PROJECTION(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); - yyprintf((stderr, "%s\n", "PROJECTION")); if (!yymatchChar(yy, '|')) goto l219; if (!yy__(yy)) goto l219; if (!yy_PROJNODES(yy)) goto l219; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_1_PROJECTION, yy->__begin, yy->__end); - l220:; - { int yypos221= yy->__pos, yythunkpos221= yy->__thunkpos; if (!yy__(yy)) goto l221; yyText(yy, yy->__begin, yy->__end); { +YY_RULE(int) yy_PROJECTION(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 2, 0); + yyprintf((stderr, "%s\n", "PROJECTION")); + if (!yymatchChar(yy, '|')) { + goto l222; + } + if (!yy__(yy)) { + goto l222; + } + if (!yy_PROJNODES(yy)) { + goto l222; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_1_PROJECTION, yy->__begin, yy->__end); +l223: + ; + { + int yypos224 = yy->__pos, yythunkpos224 = yy->__thunkpos; + if (!yy__(yy)) { + goto l224; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l221; + if (!(YY_BEGIN)) { + goto l224; + } #undef yytext #undef yyleng - } if (!yy_PROJOIN(yy)) goto l221; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_PROJOIN(yy)) { + goto l224; + } + yyText(yy, yy->__begin, yy->__end); + { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l221; + if (!(YY_END)) { + goto l224; + } #undef yytext #undef yyleng - } yyDo(yy, yy_2_PROJECTION, yy->__begin, yy->__end); if (!yy__(yy)) goto l221; if (!yy_PROJNODES(yy)) goto l221; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_3_PROJECTION, yy->__begin, yy->__end); goto l220; - l221:; yy->__pos= yypos221; yy->__thunkpos= yythunkpos221; + } yyDo(yy, yy_2_PROJECTION, yy->__begin, yy->__end); + if (!yy__(yy)) { + goto l224; + } + if (!yy_PROJNODES(yy)) { + goto l224; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_3_PROJECTION, yy->__begin, yy->__end); + goto l223; +l224: + ; + yy->__pos = yypos224; + yy->__thunkpos = yythunkpos224; } yyDo(yy, yy_4_PROJECTION, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "PROJECTION", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); + yyprintf((stderr, " ok %s @ %s\n", "PROJECTION", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 2, 0); return 1; - l219:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PROJECTION", yy->__buf+yy->__pos)); +l222: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PROJECTION", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_UPSERT(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "UPSERT")); if (!yymatchString(yy, "upsert")) goto l222; if (!yy___(yy)) goto l222; - { int yypos223= yy->__pos, yythunkpos223= yy->__thunkpos; if (!yy_PLACEHOLDER(yy)) goto l224; goto l223; - l224:; yy->__pos= yypos223; yy->__thunkpos= yythunkpos223; if (!yy_OBJJ(yy)) goto l225; goto l223; - l225:; yy->__pos= yypos223; yy->__thunkpos= yythunkpos223; if (!yy_ARRJ(yy)) goto l222; +YY_RULE(int) yy_UPSERT(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "UPSERT")); + if (!yymatchString(yy, "upsert")) { + goto l225; + } + if (!yy___(yy)) { + goto l225; } - l223:; - yyprintf((stderr, " ok %s @ %s\n", "UPSERT", yy->__buf+yy->__pos)); + { + int yypos226 = yy->__pos, yythunkpos226 = yy->__thunkpos; + if (!yy_PLACEHOLDER(yy)) { + goto l227; + } + goto l226; +l227: + ; + yy->__pos = yypos226; + yy->__thunkpos = yythunkpos226; + if (!yy_OBJJ(yy)) { + goto l228; + } + goto l226; +l228: + ; + yy->__pos = yypos226; + yy->__thunkpos = yythunkpos226; + if (!yy_ARRJ(yy)) { + goto l225; + } + } +l226: + ; + yyprintf((stderr, " ok %s @ %s\n", "UPSERT", yy->__buf + yy->__pos)); return 1; - l222:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "UPSERT", yy->__buf+yy->__pos)); +l225: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "UPSERT", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_APPLY(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "APPLY")); if (!yymatchString(yy, "apply")) goto l226; if (!yy___(yy)) goto l226; - { int yypos227= yy->__pos, yythunkpos227= yy->__thunkpos; if (!yy_PLACEHOLDER(yy)) goto l228; goto l227; - l228:; yy->__pos= yypos227; yy->__thunkpos= yythunkpos227; if (!yy_OBJJ(yy)) goto l229; goto l227; - l229:; yy->__pos= yypos227; yy->__thunkpos= yythunkpos227; if (!yy_ARRJ(yy)) goto l226; +YY_RULE(int) yy_APPLY(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyprintf((stderr, "%s\n", "APPLY")); + if (!yymatchString(yy, "apply")) { + goto l229; + } + if (!yy___(yy)) { + goto l229; } - l227:; - yyprintf((stderr, " ok %s @ %s\n", "APPLY", yy->__buf+yy->__pos)); + { + int yypos230 = yy->__pos, yythunkpos230 = yy->__thunkpos; + if (!yy_PLACEHOLDER(yy)) { + goto l231; + } + goto l230; +l231: + ; + yy->__pos = yypos230; + yy->__thunkpos = yythunkpos230; + if (!yy_OBJJ(yy)) { + goto l232; + } + goto l230; +l232: + ; + yy->__pos = yypos230; + yy->__thunkpos = yythunkpos230; + if (!yy_ARRJ(yy)) { + goto l229; + } + } +l230: + ; + yyprintf((stderr, " ok %s @ %s\n", "APPLY", yy->__buf + yy->__pos)); return 1; - l226:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "APPLY", yy->__buf+yy->__pos)); +l229: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "APPLY", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy__(yycontext *yy) -{ +YY_RULE(int) yy__(yycontext * yy) { yyprintf((stderr, "%s\n", "_")); - l231:; - { int yypos232= yy->__pos, yythunkpos232= yy->__thunkpos; if (!yy_SPACE(yy)) goto l232; goto l231; - l232:; yy->__pos= yypos232; yy->__thunkpos= yythunkpos232; +l234: + ; + { + int yypos235 = yy->__pos, yythunkpos235 = yy->__thunkpos; + if (!yy_SPACE(yy)) { + goto l235; + } + goto l234; +l235: + ; + yy->__pos = yypos235; + yy->__thunkpos = yythunkpos235; } - yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); + yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf + yy->__pos)); return 1; } -YY_RULE(int) yy_QEXPR(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; +YY_RULE(int) yy_QEXPR(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; yyprintf((stderr, "%s\n", "QEXPR")); - { int yypos234= yy->__pos, yythunkpos234= yy->__thunkpos; if (!yy_FILTEREXPR_PK(yy)) goto l235; goto l234; - l235:; yy->__pos= yypos234; yy->__thunkpos= yythunkpos234; if (!yy_FILTEREXPR(yy)) goto l233; + { + int yypos237 = yy->__pos, yythunkpos237 = yy->__thunkpos; + if (!yy_FILTEREXPR_PK(yy)) { + goto l238; + } + goto l237; +l238: + ; + yy->__pos = yypos237; + yy->__thunkpos = yythunkpos237; + if (!yy_FILTEREXPR(yy)) { + goto l236; + } } - l234:; - yyprintf((stderr, " ok %s @ %s\n", "QEXPR", yy->__buf+yy->__pos)); +l237: + ; + yyprintf((stderr, " ok %s @ %s\n", "QEXPR", yy->__buf + yy->__pos)); return 1; - l233:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "QEXPR", yy->__buf+yy->__pos)); +l236: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "QEXPR", yy->__buf + yy->__pos)); return 0; } -YY_RULE(int) yy_QUERY(yycontext *yy) -{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 4, 0); - yyprintf((stderr, "%s\n", "QUERY")); if (!yy_QEXPR(yy)) goto l236; yyDo(yy, yySet, -4, 0); yyDo(yy, yy_1_QUERY, yy->__begin, yy->__end); - { int yypos237= yy->__pos, yythunkpos237= yy->__thunkpos; if (!yy__(yy)) goto l237; if (!yymatchChar(yy, '|')) goto l237; if (!yy__(yy)) goto l237; - { int yypos239= yy->__pos, yythunkpos239= yy->__thunkpos; if (!yy_APPLY(yy)) goto l240; yyDo(yy, yySet, -3, 0); yyDo(yy, yy_2_QUERY, yy->__begin, yy->__end); goto l239; - l240:; yy->__pos= yypos239; yy->__thunkpos= yythunkpos239; if (!yymatchString(yy, "del")) goto l241; yyDo(yy, yy_3_QUERY, yy->__begin, yy->__end); goto l239; - l241:; yy->__pos= yypos239; yy->__thunkpos= yythunkpos239; if (!yy_UPSERT(yy)) goto l237; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_4_QUERY, yy->__begin, yy->__end); - } - l239:; goto l238; - l237:; yy->__pos= yypos237; yy->__thunkpos= yythunkpos237; - } - l238:; - { int yypos242= yy->__pos, yythunkpos242= yy->__thunkpos; if (!yy__(yy)) goto l242; if (!yy_PROJECTION(yy)) goto l242; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_5_QUERY, yy->__begin, yy->__end); goto l243; - l242:; yy->__pos= yypos242; yy->__thunkpos= yythunkpos242; - } - l243:; - { int yypos244= yy->__pos, yythunkpos244= yy->__thunkpos; if (!yy__(yy)) goto l244; if (!yy_OPTS(yy)) goto l244; goto l245; - l244:; yy->__pos= yypos244; yy->__thunkpos= yythunkpos244; +YY_RULE(int) yy_QUERY(yycontext * yy) { + int yypos0 = yy->__pos, yythunkpos0 = yy->__thunkpos; + yyDo(yy, yyPush, 4, 0); + yyprintf((stderr, "%s\n", "QUERY")); + if (!yy_QEXPR(yy)) { + goto l239; } - l245:; if (!yy__(yy)) goto l236; if (!yy_EOF(yy)) goto l236; yyDo(yy, yy_6_QUERY, yy->__begin, yy->__end); - yyprintf((stderr, " ok %s @ %s\n", "QUERY", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 4, 0); + yyDo(yy, yySet, -4, 0); + yyDo(yy, yy_1_QUERY, yy->__begin, yy->__end); + { + int yypos240 = yy->__pos, yythunkpos240 = yy->__thunkpos; + if (!yy__(yy)) { + goto l240; + } + if (!yymatchChar(yy, '|')) { + goto l240; + } + if (!yy__(yy)) { + goto l240; + } + { + int yypos242 = yy->__pos, yythunkpos242 = yy->__thunkpos; + if (!yy_APPLY(yy)) { + goto l243; + } + yyDo(yy, yySet, -3, 0); + yyDo(yy, yy_2_QUERY, yy->__begin, yy->__end); + goto l242; +l243: + ; + yy->__pos = yypos242; + yy->__thunkpos = yythunkpos242; + if (!yymatchString(yy, "del")) { + goto l244; + } + yyDo(yy, yy_3_QUERY, yy->__begin, yy->__end); + goto l242; +l244: + ; + yy->__pos = yypos242; + yy->__thunkpos = yythunkpos242; + if (!yy_UPSERT(yy)) { + goto l240; + } + yyDo(yy, yySet, -2, 0); + yyDo(yy, yy_4_QUERY, yy->__begin, yy->__end); + } +l242: + ; + goto l241; +l240: + ; + yy->__pos = yypos240; + yy->__thunkpos = yythunkpos240; + } +l241: + ; + { + int yypos245 = yy->__pos, yythunkpos245 = yy->__thunkpos; + if (!yy__(yy)) { + goto l245; + } + if (!yy_PROJECTION(yy)) { + goto l245; + } + yyDo(yy, yySet, -1, 0); + yyDo(yy, yy_5_QUERY, yy->__begin, yy->__end); + goto l246; +l245: + ; + yy->__pos = yypos245; + yy->__thunkpos = yythunkpos245; + } +l246: + ; + { + int yypos247 = yy->__pos, yythunkpos247 = yy->__thunkpos; + if (!yy__(yy)) { + goto l247; + } + if (!yy_OPTS(yy)) { + goto l247; + } + goto l248; +l247: + ; + yy->__pos = yypos247; + yy->__thunkpos = yythunkpos247; + } +l248: + ; + if (!yy__(yy)) { + goto l239; + } + if (!yy_EOF(yy)) { + goto l239; + } + yyDo(yy, yy_6_QUERY, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "QUERY", yy->__buf + yy->__pos)); + yyDo(yy, yyPop, 4, 0); return 1; - l236:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "QUERY", yy->__buf+yy->__pos)); +l239: + ; + yy->__pos = yypos0; + yy->__thunkpos = yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "QUERY", yy->__buf + yy->__pos)); return 0; } @@ -3119,45 +5119,42 @@ YY_RULE(int) yy_QUERY(yycontext *yy) typedef int (*yyrule)(yycontext *yy); -YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) -{ +YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) { int yyok; - if (!yyctx->__buflen) - { - yyctx->__buflen= YY_BUFFER_SIZE; - yyctx->__buf= (char *)YY_MALLOC(yyctx, yyctx->__buflen); - yyctx->__textlen= YY_BUFFER_SIZE; - yyctx->__text= (char *)YY_MALLOC(yyctx, yyctx->__textlen); - yyctx->__thunkslen= YY_STACK_SIZE; - yyctx->__thunks= (yythunk *)YY_MALLOC(yyctx, sizeof(yythunk) * yyctx->__thunkslen); - yyctx->__valslen= YY_STACK_SIZE; - yyctx->__vals= (YYSTYPE *)YY_MALLOC(yyctx, sizeof(YYSTYPE) * yyctx->__valslen); - yyctx->__begin= yyctx->__end= yyctx->__pos= yyctx->__limit= yyctx->__thunkpos= 0; - } - yyctx->__begin= yyctx->__end= yyctx->__pos; - yyctx->__thunkpos= 0; - yyctx->__val= yyctx->__vals; - yyok= yystart(yyctx); - if (yyok) yyDone(yyctx); + if (!yyctx->__buflen) { + yyctx->__buflen = YY_BUFFER_SIZE; + yyctx->__buf = (char*) YY_MALLOC(yyctx, yyctx->__buflen); + yyctx->__textlen = YY_BUFFER_SIZE; + yyctx->__text = (char*) YY_MALLOC(yyctx, yyctx->__textlen); + yyctx->__thunkslen = YY_STACK_SIZE; + yyctx->__thunks = (yythunk*) YY_MALLOC(yyctx, sizeof(yythunk) * yyctx->__thunkslen); + yyctx->__valslen = YY_STACK_SIZE; + yyctx->__vals = (YYSTYPE*) YY_MALLOC(yyctx, sizeof(YYSTYPE) * yyctx->__valslen); + yyctx->__begin = yyctx->__end = yyctx->__pos = yyctx->__limit = yyctx->__thunkpos = 0; + } + yyctx->__begin = yyctx->__end = yyctx->__pos; + yyctx->__thunkpos = 0; + yyctx->__val = yyctx->__vals; + yyok = yystart(yyctx); + if (yyok) { + yyDone(yyctx); + } yyCommit(yyctx); return yyok; } -YY_PARSE(int) YYPARSE(YY_CTX_PARAM) -{ +YY_PARSE(int) YYPARSE(YY_CTX_PARAM) { return YYPARSEFROM(YY_CTX_ARG_ yy_QUERY); } -YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) -{ - if (yyctx->__buflen) - { - yyctx->__buflen= 0; - YY_FREE(yyctx, yyctx->__buf); - YY_FREE(yyctx, yyctx->__text); - YY_FREE(yyctx, yyctx->__thunks); - YY_FREE(yyctx, yyctx->__vals); - } +YY_PARSE(yycontext*) YYRELEASE(yycontext * yyctx) { + if (yyctx->__buflen) { + yyctx->__buflen = 0; + YY_FREE(yyctx, yyctx->__buf); + YY_FREE(yyctx, yyctx->__text); + YY_FREE(yyctx, yyctx->__thunks); + YY_FREE(yyctx, yyctx->__vals); + } return yyctx; } diff --git a/src/jql/jqp.h b/src/jql/jqp.h index af09b8b03..2b49c7d50 100644 --- a/src/jql/jqp.h +++ b/src/jql/jqp.h @@ -8,7 +8,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,12 +30,12 @@ *************************************************************************************************/ #include "jql.h" -#include "jbl.h" -#include + +#include +#include + #include #include -#include -#include typedef uint16_t jqp_string_flavours_t; /** Query string parameter placeholder */ @@ -56,6 +56,8 @@ typedef uint16_t jqp_string_flavours_t; #define JQP_STR_DBL_STAR ((jqp_string_flavours_t) 0x80U) /** Projection JOIN */ #define JQP_STR_PROJOIN ((jqp_string_flavours_t) 0x100U) +/** Projection path */ +#define JQP_STR_PROJPATH ((jqp_string_flavours_t) 0x200U) typedef uint8_t jqp_int_flavours_t; @@ -99,104 +101,104 @@ typedef enum { JQP_OP_PREFIX, } jqp_op_t; -struct JQP_AUX; +struct jqp_aux; -typedef union _JQP_UNIT JQPUNIT; +typedef union jqp_unit JQPUNIT; #define JQP_EXPR_NODE_FLAG_PK 0x01U -#define JQP_EXPR_NODE_HEAD \ - jqp_unit_t type; \ - struct JQP_EXPR_NODE *next; \ - struct JQP_JOIN *join; \ - void *opaque; \ - uint8_t flags; +#define JQP_EXPR_NODE_HEAD \ + jqp_unit_t type; \ + struct jqp_expr_node *next; \ + struct jqp_join *join; \ + void *opaque; \ + uint8_t flags; -typedef struct JQP_EXPR_NODE { // Base for JQP_FILTER +typedef struct jqp_expr_node { // Base for JQP_FILTER JQP_EXPR_NODE_HEAD - struct JQP_EXPR_NODE *chain; + struct jqp_expr_node *chain; } JQP_EXPR_NODE; -typedef struct JQP_EXPR_NODE_PK { +typedef struct jqp_expr_node_pk { JQP_EXPR_NODE_HEAD - struct JQP_EXPR_NODE *chain; // Not used, plased for JQP_EXPR_NODE compatibility + struct jqp_expr_node *chain; // Not used, plased for JQP_EXPR_NODE compatibility const char *anchor; JQPUNIT *argument; } JQP_EXPR_NODE_PK; -typedef struct JQP_FILTER { +typedef struct jqp_filter { JQP_EXPR_NODE_HEAD const char *anchor; - struct JQP_NODE *node; + struct jqp_node *node; } JQP_FILTER; -typedef struct JQP_JSON { - jqp_unit_t type; - struct _JBL_NODE jn; +typedef struct jqp_json { + jqp_unit_t type; + struct jbl_node jn; void *opaque; } JQP_JSON; -typedef struct JQP_NODE { +typedef struct jqp_node { jqp_unit_t type; jqp_node_type_t ntype; - struct JQP_NODE *next; + struct jqp_node *next; JQPUNIT *value; int start; // Used in query matching int end; // Used in query matching } JQP_NODE; -typedef struct JQP_STRING { +typedef struct jqp_string { jqp_unit_t type; jqp_string_flavours_t flavour; const char *value; - struct JQP_STRING *next; - struct JQP_STRING *subnext; - struct JQP_STRING *placeholder_next; + struct jqp_string *next; + struct jqp_string *subnext; + struct jqp_string *placeholder_next; void *opaque; } JQP_STRING; -typedef struct JQP_INTEGER { +typedef struct jqp_integer { jqp_unit_t type; jqp_int_flavours_t flavour; int64_t value; void *opaque; } JQP_INTEGER; -typedef struct JQP_DOUBLE { +typedef struct jqp_double { jqp_unit_t type; jqp_int_flavours_t flavour; double value; void *opaque; } JQP_DOUBLE; -typedef struct JQP_OP { +typedef struct jqp_op { jqp_unit_t type; bool negate; jqp_op_t value; - struct JQP_OP *next; + struct jqp_op *next; void *opaque; } JQP_OP; -typedef struct JQP_JOIN { +typedef struct jqp_join { jqp_unit_t type; bool negate; jqp_op_t value; } JQP_JOIN; -typedef struct JQP_EXPR { +typedef struct jqp_expr { jqp_unit_t type; - struct JQP_JOIN *join; - struct JQP_OP *op; + struct jqp_join *join; + struct jqp_op *op; JQPUNIT *left; JQPUNIT *right; - struct JQP_EXPR *next; + struct jqp_expr *next; bool prematched; } JQP_EXPR; -typedef struct JQP_PROJECTION { +typedef struct jqp_projection { jqp_unit_t type; - struct JQP_STRING *value; - struct JQP_PROJECTION *next; + struct jqp_string *value; + struct jqp_projection *next; int16_t pos; // Current matching position, used in jql.c#_jql_project int16_t cnt; // Number of projection sections, used in jql.c#_jql_project @@ -206,28 +208,28 @@ typedef struct JQP_PROJECTION { uint8_t flags; } JQP_PROJECTION; -typedef struct JQP_QUERY { +typedef struct jqp_query { jqp_unit_t type; - struct JQP_AUX *aux; + struct jqp_aux *aux; } JQP_QUERY; //-- -union _JQP_UNIT { +union jqp_unit { jqp_unit_t type; - struct JQP_QUERY query; - struct JQP_EXPR_NODE exprnode; - struct JQP_EXPR_NODE_PK exprnode_pk; - struct JQP_FILTER filter; - struct JQP_NODE node; - struct JQP_EXPR expr; - struct JQP_JOIN join; - struct JQP_OP op; - struct JQP_STRING string; - struct JQP_INTEGER intval; - struct JQP_DOUBLE dblval; - struct JQP_JSON json; - struct JQP_PROJECTION projection; + struct jqp_query query; + struct jqp_expr_node exprnode; + struct jqp_expr_node_pk exprnode_pk; + struct jqp_filter filter; + struct jqp_node node; + struct jqp_expr expr; + struct jqp_join join; + struct jqp_op op; + struct jqp_string string; + struct jqp_integer intval; + struct jqp_double dblval; + struct jqp_json json; + struct jqp_projection projection; }; typedef enum { @@ -237,15 +239,15 @@ typedef enum { STACK_FLOAT, } jqp_stack_t; -typedef struct JQP_STACK { +typedef struct jqp_stack { jqp_stack_t type; - struct JQP_STACK *next; - struct JQP_STACK *prev; + struct jqp_stack *next; + struct jqp_stack *prev; union { - JQPUNIT *unit; - char *str; - int64_t i64; - double f64; + union jqp_unit *unit; + char *str; + int64_t i64; + double f64; }; } JQP_STACK; @@ -261,50 +263,50 @@ typedef uint8_t jqp_query_mode_t; #define JQP_QRY_AGGREGATE (JQP_QRY_COUNT) -typedef struct JQP_AUX { +typedef struct jqp_aux { int pos; int stackn; int num_placeholders; int orderby_num; /**< Number of order-by blocks */ iwrc rc; jmp_buf fatal_jmp; - const char *buf; - IWXSTR *xerr; - IWPOOL *pool; - struct JQP_QUERY *query; - JQP_STACK *stack; + const char *buf; + struct iwxstr *xerr; + struct iwpool *pool; + struct jqp_query *query; + struct jqp_stack *stack; jql_create_mode_t mode; // - struct JQP_EXPR_NODE *expr; - struct JQP_PROJECTION *projection; - JQP_STRING *start_placeholder; - JQP_STRING *end_placeholder; - JQP_STRING *orderby; - JBL_PTR *orderby_ptrs; /**< Order-by pointers, orderby_num - number of pointers allocated */ - JQP_OP *start_op; - JQP_OP *end_op; - JQPUNIT *skip; - JQPUNIT *limit; - JBL_NODE apply; - const char *apply_placeholder; - const char *first_anchor; + struct jqp_expr_node *expr; + struct jqp_projection *projection; + struct jqp_string *start_placeholder; + struct jqp_string *end_placeholder; + struct jqp_string *orderby; + struct jbl_ptr **orderby_ptrs; /**< Order-by pointers, orderby_num - number of pointers allocated */ + struct jqp_op *start_op; + struct jqp_op *end_op; + union jqp_unit *skip; + union jqp_unit *limit; + struct jbl_node *apply; + const char *apply_placeholder; + const char *first_anchor; jqp_query_mode_t qmode; - bool negate; - bool has_keep_projections; - bool has_exclude_all_projection; - JQP_STACK stackpool[JQP_AUX_STACKPOOL_NUM]; + bool negate; + bool has_keep_projections; + bool has_exclude_all_projection; + struct jqp_stack stackpool[JQP_AUX_STACKPOOL_NUM]; } JQP_AUX; -iwrc jqp_aux_create(JQP_AUX **auxp, const char *input); +iwrc jqp_aux_create(struct jqp_aux **auxp, const char *input); -void jqp_aux_destroy(JQP_AUX **auxp); +void jqp_aux_destroy(struct jqp_aux **auxp); -iwrc jqp_parse(JQP_AUX *aux); +iwrc jqp_parse(struct jqp_aux *aux); -iwrc jqp_print_query(const JQP_QUERY *q, jbl_json_printer pt, void *op); +iwrc jqp_print_query(const struct jqp_query *q, jbl_json_printer pt, void *op); -iwrc jqp_alloc_orderby_pointers(const JQP_QUERY *q, JBL_PTR *optr, size_t *nptr); +iwrc jqp_alloc_orderby_pointers(const struct jqp_query *q, struct jbl_ptr **optr, size_t *nptr); -iwrc jqp_print_filter_node_expr(const JQP_EXPR *e, jbl_json_printer pt, void *op); +iwrc jqp_print_filter_node_expr(const struct jqp_expr *e, jbl_json_printer pt, void *op); #endif diff --git a/src/jql/jqp.leg b/src/jql/jqp.leg index 63eff7e5a..2ad1de0de 100644 --- a/src/jql/jqp.leg +++ b/src/jql/jqp.leg @@ -1,6 +1,6 @@ %{ #include "jqp.h" -#include "jbl.h" +#include #define YY_CTX_LOCAL 1 @@ -133,7 +133,7 @@ PROJNODE = '/' (PROJFIELDS | PROJPROP) PROJFIELDS = ('{' _ sp:PROJPROP { _jqp_unit_push(yy, sp); } (_ ',' _ p:PROJPROP { _jqp_unit_push(yy, p); } )* _ '}') { $$ = _jqp_pop_projfields_chain(yy, sp); } -PROJPROP = STRN | PSTRP +PROJPROP = STRN | PLACEHOLDER | PSTRP PROJOIN = ('+' | '-') @@ -238,7 +238,7 @@ NUMI = '0' | [1-9] [0-9]* NUMF = '.' [0-9]+ -NUME = [eE] [+-]? [0-9]+ +NUME = [eE] [+\-]? [0-9]+ _ = SPACE* diff --git a/src/jql/tests/jql_test1.c b/src/jql/tests/jql_test1.c index c36d28fbe..a25e0c1b8 100644 --- a/src/jql/tests/jql_test1.c +++ b/src/jql/tests/jql_test1.c @@ -1,7 +1,7 @@ #include "jqp.h" #include "ejdb2_internal.h" -#include -#include +#include +#include #include #include @@ -66,8 +66,7 @@ void _jql_test1_1(int num, iwrc expected) { jqp_aux_destroy(&aux); } -void jql_test1_1() { - +static void jql_test1_1(void) { _jql_test1_1(22, 0); for (int i = 0; i <= 10; ++i) { @@ -100,7 +99,7 @@ static void _jql_test1_2(const char *jsondata, const char *q, bool match) { free(json); } -void jql_test1_2() { +static void jql_test1_2(void) { _jql_test1_2("{}", "/*", true); _jql_test1_2("{}", "/**", true); _jql_test1_2("{'foo':{'bar':22}}", "/*", true); @@ -249,8 +248,7 @@ static void _jql_test1_3(bool has_apply_or_project, const char *jsondata, const iwpool_destroy(pool); } -void jql_test1_3() { - +static void jql_test1_3(void) { _jql_test1_3(true, "{'foo':{'bar':22}}", "/foo/bar | apply [{'op':'add', 'path':'/baz', 'value':'qux'}]", "{'foo':{'bar':22},'baz':'qux'}"); @@ -261,8 +259,7 @@ void jql_test1_3() { } // Test projections -void jql_test_1_4() { - +static void jql_test_1_4(void) { _jql_test1_3(false, "{'foo':{'bar':22}}", "/** | all", "{'foo':{'bar':22}}"); _jql_test1_3(false, "{'foo':{'bar':22}}", "/** | all+all + all", "{'foo':{'bar':22}}"); _jql_test1_3(true, "{'foo':{'bar':22}}", "/** | all - all", "{}"); @@ -281,6 +278,53 @@ void jql_test_1_4() { _jql_test1_3(true, "{'foo':{'bar':22},'name':'test'}", "/** | all - /name", "{'foo':{'bar':22}}"); } +// Test placeholder projecttion +static void jql_test_1_5(void) { + JQL q = 0; + JBL jbl = 0; + JBL_NODE n = 0, n2 = 0; + IWXSTR *xstr = iwxstr_new(); + IWPOOL *pool = iwpool_create_empty(); + CU_ASSERT_PTR_NOT_NULL_FATAL(pool); + iwrc rc = jql_create(&q, "c1", "/* | /:name+/:?"); + CU_ASSERT_EQUAL_FATAL(rc, 0); + + rc = jql_set_i64(q, 0, 0, 1); + CU_ASSERT_EQUAL(rc, JQL_ERROR_INVALID_PLACEHOLDER_VALUE_TYPE); + + rc = jql_set_str(q, "name", 0, "foo"); + CU_ASSERT_EQUAL_FATAL(rc, 0); + + rc = jql_set_str(q, 0, 0, "baz"); + CU_ASSERT_EQUAL_FATAL(rc, 0); + + rc = jbl_from_json(&jbl, "{\"foo\":1,\"bar\":2,\"baz\":3}"); + CU_ASSERT_EQUAL_FATAL(rc, 0); + bool m = false; + rc = jql_matched(q, jbl, &m); + CU_ASSERT_EQUAL_FATAL(rc, 0); + CU_ASSERT_TRUE(m && jql_has_projection(q)); + + rc = jql_apply_and_project(q, jbl, &n, 0, pool); + CU_ASSERT_EQUAL_FATAL(rc, 0); + + jbn_as_json(n, jbl_xstr_json_printer, xstr, 0); + CU_ASSERT_STRING_EQUAL(iwxstr_ptr(xstr), "{\"foo\":1,\"baz\":3}"); + + jql_destroy(&q); + jbl_destroy(&jbl); + iwpool_destroy(pool); + iwxstr_destroy(xstr); +} + +// https://github.com/Softmotions/ejdb/issues/378 +static void jql_test_1_6(void) { + JQL q = 0; + iwrc rc = jql_create(&q, "c1", "/* | apply {\"pr\":2.2E1,\"b\":1}"); + CU_ASSERT_EQUAL_FATAL(rc, 0); + jql_destroy(&q); +} + int main() { CU_pSuite pSuite = NULL; if (CUE_SUCCESS != CU_initialize_registry()) { @@ -294,7 +338,9 @@ int main() { if ( (NULL == CU_add_test(pSuite, "jql_test1_1", jql_test1_1)) || (NULL == CU_add_test(pSuite, "jql_test1_2", jql_test1_2)) || (NULL == CU_add_test(pSuite, "jql_test1_3", jql_test1_3)) - || (NULL == CU_add_test(pSuite, "jql_test1_4", jql_test_1_4))) { + || (NULL == CU_add_test(pSuite, "jql_test1_4", jql_test_1_4)) + || (NULL == CU_add_test(pSuite, "jql_test1_5", jql_test_1_5)) + || (NULL == CU_add_test(pSuite, "jql_test1_6", jql_test_1_6))) { CU_cleanup_registry(); return CU_get_error(); } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 78bc33406..575369810 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -8,6 +8,7 @@ set(TESTS ejdb_test1 ejdb_test2 ejdb_test3 ejdb_test4 + ejdb_test5 ) foreach (TN IN ITEMS ${TESTS}) diff --git a/src/tests/ejdb_test.h b/src/tests/ejdb_test.h index 3c486823b..5dc64ee86 100644 --- a/src/tests/ejdb_test.h +++ b/src/tests/ejdb_test.h @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/tests/ejdb_test1.c b/src/tests/ejdb_test1.c index e2e35800c..77790d20a 100644 --- a/src/tests/ejdb_test1.c +++ b/src/tests/ejdb_test1.c @@ -1,6 +1,6 @@ #include "ejdb2.h" #include "ejdb_test.h" -#include +#include #include int init_suite() { @@ -14,11 +14,11 @@ int clean_suite() { void ejdb_test1_3() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test1_3.db", + .kv = { + .path = "ejdb_test1_3.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; JBL jbl; @@ -56,11 +56,11 @@ void ejdb_test1_3() { void ejdb_test1_2() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test1_2.db", + .kv = { + .path = "ejdb_test1_2.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; JBL jbl, at, meta; @@ -233,11 +233,11 @@ void ejdb_test1_2() { void ejdb_test1_1() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test1_1.db", + .kv = { + .path = "ejdb_test1_1.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; JBL meta, jbl; diff --git a/src/tests/ejdb_test2.c b/src/tests/ejdb_test2.c index e61642896..62c24b35d 100644 --- a/src/tests/ejdb_test2.c +++ b/src/tests/ejdb_test2.c @@ -14,13 +14,13 @@ int clean_suite() { // Test document sorting overflow on disk static void ejdb_test2_2() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test2_2.db", - .oflags = IWKV_TRUNC + .kv = { + .path = "ejdb_test2_2.db", + .oflags = IWKV_TRUNC }, .document_buffer_sz = 16 * 1024, // 16K - .sort_buffer_sz = 1024 * 1024, // 1M - .no_wal = true + .sort_buffer_sz = 1024 * 1024, // 1M + .no_wal = true }; EJDB db; EJDB_LIST list = 0; @@ -67,7 +67,7 @@ struct TEST21_1 { IWXSTR *xstr; }; -static iwrc ejdb_test2_1_exec_visitor1(struct _EJDB_EXEC *ctx, const EJDB_DOC doc, int64_t *step) { +static iwrc ejdb_test2_1_exec_visitor1(struct ejdb_exec *ctx, const EJDB_DOC doc, int64_t *step) { struct TEST21_1 *tc = ctx->opaque; JBL jbl; iwrc rc = jbl_at(doc->raw, "/f", &jbl); @@ -81,18 +81,18 @@ static iwrc ejdb_test2_1_exec_visitor1(struct _EJDB_EXEC *ctx, const EJDB_DOC do *step = -1; } jbl_destroy(&jbl); - iwxstr_printf(tc->xstr, "%lld", llv); + iwxstr_printf(tc->xstr, "%" PRId64, llv); tc->cnt++; return rc; } static void ejdb_test2_1() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test2_1.db", + .kv = { + .path = "ejdb_test2_1.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; @@ -270,9 +270,9 @@ static void ejdb_test2_1() { rc = jql_create(&q, "a", "/f"); CU_ASSERT_EQUAL_FATAL(rc, 0); EJDB_EXEC ux = { - .db = db, - .q = q, - .opaque = &tc, + .db = db, + .q = q, + .opaque = &tc, .visitor = ejdb_test2_1_exec_visitor1 }; rc = ejdb_exec(&ux); diff --git a/src/tests/ejdb_test3.c b/src/tests/ejdb_test3.c index 170912a1b..d4d3761c1 100644 --- a/src/tests/ejdb_test3.c +++ b/src/tests/ejdb_test3.c @@ -12,11 +12,11 @@ int clean_suite() { static void ejdb_test3_1() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_1.db", + .kv = { + .path = "ejdb_test3_1.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; @@ -340,11 +340,11 @@ static void ejdb_test3_1() { static void ejdb_test3_2() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_2.db", + .kv = { + .path = "ejdb_test3_2.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; @@ -520,11 +520,11 @@ static void ejdb_test3_2() { static void ejdb_test3_3() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_3.db", + .kv = { + .path = "ejdb_test3_3.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; char dbuf[1024]; @@ -543,7 +543,6 @@ static void ejdb_test3_3() { CU_ASSERT_EQUAL_FATAL(rc, 0); char *data[] = { - // len: 200 "Ar4prlJssa2ckf0IpmDuRBZ2b0Q6PtPdTacjWFFuO23CiCjdyfHaliz9JaqK1HFEeaneiMO" "7sNh87oDLVkvz7TnOV22v0njqmmd6b8DSfzaCwxFxcqrF7MinjUvJvct1Fr07MJWeG7C6SP" @@ -691,11 +690,11 @@ static void ejdb_test3_3() { // Test array index static void ejdb_test3_4() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_4.db", + .kv = { + .path = "ejdb_test3_4.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; char dbuf[1024]; @@ -837,11 +836,11 @@ static void ejdb_test3_4() { void ejdb_test3_5() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_5.db", + .kv = { + .path = "ejdb_test3_5.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; EJDB_LIST list = 0; @@ -932,8 +931,8 @@ static void jql_free_str(void *ptr, void *op) { void ejdb_test3_6() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_6.db", + .kv = { + .path = "ejdb_test3_6.db", .oflags = IWKV_TRUNC } }; @@ -988,8 +987,8 @@ void ejdb_test3_6() { void ejdb_test3_7() { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_7.db", + .kv = { + .path = "ejdb_test3_7.db", .oflags = IWKV_TRUNC } }; @@ -1032,11 +1031,11 @@ void ejdb_test3_7() { void ejdb_test3_8(void) { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_8.db", + .kv = { + .path = "ejdb_test3_8.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; @@ -1121,11 +1120,11 @@ void ejdb_test3_8(void) { static void ejdb_test3_9(void) { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test3_9", + .kv = { + .path = "ejdb_test3_9", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; EJDB_LIST list = 0; diff --git a/src/tests/ejdb_test4.c b/src/tests/ejdb_test4.c index 33a29bffa..f3ba70c4c 100644 --- a/src/tests/ejdb_test4.c +++ b/src/tests/ejdb_test4.c @@ -1,7 +1,7 @@ #include "ejdb_test.h" #include -#include +#include int init_suite(void) { iwrc rc = ejdb_init(); @@ -29,11 +29,11 @@ static void set_apply_int(JQL q, int idx, const char *key, int64_t id) { static void ejdb_test4_1(void) { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test4_1.db", + .kv = { + .path = "ejdb_test4_1.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; @@ -133,11 +133,11 @@ static void ejdb_test4_1(void) { static void ejdb_test4_2(void) { EJDB_OPTS opts = { - .kv = { - .path = "ejdb_test4_2.db", + .kv = { + .path = "ejdb_test4_2.db", .oflags = IWKV_TRUNC }, - .no_wal = true + .no_wal = true }; EJDB db; diff --git a/src/tests/ejdb_test5.c b/src/tests/ejdb_test5.c new file mode 100644 index 000000000..68c99f521 --- /dev/null +++ b/src/tests/ejdb_test5.c @@ -0,0 +1,143 @@ +#include "ejdb_test.h" +#include + +#include +#include +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#undef CHECK +#define CHECK(rc_) \ + if (rc_) \ + { \ + iwlog_ecode_error3(rc_); \ + return 1; \ + } + +#undef print_message +#define print_message(fmt, ...) \ + { \ + iwlog_info("Thread[%u] | " fmt, (unsigned int) 0, ## __VA_ARGS__); \ + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// IWKV_NO_TRIM_ON_CLOSE +iwrc get_ejdb(EJDB *db) { + EJDB_OPTS opts = { + .kv = { + .path = "ejdb_test5.db", + .oflags = IWKV_NO_TRIM_ON_CLOSE | IWKV_TRUNC, + .wal = { + .savepoint_timeout_sec = 5, + .checkpoint_timeout_sec = 10, + .wal_buffer_sz = 4096, + .checkpoint_buffer_sz = 1024 * 1024 + }, + }, + .no_wal = 0, + .sort_buffer_sz = 1024 * 1024, // 1M + .document_buffer_sz = 16 * 1024 // 16K + }; + + print_message("step-1 ejdb_init"); + iwrc rc = ejdb_init(); + CHECK(rc); + + print_message("step-2 ejdb_open"); + rc = ejdb_open(&opts, db); + CHECK(rc); + return 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +iwrc show_db_meta(EJDB db) { + JBL jbl = 0; // Json document + iwrc rc = ejdb_get_meta(db, &jbl); + RCGO(rc, finish); + + fprintf(stderr, "\n"); + rc = jbl_as_json(jbl, jbl_fstream_json_printer, stderr, JBL_PRINT_CODEPOINTS); + RCGO(rc, finish); + fprintf(stderr, "\n"); +finish: + if (jbl) { + jbl_destroy(&jbl); + } + return 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +iwrc add_record_large(EJDB db, char *collection, int total) { + JBL jbl = 0; // Json document + int64_t id; // Document id placeholder + char json[1024]; + for (int ii = 0; ii < total; ii++) { + memset(json, 0, sizeof(json)); + sprintf(json, + "{\"name\":\"Darko\", \"time_\":%d, \"largeValue\": \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"}", + ii); + iwrc rc = jbl_from_json(&jbl, json); + RCGO(rc, finish); + rc = ejdb_put_new(db, collection, jbl, &id); + RCGO(rc, finish); + if (jbl) { + jbl_destroy(&jbl); + jbl = 0; + } + } + +finish: + if (jbl) { + jbl_destroy(&jbl); + } + return 0; +} + +// delete function ///////////////////////////////////////////////////////////////////////////////////////////////////// +iwrc delete_record_large(EJDB db, char *collection, int64_t to, int limit) { + JQL q = 0; + + char deleteSql[128]; + memset(deleteSql, 0, sizeof(deleteSql)); + sprintf(deleteSql, "(/[time_ <= %lld ]) | del | asc /time_ limit %d count", (long long) to, limit); + print_message("sql=%s\n", deleteSql); + iwrc rc = jql_create(&q, collection, deleteSql); + RCGO(rc, finish); + + EJDB_EXEC ux = { + .db = db, + .q = q, + }; + + rc = ejdb_exec(&ux); + RCGO(rc, finish); + print_message("delete successful"); +finish: + if (q) { + jql_destroy(&q); + } + return 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +int main(int argc, char *argv[]) { + EJDB db = 0; + iwrc rc = get_ejdb(&db); + CHECK(rc); + + char *collection = "collection"; + + int addTotal = 20000; + add_record_large(db, collection, addTotal); + + int64_t time = addTotal - 10000; + int limit = 10000; + show_db_meta(db); + delete_record_large(db, collection, time, limit); + show_db_meta(db); + ejdb_close(&db); + return 0; +} diff --git a/src/tests/package.json b/src/tests/package.json index f16ab7ae9..b8769b1f6 100644 --- a/src/tests/package.json +++ b/src/tests/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "@react-native-community/eslint-config": "^0.0.5", - "eslint": "^6.6.0" + "@react-native-community/eslint-config": "^3.1.0", + "eslint": "^8.21.0" } } diff --git a/src/tests/yarn.lock b/src/tests/yarn.lock index 17321dd1f..7ed502f74 100644 --- a/src/tests/yarn.lock +++ b/src/tests/yarn.lock @@ -2,233 +2,480 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d" - integrity sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw== - dependencies: - "@babel/highlight" "^7.0.0" - -"@babel/generator@^7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.7.2.tgz#2f4852d04131a5e17ea4f6645488b5da66ebf3af" - integrity sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ== - dependencies: - "@babel/types" "^7.7.2" +"@ampproject/remapping@^2.1.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" + integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== + dependencies: + "@jridgewell/gen-mapping" "^0.1.0" + "@jridgewell/trace-mapping" "^0.3.9" + +"@babel/code-frame@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" + integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== + dependencies: + "@babel/highlight" "^7.18.6" + +"@babel/compat-data@^7.18.8": + version "7.18.8" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.8.tgz#2483f565faca607b8535590e84e7de323f27764d" + integrity sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ== + +"@babel/core@^7.14.0": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.18.10.tgz#39ad504991d77f1f3da91be0b8b949a5bc466fb8" + integrity sha512-JQM6k6ENcBFKVtWvLavlvi/mPcpYZ3+R+2EySDEMSMbp7Mn4FexlbbJVrx2R7Ijhr01T8gyqrOaABWIOgxeUyw== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.18.10" + "@babel/helper-compilation-targets" "^7.18.9" + "@babel/helper-module-transforms" "^7.18.9" + "@babel/helpers" "^7.18.9" + "@babel/parser" "^7.18.10" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.18.10" + "@babel/types" "^7.18.10" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" + +"@babel/eslint-parser@^7.18.2": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.18.9.tgz#255a63796819a97b7578751bb08ab9f2a375a031" + integrity sha512-KzSGpMBggz4fKbRbWLNyPVTuQr6cmCcBhOyXTw/fieOVaw5oYAwcAj4a7UKcDYCPxQq+CG1NCDZH9e2JTXquiQ== + dependencies: + eslint-scope "^5.1.1" + eslint-visitor-keys "^2.1.0" + semver "^6.3.0" + +"@babel/generator@^7.18.10": + version "7.18.12" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.12.tgz#fa58daa303757bd6f5e4bbca91b342040463d9f4" + integrity sha512-dfQ8ebCN98SvyL7IxNMCUtZQSq5R7kxgN+r8qYTGDmmSion1hX2C0zq2yo1bsCDhXixokv1SAWTZUMYbO/V5zg== + dependencies: + "@babel/types" "^7.18.10" + "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" - lodash "^4.17.13" - source-map "^0.5.0" - -"@babel/helper-function-name@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz#44a5ad151cfff8ed2599c91682dda2ec2c8430a3" - integrity sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q== - dependencies: - "@babel/helper-get-function-arity" "^7.7.0" - "@babel/template" "^7.7.0" - "@babel/types" "^7.7.0" - -"@babel/helper-get-function-arity@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz#c604886bc97287a1d1398092bc666bc3d7d7aa2d" - integrity sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw== - dependencies: - "@babel/types" "^7.7.0" - -"@babel/helper-split-export-declaration@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz#1365e74ea6c614deeb56ebffabd71006a0eb2300" - integrity sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA== - dependencies: - "@babel/types" "^7.7.0" -"@babel/highlight@^7.0.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" - integrity sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ== - dependencies: +"@babel/helper-compilation-targets@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz#69e64f57b524cde3e5ff6cc5a9f4a387ee5563bf" + integrity sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg== + dependencies: + "@babel/compat-data" "^7.18.8" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.20.2" + semver "^6.3.0" + +"@babel/helper-environment-visitor@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" + integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== + +"@babel/helper-function-name@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz#940e6084a55dee867d33b4e487da2676365e86b0" + integrity sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A== + dependencies: + "@babel/template" "^7.18.6" + "@babel/types" "^7.18.9" + +"@babel/helper-hoist-variables@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" + integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-module-imports@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" + integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-module-transforms@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz#5a1079c005135ed627442df31a42887e80fcb712" + integrity sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.18.6" + "@babel/template" "^7.18.6" + "@babel/traverse" "^7.18.9" + "@babel/types" "^7.18.9" + +"@babel/helper-simple-access@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz#d6d8f51f4ac2978068df934b569f08f29788c7ea" + integrity sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-split-export-declaration@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" + integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-string-parser@^7.18.10": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" + integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== + +"@babel/helper-validator-identifier@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" + integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== + +"@babel/helper-validator-option@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" + integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== + +"@babel/helpers@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.18.9.tgz#4bef3b893f253a1eced04516824ede94dcfe7ff9" + integrity sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ== + dependencies: + "@babel/template" "^7.18.6" + "@babel/traverse" "^7.18.9" + "@babel/types" "^7.18.9" + +"@babel/highlight@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" + integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== + dependencies: + "@babel/helper-validator-identifier" "^7.18.6" chalk "^2.0.0" - esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.7.0", "@babel/parser@^7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.2.tgz#ea8334dc77416bfd9473eb470fd00d8245b3943b" - integrity sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w== - -"@babel/template@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.7.0.tgz#4fadc1b8e734d97f56de39c77de76f2562e597d0" - integrity sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.7.0" - "@babel/types" "^7.7.0" - -"@babel/traverse@^7.0.0": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.7.2.tgz#ef0a65e07a2f3c550967366b3d9b62a2dcbeae09" - integrity sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw== - dependencies: - "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.7.2" - "@babel/helper-function-name" "^7.7.0" - "@babel/helper-split-export-declaration" "^7.7.0" - "@babel/parser" "^7.7.2" - "@babel/types" "^7.7.2" +"@babel/parser@^7.18.10", "@babel/parser@^7.18.11": + version "7.18.11" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.11.tgz#68bb07ab3d380affa9a3f96728df07969645d2d9" + integrity sha512-9JKn5vN+hDt0Hdqn1PiJ2guflwP+B6Ga8qbDuoF0PzzVhrzsKIJo8yGqVk6CmMHiMei9w1C1Bp9IMJSIK+HPIQ== + +"@babel/template@^7.18.10", "@babel/template@^7.18.6": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" + integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/parser" "^7.18.10" + "@babel/types" "^7.18.10" + +"@babel/traverse@^7.18.10", "@babel/traverse@^7.18.9", "@babel/traverse@^7.7.4": + version "7.18.11" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.11.tgz#3d51f2afbd83ecf9912bcbb5c4d94e3d2ddaa16f" + integrity sha512-TG9PiM2R/cWCAy6BPJKeHzNbu4lPzOSZpeMfeNErskGpTJx6trEvFaVCbDvpcxwy49BKWmEPwiW8mrysNiDvIQ== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.18.10" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.18.9" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.18.11" + "@babel/types" "^7.18.10" debug "^4.1.0" globals "^11.1.0" - lodash "^4.17.13" -"@babel/types@^7.0.0", "@babel/types@^7.7.0", "@babel/types@^7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.2.tgz#550b82e5571dcd174af576e23f0adba7ffc683f7" - integrity sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA== +"@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.10.tgz#4908e81b6b339ca7c6b7a555a5fc29446f26dde6" + integrity sha512-MJvnbEiiNkpjo+LknnmRrqbY1GPUUggjv+wQVjetM/AONoupqRALB7I6jGqNUAZsKcRIEu2J6FRFvsczljjsaQ== dependencies: - esutils "^2.0.2" - lodash "^4.17.13" + "@babel/helper-string-parser" "^7.18.10" + "@babel/helper-validator-identifier" "^7.18.6" to-fast-properties "^2.0.0" -"@react-native-community/eslint-config@^0.0.5": - version "0.0.5" - resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.5.tgz#584f6493258202a57efc22e7be66966e43832795" - integrity sha512-jwO2tnKaTPTLX5XYXMHGEnFdf543SU7jz98/OF5mDH3b7lP+BOaCD+jVfqqHoDRkcqyPlYiR1CgwVGWpi0vMWg== - dependencies: - "@typescript-eslint/eslint-plugin" "^1.5.0" - "@typescript-eslint/parser" "^1.5.0" - babel-eslint "10.0.1" - eslint-plugin-eslint-comments "^3.1.1" - eslint-plugin-flowtype "2.50.3" - eslint-plugin-jest "22.4.1" - eslint-plugin-prettier "2.6.2" - eslint-plugin-react "7.12.4" - eslint-plugin-react-hooks "^1.5.1" - eslint-plugin-react-native "3.6.0" - prettier "1.16.4" - -"@types/eslint-visitor-keys@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" - integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== +"@eslint/eslintrc@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.0.tgz#29f92c30bb3e771e4a2048c95fa6855392dfac4f" + integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.3.2" + globals "^13.15.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + +"@humanwhocodes/config-array@^0.10.4": + version "0.10.4" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c" + integrity sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw== + dependencies: + "@humanwhocodes/object-schema" "^1.2.1" + debug "^4.1.1" + minimatch "^3.0.4" -"@types/json-schema@^7.0.3": - version "7.0.3" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636" - integrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A== +"@humanwhocodes/gitignore-to-minimatch@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d" + integrity sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA== -"@typescript-eslint/eslint-plugin@^1.5.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.13.0.tgz#22fed9b16ddfeb402fd7bcde56307820f6ebc49f" - integrity sha512-WQHCozMnuNADiqMtsNzp96FNox5sOVpU8Xt4meaT4em8lOG1SrOv92/mUbEHQVh90sldKSfcOc/I0FOb/14G1g== - dependencies: - "@typescript-eslint/experimental-utils" "1.13.0" - eslint-utils "^1.3.1" - functional-red-black-tree "^1.0.1" - regexpp "^2.0.1" - tsutils "^3.7.0" +"@humanwhocodes/object-schema@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@typescript-eslint/experimental-utils@1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz#b08c60d780c0067de2fb44b04b432f540138301e" - integrity sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg== +"@jridgewell/gen-mapping@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" + integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "1.13.0" - eslint-scope "^4.0.0" + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" -"@typescript-eslint/parser@^1.5.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.13.0.tgz#61ac7811ea52791c47dc9fd4dd4a184fae9ac355" - integrity sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ== +"@jridgewell/gen-mapping@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" + integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== dependencies: - "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "1.13.0" - "@typescript-eslint/typescript-estree" "1.13.0" - eslint-visitor-keys "^1.0.0" + "@jridgewell/set-array" "^1.0.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" -"@typescript-eslint/typescript-estree@1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz#8140f17d0f60c03619798f1d628b8434913dc32e" - integrity sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw== +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== + +"@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/trace-mapping@^0.3.9": + version "0.3.15" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz#aba35c48a38d3fd84b37e66c9c0423f9744f9774" + integrity sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g== dependencies: - lodash.unescape "4.0.1" - semver "5.5.0" + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" -acorn-jsx@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384" - integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw== +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" -acorn@^7.1.0: - version "7.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" - integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -ajv@^6.10.0, ajv@^6.10.2: - version "6.10.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" - integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw== +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== dependencies: - fast-deep-equal "^2.0.1" + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@react-native-community/eslint-config@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-3.1.0.tgz#80f9471bae00d0676b98436bbb3a596eca2d69ab" + integrity sha512-LCN0QkMNIHoXp2B/uedxQI2GMLbupkIDKSb/6Q7e+pHp4fHrGIkmixSDR5sbjzeqNIf7a1+VcRxRp9u6qv10Ng== + dependencies: + "@babel/core" "^7.14.0" + "@babel/eslint-parser" "^7.18.2" + "@react-native-community/eslint-plugin" "^1.1.0" + "@typescript-eslint/eslint-plugin" "^5.30.5" + "@typescript-eslint/parser" "^5.30.5" + eslint-config-prettier "^8.5.0" + eslint-plugin-eslint-comments "^3.2.0" + eslint-plugin-ft-flow "^2.0.1" + eslint-plugin-jest "^26.5.3" + eslint-plugin-prettier "^4.2.1" + eslint-plugin-react "^7.30.1" + eslint-plugin-react-hooks "^4.6.0" + eslint-plugin-react-native "^4.0.0" + +"@react-native-community/eslint-plugin@^1.1.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.2.0.tgz#7d6d789ae8edf73dc9bed1246cd48277edea8066" + integrity sha512-o6aam+0Ug1xGK3ABYmBm0B1YuEKfM/5kaoZO0eHbZwSpw9UzDX4G5y4Nx/K20FHqUmJHkZmLvOUFYwN4N+HqKA== + +"@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + +"@typescript-eslint/eslint-plugin@^5.30.5": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.33.0.tgz#059798888720ec52ffa96c5f868e31a8f70fa3ec" + integrity sha512-jHvZNSW2WZ31OPJ3enhLrEKvAZNyAFWZ6rx9tUwaessTc4sx9KmgMNhVcqVAl1ETnT5rU5fpXTLmY9YvC1DCNg== + dependencies: + "@typescript-eslint/scope-manager" "5.33.0" + "@typescript-eslint/type-utils" "5.33.0" + "@typescript-eslint/utils" "5.33.0" + debug "^4.3.4" + functional-red-black-tree "^1.0.1" + ignore "^5.2.0" + regexpp "^3.2.0" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/parser@^5.30.5": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.33.0.tgz#26ec3235b74f0667414613727cb98f9b69dc5383" + integrity sha512-cgM5cJrWmrDV2KpvlcSkelTBASAs1mgqq+IUGKJvFxWrapHpaRy5EXPQz9YaKF3nZ8KY18ILTiVpUtbIac86/w== + dependencies: + "@typescript-eslint/scope-manager" "5.33.0" + "@typescript-eslint/types" "5.33.0" + "@typescript-eslint/typescript-estree" "5.33.0" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@5.33.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.33.0.tgz#509d7fa540a2c58f66bdcfcf278a3fa79002e18d" + integrity sha512-/Jta8yMNpXYpRDl8EwF/M8It2A9sFJTubDo0ATZefGXmOqlaBffEw0ZbkbQ7TNDK6q55NPHFshGBPAZvZkE8Pw== + dependencies: + "@typescript-eslint/types" "5.33.0" + "@typescript-eslint/visitor-keys" "5.33.0" + +"@typescript-eslint/type-utils@5.33.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.33.0.tgz#92ad1fba973c078d23767ce2d8d5a601baaa9338" + integrity sha512-2zB8uEn7hEH2pBeyk3NpzX1p3lF9dKrEbnXq1F7YkpZ6hlyqb2yZujqgRGqXgRBTHWIUG3NGx/WeZk224UKlIA== + dependencies: + "@typescript-eslint/utils" "5.33.0" + debug "^4.3.4" + tsutils "^3.21.0" + +"@typescript-eslint/types@5.33.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.33.0.tgz#d41c584831805554b063791338b0220b613a275b" + integrity sha512-nIMt96JngB4MYFYXpZ/3ZNU4GWPNdBbcB5w2rDOCpXOVUkhtNlG2mmm8uXhubhidRZdwMaMBap7Uk8SZMU/ppw== + +"@typescript-eslint/typescript-estree@5.33.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.0.tgz#02d9c9ade6f4897c09e3508c27de53ad6bfa54cf" + integrity sha512-tqq3MRLlggkJKJUrzM6wltk8NckKyyorCSGMq4eVkyL5sDYzJJcMgZATqmF8fLdsWrW7OjjIZ1m9v81vKcaqwQ== + dependencies: + "@typescript-eslint/types" "5.33.0" + "@typescript-eslint/visitor-keys" "5.33.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/utils@5.33.0", "@typescript-eslint/utils@^5.10.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.33.0.tgz#46797461ce3146e21c095d79518cc0f8ec574038" + integrity sha512-JxOAnXt9oZjXLIiXb5ZIcZXiwVHCkqZgof0O8KPgz7C7y0HS42gi75PdPlqh1Tf109M0fyUw45Ao6JLo7S5AHw== + dependencies: + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.33.0" + "@typescript-eslint/types" "5.33.0" + "@typescript-eslint/typescript-estree" "5.33.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + +"@typescript-eslint/visitor-keys@5.33.0": + version "5.33.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.0.tgz#fbcbb074e460c11046e067bc3384b5d66b555484" + integrity sha512-/XsqCzD4t+Y9p5wd9HZiptuGKBlaZO5showwqODii5C0nZawxWLF+Q6k5wYHBrQv96h6GYKyqqMHCSTqta8Kiw== + dependencies: + "@typescript-eslint/types" "5.33.0" + eslint-visitor-keys "^3.3.0" + +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn@^8.8.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" + integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== + +ajv@^6.10.0, ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-escapes@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.2.1.tgz#4dccdb846c3eee10f6d64dea66273eab90c37228" - integrity sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q== - dependencies: - type-fest "^0.5.2" - -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== -ansi-styles@^3.2.0, ansi-styles@^3.2.1: +ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== +ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: - sprintf-js "~1.0.2" + color-convert "^2.0.1" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== -array-includes@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d" - integrity sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0= +array-includes@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.5.tgz#2c320010db8d31031fd2a5f6b3bbd4b1aad31bdb" + integrity sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ== dependencies: - define-properties "^1.1.2" - es-abstract "^1.7.0" + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" + get-intrinsic "^1.1.1" + is-string "^1.0.7" -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== +array-union@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -babel-eslint@10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed" - integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ== +array.prototype.flatmap@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.0.tgz#a7e8ed4225f4788a70cd910abcf0791e76a5534f" + integrity sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg== dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.0.0" - "@babel/traverse" "^7.0.0" - "@babel/types" "^7.0.0" - eslint-scope "3.7.1" - eslint-visitor-keys "^1.0.0" + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.2" + es-shim-unscopables "^1.0.0" balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== brace-expansion@^1.1.7: version "1.1.11" @@ -238,12 +485,42 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browserslist@^4.20.2: + version "4.21.3" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" + integrity sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ== + dependencies: + caniuse-lite "^1.0.30001370" + electron-to-chromium "^1.4.202" + node-releases "^2.0.6" + update-browserslist-db "^1.0.5" + +call-bind@^1.0.0, call-bind@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: +caniuse-lite@^1.0.30001370: + version "1.0.30001375" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001375.tgz#8e73bc3d1a4c800beb39f3163bf0190d7e5d7672" + integrity sha512-kWIMkNzLYxSvnjy0hL8w1NOaWNr2rn39RTAVyIwcw8juu60bZDWiF1/loOYANzjtJmy6qPgNmn38ro5Pygagdw== + +chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -252,22 +529,13 @@ chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== +chalk@^4.0.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== dependencies: - restore-cursor "^3.1.0" - -cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= + ansi-styles "^4.1.0" + supports-color "^7.1.0" color-convert@^1.9.0: version "1.9.3" @@ -276,46 +544,85 @@ color-convert@^1.9.0: dependencies: color-name "1.1.3" +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== +convert-source-map@^1.7.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" + integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== + dependencies: + safe-buffer "~5.1.1" + +cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" -debug@^4.0.1, debug@^4.1.0: +debug@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: ms "^2.1.1" -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= +debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +deep-is@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -define-properties@^1.1.2, define-properties@^1.1.3: +define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== dependencies: object-keys "^1.0.12" +define-properties@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" + integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== + dependencies: + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + +dir-glob@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== + dependencies: + path-type "^4.0.0" + doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" @@ -330,277 +637,332 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +electron-to-chromium@^1.4.202: + version "1.4.218" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.218.tgz#d6b817b5454499a92c85888b42dc2ad075e4493a" + integrity sha512-INDylKH//YIf2w67D+IjkfVnGVrZ/D94DAU/FPPm6T4jEPbEDQvo9r2wTj0ncFdtJH8+V8BggZTaN8Rzk5wkgw== -es-abstract@^1.15.0, es-abstract@^1.7.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.16.0.tgz#d3a26dc9c3283ac9750dca569586e976d9dcc06d" - integrity sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg== +es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.2, es-abstract@^1.19.5: + version "1.20.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814" + integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA== dependencies: - es-to-primitive "^1.2.0" + call-bind "^1.0.2" + es-to-primitive "^1.2.1" function-bind "^1.1.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.1.1" + get-symbol-description "^1.0.0" has "^1.0.3" - has-symbols "^1.0.0" - is-callable "^1.1.4" - is-regex "^1.0.4" - object-inspect "^1.6.0" + has-property-descriptors "^1.0.0" + has-symbols "^1.0.3" + internal-slot "^1.0.3" + is-callable "^1.2.4" + is-negative-zero "^2.0.2" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + is-string "^1.0.7" + is-weakref "^1.0.2" + object-inspect "^1.12.0" object-keys "^1.1.1" - string.prototype.trimleft "^2.1.0" - string.prototype.trimright "^2.1.0" + object.assign "^4.1.2" + regexp.prototype.flags "^1.4.3" + string.prototype.trimend "^1.0.5" + string.prototype.trimstart "^1.0.5" + unbox-primitive "^1.0.2" -es-to-primitive@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" - integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg== +es-shim-unscopables@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz#702e632193201e3edf8713635d083d378e510241" + integrity sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w== + dependencies: + has "^1.0.3" + +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== dependencies: is-callable "^1.1.4" is-date-object "^1.0.1" is-symbol "^1.0.2" +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -eslint-plugin-eslint-comments@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.1.2.tgz#4ef6c488dbe06aa1627fea107b3e5d059fc8a395" - integrity sha512-QexaqrNeteFfRTad96W+Vi4Zj1KFbkHHNMMaHZEYcovKav6gdomyGzaxSDSL3GoIyUOo078wRAdYlu1caiauIQ== +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + +eslint-plugin-eslint-comments@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa" + integrity sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ== dependencies: escape-string-regexp "^1.0.5" ignore "^5.0.5" -eslint-plugin-flowtype@2.50.3: - version "2.50.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.50.3.tgz#61379d6dce1d010370acd6681740fd913d68175f" - integrity sha512-X+AoKVOr7Re0ko/yEXyM5SSZ0tazc6ffdIOocp2fFUlWoDt7DV0Bz99mngOkAFLOAWjqRA5jPwqUCbrx13XoxQ== +eslint-plugin-ft-flow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-ft-flow/-/eslint-plugin-ft-flow-2.0.1.tgz#57d9a12ef02b7af8f9bd6ccd6bd8fa4034809716" + integrity sha512-dGBnCo+ok6H9p6Vw2oPFEM4vA9IEclRXQQAA/Zws51/L5zr3FDl9FxQiWGfaw0WaTIX5biiAxp/q1W5bGXjlVA== dependencies: - lodash "^4.17.10" + lodash "^4.17.21" + string-natural-compare "^3.0.1" -eslint-plugin-jest@22.4.1: - version "22.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.4.1.tgz#a5fd6f7a2a41388d16f527073b778013c5189a9c" - integrity sha512-gcLfn6P2PrFAVx3AobaOzlIEevpAEf9chTpFZz7bYfc7pz8XRv7vuKTIE4hxPKZSha6XWKKplDQ0x9Pq8xX2mg== +eslint-plugin-jest@^26.5.3: + version "26.8.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.8.2.tgz#42a1248a5ade2bc589eb0f9c4e0608dd89b18cf3" + integrity sha512-67oh0FKaku9y48OpLzL3uK9ckrgLb83Sp5gxxTbtOGDw9lq6D8jw/Psj/9CipkbK406I2M7mvx1q+pv/MdbvxA== + dependencies: + "@typescript-eslint/utils" "^5.10.0" -eslint-plugin-prettier@2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.2.tgz#71998c60aedfa2141f7bfcbf9d1c459bf98b4fad" - integrity sha512-tGek5clmW5swrAx1mdPYM8oThrBE83ePh7LeseZHBWfHVGrHPhKn7Y5zgRMbU/9D5Td9K4CEmUPjGxA7iw98Og== +eslint-plugin-prettier@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" + integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ== dependencies: - fast-diff "^1.1.1" - jest-docblock "^21.0.0" + prettier-linter-helpers "^1.0.0" -eslint-plugin-react-hooks@^1.5.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04" - integrity sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA== +eslint-plugin-react-hooks@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" + integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== eslint-plugin-react-native-globals@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2" integrity sha512-9aEPf1JEpiTjcFAmmyw8eiIXmcNZOqaZyHO77wgm0/dWfT/oxC1SrIq8ET38pMxHYrcB6Uew+TzUVsBeczF88g== -eslint-plugin-react-native@3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.6.0.tgz#7cad3b7c6159df6d26fe3252c6c5417a17f27b4b" - integrity sha512-BEQcHZ06hZSBYWFVuNEq0xuui5VEsWpHDsZGBtfadHfCRqRMUrkYPgdDb3bpc60qShHE83kqIv59uKdinEg91Q== +eslint-plugin-react-native@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-4.0.0.tgz#eec41984abe4970bdd7c6082dff7a98a5e34d0bb" + integrity sha512-kMmdxrSY7A1WgdqaGC+rY/28rh7kBGNBRsk48ovqkQmdg5j4K+DaFmegENDzMrdLkoufKGRNkKX6bgSwQTCAxQ== dependencies: + "@babel/traverse" "^7.7.4" eslint-plugin-react-native-globals "^0.1.1" -eslint-plugin-react@7.12.4: - version "7.12.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.12.4.tgz#b1ecf26479d61aee650da612e425c53a99f48c8c" - integrity sha512-1puHJkXJY+oS1t467MjbqjvX53uQ05HXwjqDgdbGBqf5j9eeydI54G3KwiJmWciQ0HTBacIKw2jgwSBSH3yfgQ== +eslint-plugin-react@^7.30.1: + version "7.30.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.30.1.tgz#2be4ab23ce09b5949c6631413ba64b2810fd3e22" + integrity sha512-NbEvI9jtqO46yJA3wcRF9Mo0lF9T/jhdHqhCHXiXtD+Zcb98812wvokjWpU7Q4QH5edo6dmqrukxVvWWXHlsUg== dependencies: - array-includes "^3.0.3" + array-includes "^3.1.5" + array.prototype.flatmap "^1.3.0" doctrine "^2.1.0" - has "^1.0.3" - jsx-ast-utils "^2.0.1" - object.fromentries "^2.0.0" - prop-types "^15.6.2" - resolve "^1.9.0" - -eslint-scope@3.7.1: - version "3.7.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" - integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug= - dependencies: - esrecurse "^4.1.0" + estraverse "^5.3.0" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.1.2" + object.entries "^1.1.5" + object.fromentries "^2.0.5" + object.hasown "^1.1.1" + object.values "^1.1.5" + prop-types "^15.8.1" + resolve "^2.0.0-next.3" + semver "^6.3.0" + string.prototype.matchall "^4.0.7" + +eslint-scope@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-scope@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" - integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== +eslint-scope@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" + integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" + esrecurse "^4.3.0" + estraverse "^5.2.0" -eslint-scope@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" - integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw== - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-utils@^1.3.1, eslint-utils@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== dependencies: - eslint-visitor-keys "^1.1.0" + eslint-visitor-keys "^2.0.0" -eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" - integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== - -eslint@^6.6.0: - version "6.6.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.6.0.tgz#4a01a2fb48d32aacef5530ee9c5a78f11a8afd04" - integrity sha512-PpEBq7b6qY/qrOmpYQ/jTMDYfuQMELR4g4WI1M/NaSDDD/bdcMb+dj4Hgks7p41kW2caXsPsEZAEAyAgjVVC0g== - dependencies: - "@babel/code-frame" "^7.0.0" +eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== + +eslint-visitor-keys@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + +eslint@^8.21.0: + version "8.21.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.21.0.tgz#1940a68d7e0573cef6f50037addee295ff9be9ef" + integrity sha512-/XJ1+Qurf1T9G2M5IHrsjp+xrGT73RZf23xA1z5wB1ZzzEAWSZKvRwhWxTFp1rvkvCfwcvAUNAP31bhKTTGfDA== + dependencies: + "@eslint/eslintrc" "^1.3.0" + "@humanwhocodes/config-array" "^0.10.4" + "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" - debug "^4.0.1" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.3" - eslint-visitor-keys "^1.1.0" - espree "^6.1.2" - esquery "^1.0.1" + escape-string-regexp "^4.0.0" + eslint-scope "^7.1.1" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.3.0" + espree "^9.3.3" + esquery "^1.4.0" esutils "^2.0.2" - file-entry-cache "^5.0.1" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" - globals "^11.7.0" - ignore "^4.0.6" + glob-parent "^6.0.1" + globals "^13.15.0" + globby "^11.1.0" + grapheme-splitter "^1.0.4" + ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^7.0.0" is-glob "^4.0.0" - js-yaml "^3.13.1" + js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" - minimatch "^3.0.4" - mkdirp "^0.5.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.8.2" - progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" - table "^5.2.3" + optionator "^0.9.1" + regexpp "^3.2.0" + strip-ansi "^6.0.1" + strip-json-comments "^3.1.0" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^6.1.2: - version "6.1.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d" - integrity sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA== +espree@^9.3.2, espree@^9.3.3: + version "9.3.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.3.3.tgz#2dd37c4162bb05f433ad3c1a52ddf8a49dc08e9d" + integrity sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng== dependencies: - acorn "^7.1.0" - acorn-jsx "^5.1.0" - eslint-visitor-keys "^1.1.0" - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + acorn "^8.8.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.3.0" -esquery@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" - integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== +esquery@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" + integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== dependencies: - estraverse "^4.0.0" + estraverse "^5.1.0" -esrecurse@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" - integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== dependencies: - estraverse "^4.1.0" + estraverse "^5.2.0" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: +estraverse@^4.1.1: version "4.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== +estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - -fast-deep-equal@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" - integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-diff@^1.1.1: +fast-diff@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== +fast-glob@^3.2.9: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" - integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -figures@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec" - integrity sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg== +fastq@^1.6.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== dependencies: - escape-string-regexp "^1.0.5" + reusify "^1.0.4" -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== dependencies: - flat-cache "^2.0.1" + flat-cache "^3.0.4" -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" + to-regex-range "^5.0.1" -flatted@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" - integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== + dependencies: + flatted "^3.1.0" + rimraf "^3.0.2" + +flatted@^3.1.0: + version "3.2.6" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.6.tgz#022e9218c637f9f3fc9c35ab9c9193f05add60b2" + integrity sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ== fs.realpath@^1.0.0: version "1.0.0" @@ -612,18 +974,62 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +function.prototype.name@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.0" + functions-have-names "^1.2.2" + functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= -glob-parent@^5.0.0: +functions-have-names@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== + +gensync@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== + +get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.2.tgz#336975123e05ad0b7ba41f152ee4aadbea6cf598" + integrity sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.3" + +get-symbol-description@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6" + integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.1" + +glob-parent@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" +glob-parent@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + glob@^7.1.3: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" @@ -636,45 +1042,91 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^11.1.0, globals@^11.7.0: +globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== +globals@^13.15.0: + version "13.17.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4" + integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw== + dependencies: + type-fest "^0.20.2" + +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + +grapheme-splitter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" + integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== + +has-bigints@^1.0.1, has-bigints@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" + has-symbols@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= -has@^1.0.1, has@^1.0.3: +has-symbols@^1.0.2, has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +has-tostringtag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" + integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== + dependencies: + has-symbols "^1.0.2" + +has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: function-bind "^1.1.1" -iconv-lite@^0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - ignore@^5.0.5: version "5.1.4" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A== +ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== + import-fresh@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.1.0.tgz#6d33fa1dcef6df930fae003446f33415af905118" @@ -683,6 +1135,14 @@ import-fresh@^3.0.0: parent-module "^1.0.0" resolve-from "^4.0.0" +import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -701,30 +1161,47 @@ inherits@2: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -inquirer@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.0.0.tgz#9e2b032dde77da1db5db804758b8fea3a970519a" - integrity sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ== - dependencies: - ansi-escapes "^4.2.1" - chalk "^2.4.2" - cli-cursor "^3.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^3.0.0" - lodash "^4.17.15" - mute-stream "0.0.8" - run-async "^2.2.0" - rxjs "^6.4.0" - string-width "^4.1.0" - strip-ansi "^5.1.0" - through "^2.3.6" +internal-slot@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" + integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== + dependencies: + get-intrinsic "^1.1.0" + has "^1.0.3" + side-channel "^1.0.4" + +is-bigint@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3" + integrity sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg== + dependencies: + has-bigints "^1.0.1" + +is-boolean-object@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719" + integrity sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" is-callable@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== +is-callable@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" + integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== + +is-core-module@^2.9.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.10.0.tgz#9012ede0a91c69587e647514e1d5277019e728ed" + integrity sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg== + dependencies: + has "^1.0.3" + is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" @@ -735,16 +1212,6 @@ is-extglob@^2.1.1: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - is-glob@^4.0.0, is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" @@ -752,17 +1219,51 @@ is-glob@^4.0.0, is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= +is-glob@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= +is-negative-zero@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== + +is-number-object@^1.0.4: + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.7.tgz#59d50ada4c45251784e9904f5246c742f07a42fc" + integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== + dependencies: + has-tostringtag "^1.0.0" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-regex@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" + integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== dependencies: - has "^1.0.1" + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + +is-shared-array-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" + +is-string@^1.0.5, is-string@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" + integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== + dependencies: + has-tostringtag "^1.0.0" is-symbol@^1.0.2: version "1.0.2" @@ -771,28 +1272,36 @@ is-symbol@^1.0.2: dependencies: has-symbols "^1.0.0" +is-symbol@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" + integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== + dependencies: + has-symbols "^1.0.2" + +is-weakref@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== + dependencies: + call-bind "^1.0.2" + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -jest-docblock@^21.0.0: - version "21.2.0" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" - integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: - argparse "^1.0.7" - esprima "^4.0.0" + argparse "^2.0.1" jsesc@^2.5.1: version "2.5.2" @@ -809,28 +1318,40 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= -jsx-ast-utils@^2.0.1: +json5@^2.2.1: version "2.2.3" - resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz#8a9364e402448a3ce7f14d357738310d9248054f" - integrity sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA== + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + +"jsx-ast-utils@^2.4.1 || ^3.0.0": + version "3.3.3" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" + integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== dependencies: - array-includes "^3.0.3" - object.assign "^4.1.0" + array-includes "^3.1.5" + object.assign "^4.1.3" -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" + prelude-ls "^1.2.1" + type-check "~0.4.0" -lodash.unescape@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" - integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: +lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -842,84 +1363,107 @@ loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== dependencies: - brace-expansion "^1.1.7" + yallist "^4.0.0" + +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" -mkdirp@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= +minimatch@^3.0.4, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: - minimist "0.0.8" + brace-expansion "^1.1.7" -ms@^2.1.1: +ms@2.1.2, ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +node-releases@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" + integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= -object-inspect@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b" - integrity sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ== +object-inspect@^1.12.0, object-inspect@^1.9.0: + version "1.12.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" + integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== -object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: +object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== -object.assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== +object.assign@^4.1.2, object.assign@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.3.tgz#d36b7700ddf0019abb6b1df1bb13f6445f79051f" + integrity sha512-ZFJnX3zltyjcYJL0RoCJuzb+11zWGyaDbjgxZbdV7rFEcHQuYxrZqhow67aA7xpes6LhojyFDaBKAFfogQrikA== dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" + call-bind "^1.0.2" + define-properties "^1.1.4" + has-symbols "^1.0.3" + object-keys "^1.1.1" -object.fromentries@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.1.tgz#050f077855c7af8ae6649f45c80b16ee2d31e704" - integrity sha512-PUQv8Hbg3j2QX0IQYv3iAGCbGcu4yY4KQ92/dhA4sFSixBmSmp13UpDLs6jGK8rBtbmhNNIK99LD2k293jpiGA== +object.entries@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.5.tgz#e1acdd17c4de2cd96d5a08487cfb9db84d881861" + integrity sha512-TyxmjUoZggd4OrrU1W66FMDG6CuqJxsFvymeyXI51+vQLN67zYfZseptRge703kKQdo4uccgAKebXFcRCzk4+g== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.15.0" - function-bind "^1.1.1" - has "^1.0.3" + es-abstract "^1.19.1" + +object.fromentries@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.5.tgz#7b37b205109c21e741e605727fe8b0ad5fa08251" + integrity sha512-CAyG5mWQRRiBU57Re4FKoTBjXfDoNwdFVH2Y1tS9PqCsfUTymAohOkEMSG3aRNKmv4lV3O7p1et7c187q6bynw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.1" + +object.hasown@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.1.tgz#ad1eecc60d03f49460600430d97f23882cf592a3" + integrity sha512-LYLe4tivNQzq4JdaWW6WO3HMZZJWzkkH8fnI6EebWl0VZth2wL2Lovm74ep2/gZzlaTdV62JZHEqHQ2yVn8Q/A== + dependencies: + define-properties "^1.1.4" + es-abstract "^1.19.5" + +object.values@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" + integrity sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.1" once@^1.3.0: version "1.4.0" @@ -928,29 +1472,31 @@ once@^1.3.0: dependencies: wrappy "1" -onetime@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" - integrity sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q== +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== dependencies: - mimic-fn "^2.1.0" + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" -optionator@^0.8.2: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" + yocto-queue "^0.1.0" -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" parent-module@^1.0.0: version "1.0.1" @@ -959,202 +1505,215 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-parse@^1.0.6: +path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +path-type@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -prettier@1.16.4: - version "1.16.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717" - integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g== +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -prop-types@^15.6.2: - version "15.7.2" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" - integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prop-types@^15.8.1: + version "15.8.1" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" + integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== dependencies: loose-envify "^1.4.0" object-assign "^4.1.1" - react-is "^16.8.1" + react-is "^16.13.1" punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -react-is@^16.8.1: - version "16.11.0" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.11.0.tgz#b85dfecd48ad1ce469ff558a882ca8e8313928fa" - integrity sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw== +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== +react-is@^16.13.1: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + +regexp.prototype.flags@^1.4.1, regexp.prototype.flags@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" + integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + functions-have-names "^1.2.2" + +regexpp@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" + integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.9.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6" - integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w== +resolve@^2.0.0-next.3: + version "2.0.0-next.4" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.4.tgz#3d37a113d6429f496ec4752d2a2e58efb1fd4660" + integrity sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ== dependencies: - path-parse "^1.0.6" + is-core-module "^2.9.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: glob "^7.1.3" -run-async@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" - integrity sha1-A3GrSuC91yDUFm19/aZP96RFpsA= - dependencies: - is-promise "^2.1.0" - -rxjs@^6.4.0: - version "6.5.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a" - integrity sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA== +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== dependencies: - tslib "^1.9.0" + queue-microtask "^1.2.2" -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -semver@5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" - integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== - -semver@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== +safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -semver@^6.1.2: +semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= +semver@^7.3.7: + version "7.3.7" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: - shebang-regex "^1.0.0" + lru-cache "^6.0.0" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -signal-exit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= - -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" - -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + shebang-regex "^3.0.0" -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" -string-width@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff" - integrity sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^5.2.0" +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -string.prototype.trimleft@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz#6cc47f0d7eb8d62b0f3701611715a3954591d634" - integrity sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw== +string-natural-compare@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" + integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== + +string.prototype.matchall@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz#8e6ecb0d8a1fb1fda470d81acecb2dba057a481d" + integrity sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - function-bind "^1.1.1" + es-abstract "^1.19.1" + get-intrinsic "^1.1.1" + has-symbols "^1.0.3" + internal-slot "^1.0.3" + regexp.prototype.flags "^1.4.1" + side-channel "^1.0.4" + +string.prototype.trimend@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz#914a65baaab25fbdd4ee291ca7dde57e869cb8d0" + integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" -string.prototype.trimright@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz#669d164be9df9b6f7559fa8e89945b168a5a6c58" - integrity sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg== +string.prototype.trimstart@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz#5466d93ba58cfa2134839f81d7f42437e8c01fef" + integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== dependencies: - define-properties "^1.1.3" - function-bind "^1.1.1" + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" -strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== +strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^4.1.0" + ansi-regex "^5.0.1" -strip-json-comments@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" - integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== supports-color@^5.3.0: version "5.5.0" @@ -1163,66 +1722,81 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= -tslib@^1.8.1, tslib@^1.9.0: +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +tslib@^1.8.1: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== -tsutils@^3.7.0: - version "3.17.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" - integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== +tsutils@^3.21.0: + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== dependencies: tslib "^1.8.1" -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== dependencies: - prelude-ls "~1.1.2" + prelude-ls "^1.2.1" + +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== -type-fest@^0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2" - integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw== +unbox-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== + dependencies: + call-bind "^1.0.2" + has-bigints "^1.0.2" + has-symbols "^1.0.3" + which-boxed-primitive "^1.0.2" + +update-browserslist-db@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38" + integrity sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" uri-js@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" - integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== dependencies: punycode "^2.1.0" @@ -1231,14 +1805,25 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" integrity sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g== -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== +which-boxed-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" + integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== + dependencies: + is-bigint "^1.0.1" + is-boolean-object "^1.1.0" + is-number-object "^1.0.4" + is-string "^1.0.5" + is-symbol "^1.0.3" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" -word-wrap@~1.2.3: +word-wrap@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== @@ -1248,9 +1833,12 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== - dependencies: - mkdirp "^0.5.1" +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/src/tmpl/ejdb2cfg.h b/src/tmpl/ejdb2cfg.h index bcacc6e7b..670366161 100644 --- a/src/tmpl/ejdb2cfg.h +++ b/src/tmpl/ejdb2cfg.h @@ -7,7 +7,7 @@ * * MIT License * - * Copyright (c) 2012-2021 Softmotions Ltd + * Copyright (c) 2012-2022 Softmotions Ltd * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -48,8 +48,6 @@ #include #include -#define JBNUMBUF_SIZE 64 - #ifndef static_assert #define static_assert _Static_assert #endif diff --git a/src/tmpl/libejdb2.pc.in b/src/tmpl/libejdb2.pc.in index fa06a59eb..a08529bac 100644 --- a/src/tmpl/libejdb2.pc.in +++ b/src/tmpl/libejdb2.pc.in @@ -9,5 +9,5 @@ URL: @PROJECT_WEBSITE@ Version: @PROJECT_VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@ Cflags: -I${includedir} -Libs.private: -liowow -lm +Libs.private: @PCLIBS@ diff --git a/src/util/convert.h b/src/util/convert.h deleted file mode 100644 index 9a932706a..000000000 --- a/src/util/convert.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#ifndef CONVERT_H -#define CONVERT_H - -#include - -/** - * sizeof `buf` must be at least 64 bytes - */ -static void jbi_ftoa(long double val, char buf[static 64], size_t *osz) { - // TODO: review - int sz = snprintf(buf, 64, "%.8Lf", val); - if (sz <= 0) { - buf[0] = '\0'; - *osz = 0; - return; - } - while (sz > 0 && buf[sz - 1] == '0') { // trim right zeroes - buf[sz - 1] = '\0'; - sz--; - } - if ((sz > 0) && (buf[sz - 1] == '.')) { - buf[sz - 1] = '\0'; - sz--; - } - *osz = (size_t) sz; -} - -#endif diff --git a/src/util/khash.h b/src/util/khash.h deleted file mode 100644 index b70919cca..000000000 --- a/src/util/khash.h +++ /dev/null @@ -1,619 +0,0 @@ -// -V::1003 -#ifndef __AC_KHASH_H -#define __AC_KHASH_H - -/* The MIT License - - Copyright (c) 2008, 2009, 2011 by Attractive Chaos - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - 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 AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -/* - An example: - -#include "khash.h" -KHASH_MAP_INIT_INT(32, char) -int main() { - int ret, is_missing; - khiter_t k; - khash_t(32) *h = kh_init(32); - k = kh_put(32, h, 5, &ret); - kh_value(h, k) = 10; - k = kh_get(32, h, 10); - is_missing = (k == kh_end(h)); - k = kh_get(32, h, 5); - kh_del(32, h, k); - for (k = kh_begin(h); k != kh_end(h); ++k) - if (kh_exist(h, k)) kh_value(h, k) = 1; - kh_destroy(32, h); - return 0; -} -*/ - -/* - 2013-05-02 (0.2.8): - - * Use quadratic probing. When the capacity is power of 2, stepping function - i*(i+1)/2 guarantees to traverse each bucket. It is better than double - hashing on cache performance and is more robust than linear probing. - - In theory, double hashing should be more robust than quadratic probing. - However, my implementation is probably not for large hash tables, because - the second hash function is closely tied to the first hash function, - which reduce the effectiveness of double hashing. - - Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php - - 2011-12-29 (0.2.7): - - * Minor code clean up; no actual effect. - - 2011-09-16 (0.2.6): - - * The capacity is a power of 2. This seems to dramatically improve the - speed for simple keys. Thank Zilong Tan for the suggestion. Reference: - - - http://code.google.com/p/ulib/ - - http://nothings.org/computer/judy/ - - * Allow to optionally use linear probing which usually has better - performance for random input. Double hashing is still the default as it - is more robust to certain non-random input. - - * Added Wang's integer hash function (not used by default). This hash - function is more robust to certain non-random input. - - 2011-02-14 (0.2.5): - - * Allow to declare global functions. - - 2009-09-26 (0.2.4): - - * Improve portability - - 2008-09-19 (0.2.3): - - * Corrected the example - * Improved interfaces - - 2008-09-11 (0.2.2): - - * Improved speed a little in kh_put() - - 2008-09-10 (0.2.1): - - * Added kh_clear() - * Fixed a compiling error - - 2008-09-02 (0.2.0): - - * Changed to token concatenation which increases flexibility. - - 2008-08-31 (0.1.2): - - * Fixed a bug in kh_get(), which has not been tested previously. - - 2008-08-31 (0.1.1): - - * Added destructor -*/ - -/*! - @header - - Generic hash table library. - */ - -#define AC_VERSION_KHASH_H "0.2.8" - -#include -#include -#include - -/* compiler specific configuration */ - -#if UINT_MAX == 0xffffffffu -typedef unsigned int khint32_t; -#elif ULONG_MAX == 0xffffffffu -typedef unsigned long khint32_t; -#endif - -#if ULONG_MAX == ULLONG_MAX -typedef unsigned long khint64_t; -#else -typedef unsigned long long khint64_t; -#endif - -#ifndef kh_inline -#ifdef _MSC_VER -#define kh_inline __inline -#else -#define kh_inline inline -#endif -#endif /* kh_inline */ - -typedef khint32_t khint_t; -typedef khint_t khiter_t; - -#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2) -#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1) -#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3) -#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1))) -#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1))) -#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1))) -#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1)) - -#define __ac_fsize(m) ((m) < 16? 1 : (m)>>4) - -#ifndef kroundup32 -#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) -#endif - -#ifndef kcalloc -#define kcalloc(N,Z) calloc(N,Z) -#endif -#ifndef kmalloc -#define kmalloc(Z) malloc(Z) -#endif -#ifndef krealloc -#define krealloc(P,Z) realloc(P,Z) -#endif -#ifndef kfree -#define kfree(P) free(P) -#endif - -static const double __ac_HASH_UPPER = 0.77; - -#define __KHASH_TYPE(name, khkey_t, khval_t) \ - typedef struct kh_##name##_s { \ - khint_t n_buckets, size, n_occupied, upper_bound; \ - khint32_t *flags; \ - khkey_t *keys; \ - khval_t *vals; \ - } kh_##name##_t; - -#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \ - extern kh_##name##_t *kh_init_##name(void); \ - extern void kh_destroy_##name(kh_##name##_t *h); \ - extern void kh_clear_##name(kh_##name##_t *h); \ - extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \ - extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \ - extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \ - extern void kh_del_##name(kh_##name##_t *h, khint_t x); - -#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ - SCOPE kh_##name##_t *kh_init_##name(void) { \ - return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \ - } \ - SCOPE void kh_destroy_##name(kh_##name##_t *h) \ - { \ - if (h) { \ - kfree((void *)h->keys); kfree(h->flags); \ - kfree((void *)h->vals); \ - kfree(h); \ - } \ - } \ - SCOPE void kh_clear_##name(kh_##name##_t *h) \ - { \ - if (h && h->flags) { \ - memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \ - h->size = h->n_occupied = 0; \ - } \ - } \ - SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \ - { \ - if (h->n_buckets) { \ - khint_t k, i, last, mask, step = 0; \ - mask = h->n_buckets - 1; \ - k = __hash_func(key); i = k & mask; \ - last = i; \ - while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ - i = (i + (++step)) & mask; \ - if (i == last) return h->n_buckets; \ - } \ - return __ac_iseither(h->flags, i)? h->n_buckets : i; \ - } else return 0; \ - } \ - SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \ - { /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \ - khint32_t *new_flags = 0; \ - khint_t j = 1; \ - { \ - kroundup32(new_n_buckets); \ - if (new_n_buckets < 4) new_n_buckets = 4; \ - if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \ - else { /* hash table size to be changed (shrink or expand); rehash */ \ - new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \ - if (!new_flags) return -1; \ - memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \ - if (h->n_buckets < new_n_buckets) { /* expand */ \ - khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \ - if (!new_keys) { kfree(new_flags); return -1; } \ - h->keys = new_keys; \ - if (kh_is_map) { \ - khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \ - if (!new_vals) { kfree(new_flags); return -1; } \ - h->vals = new_vals; \ - } \ - } /* otherwise shrink */ \ - } \ - } \ - if (j) { /* rehashing is needed */ \ - for (j = 0; j != h->n_buckets; ++j) { \ - if (__ac_iseither(h->flags, j) == 0) { \ - khkey_t key = h->keys[j]; \ - khval_t val; \ - khint_t new_mask; \ - new_mask = new_n_buckets - 1; \ - if (kh_is_map) val = h->vals[j]; \ - __ac_set_isdel_true(h->flags, j); \ - while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \ - khint_t k, i, step = 0; \ - k = __hash_func(key); \ - i = k & new_mask; \ - while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \ - __ac_set_isempty_false(new_flags, i); \ - if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \ - { khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \ - if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \ - __ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \ - } else { /* write the element and jump out of the loop */ \ - h->keys[i] = key; \ - if (kh_is_map) h->vals[i] = val; \ - break; \ - } \ - } \ - } \ - } \ - if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \ - h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \ - if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \ - } \ - kfree(h->flags); /* free the working space */ \ - h->flags = new_flags; \ - h->n_buckets = new_n_buckets; \ - h->n_occupied = h->size; \ - h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \ - } \ - return 0; \ - } \ - SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \ - { \ - khint_t x; \ - if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \ - if (h->n_buckets > (h->size<<1)) { \ - if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \ - *ret = -1; return h->n_buckets; \ - } \ - } else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \ - *ret = -1; return h->n_buckets; \ - } \ - } /* TODO: to implement automatically shrinking; resize() already support shrinking */ \ - { \ - khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \ - x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \ - if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \ - else { \ - last = i; \ - while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ - if (__ac_isdel(h->flags, i)) site = i; \ - i = (i + (++step)) & mask; \ - if (i == last) { x = site; break; } \ - } \ - if (x == h->n_buckets) { \ - if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \ - else x = i; \ - } \ - } \ - } \ - if (__ac_isempty(h->flags, x)) { /* not present at all */ \ - h->keys[x] = key; \ - __ac_set_isboth_false(h->flags, x); \ - ++h->size; ++h->n_occupied; \ - *ret = 1; \ - } else if (__ac_isdel(h->flags, x)) { /* deleted */ \ - h->keys[x] = key; \ - __ac_set_isboth_false(h->flags, x); \ - ++h->size; \ - *ret = 2; \ - } else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \ - return x; \ - } \ - SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \ - { \ - if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \ - __ac_set_isdel_true(h->flags, x); \ - --h->size; \ - } \ - } - -#define KHASH_DECLARE(name, khkey_t, khval_t) \ - __KHASH_TYPE(name, khkey_t, khval_t) \ - __KHASH_PROTOTYPES(name, khkey_t, khval_t) - -#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ - __KHASH_TYPE(name, khkey_t, khval_t) \ - __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) - -#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ - KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) - -/* --- BEGIN OF HASH FUNCTIONS --- */ - -/*! @function - @abstract Integer hash function - @param key The integer [khint32_t] - @return The hash value [khint_t] - */ -#define kh_int_hash_func(key) (khint32_t)(key) -/*! @function - @abstract Integer comparison function - */ -#define kh_int_hash_equal(a, b) ((a) == (b)) -/*! @function - @abstract 64-bit integer hash function - @param key The integer [khint64_t] - @return The hash value [khint_t] - */ -#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11) -/*! @function - @abstract 64-bit integer comparison function - */ -#define kh_int64_hash_equal(a, b) ((a) == (b)) -/*! @function - @abstract const char* hash function - @param s Pointer to a null terminated string - @return The hash value - */ -static kh_inline khint_t __ac_X31_hash_string(const char *s) -{ - khint_t h = (khint_t)*s; - if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s; - return h; -} -/*! @function - @abstract Another interface to const char* hash function - @param key Pointer to a null terminated string [const char*] - @return The hash value [khint_t] - */ -#define kh_str_hash_func(key) __ac_X31_hash_string(key) -/*! @function - @abstract Const char* comparison function - */ -#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) - -static kh_inline khint_t __ac_Wang_hash(khint_t key) -{ - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - return key; -} -#define kh_int_hash_func2(k) __ac_Wang_hash((khint_t)key) - -/* --- END OF HASH FUNCTIONS --- */ - -/* Other convenient macros... */ - -/*! - @abstract Type of the hash table. - @param name Name of the hash table [symbol] - */ -#define khash_t(name) kh_##name##_t - -/*! @function - @abstract Initiate a hash table. - @param name Name of the hash table [symbol] - @return Pointer to the hash table [khash_t(name)*] - */ -#define kh_init(name) kh_init_##name() - -/*! @function - @abstract Destroy a hash table. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - */ -#define kh_destroy(name, h) kh_destroy_##name(h) - -/*! @function - @abstract Reset a hash table without deallocating memory. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - */ -#define kh_clear(name, h) kh_clear_##name(h) - -/*! @function - @abstract Resize a hash table. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - @param s New size [khint_t] - */ -#define kh_resize(name, h, s) kh_resize_##name(h, s) - -/*! @function - @abstract Insert a key to the hash table. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - @param k Key [type of keys] - @param r Extra return code: -1 if the operation failed; - 0 if the key is present in the hash table; - 1 if the bucket is empty (never used); 2 if the element in - the bucket has been deleted [int*] - @return Iterator to the inserted element [khint_t] - */ -#define kh_put(name, h, k, r) kh_put_##name(h, k, r) - -/*! @function - @abstract Retrieve a key from the hash table. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - @param k Key [type of keys] - @return Iterator to the found element, or kh_end(h) if the element is absent [khint_t] - */ -#define kh_get(name, h, k) kh_get_##name(h, k) - -/*! @function - @abstract Remove a key from the hash table. - @param name Name of the hash table [symbol] - @param h Pointer to the hash table [khash_t(name)*] - @param k Iterator to the element to be deleted [khint_t] - */ -#define kh_del(name, h, k) kh_del_##name(h, k) - -/*! @function - @abstract Test whether a bucket contains data. - @param h Pointer to the hash table [khash_t(name)*] - @param x Iterator to the bucket [khint_t] - @return 1 if containing data; 0 otherwise [int] - */ -#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x))) - -/*! @function - @abstract Get key given an iterator - @param h Pointer to the hash table [khash_t(name)*] - @param x Iterator to the bucket [khint_t] - @return Key [type of keys] - */ -#define kh_key(h, x) ((h)->keys[x]) - -/*! @function - @abstract Get value given an iterator - @param h Pointer to the hash table [khash_t(name)*] - @param x Iterator to the bucket [khint_t] - @return Value [type of values] - @discussion For hash sets, calling this results in segfault. - */ -#define kh_val(h, x) ((h)->vals[x]) - -/*! @function - @abstract Alias of kh_val() - */ -#define kh_value(h, x) ((h)->vals[x]) - -/*! @function - @abstract Get the start iterator - @param h Pointer to the hash table [khash_t(name)*] - @return The start iterator [khint_t] - */ -#define kh_begin(h) (khint_t)(0) - -/*! @function - @abstract Get the end iterator - @param h Pointer to the hash table [khash_t(name)*] - @return The end iterator [khint_t] - */ -#define kh_end(h) ((h)->n_buckets) - -/*! @function - @abstract Get the number of elements in the hash table - @param h Pointer to the hash table [khash_t(name)*] - @return Number of elements in the hash table [khint_t] - */ -#define kh_size(h) ((h)->size) - -/*! @function - @abstract Get the number of buckets in the hash table - @param h Pointer to the hash table [khash_t(name)*] - @return Number of buckets in the hash table [khint_t] - */ -#define kh_n_buckets(h) ((h)->n_buckets) - -/*! @function - @abstract Iterate over the entries in the hash table - @param h Pointer to the hash table [khash_t(name)*] - @param kvar Variable to which key will be assigned - @param vvar Variable to which value will be assigned - @param code Block of code to execute - */ -#define kh_foreach(h, kvar, vvar, code) { khint_t __i; \ - for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ - if (!kh_exist(h,__i)) continue; \ - (kvar) = kh_key(h,__i); \ - (vvar) = kh_val(h,__i); \ - code; \ - } } - -/*! @function - @abstract Iterate over the values in the hash table - @param h Pointer to the hash table [khash_t(name)*] - @param vvar Variable to which value will be assigned - @param code Block of code to execute - */ -#define kh_foreach_value(h, vvar, code) { khint_t __i; \ - for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ - if (!kh_exist(h,__i)) continue; \ - (vvar) = kh_val(h,__i); \ - code; \ - } } - -/* More conenient interfaces */ - -/*! @function - @abstract Instantiate a hash set containing integer keys - @param name Name of the hash table [symbol] - */ -#define KHASH_SET_INIT_INT(name) \ - KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal) - -/*! @function - @abstract Instantiate a hash map containing integer keys - @param name Name of the hash table [symbol] - @param khval_t Type of values [type] - */ -#define KHASH_MAP_INIT_INT(name, khval_t) \ - KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal) - -/*! @function - @abstract Instantiate a hash map containing 64-bit integer keys - @param name Name of the hash table [symbol] - */ -#define KHASH_SET_INIT_INT64(name) \ - KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal) - -/*! @function - @abstract Instantiate a hash map containing 64-bit integer keys - @param name Name of the hash table [symbol] - @param khval_t Type of values [type] - */ -#define KHASH_MAP_INIT_INT64(name, khval_t) \ - KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal) - -typedef const char *kh_cstr_t; -/*! @function - @abstract Instantiate a hash map containing const char* keys - @param name Name of the hash table [symbol] - */ -#define KHASH_SET_INIT_STR(name) \ - KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal) - -/*! @function - @abstract Instantiate a hash map containing const char* keys - @param name Name of the hash table [symbol] - @param khval_t Type of values [type] - */ -#define KHASH_MAP_INIT_STR(name, khval_t) \ - KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal) - -#endif /* __AC_KHASH_H */ diff --git a/src/util/lwre.c b/src/util/lwre.c deleted file mode 100644 index b90f37919..000000000 --- a/src/util/lwre.c +++ /dev/null @@ -1,988 +0,0 @@ -// -V::506 - -/* Copyright (c) 2014 by Ian Piumarta - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the 'Software'), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software. Acknowledgement - * of the use of this Software in supporting documentation would be - * appreciated but is not required. - * - * THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. - */ - -#include -#include -#include -#include -#include - -#include "lwre.h" - -#ifndef RE_ERROR -# define RE_ERROR(RE, CODE, MESSAGE) { (RE)->error_message = (MESSAGE); \ - longjmp(*(RE)->error_env, (re->error_code = RE_ERROR_ ## CODE)); } -#endif - -#ifndef RE_MALLOC -# define RE_MALLOC(RE, SIZE) re__malloc((RE), (SIZE)) - -static void *re__malloc(struct re *re, size_t size) { - void *p = malloc(size); - if (!p) { - RE_ERROR(re, NOMEM, "out of memory"); - } - return p; -} - -#endif - -#ifndef RE_CALLOC -# define RE_CALLOC(RE, NMEMB, SIZE) re__calloc((RE), (NMEMB), (SIZE)) - -static void *re__calloc(struct re *re, size_t nmemb, size_t size) { - void *p = calloc(nmemb, size); - if (p) { - return p; - } - if (re) { - RE_ERROR(re, NOMEM, "out of memory"); - } - return p; -} - -#endif - -#ifndef RE_REALLOC -# define RE_REALLOC(RE, PTR, SIZE) re__realloc((RE), (PTR), (SIZE)) - -static inline void *re__realloc(struct re *re, void *ptr, size_t size) { - void *p = realloc(ptr, size); - if (!p) { - RE_ERROR(re, NOMEM, "out of memory"); - } - return p; -} - -#endif - -#ifndef RE_FREE -# define RE_FREE(RE, PTR) free(PTR) -#endif - -/* arrays */ - -#define re_array_of(TYPE) \ - struct { \ - int size; \ - int capacity; \ - TYPE *at; \ - } - -#define RE_ARRAY_OF_INITIALISER { 0, 0, 0 } - -#define re_array_append(RE, ARRAY, ELEMENT) \ - ((ARRAY).size++, \ - (((ARRAY).size > (ARRAY).capacity) \ - ? ((ARRAY).at = RE_REALLOC((RE), (ARRAY).at, \ - sizeof(*(ARRAY).at) * ((ARRAY).capacity = ((ARRAY).capacity \ - ? ((ARRAY).capacity * 2) \ - : 8)))) \ - : (ARRAY).at) \ - [(ARRAY).size - 1] = (ELEMENT)) - -#define re_array_copy(RE, ARRAY) \ - { (ARRAY).size, \ - (ARRAY).size, \ - memcpy(RE_MALLOC((RE), sizeof((ARRAY).at[0]) * (ARRAY).size), \ - (ARRAY).at, \ - sizeof((ARRAY).at[0]) * (ARRAY).size) } - -#define re_array_release(RE, ARRAY) { \ - if ((ARRAY).at) { \ - RE_FREE((RE), (ARRAY).at); \ - (ARRAY).at = 0; \ - } \ -} - -/* bit sets */ - -struct RE_BitSet; -typedef struct RE_BitSet RE_BitSet; - -struct RE_BitSet { - int inverted; - unsigned char bits[256 / sizeof(unsigned char)]; -}; - -static int re_bitset__includes(RE_BitSet *c, int i) { - if ((i < 0) || (255 < i)) { - return 0; - } - return (c->bits[i / 8] >> (i % 8)) & 1; -} - -static int re_bitset_includes(RE_BitSet *c, int i) { - int inc = re_bitset__includes(c, i); - if (c->inverted) { - inc = !inc; - } - return inc; -} - -static void re_bitset_add(RE_BitSet *c, int i) { - if ((i < 0) || (255 < i)) { - return; - } - c->bits[i / 8] |= (1 << (i % 8)); -} - -/* character classes */ - -static int re_make_char(struct re *re) { - const char *p = re->position; - if (!*p) { - return 0; - } - int c = *p++; - if (('\\' == c) && *p) { - c = *p++; - } - re->position = p; - return c; -} - -static RE_BitSet *re_make_class(struct re *re) { - RE_BitSet *c = RE_CALLOC(re, 1, sizeof(RE_BitSet)); - int last = -1; - c->inverted = ('^' == *re->position); // -V522 - if (c->inverted) { - re->position++; - } - while (*re->position && (']' != *re->position)) { - int this = re->position[0]; - if (('-' == this) && (last >= 0) && re->position[1] && (']' != re->position[1])) { - re->position++; - this = re_make_char(re); - do { - re_bitset_add(c, last++); - } while (last <= this); - last = -1; - } else { - this = re_make_char(re); - re_bitset_add(c, this); - last = this; - } - } - return c; -} - -/* instructions */ - -enum { RE_Any, RE_Char, RE_Class, RE_Accept, RE_Jump, RE_Fork, RE_Begin, RE_End, }; - -struct RE_Insn; -typedef struct RE_Insn RE_Insn; - -struct RE_Insn { - int opcode; - long x; - union { - long y; - RE_BitSet *c; - }; - union { - RE_Insn *next; - char *stamp; - }; -}; - -struct RE_Compiled; -typedef struct RE_Compiled RE_Compiled; - -/* - struct RE_Compiled - { - int size; - RE_Insn *first; - RE_Insn *last; - }; - - #define RE_COMPILED_INITIALISER { 0, 0, 0 } - */ - -static RE_Compiled re_insn_new(struct re *re, int opc) { - RE_Insn *insn = RE_CALLOC(re, 1, sizeof(RE_Insn)); - insn->opcode = opc; // -V522 - RE_Compiled insns = { 1, insn, insn }; - return insns; -} - -static RE_Compiled re_new_Any(struct re *re) { - RE_Compiled insns = re_insn_new(re, RE_Any); - return insns; -} - -static RE_Compiled re_new_Char(struct re *re, int c) { - RE_Compiled insns = re_insn_new(re, RE_Char); - insns.first->x = c; - return insns; -} - -static RE_Compiled re_new_Class(struct re *re, RE_BitSet *c) { - RE_Compiled insns = re_insn_new(re, RE_Class); - insns.first->c = c; - return insns; -} - -static RE_Compiled re_new_Accept(struct re *re) { - RE_Compiled insns = re_insn_new(re, RE_Accept); - return insns; -} - -static RE_Compiled re_new_Jump(struct re *re, int x) { - RE_Compiled insns = re_insn_new(re, RE_Jump); - insns.first->x = x; - return insns; -} - -static RE_Compiled re_new_Fork(struct re *re, int x, int y) { - RE_Compiled insns = re_insn_new(re, RE_Fork); - insns.first->x = x; - insns.first->y = y; - return insns; -} - -static RE_Compiled re_new_Begin(struct re *re) { - RE_Compiled insns = re_insn_new(re, RE_Begin); - return insns; -} - -static RE_Compiled re_new_End(struct re *re) { - RE_Compiled insns = re_insn_new(re, RE_End); - return insns; -} - -static void re_program_append(RE_Compiled *insns, RE_Compiled tail) { - insns->last->next = tail.first; - insns->last = tail.last; - insns->size += tail.size; -} - -static void re_program_prepend(RE_Compiled *insns, RE_Compiled head) { - head.last->next = insns->first; - insns->first = head.first; - insns->size += head.size; -} - -static void re_program_free(struct re *re, RE_Compiled *insns) { - int i; - for (i = 0; i < insns->size; ++i) { - switch (insns->first[i].opcode) { - case RE_Class: { - RE_FREE(re, insns->first[i].c); - insns->first[i].c = 0; - break; - } - } - } - RE_FREE(re, insns->first); - insns->first = insns->last = 0; - insns->size = 0; -} - -/* compilation */ - -/* - struct re - { - char *expression; - char *position; - jmp_buf *error_env; - int error_code; - char *error_message; - struct RE_Compiled code; - char **matches; - int nmatches; - }; - */ - -static RE_Compiled re_compile_expression(struct re *re); - -static RE_Compiled re_compile_primary(struct re *re) { - int c = *re->position++; - assert(0 != c); - switch (c) { - case '\\': { - if (*re->position) { - c = *re->position++; - } - break; - } - case '.': { - return re_new_Any(re); - } - case '[': { - RE_BitSet *cc = re_make_class(re); - if (']' != *re->position) { - RE_FREE(re, cc); - RE_ERROR(re, CHARSET, "expected ']' at end of character set"); - } - re->position++; - return re_new_Class(re, cc); - }; - case '(': { - RE_Compiled insns = re_compile_expression(re); - if (')' != *re->position) { - RE_Insn *insn, *next; - for (insn = insns.first; insn; insn = next) { - next = insn->next; - RE_FREE(re, insn); - } - RE_ERROR(re, SUBEXP, "expected ')' at end of subexpression"); - } - re->position++; - return insns; - } - case '{': { - RE_Compiled insns = re_compile_expression(re); - if ('}' != *re->position) { - RE_Insn *insn, *next; - for (insn = insns.first; insn; insn = next) { - next = insn->next; - RE_FREE(re, insn); - } - RE_ERROR(re, SUBMATCH, "expected '}' at end of submatch"); - } - re_program_prepend(&insns, re_new_Begin(re)); - re_program_append(&insns, re_new_End(re)); - re->position++; - return insns; - } - } - return re_new_Char(re, c); -} - -static RE_Compiled re_compile_suffix(struct re *re) { - RE_Compiled insns = re_compile_primary(re); - switch (*re->position) { - case '?': { - re->position++; - if ('?' == *re->position) { - re->position++; - re_program_prepend(&insns, re_new_Fork(re, insns.size, 0)); - } else { - re_program_prepend(&insns, re_new_Fork(re, 0, insns.size)); - } - break; - } - case '*': { - re->position++; - if ('?' == *re->position) { - re->position++; - re_program_prepend(&insns, re_new_Fork(re, insns.size + 1, 0)); - } else { - re_program_prepend(&insns, re_new_Fork(re, 0, insns.size + 1)); - } - re_program_append(&insns, re_new_Jump(re, -(insns.size + 1))); - break; - } - case '+': { - re->position++; - if ('?' == *re->position) { - re->position++; - re_program_append(&insns, re_new_Fork(re, 0, -(insns.size + 1))); - } else { - re_program_append(&insns, re_new_Fork(re, -(insns.size + 1), 0)); - } - break; - } - } - return insns; -} - -static RE_Compiled re_compile_sequence(struct re *re) { - if (!*re->position) { - return re_new_Accept(re); - } - RE_Compiled head = re_compile_suffix(re); - while (*re->position && !strchr("|)}>", *re->position)) - re_program_append(&head, re_compile_suffix(re)); - if (!*re->position) { - re_program_append(&head, re_new_Accept(re)); - } - return head; -} - -static RE_Compiled re_compile_expression(struct re *re) { - RE_Compiled head = re_compile_sequence(re); - while ('|' == *re->position) { - re->position++; - RE_Compiled tail = re_compile_sequence(re); - re_program_append(&head, re_new_Jump(re, tail.size)); - re_program_prepend(&head, re_new_Fork(re, 0, head.size)); - re_program_append(&head, tail); - } - return head; -} - -static RE_Compiled re_compile(struct re *re) { - jmp_buf env; - RE_Compiled insns = RE_COMPILED_INITIALISER; - re->error_env = &env; - if (setjmp(env)) { /* syntax error */ - return insns; - } - insns = re_compile_expression(re); - re_array_of(RE_Insn) program = RE_ARRAY_OF_INITIALISER; - RE_Insn *insn, *next; - for (insn = insns.first; insn; insn = next) { - re_array_append(re, program, *insn); - next = insn->next; - RE_FREE(re, insn); - } - -#if 0 - int i; - for (i = 0; i < program.size; ++i) { - RE_Insn *insn = &program.at[i]; - printf("%03i ", i); - switch (insn->opcode) { - case RE_Any: - printf("Any\n"); - break; - case RE_Char: - printf("Char %li\n", insn->x); - break; - case RE_Class: { - printf("Class "); - { - RE_BitSet *c = insn->c; - int i; - putchar('['); - if (c->inverted) { - putchar('^'); - } - for (i = 0; i < 256; ++i) - if (re_bitset__includes(c, i)) { - switch (i) { - case '\a': - printf("\\a"); - break; - case '\b': - printf("\\b"); - break; - case '\t': - printf("\\t"); - break; - case '\n': - printf("\\n"); - break; - case '\v': - printf("\\v"); - break; - case '\f': - printf("\\f"); - break; - case '\r': - printf("\\r"); - break; - case '\\': - printf("\\\\"); - break; - case ']': - printf("\\]"); - break; - case '^': - printf("\\^"); - break; - case '-': - printf("\\-"); - break; - default: - if (isprint(i)) { - putchar(i); - } else { - printf("\\x%02x", i); - } - } - } - putchar(']'); - } - putchar('\n'); - break; - } - case RE_Accept: - printf("Accept\n"); - break; - case RE_Jump: - printf("Jump %li -> %03li\n", insn->x, i + 1 + insn->x); - break; - case RE_Fork: - printf("Fork %li %li -> %03li %03li\n", insn->x, insn->y, i + 1 + insn->x, i + 1 + insn->y); - break; - case RE_Begin: - printf("Begin\n"); - break; - case RE_End: - printf("End\n"); - break; - default: - printf("?%i\n", insn->opcode); - break; - } - } -#endif - - assert(program.size == insns.size); - - insns.first = program.at; - insns.last = insns.first + insns.size; - - return insns; -} - -/* submatch recording */ - -typedef re_array_of(char*) re_array_of_charp; - -struct RE_Submatches; -typedef struct RE_Submatches RE_Submatches; - -struct RE_Submatches { - int refs; - re_array_of_charp beginnings; - re_array_of_charp endings; -}; - -static RE_Submatches *re_submatches_copy(struct re *re, RE_Submatches *orig) { - RE_Submatches *subs = RE_CALLOC(re, 1, sizeof(RE_Submatches)); - if (orig) { - subs->beginnings = (re_array_of_charp) re_array_copy(re, orig->beginnings); // -V522 - subs->endings = (re_array_of_charp) re_array_copy(re, orig->endings); - } - return subs; -} - -static void re_submatches_free(struct re *re, RE_Submatches *subs) { - assert(subs); - assert(!subs->refs); - re_array_release(re, subs->beginnings); - re_array_release(re, subs->endings); - RE_FREE(re, subs); -} - -static inline RE_Submatches *re_submatches_link(RE_Submatches *subs) { - if (subs) { - subs->refs++; - } - return subs; -} - -static inline void re_submatches_unlink(struct re *re, RE_Submatches *subs) { - if (subs && (0 == --(subs->refs))) { - re_submatches_free(re, subs); - } -} - -/* matching */ - -struct RE_Thread; -typedef struct RE_Thread RE_Thread; - -struct RE_Thread { - RE_Insn *pc; - RE_Submatches *submatches; -}; - -struct RE_ThreadList; -typedef struct RE_ThreadList RE_ThreadList; - -struct RE_ThreadList { - int size; - RE_Thread *at; -}; - -static inline RE_Thread re_thread(RE_Insn *pc, RE_Submatches *subs) { - return (RE_Thread) { - pc, subs - }; -} - -static void re_thread_schedule(struct re *re, RE_ThreadList *threads, RE_Insn *pc, char *sp, RE_Submatches *subs) { - if (pc->stamp == sp) { - return; - } - pc->stamp = sp; - - switch (pc->opcode) { - case RE_Jump: - re_thread_schedule(re, threads, pc + 1 + pc->x, sp, subs); - return; - case RE_Fork: - re_thread_schedule(re, threads, pc + 1 + pc->x, sp, subs); - re_thread_schedule(re, threads, pc + 1 + pc->y, sp, subs); - return; - case RE_Begin: - subs = re_submatches_copy(re, subs); - re_array_append(re, subs->beginnings, sp); // -V522 - re_thread_schedule(re, threads, pc + 1, sp, subs); - if (!subs->refs) { - re_submatches_free(re, subs); - } - return; - case RE_End: { - subs = re_submatches_copy(re, subs); -# if 0 /* non-nesting groups: ab{cd{ef}gh}ij => {cdef} {efgh} */ - re_array_append(re, subs->endings, sp); -# else /* nesting groups: ab{cd{ef}gh}ij => {cdefgh} {ef} */ - while (subs->endings.size < subs->beginnings.size) re_array_append(re, subs->endings, 0); - int i; - for (i = subs->endings.size; i--; ) { - if (!subs->endings.at[i]) { - subs->endings.at[i] = sp; - break; - } - } -# endif - re_thread_schedule(re, threads, pc + 1, sp, subs); - if (!subs->refs) { - re_submatches_free(re, subs); - } - return; - } - } - threads->at[threads->size++] = re_thread(pc, re_submatches_link(subs)); -} - -static int re_program_run(struct re *re, char *input, char ***saved, int *nsaved) { - int matched = RE_ERROR_NOMATCH; - if (!re) { - return matched; - } - - RE_Submatches *submatches = 0; - RE_ThreadList a = { 0, 0 }, b = { 0, 0 }, *here = &a, *next = &b; - - char *sp = input; - re->position = 0; - - jmp_buf env; - re->error_env = &env; - - if (setjmp(env)) { /* out of memory */ - matched = re->error_code; - goto bailout; - } - - a.at = RE_CALLOC(re, re->code.size, sizeof(RE_Thread)); - b.at = RE_CALLOC(re, re->code.size, sizeof(RE_Thread)); - - re_thread_schedule(re, here, re->code.first, input, 0); - - { - int i; - for (i = 0; i < re->code.size; ++i) - re->code.first[i].stamp = 0; - } - - for (sp = input; here->size; ++sp) { - int i; - for (i = 0; i < here->size; ++i) { - RE_Thread t = here->at[i]; - switch (t.pc->opcode) { - case RE_Any: { - if (*sp) { - re_thread_schedule(re, next, t.pc + 1, sp + 1, t.submatches); - } - break; - } - case RE_Char: { - if (*sp == t.pc->x) { - re_thread_schedule(re, next, t.pc + 1, sp + 1, t.submatches); - } - break; - } - case RE_Class: { - if (re_bitset_includes(t.pc->c, *sp)) { - re_thread_schedule(re, next, t.pc + 1, sp + 1, t.submatches); - } - break; - } - case RE_Accept: { - matched = sp - input; - re_submatches_unlink(re, submatches); - submatches = re_submatches_link(t.submatches); - while (i < here->size) re_submatches_unlink(re, here->at[i++].submatches); - goto nextchar; - } - default: - RE_ERROR(re, ENGINE, "illegal instruction in compiled regular expression (please report this bug)"); - } - re_submatches_unlink(re, t.submatches); - } -nextchar: - ; - RE_ThreadList *tmp = here; - here = next; - next = tmp; - next->size = 0; - if (!*sp) { - break; - } - } - -bailout: - re->position = sp; - - { - int i; - for (i = 0; i < here->size; ++i) - re_submatches_unlink(re, here->at[i].submatches); - } - - RE_FREE(re, a.at); - RE_FREE(re, b.at); - - if (submatches) { - if (saved && nsaved && (matched >= 0)) { - assert(submatches->beginnings.size == submatches->endings.size); - *nsaved = submatches->beginnings.size * 2; - *saved = RE_CALLOC(re, *nsaved, sizeof(char*)); - int i; - for (i = 0; i < *nsaved; i += 2) { - (*saved)[i + 0] = submatches->beginnings.at[i / 2]; - (*saved)[i + 1] = submatches->endings.at[i / 2]; - } - } - re_submatches_unlink(re, submatches); - } - - return matched; -} - -/* public interface */ - -struct re *lwre_new(const char *expr) { - struct re *re = RE_CALLOC(0, 1, sizeof(struct re)); - if (re) { - re->expression = expr; - } - return re; -} - -int lwre_match(struct re *re, char *input) { - RE_FREE(re, re->matches); - re->matches = 0; - re->nmatches = 0; - if (!re->expression) { - return 0; - } - if (!re->code.size) { - re->position = re->expression; - re->error_code = 0; - re->error_message = 0; - re->code = re_compile(re); - if (re->error_code) { - return re->error_code; - } - re->position = 0; - } - return re_program_run(re, input, &re->matches, &re->nmatches); -} - -void lwre_release(struct re *re) { - RE_FREE(re, re->matches); - if (re->code.first) { - re_program_free(re, &re->code); - } - memset(re, 0, sizeof(*re)); -} - -void lwre_reset(struct re *re, const char *expression) { - lwre_release(re); - re->expression = expression; -} - -void lwre_free(struct re *re) { - lwre_release(re); - RE_FREE(0, re); -} - -/* utility */ - -static int re_digit(int c, int base) { - if ((c >= '0') && (c <= '9')) { - c -= '0'; - } else if ((c >= 'A') && (c <= 'Z')) { - c -= ('A' - 10); - } else if ((c >= 'a') && (c <= 'z')) { - c -= ('a' - 10); - } else { - return -1; - } - if (c >= base) { - return -1; - } - return c; -} - -static int re_byte(char **sp, int least, int most, int base, int liberal) { - int c = 0; - char *s = *sp; - while (s - *sp < most) { - int d = re_digit(*s, base); - if (d < 0) { - break; - } - ++s; - c = c * base + d; - } - if (s - *sp < least) { - if (liberal) { - return (*sp)[-1]; - } - --*sp; - return '\\'; - } - *sp = s; - return c; -} - -static int re_log2floor(unsigned int n) { - if (!n) { - return 0; - } - int b = 1; -# define _do(x) if (n >= (1U << x)) (b += x), (n >>= x) - _do(16); - _do(8); - _do(4); - _do(2); - _do(1); -# undef _do - return b; -} - -static void re_escape_utf8(char **sp, unsigned int c) { - char *s = *sp; - if (c < 128) { - *s++ = c; - } else { /* this is good for up to 36 bits of c, which proves that Gordon Bell was right all along */ - int n = re_log2floor((unsigned) c) / 6; - int m = 6 * n; - *s++ = (0xff << (7 - n)) + (c >> m); - while ((m -= 6) >= 0) *s++ = 0x80 + ((c >> m) & 0x3F); - } - *sp = s; -} - -char *lwre_escape(char *s, int liberal) { - char *in = s, *out = s; - int c; - while ((c = *in++)) { - int u = 0; - if ('\\' == c) { - c = *in++; - switch (c) { - case '0': - case '1': - c = re_byte(&in, 1, 3, 8, liberal); - break; - case '\\': - //c = '\\'; - break; - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'U': - c = re_byte(&in, 8, 8, 16, liberal); - u = 1; - break; - case 'u': - c = re_byte(&in, 4, 4, 16, liberal); - u = 1; - break; - case 'v': - c = '\v'; - break; - case 'x': - c = re_byte(&in, 1, 2, 16, liberal); - break; - default: { - if (!liberal) { /* pass escape character through unharmed */ - --in; - c = '\\'; - } - break; - } - } - } - if (u) { - re_escape_utf8(&out, c); - } else { - *out++ = c; - } - } - assert(out <= in); - *out = 0; - return s; -} - -/* testing */ - -#ifdef LWRE_TEST - -#include - -/* echo stdin to stout with ANSI terminal escapes to turn every number red */ - -int main(int argc, char **argv) { - static struct re re = RE_INITIALISER("(.*?{[0-9]+})*"); - char buf[1024]; - while (fgets(buf, sizeof(buf), stdin)) { - int n; - if (((n = lwre_match(&re, buf)) < 0) && (RE_ERROR_NOMATCH != n)) { - fprintf(stderr, "%i %ss: %s\n", n, re.error_message, re.position); - break; - } else { - char *p = buf; - int n = 0; - while (*p) { - if ((n < re.nmatches) && (p == re.matches[n])) { - if (n & 1) { - printf("\033[0m"); /* end of match: clear all attributes */ - } else { - printf("\033[1;31m"); /* start of match: bold and foreground red */ - } - ++n; - } - putchar(*p++); - } - } - } - lwre_release(&re); - return 0; -} - -#endif /* REGEXP_TEST */ diff --git a/src/util/lwre.h b/src/util/lwre.h deleted file mode 100644 index 9f2bc907c..000000000 --- a/src/util/lwre.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef __lwre_h_ -#define __lwre_h_ - -#include -#include - -struct RE_Insn; - -struct RE_Compiled { - int size; - struct RE_Insn *first; - struct RE_Insn *last; -}; - -#define RE_COMPILED_INITIALISER { 0, 0, 0 } - -struct re { - const char *expression; - const char *position; - jmp_buf *error_env; - int error_code; - char *error_message; - struct RE_Compiled code; - char **matches; - int nmatches; -#ifdef RE_EXTRA_MEMBERS - RE_MEMBERS -#endif -}; - -#define RE_INITIALISER(EXPR) { (EXPR), 0, 0, 0, 0, RE_COMPILED_INITIALISER, 0, 0 } - -#define RE_ERROR_NONE 0 -#define RE_ERROR_NOMATCH -1 -#define RE_ERROR_NOMEM -2 -#define RE_ERROR_CHARSET -3 -#define RE_ERROR_SUBEXP -4 -#define RE_ERROR_SUBMATCH -5 -#define RE_ERROR_ENGINE -6 - -IW_EXPORT IW_ALLOC struct re *lwre_new(const char *expression); -IW_EXPORT int lwre_match(struct re *re, char *input); -IW_EXPORT void lwre_release(struct re *re); -IW_EXPORT void lwre_reset(struct re *re, const char *expression); -IW_EXPORT void lwre_free(struct re *re); -IW_EXPORT char *lwre_escape(char *string, int liberal); - -#endif /* __lwre_h_ */ diff --git a/src/util/utf8proc.c b/src/util/utf8proc.c deleted file mode 100644 index 56d2234de..000000000 --- a/src/util/utf8proc.c +++ /dev/null @@ -1,327 +0,0 @@ -/* -*- mode: c; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*- */ -/* - * Copyright (c) 2015 Steven G. Johnson, Jiahao Chen, Peter Colberg, Tony Kelman, Scott P. Jones, and other - * contributors. - * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * This library contains derived data from a modified version of the - * Unicode data files. - * - * The original data files are available at - * http://www.unicode.org/Public/UNIDATA/ - * - * Please notice the copyright statement in the file "utf8proc_data.c". - */ - - -/* - * File name: utf8proc.c - * - * Description: - * Implementation of libutf8proc. - */ - - -#include "utf8proc.h" - -UTF8PROC_DLLEXPORT const utf8proc_int8_t utf8proc_utf8class[256] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -#define UTF8PROC_HANGUL_SBASE 0xAC00 -#define UTF8PROC_HANGUL_LBASE 0x1100 -#define UTF8PROC_HANGUL_VBASE 0x1161 -#define UTF8PROC_HANGUL_TBASE 0x11A7 -#define UTF8PROC_HANGUL_LCOUNT 19 -#define UTF8PROC_HANGUL_VCOUNT 21 -#define UTF8PROC_HANGUL_TCOUNT 28 -#define UTF8PROC_HANGUL_NCOUNT 588 -#define UTF8PROC_HANGUL_SCOUNT 11172 -/* END is exclusive */ -#define UTF8PROC_HANGUL_L_START 0x1100 -#define UTF8PROC_HANGUL_L_END 0x115A -#define UTF8PROC_HANGUL_L_FILLER 0x115F -#define UTF8PROC_HANGUL_V_START 0x1160 -#define UTF8PROC_HANGUL_V_END 0x11A3 -#define UTF8PROC_HANGUL_T_START 0x11A8 -#define UTF8PROC_HANGUL_T_END 0x11FA -#define UTF8PROC_HANGUL_S_START 0xAC00 -#define UTF8PROC_HANGUL_S_END 0xD7A4 - -/* Should follow semantic-versioning rules (semver.org) based on API - compatibility. (Note that the shared-library version number will - be different, being based on ABI compatibility.): */ -#define STRINGIZEx(x) #x -#define STRINGIZE(x) STRINGIZEx(x) - -UTF8PROC_DLLEXPORT const char *utf8proc_version(void) { - return STRINGIZE(UTF8PROC_VERSION_MAJOR) "." STRINGIZE(UTF8PROC_VERSION_MINOR) "." STRINGIZE(UTF8PROC_VERSION_PATCH) - ""; -} - -UTF8PROC_DLLEXPORT const char *utf8proc_errmsg(utf8proc_ssize_t errcode) { - switch (errcode) { - case UTF8PROC_ERROR_NOMEM: - return "Memory for processing UTF-8 data could not be allocated."; - case UTF8PROC_ERROR_OVERFLOW: - return "UTF-8 string is too long to be processed."; - case UTF8PROC_ERROR_INVALIDUTF8: - return "Invalid UTF-8 string"; - case UTF8PROC_ERROR_NOTASSIGNED: - return "Unassigned Unicode code point found in UTF-8 string."; - case UTF8PROC_ERROR_INVALIDOPTS: - return "Invalid options for UTF-8 processing chosen."; - default: - return "An unknown error occurred while processing UTF-8 data."; - } -} - -#define utf_cont(ch) (((ch) & 0xc0) == 0x80) - -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_int32_t *dst - ) { - utf8proc_uint32_t uc; - const utf8proc_uint8_t *end; - - *dst = -1; - if (!strlen) { - return 0; - } - end = str + ((strlen < 0) ? 4 : strlen); - uc = *str++; - if (uc < 0x80) { - *dst = uc; - return 1; - } - // Must be between 0xc2 and 0xf4 inclusive to be valid - if ((uc - 0xc2) > (0xf4 - 0xc2)) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - if (uc < 0xe0) { // 2-byte sequence - // Must have valid continuation character - if ((str >= end) || !utf_cont(*str)) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - *dst = ((uc & 0x1f) << 6) | (*str & 0x3f); - return 2; - } - if (uc < 0xf0) { // 3-byte sequence - if ((str + 1 >= end) || !utf_cont(*str) || !utf_cont(str[1])) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - // Check for surrogate chars - if ((uc == 0xed) && (*str > 0x9f) ) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - uc = ((uc & 0xf) << 12) | ((*str & 0x3f) << 6) | (str[1] & 0x3f); - if (uc < 0x800) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - *dst = uc; - return 3; - } - // 4-byte sequence - // Must have 3 valid continuation characters - if ((str + 2 >= end) || !utf_cont(*str) || !utf_cont(str[1]) || !utf_cont(str[2])) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - // Make sure in correct range (0x10000 - 0x10ffff) - if (uc == 0xf0) { - if (*str < 0x90) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - } else if (uc == 0xf4) { - if (*str > 0x8f) { - return UTF8PROC_ERROR_INVALIDUTF8; - } - } - *dst = ((uc & 7) << 18) | ((*str & 0x3f) << 12) | ((str[1] & 0x3f) << 6) | (str[2] & 0x3f); - return 4; -} - -UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_codepoint_valid(utf8proc_int32_t uc) { - return (((utf8proc_uint32_t) uc) - 0xd800 > 0x07ff) && ((utf8proc_uint32_t) uc < 0x110000); -} - -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) { - if (uc < 0x00) { - return 0; - } else if (uc < 0x80) { - dst[0] = (utf8proc_uint8_t) uc; - return 1; - } else if (uc < 0x800) { - dst[0] = (utf8proc_uint8_t) (0xC0 + (uc >> 6)); - dst[1] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 2; - // Note: we allow encoding 0xd800-0xdfff here, so as not to change - // the API, however, these are actually invalid in UTF-8 - } else if (uc < 0x10000) { - dst[0] = (utf8proc_uint8_t) (0xE0 + (uc >> 12)); - dst[1] = (utf8proc_uint8_t) (0x80 + ((uc >> 6) & 0x3F)); - dst[2] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 3; - } else if (uc < 0x110000) { - dst[0] = (utf8proc_uint8_t) (0xF0 + (uc >> 18)); - dst[1] = (utf8proc_uint8_t) (0x80 + ((uc >> 12) & 0x3F)); - dst[2] = (utf8proc_uint8_t) (0x80 + ((uc >> 6) & 0x3F)); - dst[3] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 4; - } else { - return 0; - } -} - -/* internal "unsafe" version that does not check whether uc is in range */ -static utf8proc_ssize_t unsafe_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) { - if (uc < 0x00) { - return 0; - } else if (uc < 0x80) { - dst[0] = (utf8proc_uint8_t) uc; - return 1; - } else if (uc < 0x800) { - dst[0] = (utf8proc_uint8_t) (0xC0 + (uc >> 6)); - dst[1] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 2; - } else if (uc == 0xFFFF) { - dst[0] = (utf8proc_uint8_t) 0xFF; - return 1; - } else if (uc == 0xFFFE) { - dst[0] = (utf8proc_uint8_t) 0xFE; - return 1; - } else if (uc < 0x10000) { - dst[0] = (utf8proc_uint8_t) (0xE0 + (uc >> 12)); - dst[1] = (utf8proc_uint8_t) (0x80 + ((uc >> 6) & 0x3F)); - dst[2] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 3; - } else if (uc < 0x110000) { - dst[0] = (utf8proc_uint8_t) (0xF0 + (uc >> 18)); - dst[1] = (utf8proc_uint8_t) (0x80 + ((uc >> 12) & 0x3F)); - dst[2] = (utf8proc_uint8_t) (0x80 + ((uc >> 6) & 0x3F)); - dst[3] = (utf8proc_uint8_t) (0x80 + (uc & 0x3F)); - return 4; - } else { - return 0; - } -} - -/* return whether there is a grapheme break between boundclasses lbc and tbc - (according to the definition of extended grapheme clusters) - - Rule numbering refers to TR29 Version 29 (Unicode 9.0.0): - http://www.unicode.org/reports/tr29/tr29-29.html - - CAVEATS: - Please note that evaluation of GB10 (grapheme breaks between emoji zwj sequences) - and GB 12/13 (regional indicator code points) require knowledge of previous characters - and are thus not handled by this function. This may result in an incorrect break before - an E_Modifier class codepoint and an incorrectly missing break between two - REGIONAL_INDICATOR class code points if such support does not exist in the caller. - - See the special support in grapheme_break_extended, for required bookkeeping by the caller. - */ -static utf8proc_bool grapheme_break_simple(int lbc, int tbc) { - return (lbc == UTF8PROC_BOUNDCLASS_START) ? true // GB1 - : ( lbc == UTF8PROC_BOUNDCLASS_CR // GB3 - && tbc == UTF8PROC_BOUNDCLASS_LF) ? false // --- - : (lbc >= UTF8PROC_BOUNDCLASS_CR && lbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true // GB4 - : (tbc >= UTF8PROC_BOUNDCLASS_CR && tbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true // GB5 - : ( lbc == UTF8PROC_BOUNDCLASS_L // GB6 - && ( tbc == UTF8PROC_BOUNDCLASS_L // --- - || tbc == UTF8PROC_BOUNDCLASS_V // --- - || tbc == UTF8PROC_BOUNDCLASS_LV // --- - || tbc == UTF8PROC_BOUNDCLASS_LVT)) ? false // --- - : ( ( lbc == UTF8PROC_BOUNDCLASS_LV // GB7 - || lbc == UTF8PROC_BOUNDCLASS_V) // --- - && ( tbc == UTF8PROC_BOUNDCLASS_V // --- - || tbc == UTF8PROC_BOUNDCLASS_T)) ? false // --- - : ( ( lbc == UTF8PROC_BOUNDCLASS_LVT // GB8 - || lbc == UTF8PROC_BOUNDCLASS_T) // --- - && tbc == UTF8PROC_BOUNDCLASS_T) ? false // --- - : ( tbc == UTF8PROC_BOUNDCLASS_EXTEND // GB9 - || tbc == UTF8PROC_BOUNDCLASS_ZWJ // --- - || tbc == UTF8PROC_BOUNDCLASS_SPACINGMARK // GB9a - || lbc == UTF8PROC_BOUNDCLASS_PREPEND) ? false // GB9b - : ( ( lbc == UTF8PROC_BOUNDCLASS_E_BASE // GB10 (requires additional - // handling below) - || lbc == UTF8PROC_BOUNDCLASS_E_BASE_GAZ) // ---- - && tbc == UTF8PROC_BOUNDCLASS_E_MODIFIER) ? false // ---- - : ( lbc == UTF8PROC_BOUNDCLASS_ZWJ // GB11 - && ( tbc == UTF8PROC_BOUNDCLASS_GLUE_AFTER_ZWJ // ---- - || tbc == UTF8PROC_BOUNDCLASS_E_BASE_GAZ)) ? false // ---- - : ( lbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR // GB12/13 (requires additional - // handling below) - && tbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR) ? false // ---- - : true; // GB999 -} - -static utf8proc_bool grapheme_break_extended(int lbc, int tbc, utf8proc_int32_t *state) { - int lbc_override = ((state && *state != UTF8PROC_BOUNDCLASS_START) - ? *state : lbc); - utf8proc_bool break_permitted = grapheme_break_simple(lbc_override, tbc); - if (state) { - // Special support for GB 12/13 made possible by GB999. After two RI - // class codepoints we want to force a break. Do this by resetting the - // second RI's bound class to UTF8PROC_BOUNDCLASS_OTHER, to force a break - // after that character according to GB999 (unless of course such a break is - // forbidden by a different rule such as GB9). - if ((*state == tbc) && (tbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR)) { - *state = UTF8PROC_BOUNDCLASS_OTHER; - } - // Special support for GB10. Fold any EXTEND codepoints into the previous - // boundclass if we're dealing with an emoji base boundclass. - else if ( ( (*state == UTF8PROC_BOUNDCLASS_E_BASE) - || (*state == UTF8PROC_BOUNDCLASS_E_BASE_GAZ) ) - && (tbc == UTF8PROC_BOUNDCLASS_EXTEND) ) { - *state = UTF8PROC_BOUNDCLASS_E_BASE; - } else { - *state = tbc; - } - } - return break_permitted; -} - -static utf8proc_int32_t seqindex_decode_entry(const utf8proc_uint16_t **entry) { - utf8proc_int32_t entry_cp = **entry; - if ((entry_cp & 0xF800) == 0xD800) { - *entry = *entry + 1; - entry_cp = ((entry_cp & 0x03FF) << 10) | (**entry & 0x03FF); - entry_cp += 0x10000; - } - return entry_cp; -} diff --git a/src/util/utf8proc.h b/src/util/utf8proc.h deleted file mode 100644 index e962595fe..000000000 --- a/src/util/utf8proc.h +++ /dev/null @@ -1,733 +0,0 @@ -/* - * Copyright (c) 2015 Steven G. Johnson, Jiahao Chen, Peter Colberg, Tony Kelman, Scott P. Jones, and other - * contributors. - * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/** - * @mainpage - * - * utf8proc is a free/open-source (MIT/expat licensed) C library - * providing Unicode normalization, case-folding, and other operations - * for strings in the UTF-8 encoding, supporting Unicode version - * 9.0.0. See the utf8proc home page (http://julialang.org/utf8proc/) - * for downloads and other information, or the source code on github - * (https://github.com/JuliaLang/utf8proc). - * - * For the utf8proc API documentation, see: @ref utf8proc.h - * - * The features of utf8proc include: - * - * - Transformation of strings (@ref utf8proc_map) to: - * - decompose (@ref UTF8PROC_DECOMPOSE) or compose (@ref UTF8PROC_COMPOSE) Unicode combining characters - *(http://en.wikipedia.org/wiki/Combining_character) - * - canonicalize Unicode compatibility characters (@ref UTF8PROC_COMPAT) - * - strip "ignorable" (@ref UTF8PROC_IGNORE) characters, control characters (@ref UTF8PROC_STRIPCC), or combining - * characters such as accents (@ref UTF8PROC_STRIPMARK) - * - case-folding (@ref UTF8PROC_CASEFOLD) - * - Unicode normalization: @ref utf8proc_NFD, @ref utf8proc_NFC, @ref utf8proc_NFKD, @ref utf8proc_NFKC - * - Detecting grapheme boundaries (@ref utf8proc_grapheme_break and @ref UTF8PROC_CHARBOUND) - * - Character-width computation: @ref utf8proc_charwidth - * - Classification of characters by Unicode category: @ref utf8proc_category and @ref utf8proc_category_string - * - Encode (@ref utf8proc_encode_char) and decode (@ref utf8proc_iterate) Unicode codepoints to/from UTF-8. - */ - -/** @file */ - -#ifndef UTF8PROC_H -#define UTF8PROC_H - -/** @name API version - * - * The utf8proc API version MAJOR.MINOR.PATCH, following - * semantic-versioning rules (http://semver.org) based on API - * compatibility. - * - * This is also returned at runtime by @ref utf8proc_version; however, the - * runtime version may append a string like "-dev" to the version number - * for prerelease versions. - * - * @note The shared-library version number in the Makefile - * (and CMakeLists.txt, and MANIFEST) may be different, - * being based on ABI compatibility rather than API compatibility. - */ -/** @{ */ -/** The MAJOR version number (increased when backwards API compatibility is broken). */ -#define UTF8PROC_VERSION_MAJOR 2 -/** The MINOR version number (increased when new functionality is added in a backwards-compatible manner). */ -#define UTF8PROC_VERSION_MINOR 2 -/** The PATCH version (increased for fixes that do not change the API). */ -#define UTF8PROC_VERSION_PATCH 0 -/** @} */ - -#include - -#if defined(_MSC_VER) && _MSC_VER < 1800 -// MSVC prior to 2013 lacked stdbool.h and inttypes.h -typedef signed char utf8proc_int8_t; -typedef unsigned char utf8proc_uint8_t; -typedef short utf8proc_int16_t; -typedef unsigned short utf8proc_uint16_t; -typedef int utf8proc_int32_t; -typedef unsigned int utf8proc_uint32_t; -# ifdef _WIN64 -typedef __int64 utf8proc_ssize_t; -typedef unsigned __int64 utf8proc_size_t; -# else -typedef int utf8proc_ssize_t; -typedef unsigned int utf8proc_size_t; -# endif -# ifndef __cplusplus -// emulate C99 bool -typedef unsigned char utf8proc_bool; -# ifndef __bool_true_false_are_defined -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -# endif -# else -typedef bool utf8proc_bool; -# endif -#else -# include -# include -# include -typedef int8_t utf8proc_int8_t; -typedef uint8_t utf8proc_uint8_t; -typedef int16_t utf8proc_int16_t; -typedef uint16_t utf8proc_uint16_t; -typedef int32_t utf8proc_int32_t; -typedef uint32_t utf8proc_uint32_t; -typedef size_t utf8proc_size_t; -typedef ptrdiff_t utf8proc_ssize_t; -typedef bool utf8proc_bool; -#endif -#include - -#define UTF8PROC_STATIC - -#ifdef UTF8PROC_STATIC -# define UTF8PROC_DLLEXPORT -#else -# ifdef _WIN32 -# ifdef UTF8PROC_EXPORTS -# define UTF8PROC_DLLEXPORT __declspec(dllexport) -# else -# define UTF8PROC_DLLEXPORT __declspec(dllimport) -# endif -# elif __GNUC__ >= 4 -# define UTF8PROC_DLLEXPORT __attribute__((visibility("default"))) -# else -# define UTF8PROC_DLLEXPORT -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef SSIZE_MAX -#define SSIZE_MAX ((size_t) SIZE_MAX / 2) -#endif - -#ifndef UINT16_MAX -# define UINT16_MAX 65535U -#endif - -/** - * Option flags used by several functions in the library. - */ -typedef enum { - /** The given UTF-8 input is NULL terminated. */ - UTF8PROC_NULLTERM = (1 << 0), - /** Unicode Versioning Stability has to be respected. */ - UTF8PROC_STABLE = (1 << 1), - /** Compatibility decomposition (i.e. formatting information is lost). */ - UTF8PROC_COMPAT = (1 << 2), - /** Return a result with decomposed characters. */ - UTF8PROC_COMPOSE = (1 << 3), - /** Return a result with decomposed characters. */ - UTF8PROC_DECOMPOSE = (1 << 4), - /** Strip "default ignorable characters" such as SOFT-HYPHEN or ZERO-WIDTH-SPACE. */ - UTF8PROC_IGNORE = (1 << 5), - /** Return an error, if the input contains unassigned codepoints. */ - UTF8PROC_REJECTNA = (1 << 6), - /** - * Indicating that NLF-sequences (LF, CRLF, CR, NEL) are representing a - * line break, and should be converted to the codepoint for line - * separation (LS). - */ - UTF8PROC_NLF2LS = (1 << 7), - /** - * Indicating that NLF-sequences are representing a paragraph break, and - * should be converted to the codepoint for paragraph separation - * (PS). - */ - UTF8PROC_NLF2PS = (1 << 8), - /** Indicating that the meaning of NLF-sequences is unknown. */ - UTF8PROC_NLF2LF = (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS), - /** Strips and/or convers control characters. - * - * NLF-sequences are transformed into space, except if one of the - * NLF2LS/PS/LF options is given. HorizontalTab (HT) and FormFeed (FF) - * are treated as a NLF-sequence in this case. All other control - * characters are simply removed. - */ - UTF8PROC_STRIPCC = (1 << 9), - /** - * Performs unicode case folding, to be able to do a case-insensitive - * string comparison. - */ - UTF8PROC_CASEFOLD = (1 << 10), - /** - * Inserts 0xFF bytes at the beginning of each sequence which is - * representing a single grapheme cluster (see UAX#29). - */ - UTF8PROC_CHARBOUND = (1 << 11), - /** Lumps certain characters together. - * - * E.g. HYPHEN U+2010 and MINUS U+2212 to ASCII "-". See lump.md for details. - * - * If NLF2LF is set, this includes a transformation of paragraph and - * line separators to ASCII line-feed (LF). - */ - UTF8PROC_LUMP = (1 << 12), - /** Strips all character markings. - * - * This includes non-spacing, spacing and enclosing (i.e. accents). - * @note This option works only with @ref UTF8PROC_COMPOSE or - * @ref UTF8PROC_DECOMPOSE - */ - UTF8PROC_STRIPMARK = (1 << 13), - /** - * Strip unassigned codepoints. - */ - UTF8PROC_STRIPNA = (1 << 14), -} utf8proc_option_t; - -/** @name Error codes - * Error codes being returned by almost all functions. - */ -/** @{ */ -/** Memory could not be allocated. */ -#define UTF8PROC_ERROR_NOMEM -1 -/** The given string is too long to be processed. */ -#define UTF8PROC_ERROR_OVERFLOW -2 -/** The given string is not a legal UTF-8 string. */ -#define UTF8PROC_ERROR_INVALIDUTF8 -3 -/** The @ref UTF8PROC_REJECTNA flag was set and an unassigned codepoint was found. */ -#define UTF8PROC_ERROR_NOTASSIGNED -4 -/** Invalid options have been used. */ -#define UTF8PROC_ERROR_INVALIDOPTS -5 -/** @} */ - -/* @name Types */ - -/** Holds the value of a property. */ -typedef utf8proc_int16_t utf8proc_propval_t; - -/** Struct containing information about a codepoint. */ -typedef struct utf8proc_property_struct { - /** - * Unicode category. - * @see utf8proc_category_t. - */ - utf8proc_propval_t category; - utf8proc_propval_t combining_class; - /** - * Bidirectional class. - * @see utf8proc_bidi_class_t. - */ - utf8proc_propval_t bidi_class; - /** - * @anchor Decomposition type. - * @see utf8proc_decomp_type_t. - */ - utf8proc_propval_t decomp_type; - utf8proc_uint16_t decomp_seqindex; - utf8proc_uint16_t casefold_seqindex; - utf8proc_uint16_t uppercase_seqindex; - utf8proc_uint16_t lowercase_seqindex; - utf8proc_uint16_t titlecase_seqindex; - utf8proc_uint16_t comb_index; - unsigned bidi_mirrored : 1; - unsigned comp_exclusion : 1; - /** - * Can this codepoint be ignored? - * - * Used by @ref utf8proc_decompose_char when @ref UTF8PROC_IGNORE is - * passed as an option. - */ - unsigned ignorable : 1; - unsigned control_boundary : 1; - /** The width of the codepoint. */ - unsigned charwidth : 2; - unsigned pad : 2; - /** - * Boundclass. - * @see utf8proc_boundclass_t. - */ - unsigned boundclass : 8; -} utf8proc_property_t; - -/** Unicode categories. */ -typedef enum { - UTF8PROC_CATEGORY_CN = 0, /**< Other, not assigned */ - UTF8PROC_CATEGORY_LU = 1, /**< Letter, uppercase */ - UTF8PROC_CATEGORY_LL = 2, /**< Letter, lowercase */ - UTF8PROC_CATEGORY_LT = 3, /**< Letter, titlecase */ - UTF8PROC_CATEGORY_LM = 4, /**< Letter, modifier */ - UTF8PROC_CATEGORY_LO = 5, /**< Letter, other */ - UTF8PROC_CATEGORY_MN = 6, /**< Mark, nonspacing */ - UTF8PROC_CATEGORY_MC = 7, /**< Mark, spacing combining */ - UTF8PROC_CATEGORY_ME = 8, /**< Mark, enclosing */ - UTF8PROC_CATEGORY_ND = 9, /**< Number, decimal digit */ - UTF8PROC_CATEGORY_NL = 10, /**< Number, letter */ - UTF8PROC_CATEGORY_NO = 11, /**< Number, other */ - UTF8PROC_CATEGORY_PC = 12, /**< Punctuation, connector */ - UTF8PROC_CATEGORY_PD = 13, /**< Punctuation, dash */ - UTF8PROC_CATEGORY_PS = 14, /**< Punctuation, open */ - UTF8PROC_CATEGORY_PE = 15, /**< Punctuation, close */ - UTF8PROC_CATEGORY_PI = 16, /**< Punctuation, initial quote */ - UTF8PROC_CATEGORY_PF = 17, /**< Punctuation, final quote */ - UTF8PROC_CATEGORY_PO = 18, /**< Punctuation, other */ - UTF8PROC_CATEGORY_SM = 19, /**< Symbol, math */ - UTF8PROC_CATEGORY_SC = 20, /**< Symbol, currency */ - UTF8PROC_CATEGORY_SK = 21, /**< Symbol, modifier */ - UTF8PROC_CATEGORY_SO = 22, /**< Symbol, other */ - UTF8PROC_CATEGORY_ZS = 23, /**< Separator, space */ - UTF8PROC_CATEGORY_ZL = 24, /**< Separator, line */ - UTF8PROC_CATEGORY_ZP = 25, /**< Separator, paragraph */ - UTF8PROC_CATEGORY_CC = 26, /**< Other, control */ - UTF8PROC_CATEGORY_CF = 27, /**< Other, format */ - UTF8PROC_CATEGORY_CS = 28, /**< Other, surrogate */ - UTF8PROC_CATEGORY_CO = 29, /**< Other, private use */ -} utf8proc_category_t; - -/** Bidirectional character classes. */ -typedef enum { - UTF8PROC_BIDI_CLASS_L = 1, /**< Left-to-Right */ - UTF8PROC_BIDI_CLASS_LRE = 2, /**< Left-to-Right Embedding */ - UTF8PROC_BIDI_CLASS_LRO = 3, /**< Left-to-Right Override */ - UTF8PROC_BIDI_CLASS_R = 4, /**< Right-to-Left */ - UTF8PROC_BIDI_CLASS_AL = 5, /**< Right-to-Left Arabic */ - UTF8PROC_BIDI_CLASS_RLE = 6, /**< Right-to-Left Embedding */ - UTF8PROC_BIDI_CLASS_RLO = 7, /**< Right-to-Left Override */ - UTF8PROC_BIDI_CLASS_PDF = 8, /**< Pop Directional Format */ - UTF8PROC_BIDI_CLASS_EN = 9, /**< European Number */ - UTF8PROC_BIDI_CLASS_ES = 10, /**< European Separator */ - UTF8PROC_BIDI_CLASS_ET = 11, /**< European Number Terminator */ - UTF8PROC_BIDI_CLASS_AN = 12, /**< Arabic Number */ - UTF8PROC_BIDI_CLASS_CS = 13, /**< Common Number Separator */ - UTF8PROC_BIDI_CLASS_NSM = 14, /**< Nonspacing Mark */ - UTF8PROC_BIDI_CLASS_BN = 15, /**< Boundary Neutral */ - UTF8PROC_BIDI_CLASS_B = 16, /**< Paragraph Separator */ - UTF8PROC_BIDI_CLASS_S = 17, /**< Segment Separator */ - UTF8PROC_BIDI_CLASS_WS = 18, /**< Whitespace */ - UTF8PROC_BIDI_CLASS_ON = 19, /**< Other Neutrals */ - UTF8PROC_BIDI_CLASS_LRI = 20, /**< Left-to-Right Isolate */ - UTF8PROC_BIDI_CLASS_RLI = 21, /**< Right-to-Left Isolate */ - UTF8PROC_BIDI_CLASS_FSI = 22, /**< First Strong Isolate */ - UTF8PROC_BIDI_CLASS_PDI = 23, /**< Pop Directional Isolate */ -} utf8proc_bidi_class_t; - -/** Decomposition type. */ -typedef enum { - UTF8PROC_DECOMP_TYPE_FONT = 1, /**< Font */ - UTF8PROC_DECOMP_TYPE_NOBREAK = 2, /**< Nobreak */ - UTF8PROC_DECOMP_TYPE_INITIAL = 3, /**< Initial */ - UTF8PROC_DECOMP_TYPE_MEDIAL = 4, /**< Medial */ - UTF8PROC_DECOMP_TYPE_FINAL = 5, /**< Final */ - UTF8PROC_DECOMP_TYPE_ISOLATED = 6, /**< Isolated */ - UTF8PROC_DECOMP_TYPE_CIRCLE = 7, /**< Circle */ - UTF8PROC_DECOMP_TYPE_SUPER = 8, /**< Super */ - UTF8PROC_DECOMP_TYPE_SUB = 9, /**< Sub */ - UTF8PROC_DECOMP_TYPE_VERTICAL = 10, /**< Vertical */ - UTF8PROC_DECOMP_TYPE_WIDE = 11, /**< Wide */ - UTF8PROC_DECOMP_TYPE_NARROW = 12, /**< Narrow */ - UTF8PROC_DECOMP_TYPE_SMALL = 13, /**< Small */ - UTF8PROC_DECOMP_TYPE_SQUARE = 14, /**< Square */ - UTF8PROC_DECOMP_TYPE_FRACTION = 15, /**< Fraction */ - UTF8PROC_DECOMP_TYPE_COMPAT = 16, /**< Compat */ -} utf8proc_decomp_type_t; - -/** Boundclass property. (TR29) */ -typedef enum { - UTF8PROC_BOUNDCLASS_START = 0, /**< Start */ - UTF8PROC_BOUNDCLASS_OTHER = 1, /**< Other */ - UTF8PROC_BOUNDCLASS_CR = 2, /**< Cr */ - UTF8PROC_BOUNDCLASS_LF = 3, /**< Lf */ - UTF8PROC_BOUNDCLASS_CONTROL = 4, /**< Control */ - UTF8PROC_BOUNDCLASS_EXTEND = 5, /**< Extend */ - UTF8PROC_BOUNDCLASS_L = 6, /**< L */ - UTF8PROC_BOUNDCLASS_V = 7, /**< V */ - UTF8PROC_BOUNDCLASS_T = 8, /**< T */ - UTF8PROC_BOUNDCLASS_LV = 9, /**< Lv */ - UTF8PROC_BOUNDCLASS_LVT = 10, /**< Lvt */ - UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR = 11, /**< Regional indicator */ - UTF8PROC_BOUNDCLASS_SPACINGMARK = 12, /**< Spacingmark */ - UTF8PROC_BOUNDCLASS_PREPEND = 13, /**< Prepend */ - UTF8PROC_BOUNDCLASS_ZWJ = 14, /**< Zero Width Joiner */ - UTF8PROC_BOUNDCLASS_E_BASE = 15, /**< Emoji Base */ - UTF8PROC_BOUNDCLASS_E_MODIFIER = 16, /**< Emoji Modifier */ - UTF8PROC_BOUNDCLASS_GLUE_AFTER_ZWJ = 17, /**< Glue_After_ZWJ */ - UTF8PROC_BOUNDCLASS_E_BASE_GAZ = 18, /**< E_BASE + GLUE_AFTER_ZJW */ -} utf8proc_boundclass_t; - -/** - * Function pointer type passed to @ref utf8proc_map_custom and - * @ref utf8proc_decompose_custom, which is used to specify a user-defined - * mapping of codepoints to be applied in conjunction with other mappings. - */ -typedef utf8proc_int32_t (*utf8proc_custom_func)(utf8proc_int32_t codepoint, void *data); - -/** - * Array containing the byte lengths of a UTF-8 encoded codepoint based - * on the first byte. - */ -UTF8PROC_DLLEXPORT extern const utf8proc_int8_t utf8proc_utf8class[256]; - -/** - * Returns the utf8proc API version as a string MAJOR.MINOR.PATCH - * (http://semver.org format), possibly with a "-dev" suffix for - * development versions. - */ -UTF8PROC_DLLEXPORT const char *utf8proc_version(void); - -/** - * Returns an informative error string for the given utf8proc error code - * (e.g. the error codes returned by @ref utf8proc_map). - */ -UTF8PROC_DLLEXPORT const char *utf8proc_errmsg(utf8proc_ssize_t errcode); - -/** - * Reads a single codepoint from the UTF-8 sequence being pointed to by `str`. - * The maximum number of bytes read is `strlen`, unless `strlen` is - * negative (in which case up to 4 bytes are read). - * - * If a valid codepoint could be read, it is stored in the variable - * pointed to by `codepoint_ref`, otherwise that variable will be set to -1. - * In case of success, the number of bytes read is returned; otherwise, a - * negative error code is returned. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate( - const utf8proc_uint8_t *str, - utf8proc_ssize_t strlen, - utf8proc_int32_t *codepoint_ref); - -/** - * Check if a codepoint is valid (regardless of whether it has been - * assigned a value by the current Unicode standard). - * - * @return 1 if the given `codepoint` is valid and otherwise return 0. - */ -UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_codepoint_valid(utf8proc_int32_t codepoint); - -/** - * Encodes the codepoint as an UTF-8 string in the byte array pointed - * to by `dst`. This array must be at least 4 bytes long. - * - * In case of success the number of bytes written is returned, and - * otherwise 0 is returned. - * - * This function does not check whether `codepoint` is valid Unicode. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t codepoint, utf8proc_uint8_t *dst); - -/** - * Look up the properties for a given codepoint. - * - * @param codepoint The Unicode codepoint. - * - * @returns - * A pointer to a (constant) struct containing information about - * the codepoint. - * @par - * If the codepoint is unassigned or invalid, a pointer to a special struct is - * returned in which `category` is 0 (@ref UTF8PROC_CATEGORY_CN). - */ -UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int32_t codepoint); - -/** Decompose a codepoint into an array of codepoints. - * - * @param codepoint the codepoint. - * @param dst the destination buffer. - * @param bufsize the size of the destination buffer. - * @param options one or more of the following flags: - * - @ref UTF8PROC_REJECTNA - return an error `codepoint` is unassigned - * - @ref UTF8PROC_IGNORE - strip "default ignorable" codepoints - * - @ref UTF8PROC_CASEFOLD - apply Unicode casefolding - * - @ref UTF8PROC_COMPAT - replace certain codepoints with their - * compatibility decomposition - * - @ref UTF8PROC_CHARBOUND - insert 0xFF bytes before each grapheme cluster - * - @ref UTF8PROC_LUMP - lump certain different codepoints together - * - @ref UTF8PROC_STRIPMARK - remove all character marks - * - @ref UTF8PROC_STRIPNA - remove unassigned codepoints - * @param last_boundclass - * Pointer to an integer variable containing - * the previous codepoint's boundary class if the @ref UTF8PROC_CHARBOUND - * option is used. Otherwise, this parameter is ignored. - * - * @return - * In case of success, the number of codepoints written is returned; in case - * of an error, a negative error code is returned (@ref utf8proc_errmsg). - * @par - * If the number of written codepoints would be bigger than `bufsize`, the - * required buffer size is returned, while the buffer will be overwritten with - * undefined data. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char( - utf8proc_int32_t codepoint, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, - utf8proc_option_t options, int *last_boundclass - ); - -/** - * The same as @ref utf8proc_decompose_char, but acts on a whole UTF-8 - * string and orders the decomposed sequences correctly. - * - * If the @ref UTF8PROC_NULLTERM flag in `options` is set, processing - * will be stopped, when a NULL byte is encounted, otherwise `strlen` - * bytes are processed. The result (in the form of 32-bit unicode - * codepoints) is written into the buffer being pointed to by - * `buffer` (which must contain at least `bufsize` entries). In case of - * success, the number of codepoints written is returned; in case of an - * error, a negative error code is returned (@ref utf8proc_errmsg). - * See @ref utf8proc_decompose_custom to supply additional transformations. - * - * If the number of written codepoints would be bigger than `bufsize`, the - * required buffer size is returned, while the buffer will be overwritten with - * undefined data. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options - ); - -/** - * The same as @ref utf8proc_decompose, but also takes a `custom_func` mapping function - * that is called on each codepoint in `str` before any other transformations - * (along with a `custom_data` pointer that is passed through to `custom_func`). - * The `custom_func` argument is ignored if it is `NULL`. See also @ref utf8proc_map_custom. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options, - utf8proc_custom_func custom_func, void *custom_data - ); - -/** - * Normalizes the sequence of `length` codepoints pointed to by `buffer` - * in-place (i.e., the result is also stored in `buffer`). - * - * @param buffer the (native-endian UTF-32) unicode codepoints to re-encode. - * @param length the length (in codepoints) of the buffer. - * @param options a bitwise or (`|`) of one or more of the following flags: - * - @ref UTF8PROC_NLF2LS - convert LF, CRLF, CR and NEL into LS - * - @ref UTF8PROC_NLF2PS - convert LF, CRLF, CR and NEL into PS - * - @ref UTF8PROC_NLF2LF - convert LF, CRLF, CR and NEL into LF - * - @ref UTF8PROC_STRIPCC - strip or convert all non-affected control characters - * - @ref UTF8PROC_COMPOSE - try to combine decomposed codepoints into composite - * codepoints - * - @ref UTF8PROC_STABLE - prohibit combining characters that would violate - * the unicode versioning stability - * - * @return - * In case of success, the length (in codepoints) of the normalized UTF-32 string is - * returned; otherwise, a negative error code is returned (@ref utf8proc_errmsg). - * - * @warning The entries of the array pointed to by `str` have to be in the - * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash! - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32( - utf8proc_int32_t *buffer, - utf8proc_ssize_t length, - utf8proc_option_t options); - -/** - * Reencodes the sequence of `length` codepoints pointed to by `buffer` - * UTF-8 data in-place (i.e., the result is also stored in `buffer`). - * Can optionally normalize the UTF-32 sequence prior to UTF-8 conversion. - * - * @param buffer the (native-endian UTF-32) unicode codepoints to re-encode. - * @param length the length (in codepoints) of the buffer. - * @param options a bitwise or (`|`) of one or more of the following flags: - * - @ref UTF8PROC_NLF2LS - convert LF, CRLF, CR and NEL into LS - * - @ref UTF8PROC_NLF2PS - convert LF, CRLF, CR and NEL into PS - * - @ref UTF8PROC_NLF2LF - convert LF, CRLF, CR and NEL into LF - * - @ref UTF8PROC_STRIPCC - strip or convert all non-affected control characters - * - @ref UTF8PROC_COMPOSE - try to combine decomposed codepoints into composite - * codepoints - * - @ref UTF8PROC_STABLE - prohibit combining characters that would violate - * the unicode versioning stability - * - @ref UTF8PROC_CHARBOUND - insert 0xFF bytes before each grapheme cluster - * - * @return - * In case of success, the length (in bytes) of the resulting nul-terminated - * UTF-8 string is returned; otherwise, a negative error code is returned - * (@ref utf8proc_errmsg). - * - * @warning The amount of free space pointed to by `buffer` must - * exceed the amount of the input data by one byte, and the - * entries of the array pointed to by `str` have to be in the - * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash! - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode( - utf8proc_int32_t *buffer, - utf8proc_ssize_t length, - utf8proc_option_t options); - -/** - * Given a pair of consecutive codepoints, return whether a grapheme break is - * permitted between them (as defined by the extended grapheme clusters in UAX#29). - * - * @param state Beginning with Version 29 (Unicode 9.0.0), this algorithm requires - * state to break graphemes. This state can be passed in as a pointer - * in the `state` argument and should initially be set to 0. If the - * state is not passed in (i.e. a null pointer is passed), UAX#29 rules - * GB10/12/13 which require this state will not be applied, essentially - * matching the rules in Unicode 8.0.0. - * - * @warning If the state parameter is used, `utf8proc_grapheme_break_stateful` must - * be called IN ORDER on ALL potential breaks in a string. - */ -UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_grapheme_break_stateful( - utf8proc_int32_t codepoint1, - utf8proc_int32_t codepoint2, - utf8proc_int32_t *state); - -/** - * Same as @ref utf8proc_grapheme_break_stateful, except without support for the - * Unicode 9 additions to the algorithm. Supported for legacy reasons. - */ -UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_grapheme_break(utf8proc_int32_t codepoint1, utf8proc_int32_t codepoint2); - - -/** - * Given a codepoint `c`, return the codepoint of the corresponding - * lower-case character, if any; otherwise (if there is no lower-case - * variant, or if `c` is not a valid codepoint) return `c`. - */ -UTF8PROC_DLLEXPORT utf8proc_int32_t utf8proc_tolower(utf8proc_int32_t c); - -/** - * Given a codepoint `c`, return the codepoint of the corresponding - * upper-case character, if any; otherwise (if there is no upper-case - * variant, or if `c` is not a valid codepoint) return `c`. - */ -UTF8PROC_DLLEXPORT utf8proc_int32_t utf8proc_toupper(utf8proc_int32_t c); - -/** - * Given a codepoint `c`, return the codepoint of the corresponding - * title-case character, if any; otherwise (if there is no title-case - * variant, or if `c` is not a valid codepoint) return `c`. - */ -UTF8PROC_DLLEXPORT utf8proc_int32_t utf8proc_totitle(utf8proc_int32_t c); - -/** - * Given a codepoint, return a character width analogous to `wcwidth(codepoint)`, - * except that a width of 0 is returned for non-printable codepoints - * instead of -1 as in `wcwidth`. - * - * @note - * If you want to check for particular types of non-printable characters, - * (analogous to `isprint` or `iscntrl`), use @ref utf8proc_category. */ -UTF8PROC_DLLEXPORT int utf8proc_charwidth(utf8proc_int32_t codepoint); - -/** - * Return the Unicode category for the codepoint (one of the - * @ref utf8proc_category_t constants.) - */ -UTF8PROC_DLLEXPORT utf8proc_category_t utf8proc_category(utf8proc_int32_t codepoint); - -/** - * Return the two-letter (nul-terminated) Unicode category string for - * the codepoint (e.g. `"Lu"` or `"Co"`). - */ -UTF8PROC_DLLEXPORT const char *utf8proc_category_string(utf8proc_int32_t codepoint); - -/** - * Maps the given UTF-8 string pointed to by `str` to a new UTF-8 - * string, allocated dynamically by `malloc` and returned via `dstptr`. - * - * If the @ref UTF8PROC_NULLTERM flag in the `options` field is set, - * the length is determined by a NULL terminator, otherwise the - * parameter `strlen` is evaluated to determine the string length, but - * in any case the result will be NULL terminated (though it might - * contain NULL characters with the string if `str` contained NULL - * characters). Other flags in the `options` field are passed to the - * functions defined above, and regarded as described. See also - * @ref utfproc_map_custom to supply a custom codepoint transformation. - * - * In case of success the length of the new string is returned, - * otherwise a negative error code is returned. - * - * @note The memory of the new UTF-8 string will have been allocated - * with `malloc`, and should therefore be deallocated with `free`. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options - ); - -/** - * Like @ref utf8proc_map, but also takes a `custom_func` mapping function - * that is called on each codepoint in `str` before any other transformations - * (along with a `custom_data` pointer that is passed through to `custom_func`). - * The `custom_func` argument is ignored if it is `NULL`. - */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options, - utf8proc_custom_func custom_func, void *custom_data - ); - -/** @name Unicode normalization - * - * Returns a pointer to newly allocated memory of a NFD, NFC, NFKD, NFKC or - * NFKC_Casefold normalized version of the null-terminated string `str`. These - * are shortcuts to calling @ref utf8proc_map with @ref UTF8PROC_NULLTERM - * combined with @ref UTF8PROC_STABLE and flags indicating the normalization. - */ -/** @{ */ -/** NFD normalization (@ref UTF8PROC_DECOMPOSE). */ -UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFD(const utf8proc_uint8_t *str); - -/** NFC normalization (@ref UTF8PROC_COMPOSE). */ -UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFC(const utf8proc_uint8_t *str); - -/** NFKD normalization (@ref UTF8PROC_DECOMPOSE and @ref UTF8PROC_COMPAT). */ -UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKD(const utf8proc_uint8_t *str); - -/** NFKC normalization (@ref UTF8PROC_COMPOSE and @ref UTF8PROC_COMPAT). */ -UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKC(const utf8proc_uint8_t *str); - -/** - * NFKC_Casefold normalization (@ref UTF8PROC_COMPOSE and @ref UTF8PROC_COMPAT - * and @ref UTF8PROC_CASEFOLD and @ref UTF8PROC_IGNORE). - **/ -UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKC_Casefold(const utf8proc_uint8_t *str); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/uncrustify.cfg b/uncrustify.cfg index 1b79bbace..36f4abf6a 100644 --- a/uncrustify.cfg +++ b/uncrustify.cfg @@ -1,4 +1,4 @@ -# Uncrustify-0.72.0-102-b22264bf +# Uncrustify-0.79.0 # # General options @@ -7,7 +7,7 @@ # The type of line endings. # # Default: auto -newlines = auto # lf/crlf/cr/auto +newlines = lf # lf/crlf/cr/auto # The original size of tabs in the input. # @@ -37,27 +37,27 @@ string_replace_tab_chars = false # true/false # Improvements to template detection may make this option obsolete. tok_split_gte = false # true/false -# Disable formatting of NL_CONT ('\\n') ended lines (e.g. multiline macros) +# Disable formatting of NL_CONT ('\\n') ended lines (e.g. multi-line macros). disable_processing_nl_cont = false # true/false # Specify the marker used in comments to disable processing of part of the # file. # # Default: *INDENT-OFF* -disable_processing_cmt = " *INDENT-OFF*" # string +disable_processing_cmt = "uncrustify:off" # string # Specify the marker used in comments to (re)enable processing in a file. # # Default: *INDENT-ON* -enable_processing_cmt = " *INDENT-ON*" # string +enable_processing_cmt = "uncrustify:on" # string # Enable parsing of digraphs. enable_digraphs = false # true/false -# Option to allow both disable_processing_cmt and enable_processing_cmt strings, -# if specified, to be interpreted as ECMAScript regular expressions. If true, -# a regex search will be performed within comments according to the specified -# patterns in order to disable/enable processing +# Option to allow both disable_processing_cmt and enable_processing_cmt +# strings, if specified, to be interpreted as ECMAScript regular expressions. +# If true, a regex search will be performed within comments according to the +# specified patterns in order to disable/enable processing. processing_cmt_as_regex = false # true/false # Add or remove the UTF-8 BOM (recommend 'remove'). @@ -70,15 +70,6 @@ utf8_byte = false # true/false # Force the output encoding to UTF-8. utf8_force = false # true/false -# Add or remove space between 'do' and '{'. -sp_do_brace_open = add # ignore/add/remove/force - -# Add or remove space between '}' and 'while'. -sp_brace_close_while = add # ignore/add/remove/force - -# Add or remove space between 'while' and '('. -sp_while_paren_open = add # ignore/add/remove/force - # # Spacing options # @@ -98,23 +89,34 @@ sp_assign = force # ignore/add/remove/force # Add or remove space around '=' in C++11 lambda capture specifications. # # Overrides sp_assign. -sp_cpp_lambda_assign = ignore # ignore/add/remove/force +sp_cpp_lambda_assign = remove # ignore/add/remove/force # Add or remove space after the capture specification of a C++11 lambda when # an argument list is present, as in '[] (int x){ ... }'. -sp_cpp_lambda_square_paren = ignore # ignore/add/remove/force +sp_cpp_lambda_square_paren = remove # ignore/add/remove/force # Add or remove space after the capture specification of a C++11 lambda with # no argument list is present, as in '[] { ... }'. -sp_cpp_lambda_square_brace = ignore # ignore/add/remove/force +sp_cpp_lambda_square_brace = add # ignore/add/remove/force + +# Add or remove space after the opening parenthesis and before the closing +# parenthesis of a argument list of a C++11 lambda, as in +# '[]( ){ ... }' +# with an empty list. +sp_cpp_lambda_argument_list_empty = remove # ignore/add/remove/force + +# Add or remove space after the opening parenthesis and before the closing +# parenthesis of a argument list of a C++11 lambda, as in +# '[]( int x ){ ... }'. +sp_cpp_lambda_argument_list = remove # ignore/add/remove/force # Add or remove space after the argument list of a C++11 lambda, as in # '[](int x) { ... }'. -sp_cpp_lambda_paren_brace = ignore # ignore/add/remove/force +sp_cpp_lambda_paren_brace = add # ignore/add/remove/force # Add or remove space between a lambda body and its call operator of an # immediately invoked lambda, as in '[]( ... ){ ... } ( ... )'. -sp_cpp_lambda_fparen = ignore # ignore/add/remove/force +sp_cpp_lambda_fparen = remove # ignore/add/remove/force # Add or remove space around assignment operator '=' in a prototype. # @@ -131,6 +133,11 @@ sp_before_assign = ignore # ignore/add/remove/force # Overrides sp_assign. sp_after_assign = ignore # ignore/add/remove/force +# Add or remove space in 'enum {'. +# +# Default: add +sp_enum_brace = force # ignore/add/remove/force + # Add or remove space in 'NS_ENUM ('. sp_enum_paren = ignore # ignore/add/remove/force @@ -145,7 +152,7 @@ sp_enum_before_assign = ignore # ignore/add/remove/force # Add or remove space after assignment '=' in enum. # # Overrides sp_enum_assign. -sp_enum_after_assign = ignore # ignore/add/remove/force +sp_enum_after_assign = force # ignore/add/remove/force # Add or remove space around assignment ':' in enum. sp_enum_colon = ignore # ignore/add/remove/force @@ -176,10 +183,7 @@ sp_inside_paren = remove # ignore/add/remove/force sp_paren_paren = remove # ignore/add/remove/force # Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('. -sp_cparen_oparen = add # ignore/add/remove/force - -# Whether to balance spaces inside nested parentheses. -sp_balance_nested_parens = false # true/false +sp_cparen_oparen = remove # ignore/add/remove/force # Add or remove space between ')' and '{'. sp_paren_brace = force # ignore/add/remove/force @@ -188,14 +192,41 @@ sp_paren_brace = force # ignore/add/remove/force sp_brace_brace = remove # ignore/add/remove/force # Add or remove space before pointer star '*'. -sp_before_ptr_star = force # ignore/add/remove/force +sp_before_ptr_star = add # ignore/add/remove/force # Add or remove space before pointer star '*' that isn't followed by a # variable name. If set to ignore, sp_before_ptr_star is used instead. sp_before_unnamed_ptr_star = remove # ignore/add/remove/force -# Add or remove space between pointer stars '*'. -sp_between_ptr_star = remove # ignore/add/remove/force +# Add or remove space before pointer star '*' that is followed by a qualifier. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_qualifier_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that is followed by 'operator' keyword. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_operator_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that is followed by +# a class scope (as in 'int *MyClass::method()') or namespace scope +# (as in 'int *my_ns::func()'). +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_scope_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that is followed by '::', +# as in 'int *::func()'. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_global_scope_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between a qualifier and a pointer star '*' that isn't +# followed by a variable name, as in '(char const *)'. If set to ignore, +# sp_before_ptr_star is used instead. +sp_qualifier_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*', as in 'int ***a;'. +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer star '*' and reference '&', as in 'int *& a;'. +sp_between_ptr_ref = remove # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a word. # @@ -214,14 +245,41 @@ sp_after_ptr_star_qualifier = force # ignore/add/remove/force # Overrides sp_after_ptr_star and sp_type_func. sp_after_ptr_star_func = add # ignore/add/remove/force +# Add or remove space after a pointer star '*' in the trailing return of a +# function prototype or function definition. +sp_after_ptr_star_trailing = ignore # ignore/add/remove/force + +# Add or remove space between the pointer star '*' and the name of the variable +# in a function pointer definition. +sp_ptr_star_func_var = remove # ignore/add/remove/force + +# Add or remove space between the pointer star '*' and the name of the type +# in a function pointer type definition. +sp_ptr_star_func_type = remove # ignore/add/remove/force + # Add or remove space after a pointer star '*', if followed by an open -# parenthesis, as in 'void* (*)(). +# parenthesis, as in 'void* (*)()'. sp_ptr_star_paren = force # ignore/add/remove/force # Add or remove space before a pointer star '*', if followed by a function -# prototype or function definition. +# prototype or function definition. If set to ignore, sp_before_ptr_star is +# used instead. sp_before_ptr_star_func = remove # ignore/add/remove/force +# Add or remove space between a qualifier and a pointer star '*' followed by +# the name of the function in a function prototype or definition, as in +# 'char const *foo()`. If set to ignore, sp_before_ptr_star is used instead. +sp_qualifier_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*' in the trailing return of a +# function prototype or function definition. +sp_before_ptr_star_trailing = remove # ignore/add/remove/force + +# Add or remove space between a qualifier and a pointer star '*' in the +# trailing return of a function prototype or function definition, as in +# 'auto foo() -> char const *'. +sp_qualifier_ptr_star_trailing = remove # ignore/add/remove/force + # Add or remove space before a reference sign '&'. sp_before_byref = ignore # ignore/add/remove/force @@ -244,6 +302,10 @@ sp_after_byref_func = ignore # ignore/add/remove/force # prototype or function definition. sp_before_byref_func = ignore # ignore/add/remove/force +# Add or remove space after a reference sign '&', if followed by an open +# parenthesis, as in 'char& (*)()'. +sp_byref_paren = ignore # ignore/add/remove/force + # Add or remove space between type and word. In cases where total removal of # whitespace would be a syntax error, a value of 'remove' is treated the same # as 'force'. @@ -257,9 +319,8 @@ sp_before_byref_func = ignore # ignore/add/remove/force # Default: force sp_after_type = force # ignore/add/remove/force -# Add or remove space between 'decltype(...)' and word. -# -# Overrides sp_after_type. +# Add or remove space between 'decltype(...)' and word, +# brace or function call. sp_after_decltype = ignore # ignore/add/remove/force # (D) Add or remove space before the parenthesis in the D constructs @@ -277,6 +338,7 @@ sp_before_angle = ignore # ignore/add/remove/force sp_inside_angle = ignore # ignore/add/remove/force # Add or remove space inside '<>'. +# if empty. sp_inside_angle_empty = ignore # ignore/add/remove/force # Add or remove space between '>' and ':'. @@ -308,24 +370,50 @@ sp_permit_cpp11_shift = false # true/false # 'while', etc.). sp_before_sparen = force # ignore/add/remove/force -# Add or remove space inside '(' and ')' of control statements. +# Add or remove space inside '(' and ')' of control statements other than +# 'for'. sp_inside_sparen = remove # ignore/add/remove/force -# Add or remove space after '(' of control statements. +# Add or remove space after '(' of control statements other than 'for'. # # Overrides sp_inside_sparen. sp_inside_sparen_open = ignore # ignore/add/remove/force -# Add or remove space before ')' of control statements. +# Add or remove space before ')' of control statements other than 'for'. # # Overrides sp_inside_sparen. sp_inside_sparen_close = ignore # ignore/add/remove/force +# Add or remove space inside '(' and ')' of 'for' statements. +sp_inside_for = remove # ignore/add/remove/force + +# Add or remove space after '(' of 'for' statements. +# +# Overrides sp_inside_for. +sp_inside_for_open = ignore # ignore/add/remove/force + +# Add or remove space before ')' of 'for' statements. +# +# Overrides sp_inside_for. +sp_inside_for_close = ignore # ignore/add/remove/force + +# Add or remove space between '((' or '))' of control statements. +sp_sparen_paren = remove # ignore/add/remove/force + # Add or remove space after ')' of control statements. sp_after_sparen = force # ignore/add/remove/force -# Add or remove space between ')' and '{' of of control statements. -sp_sparen_brace = force # ignore/add/remove/force +# Add or remove space between ')' and '{' of control statements. +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space between 'do' and '{'. +sp_do_brace_open = force # ignore/add/remove/force + +# Add or remove space between '}' and 'while'. +sp_brace_close_while = force # ignore/add/remove/force + +# Add or remove space between 'while' and '('. Overrides sp_before_sparen. +sp_while_paren_open = force # ignore/add/remove/force # (D) Add or remove space between 'invariant' and '('. sp_invariant_paren = ignore # ignore/add/remove/force @@ -344,9 +432,14 @@ sp_before_semi = remove # ignore/add/remove/force # Add or remove space before ';' in non-empty 'for' statements. sp_before_semi_for = remove # ignore/add/remove/force -# Add or remove space before a semicolon of an empty part of a for statement. +# Add or remove space before a semicolon of an empty left part of a for +# statement, as in 'for ( ; ; )'. sp_before_semi_for_empty = add # ignore/add/remove/force +# Add or remove space between the semicolons of an empty middle part of a for +# statement, as in 'for ( ; ; )'. +sp_between_semi_for_empty = add # ignore/add/remove/force + # Add or remove space after ';', except when followed by a comment. # # Default: add @@ -362,7 +455,7 @@ sp_after_semi_for = force # ignore/add/remove/force sp_after_semi_for_empty = add # ignore/add/remove/force # Add or remove space before '[' (except '[]'). -sp_before_square = ignore # ignore/add/remove/force +sp_before_square = remove # ignore/add/remove/force # Add or remove space before '[' for a variable definition. # @@ -373,7 +466,11 @@ sp_before_vardef_square = remove # ignore/add/remove/force sp_before_square_asm_block = ignore # ignore/add/remove/force # Add or remove space before '[]'. -sp_before_squares = ignore # ignore/add/remove/force +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space before C++17 structured bindings +# after byref. +sp_cpp_before_struct_binding_after_byref = ignore # ignore/add/remove/force # Add or remove space before C++17 structured bindings. sp_cpp_before_struct_binding = ignore # ignore/add/remove/force @@ -382,6 +479,7 @@ sp_cpp_before_struct_binding = ignore # ignore/add/remove/force sp_inside_square = ignore # ignore/add/remove/force # Add or remove space inside '[]'. +# if empty. sp_inside_square_empty = remove # ignore/add/remove/force # (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and @@ -391,20 +489,20 @@ sp_inside_square_oc_array = ignore # ignore/add/remove/force # Add or remove space after ',', i.e. 'a,b' vs. 'a, b'. sp_after_comma = force # ignore/add/remove/force -# Add or remove space before ','. +# Add or remove space before ',', i.e. 'a,b' vs. 'a ,b'. # # Default: remove sp_before_comma = remove # ignore/add/remove/force -# (C#) Add or remove space between ',' and ']' in multidimensional array type +# (C#, Vala) Add or remove space between ',' and ']' in multidimensional array type # like 'int[,,]'. sp_after_mdatype_commas = ignore # ignore/add/remove/force -# (C#) Add or remove space between '[' and ',' in multidimensional array type +# (C#, Vala) Add or remove space between '[' and ',' in multidimensional array type # like 'int[,,]'. sp_before_mdatype_commas = ignore # ignore/add/remove/force -# (C#) Add or remove space between ',' in multidimensional array type +# (C#, Vala) Add or remove space between ',' in multidimensional array type # like 'int[,,]'. sp_between_mdatype_commas = ignore # ignore/add/remove/force @@ -414,19 +512,31 @@ sp_between_mdatype_commas = ignore # ignore/add/remove/force # Default: force sp_paren_comma = force # ignore/add/remove/force +# Add or remove space between a type and ':'. +sp_type_colon = remove # ignore/add/remove/force + +# Add or remove space after the variadic '...' when preceded by a +# non-punctuator. +# The value REMOVE will be overridden with FORCE +sp_after_ellipsis = ignore # ignore/add/remove/force + # Add or remove space before the variadic '...' when preceded by a # non-punctuator. +# The value REMOVE will be overridden with FORCE sp_before_ellipsis = force # ignore/add/remove/force # Add or remove space between a type and '...'. sp_type_ellipsis = ignore # ignore/add/remove/force -# (D) Add or remove space between a type and '?'. -sp_type_question = ignore # ignore/add/remove/force +# Add or remove space between a '*' and '...'. +sp_ptr_type_ellipsis = ignore # ignore/add/remove/force # Add or remove space between ')' and '...'. sp_paren_ellipsis = remove # ignore/add/remove/force +# Add or remove space between '&&' and '...'. +sp_byref_ellipsis = ignore # ignore/add/remove/force + # Add or remove space between ')' and a qualifier such as 'const'. sp_paren_qualifier = ignore # ignore/add/remove/force @@ -434,16 +544,20 @@ sp_paren_qualifier = ignore # ignore/add/remove/force sp_paren_noexcept = ignore # ignore/add/remove/force # Add or remove space after class ':'. -sp_after_class_colon = ignore # ignore/add/remove/force +sp_after_class_colon = remove # ignore/add/remove/force # Add or remove space before class ':'. sp_before_class_colon = ignore # ignore/add/remove/force # Add or remove space after class constructor ':'. -sp_after_constr_colon = ignore # ignore/add/remove/force +# +# Default: add +sp_after_constr_colon = add # ignore/add/remove/force # Add or remove space before class constructor ':'. -sp_before_constr_colon = ignore # ignore/add/remove/force +# +# Default: add +sp_before_constr_colon = add # ignore/add/remove/force # Add or remove space before case ':'. # @@ -481,6 +595,12 @@ sp_sizeof_ellipsis = ignore # ignore/add/remove/force # Add or remove space between 'sizeof...' and '('. sp_sizeof_ellipsis_paren = ignore # ignore/add/remove/force +# Add or remove space between '...' and a parameter pack. +sp_ellipsis_parameter_pack = ignore # ignore/add/remove/force + +# Add or remove space between a parameter pack and '...'. +sp_parameter_pack_ellipsis = ignore # ignore/add/remove/force + # Add or remove space between 'decltype' and '('. sp_decltype_paren = ignore # ignore/add/remove/force @@ -497,20 +617,28 @@ sp_inside_braces_struct = force # ignore/add/remove/force sp_inside_braces_oc_dict = ignore # ignore/add/remove/force # Add or remove space after open brace in an unnamed temporary -# direct-list-initialization. +# direct-list-initialization +# if statement is a brace_init_lst +# works only if sp_brace_brace is set to ignore. sp_after_type_brace_init_lst_open = ignore # ignore/add/remove/force # Add or remove space before close brace in an unnamed temporary -# direct-list-initialization. +# direct-list-initialization +# if statement is a brace_init_lst +# works only if sp_brace_brace is set to ignore. sp_before_type_brace_init_lst_close = ignore # ignore/add/remove/force -# Add or remove space inside an unnamed temporary direct-list-initialization. +# Add or remove space inside an unnamed temporary direct-list-initialization +# if statement is a brace_init_lst +# works only if sp_brace_brace is set to ignore +# works only if sp_before_type_brace_init_lst_close is set to ignore. sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space inside '{' and '}'. sp_inside_braces = force # ignore/add/remove/force # Add or remove space inside '{}'. +# if empty. sp_inside_braces_empty = remove # ignore/add/remove/force # Add or remove space around trailing return operator '->'. @@ -528,7 +656,7 @@ sp_type_brace_init_lst = ignore # ignore/add/remove/force sp_func_proto_paren = remove # ignore/add/remove/force # Add or remove space between function name and '()' on function declaration -# without parameters. +# if empty. sp_func_proto_paren_empty = remove # ignore/add/remove/force # Add or remove space between function name and '(' with a typedef specifier. @@ -538,7 +666,7 @@ sp_func_type_paren = remove # ignore/add/remove/force sp_func_def_paren = remove # ignore/add/remove/force # Add or remove space between function name and '()' on function definition -# without parameters. +# if empty. sp_func_def_paren_empty = remove # ignore/add/remove/force # Add or remove space inside empty function '()'. @@ -548,6 +676,16 @@ sp_inside_fparens = remove # ignore/add/remove/force # Add or remove space inside function '(' and ')'. sp_inside_fparen = remove # ignore/add/remove/force +# Add or remove space inside user functor '(' and ')'. +sp_func_call_user_inside_rparen = ignore # ignore/add/remove/force + +# Add or remove space inside empty functor '()'. +# Overrides sp_after_angle unless use_sp_after_angle_always is set to true. +sp_inside_rparens = ignore # ignore/add/remove/force + +# Add or remove space inside functor '(' and ')'. +sp_inside_rparen = ignore # ignore/add/remove/force + # Add or remove space inside the first parentheses in a function type, as in # 'void (*x)(...)'. sp_inside_tparen = remove # ignore/add/remove/force @@ -599,6 +737,11 @@ sp_func_class_paren = remove # ignore/add/remove/force # and '()'. sp_func_class_paren_empty = ignore # ignore/add/remove/force +# Add or remove space after 'return'. +# +# Default: force +sp_return = force # ignore/add/remove/force + # Add or remove space between 'return' and '('. sp_return_paren = force # ignore/add/remove/force @@ -718,6 +861,10 @@ sp_d_array_colon = ignore # ignore/add/remove/force # Default: remove sp_not = remove # ignore/add/remove/force +# Add or remove space between two '!' (not) unary operators. +# If set to ignore, sp_not will be used. +sp_not_not = remove # ignore/add/remove/force + # Add or remove space after the '~' (invert) unary operator. # # Default: remove @@ -754,7 +901,7 @@ sp_incdec = remove # ignore/add/remove/force # Add or remove space before a backslash-newline at the end of a line. # # Default: add -sp_before_nl_cont = add # ignore/add/remove/force +sp_before_nl_cont = force # ignore/add/remove/force # (OC) Add or remove space after the scope '+' or '-', as in '-(void) foo;' # or '+(int) bar;'. @@ -878,6 +1025,14 @@ sp_extern_paren = ignore # ignore/add/remove/force # Add or remove space after the opening of a C++ comment, as in '// A'. sp_cmt_cpp_start = ignore # ignore/add/remove/force +# remove space after the '//' and the pvs command '-V1234', +# only works with sp_cmt_cpp_start set to add or force. +sp_cmt_cpp_pvs = false # true/false + +# remove space after the '//' and the command 'lint', +# only works with sp_cmt_cpp_start set to add or force. +sp_cmt_cpp_lint = false # true/false + # Add or remove space in a C++ region marker comment, as in '// BEGIN'. # A region marker is defined as a comment which is not preceded by other text # (i.e. the comment is the first non-whitespace on the line), and which starts @@ -906,7 +1061,7 @@ sp_between_new_paren = ignore # ignore/add/remove/force # Add or remove space between ')' and type in 'new(foo) BAR'. sp_after_newop_paren = ignore # ignore/add/remove/force -# Add or remove space inside parenthesis of the new operator +# Add or remove space inside parentheses of the new operator # as in 'new(foo) BAR'. sp_inside_newop_paren = ignore # ignore/add/remove/force @@ -923,11 +1078,31 @@ sp_inside_newop_paren_open = ignore # ignore/add/remove/force sp_inside_newop_paren_close = ignore # ignore/add/remove/force # Add or remove space before a trailing comment. -sp_before_tr_cmt = ignore # ignore/add/remove/force/not_defined +sp_before_tr_cmt = add # ignore/add/remove/force # Number of spaces before a trailing comment. sp_num_before_tr_cmt = 0 # unsigned number +# Add or remove space before an embedded comment. +# +# Default: force +sp_before_emb_cmt = force # ignore/add/remove/force + +# Number of spaces before an embedded comment. +# +# Default: 1 +sp_num_before_emb_cmt = 1 # unsigned number + +# Add or remove space after an embedded comment. +# +# Default: force +sp_after_emb_cmt = force # ignore/add/remove/force + +# Number of spaces after an embedded comment. +# +# Default: 1 +sp_num_after_emb_cmt = 1 # unsigned number + # (Java) Add or remove space between an annotation and the open parenthesis. sp_annotation_paren = ignore # ignore/add/remove/force @@ -940,9 +1115,18 @@ sp_after_noexcept = ignore # ignore/add/remove/force # Add or remove space after '_'. sp_vala_after_translation = ignore # ignore/add/remove/force +# Add or remove space before a bit colon ':'. +sp_before_bit_colon = remove # ignore/add/remove/force + +# Add or remove space after a bit colon ':'. +sp_after_bit_colon = remove # ignore/add/remove/force + # If true, a is inserted after #define. force_tab_after_define = false # true/false +# Add or remove space between two strings. +sp_string_string = force # ignore/add/remove/force + # # Indenting options # @@ -952,15 +1136,21 @@ force_tab_after_define = false # true/false # Default: 8 indent_columns = 2 # unsigned number +# Whether to ignore indent for the first continuation line. Subsequent +# continuation lines will still be indented to match the first. +indent_ignore_first_continue = false # true/false + # The continuation indent. If non-zero, this overrides the indent of '(', '[' # and '=' continuation indents. Negative values are OK; negative value is # absolute and not increased for each '(' or '[' level. # # For FreeBSD, this is set to 4. +# Requires indent_ignore_first_continue=false. indent_continue = 0 # number # The continuation indent, only for class header line(s). If non-zero, this # overrides the indent of 'class' continuation indents. +# Requires indent_ignore_first_continue=false. indent_continue_class_head = 0 # unsigned number # Whether to indent empty lines (i.e. lines which contain only spaces before @@ -1036,16 +1226,23 @@ indent_namespace_level = 0 # unsigned number # indented. Requires indent_namespace=true. 0 means no limit. indent_namespace_limit = 0 # unsigned number +# Whether to indent only in inner namespaces (nested in other namespaces). +# Requires indent_namespace=true. +indent_namespace_inner_only = false # true/false + # Whether the 'extern "C"' body is indented. indent_extern = false # true/false # Whether the 'class' body is indented. indent_class = false # true/false +# Whether to ignore indent for the leading base class colon. +indent_ignore_before_class_colon = true # true/false + # Additional indent before the leading base class colon. # Negative values decrease indent down to the first column. -# Requires a newline break before colon (see pos_class_colon -# and nl_class_colon) +# Requires indent_ignore_before_class_colon=false and a newline break before +# the colon (see pos_class_colon and nl_class_colon) indent_before_class_colon = 0 # number # Whether to indent the stuff after a leading base class colon. @@ -1055,14 +1252,22 @@ indent_class_colon = false # true/false # colon. Requires indent_class_colon=true. indent_class_on_colon = false # true/false +# Whether to ignore indent for a leading class initializer colon. +indent_ignore_before_constr_colon = false # true/false + # Whether to indent the stuff after a leading class initializer colon. indent_constr_colon = false # true/false -# Virtual indent from the ':' for member initializers. +# Virtual indent from the ':' for leading member initializers. # # Default: 2 indent_ctor_init_leading = 2 # unsigned number +# Virtual indent from the ':' for following member initializers. +# +# Default: 2 +indent_ctor_init_following = 2 # unsigned number + # Additional indent for constructor initializer list. # Negative values decrease indent down to the first column. indent_ctor_init = 0 # number @@ -1080,9 +1285,12 @@ indent_var_def_blk = 0 # number # Whether to indent continued variable declarations instead of aligning. indent_var_def_cont = false # true/false -# Whether to indent continued shift expressions ('<<' and '>>') instead of -# aligning. Set align_left_shift=false when enabling this. -indent_shift = false # true/false +# How to indent continued shift expressions ('<<' and '>>'). +# Set align_left_shift=false when using this. +# 0: Align shift operators instead of indenting them (default) +# 1: Indent by one level +# -1: Preserve original indentation +indent_shift = 0 # number # Whether to force indentation of function definitions to start in column 1. indent_func_def_force_col1 = false # true/false @@ -1162,8 +1370,21 @@ indent_sparen_extra = 0 # number indent_relative_single_line_comments = false # true/false # Spaces to indent 'case' from 'switch'. Usually 0 or indent_columns. +# It might be wise to choose the same value for the option indent_case_brace. indent_switch_case = 2 # unsigned number +# Spaces to indent the body of a 'switch' before any 'case'. +# Usually the same as indent_columns or indent_switch_case. +indent_switch_body = 0 # unsigned number + +# Whether to ignore indent for '{' following 'case'. +indent_ignore_case_brace = false # true/false + +# Spaces to indent '{' from 'case'. By default, the brace will appear under +# the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK. +# It might be wise to choose the same value for the option indent_switch_case. +indent_case_brace = 0 # number + # indent 'break' with 'case' from 'switch'. indent_switch_break_with_case = false # true/false @@ -1176,9 +1397,15 @@ indent_switch_pp = true # true/false # Usually 0. indent_case_shift = 0 # unsigned number -# Spaces to indent '{' from 'case'. By default, the brace will appear under -# the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK. -indent_case_brace = 0 # number +# Whether to align comments before 'case' with the 'case'. +# +# Default: true +indent_case_comment = true # true/false + +# Whether to indent comments not found in first column. +# +# Default: true +indent_comment = true # true/false # Whether to indent comments found in first column. indent_col1_comment = false # true/false @@ -1186,7 +1413,15 @@ indent_col1_comment = false # true/false # Whether to indent multi string literal in first column. indent_col1_multi_string_literal = false # true/false -# How to indent goto labels. +# Align comments on adjacent lines that are this many columns apart or less. +# +# Default: 3 +indent_comment_align_thresh = 3 # unsigned number + +# Whether to ignore indent for goto labels. +indent_ignore_label = false # true/false + +# How to indent goto labels. Requires indent_ignore_label=false. # # >0: Absolute column where 1 is the leftmost column # <=0: Subtract from brace indent @@ -1216,7 +1451,8 @@ indent_paren_nl = false # true/false # 0: Indent to body level (default) # 1: Align under the open parenthesis # 2: Indent to the brace level -indent_paren_close = 0 # unsigned number +# -1: Preserve original indentation +indent_paren_close = 0 # number # Whether to indent the open parenthesis of a function definition, # if the parenthesis is on its own line. @@ -1230,20 +1466,41 @@ indent_paren_after_func_decl = false # true/false # if the parenthesis is on its own line. indent_paren_after_func_call = false # true/false -# Whether to indent a comma when inside a parenthesis. -# If true, aligns under the open parenthesis. -indent_comma_paren = false # true/false +# How to indent a comma when inside braces. +# 0: Indent by one level (default) +# 1: Align under the open brace +# -1: Preserve original indentation +indent_comma_brace = 0 # number + +# How to indent a comma when inside parentheses. +# 0: Indent by one level (default) +# 1: Align under the open parenthesis +# -1: Preserve original indentation +indent_comma_paren = 0 # number + +# How to indent a Boolean operator when inside parentheses. +# 0: Indent by one level (default) +# 1: Align under the open parenthesis +# -1: Preserve original indentation +indent_bool_paren = 1 # number -# Whether to indent a Boolean operator when inside a parenthesis. -# If true, aligns under the open parenthesis. -indent_bool_paren = true # true/false +# Whether to ignore the indentation of a Boolean operator when outside +# parentheses. +indent_ignore_bool = false # true/false + +# Whether to ignore the indentation of an arithmetic operator. +indent_ignore_arith = false # true/false # Whether to indent a semicolon when inside a for parenthesis. # If true, aligns under the open for parenthesis. indent_semicolon_for_paren = false # true/false +# Whether to ignore the indentation of a semicolon outside of a 'for' +# statement. +indent_ignore_semicolon = false # true/false + # Whether to align the first expression to following ones -# if indent_bool_paren=true. +# if indent_bool_paren=1. indent_first_bool_expr = true # true/false # Whether to align the first expression to following ones @@ -1257,6 +1514,9 @@ indent_square_nl = false # true/false # (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies. indent_preserve_sql = false # true/false +# Whether to ignore the indentation of an assignment operator. +indent_ignore_assign = false # true/false + # Whether to align continued statements at the '='. If false or if the '=' is # followed by a newline, the next line is indent one tab. # @@ -1336,10 +1596,10 @@ indent_token_after_brace = true # true/false indent_cpp_lambda_body = false # true/false # How to indent compound literals that are being returned. -# true: add both the indent from return & the compound literal open brace (ie: -# 2 indent levels) -# false: only indent 1 level, don't add the indent for the open brace, only add -# the indent for the return. +# true: add both the indent from return & the compound literal open brace +# (i.e. 2 indent levels) +# false: only indent 1 level, don't add the indent for the open brace, only +# add the indent for the return. # # Default: true indent_compound_literal_return = true # true/false @@ -1352,11 +1612,11 @@ indent_using_block = true # true/false # How to indent the continuation of ternary operator. # # 0: Off (default) -# 1: When the `if_false` is a continuation, indent it under `if_false` +# 1: When the `if_false` is a continuation, indent it under the `if_true` branch # 2: When the `:` is a continuation, indent it under `?` indent_ternary_operator = 0 # unsigned number -# Whether to indent the statments inside ternary operator. +# Whether to indent the statements inside ternary operator. indent_inside_ternary_operator = false # true/false # If true, the indentation of the chunks after a `return` sequence will be set at return indentation column. @@ -1380,10 +1640,15 @@ donot_indent_func_def_close_paren = false # true/false # Newline adding and removing options # -# Whether to collapse empty blocks between '{' and '}'. -# If true, overrides nl_inside_empty_func +# Whether to collapse empty blocks between '{' and '}' except for functions. +# Use nl_collapse_empty_body_functions to specify how empty function braces +# should be formatted. nl_collapse_empty_body = false # true/false +# Whether to collapse empty blocks between '{' and '}' for functions only. +# If true, overrides nl_inside_empty_func. +nl_collapse_empty_body_functions = false # true/false + # Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'. nl_assign_leave_one_liners = true # true/false @@ -1404,7 +1669,7 @@ nl_cs_property_leave_one_liners = false # true/false nl_func_leave_one_liners = false # true/false # Don't split one-line C++11 lambdas, as in '[]() { return 0; }'. -nl_cpp_lambda_leave_one_liners = false # true/false +nl_cpp_lambda_leave_one_liners = true # true/false # Don't split one-line if/else statements, as in 'if(...) b++;'. nl_if_leave_one_liners = false # true/false @@ -1412,6 +1677,9 @@ nl_if_leave_one_liners = false # true/false # Don't split one-line while statements, as in 'while(...) b++;'. nl_while_leave_one_liners = false # true/false +# Don't split one-line do statements, as in 'do { b++; } while(...);'. +nl_do_leave_one_liners = false # true/false + # Don't split one-line for statements, as in 'for(...) b++;'. nl_for_leave_one_liners = false # true/false @@ -1674,7 +1942,7 @@ nl_template_var = ignore # ignore/add/remove/force nl_template_using = ignore # ignore/add/remove/force # Add or remove newline between 'class' and '{'. -nl_class_brace = ignore # ignore/add/remove/force +nl_class_brace = remove # ignore/add/remove/force # Add or remove newline before or after (depending on pos_class_comma, # may not be IGNORE) each',' in the base class list. @@ -1770,10 +2038,10 @@ nl_func_decl_args_multi_line = false # true/false nl_func_def_args_multi_line = false # true/false # Add or remove newline before the ')' in a function declaration. -nl_func_decl_end = ignore # ignore/add/remove/force +nl_func_decl_end = remove # ignore/add/remove/force # Add or remove newline before the ')' in a function definition. -nl_func_def_end = ignore # ignore/add/remove/force +nl_func_def_end = remove # ignore/add/remove/force # Overrides nl_func_decl_end when there is only one parameter. nl_func_decl_end_single = ignore # ignore/add/remove/force @@ -1833,6 +2101,16 @@ nl_template_end = false # true/false # See nl_oc_msg_leave_one_liner. nl_oc_msg_args = false # true/false +# (OC) Minimum number of Objective-C message parameters before applying nl_oc_msg_args. +nl_oc_msg_args_min_params = 0 # unsigned number + +# (OC) Max code width of Objective-C message before applying nl_oc_msg_args. +nl_oc_msg_args_max_code_width = 0 # unsigned number + +# (OC) Whether to apply nl_oc_msg_args if some of the parameters are already +# on new lines. Overrides nl_oc_msg_args_min_params and nl_oc_msg_args_max_code_width. +nl_oc_msg_args_finish_multi_line = false # true/false + # Add or remove newline between function signature and '{'. nl_fdef_brace = remove # ignore/add/remove/force @@ -1844,7 +2122,10 @@ nl_fdef_brace_cond = ignore # ignore/add/remove/force nl_cpp_ldef_brace = ignore # ignore/add/remove/force # Add or remove newline between 'return' and the return expression. -nl_return_expr = remove # ignore/add/remove/force +nl_return_expr = ignore # ignore/add/remove/force + +# Add or remove newline between 'throw' and the throw expression. +nl_throw_expr = ignore # ignore/add/remove/force # Whether to add a newline after semicolons, except in 'for' statements. nl_after_semicolon = true # true/false @@ -1854,7 +2135,8 @@ nl_after_semicolon = true # true/false nl_paren_dbrace_open = ignore # ignore/add/remove/force # Whether to add a newline after the type in an unnamed temporary -# direct-list-initialization. +# direct-list-initialization, better: +# before a direct-list-initialization. nl_type_brace_init_lst = ignore # ignore/add/remove/force # Whether to add a newline after the open brace in an unnamed temporary @@ -1865,8 +2147,10 @@ nl_type_brace_init_lst_open = ignore # ignore/add/remove/force # direct-list-initialization. nl_type_brace_init_lst_close = ignore # ignore/add/remove/force -# Whether to add a newline after '{'. This also adds a newline before the -# matching '}'. +# Whether to add a newline before '{'. +nl_before_brace_open = false # true/false + +# Whether to add a newline after '{'. nl_after_brace_open = true # true/false # Whether to add a newline between the open brace and a trailing single-line @@ -1946,6 +2230,12 @@ nl_before_do = ignore # ignore/add/remove/force # Add or remove blank line after 'do/while' statement. nl_after_do = ignore # ignore/add/remove/force +# Ignore nl_before_{if,for,switch,do,synchronized} if the control +# statement is immediately after a case statement. +# if nl_before_{if,for,switch,do} is set to remove, this option +# does nothing. +nl_before_ignore_after_case = false # true/false + # Whether to put a blank line before 'return' statements, unless after an open # brace. nl_before_return = false # true/false @@ -1977,7 +2267,7 @@ nl_constr_colon = ignore # ignore/add/remove/force # Whether to collapse a two-line namespace, like 'namespace foo\n{ decl; }' # into a single line. If true, prevents other brace newline rules from turning -# such code into four lines. +# such code into four lines. If true, it also preserves one-liner namespaces. nl_namespace_two_to_one_liner = false # true/false # Whether to remove a newline in simple unbraced if statements, turning them @@ -1997,9 +2287,8 @@ nl_create_while_one_liner = false # true/false # a single line. nl_create_func_def_one_liner = false # true/false -# Whether to collapse a function definition whose body (not counting braces) -# is only one line so that the entire definition (prototype, braces, body) is -# a single line. +# Whether to split one-line simple list definitions into three lines by +# adding newlines, as in 'int a[12] = { 0 };'. nl_create_list_one_liner = false # true/false # Whether to split one-line simple unbraced if statements into two lines by @@ -2031,7 +2320,7 @@ nl_max_blank_in_func = 3 # unsigned number # The number of newlines inside an empty function body. # This option overrides eat_blanks_after_open_brace and # eat_blanks_before_close_brace, but is ignored when -# nl_collapse_empty_body=true +# nl_collapse_empty_body_functions=true nl_inside_empty_func = 0 # unsigned number # The number of newlines before a function prototype. @@ -2069,8 +2358,21 @@ nl_after_func_class_proto_group = 0 # unsigned number nl_class_leave_one_liner_groups = false # true/false # The number of newlines after '}' of a multi-line function body. +# +# Overrides nl_min_after_func_body and nl_max_after_func_body. nl_after_func_body = 2 # unsigned number +# The minimum number of newlines after '}' of a multi-line function body. +# +# Only works when nl_after_func_body is 0. +nl_min_after_func_body = 0 # unsigned number + +# The maximum number of newlines after '}' of a multi-line function body. +# +# Only works when nl_after_func_body is 0. +# Takes precedence over nl_min_after_func_body. +nl_max_after_func_body = 0 # unsigned number + # The number of newlines after '}' of a multi-line function body in a class # declaration. Also affects class constructors/destructors. # @@ -2083,12 +2385,6 @@ nl_after_func_body_class = 0 # unsigned number # Overrides nl_after_func_body and nl_after_func_body_class. nl_after_func_body_one_liner = 0 # unsigned number -# The number of blank lines after a block of variable definitions at the top -# of a function body. -# -# 0: No change (default). -nl_func_var_def_blk = 0 # unsigned number - # The number of newlines before a block of typedefs. If nl_after_access_spec # is non-zero, that option takes precedence. # @@ -2105,15 +2401,27 @@ nl_typedef_blk_end = 0 # unsigned number # 0: No change (default). nl_typedef_blk_in = 0 # unsigned number -# The number of newlines before a block of variable definitions not at the top -# of a function body. If nl_after_access_spec is non-zero, that option takes -# precedence. +# The minimum number of blank lines after a block of variable definitions +# at the top of a function body. If any preprocessor directives appear +# between the opening brace of the function and the variable block, then +# it is considered as not at the top of the function.Newlines are added +# before trailing preprocessor directives, if any exist. +# +# 0: No change (default). +nl_var_def_blk_end_func_top = 0 # unsigned number + +# The minimum number of empty newlines before a block of variable definitions +# not at the top of a function body. If nl_after_access_spec is non-zero, +# that option takes precedence. Newlines are not added at the top of the +# file or just after an opening brace. Newlines are added above any +# preprocessor directives before the block. # # 0: No change (default). nl_var_def_blk_start = 0 # unsigned number -# The number of newlines after a block of variable definitions not at the top -# of a function body. +# The minimum number of empty newlines after a block of variable definitions +# not at the top of a function body. Newlines are not added if the block +# is at the bottom of the file or just before a preprocessor directive. # # 0: No change (default). nl_var_def_blk_end = 0 # unsigned number @@ -2126,11 +2434,11 @@ nl_var_def_blk_in = 0 # unsigned number # The minimum number of newlines before a multi-line comment. # Doesn't apply if after a brace open or another multi-line comment. -nl_before_block_comment = 0 # unsigned number +nl_before_block_comment = 1 # unsigned number # The minimum number of newlines before a single-line C comment. # Doesn't apply if after a brace open or other single-line C comments. -nl_before_c_comment = 0 # unsigned number +nl_before_c_comment = 1 # unsigned number # The minimum number of newlines before a CPP comment. # Doesn't apply if after a brace open or other CPP comments. @@ -2142,6 +2450,9 @@ nl_after_multiline_comment = false # true/false # Whether to force a newline after a label's colon. nl_after_label_colon = true # true/false +# The number of newlines before a struct definition. +nl_before_struct = 0 # unsigned number + # The number of newlines after '}' or ';' of a struct/enum/union definition. nl_after_struct = 0 # unsigned number @@ -2209,7 +2520,7 @@ nl_between_get_set = 0 # unsigned number nl_property_brace = ignore # ignore/add/remove/force # Whether to remove blank lines after '{'. -eat_blanks_after_open_brace = false # true/false +eat_blanks_after_open_brace = true # true/false # Whether to remove blank lines before '}'. eat_blanks_before_close_brace = true # true/false @@ -2437,6 +2748,22 @@ align_assign_func_proto_span = 0 # unsigned number # 0: No limit (default). align_assign_thresh = 0 # number +# Whether to align on the left most assignment when multiple +# definitions are found on the same line. +# Depends on 'align_assign_span' and 'align_assign_thresh' settings. +align_assign_on_multi_var_defs = false # true/false + +# The span for aligning on '{' in braced init list. +# +# 0: Don't align (default). +align_braced_init_list_span = 0 # unsigned number + +# The threshold for aligning on '{' in braced init list. +# Use a negative number for absolute thresholds. +# +# 0: No limit (default). +align_braced_init_list_thresh = 0 # number + # How to apply align_assign_span to function declaration "assignments", i.e. # 'virtual void foo() = 0' or '~foo() = {default|delete}'. # @@ -2487,15 +2814,15 @@ align_var_struct_gap = 0 # unsigned number # The span for aligning struct initializer values. # # 0: Don't align (default). -align_struct_init_span = 1 # unsigned number +align_struct_init_span = 0 # unsigned number # The span for aligning single-line typedefs. # # 0: Don't align (default). -align_typedef_span = 1 # unsigned number +align_typedef_span = 0 # unsigned number # The minimum space between the type and the synonym of a typedef. -align_typedef_gap = 0 # unsigned number +align_typedef_gap = 1 # unsigned number # How to align typedef'd functions with other typedefs. # @@ -2549,6 +2876,29 @@ align_right_cmt_at_col = 0 # unsigned number # 0: Don't align (default). align_func_proto_span = 0 # unsigned number +# Whether to ignore continuation lines when evaluating the number of +# new lines for the function prototype alignment's span. +# +# false: continuation lines are part of the newlines count +# true: continuation lines are not counted +align_func_proto_span_ignore_cont_lines = false # true/false + +# How to consider (or treat) the '*' in the alignment of function prototypes. +# +# 0: Part of the type 'void * foo();' (default) +# 1: Part of the function 'void *foo();' +# 2: Dangling 'void *foo();' +# Dangling: the '*' will not be taken into account when aligning. +align_func_proto_star_style = 0 # unsigned number + +# How to consider (or treat) the '&' in the alignment of function prototypes. +# +# 0: Part of the type 'long & foo();' (default) +# 1: Part of the function 'long &foo();' +# 2: Dangling 'long &foo();' +# Dangling: the '&' will not be taken into account when aligning. +align_func_proto_amp_style = 0 # unsigned number + # The threshold for aligning function prototypes. # Use a negative number for absolute thresholds. # @@ -2582,9 +2932,22 @@ align_single_line_brace_gap = 0 # unsigned number # 0: Don't align (default). align_oc_msg_spec_span = 0 # unsigned number -# Whether to align macros wrapped with a backslash and a newline. This will -# not work right if the macro contains a multi-line comment. -align_nl_cont = false # true/false +# Whether and how to align backslashes that split a macro onto multiple lines. +# This will not work right if the macro contains a multi-line comment. +# +# 0: Do nothing (default) +# 1: Align the backslashes in the column at the end of the longest line +# 2: Align with the backslash that is farthest to the left, or, if that +# backslash is farther left than the end of the longest line, at the end of +# the longest line +# 3: Align with the backslash that is farthest to the right +align_nl_cont = 1 # unsigned number + +# The minimum number of spaces between the end of a line and its continuation +# backslash. Requires align_nl_cont. +# +# Default: 1 +align_nl_cont_spaces = 1 # unsigned number # Whether to align macro functions and variables together. align_pp_define_together = false # true/false @@ -2626,7 +2989,7 @@ align_oc_decl_colon = false # true/false # (OC) Whether to not align parameters in an Objectve-C message call if first # colon is not on next line of the message call (the same way Xcode does -# aligment) +# alignment) align_oc_msg_colon_xcode_like = false # true/false # @@ -2643,12 +3006,13 @@ cmt_width = 120 # unsigned number # 2: Full reflow (enable cmt_indent_multi for indent with line wrapping due to cmt_width) cmt_reflow_mode = 0 # unsigned number -# Path to a file that contains regular expressions describing patterns for which the -# end of one line and the beginning of the next will be folded into the same sentence -# or paragraph during full comment reflow. The regular expressions are described using -# ECMAScript syntax. The syntax for this specification is as follows, where "..." indicates -# the custom regular expression and "n" indicates the nth end_of_prev_line_regex -# and beg_of_next_line_regex regular expression pair: +# Path to a file that contains regular expressions describing patterns for +# which the end of one line and the beginning of the next will be folded into +# the same sentence or paragraph during full comment reflow. The regular +# expressions are described using ECMAScript syntax. The syntax for this +# specification is as follows, where "..." indicates the custom regular +# expression and "n" indicates the nth end_of_prev_line_regex and +# beg_of_next_line_regex regular expression pair: # # end_of_prev_line_regex[1] = "...$" # beg_of_next_line_regex[1] = "^..." @@ -2660,8 +3024,8 @@ cmt_reflow_mode = 0 # unsigned number # end_of_prev_line_regex[n] = "...$" # beg_of_next_line_regex[n] = "^..." # -# Note that use of this option overrides the default reflow fold regular expressions, -# which are internally defined as follows: +# Note that use of this option overrides the default reflow fold regular +# expressions, which are internally defined as follows: # # end_of_prev_line_regex[1] = "[\w,\]\)]$" # beg_of_next_line_regex[1] = "^[\w,\[\(]" @@ -2669,6 +3033,14 @@ cmt_reflow_mode = 0 # unsigned number # beg_of_next_line_regex[2] = "^[A-Z]" cmt_reflow_fold_regex_file = "" # string +# Whether to indent wrapped lines to the start of the encompassing paragraph +# during full comment reflow (cmt_reflow_mode = 2). Overrides the value +# specified by cmt_sp_after_star_cont. +# +# Note that cmt_align_doxygen_javadoc_tags overrides this option for +# paragraphs associated with javadoc tags +cmt_reflow_indent_to_paragraph_start = false # true/false + # Whether to convert all tabs to spaces in comments. If false, tabs in # comments are left alone, unless used for indenting. cmt_convert_tab_to_spaces = false # true/false @@ -2695,6 +3067,9 @@ cmt_align_doxygen_javadoc_tags = false # true/false # Default: 1 cmt_sp_before_doxygen_javadoc_tags = 1 # unsigned number +# Whether to change trailing, single-line c-comments into cpp-comments. +cmt_trailing_single_line_c_to_cpp = false # true/false + # Whether to group c-comments that look like they are in a block. cmt_c_group = false # true/false @@ -2814,12 +3189,17 @@ mod_full_brace_function = ignore # ignore/add/remove/force mod_full_brace_if = force # ignore/add/remove/force # Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either -# have, or do not have, braces. If true, braces will be added if any block -# needs braces, and will only be removed if they can be removed from all -# blocks. -# -# Overrides mod_full_brace_if. -mod_full_brace_if_chain = false # true/false +# have, or do not have, braces. Overrides mod_full_brace_if. +# +# 0: Don't override mod_full_brace_if +# 1: Add braces to all blocks if any block needs braces and remove braces if +# they can be removed from all blocks +# 2: Add braces to all blocks if any block already has braces, regardless of +# whether it needs them +# 3: Add braces to all blocks if any block needs braces and remove braces if +# they can be removed from all blocks, except if all blocks have braces +# despite none needing them +mod_full_brace_if_chain = 0 # unsigned number # Whether to add braces to all blocks of an 'if'/'else if'/'else' chain. # If true, mod_full_brace_if_chain will only remove braces from an 'if' that @@ -2851,9 +3231,12 @@ mod_full_brace_nl = 0 # unsigned number # mod_full_brace_function mod_full_brace_nl_block_rem_mlcond = false # true/false -# Add or remove unnecessary parenthesis on 'return' statement. +# Add or remove unnecessary parentheses on 'return' statement. mod_paren_on_return = ignore # ignore/add/remove/force +# Add or remove unnecessary parentheses on 'throw' statement. +mod_paren_on_throw = ignore # ignore/add/remove/force + # (Pawn) Whether to change optional semicolons to real semicolons. mod_pawn_semicolon = false # true/false @@ -2861,9 +3244,26 @@ mod_pawn_semicolon = false # true/false # statement, as in 'if (a && b > c)' => 'if (a && (b > c))'. mod_full_paren_if_bool = false # true/false +# Whether to fully parenthesize Boolean expressions after '=' +# statement, as in 'x = a && b > c;' => 'x = (a && (b > c));'. +mod_full_paren_assign_bool = false # true/false + +# Whether to fully parenthesize Boolean expressions after '=' +# statement, as in 'return a && b > c;' => 'return (a && (b > c));'. +mod_full_paren_return_bool = false # true/false + # Whether to remove superfluous semicolons. mod_remove_extra_semicolon = false # true/false +# Whether to remove duplicate include. +mod_remove_duplicate_include = false # true/false + +# the following options (mod_XX_closebrace_comment) use different comment, +# depending of the setting of the next option. +# false: Use the c comment (default) +# true : Use the cpp comment +mod_add_force_c_closebrace_comment = false # true/false + # If a function body exceeds the specified number of newlines and doesn't have # a comment after the close brace, a comment will be added. mod_add_long_function_closebrace_comment = 0 # unsigned number @@ -2925,6 +3325,10 @@ mod_sort_incl_import_grouping_enabled = false # true/false # the close brace, as in 'case X: { ... } break;' => 'case X: { ... break; }'. mod_move_case_break = false # true/false +# Whether to move a 'return' that appears after a fully braced 'case' before +# the close brace, as in 'case X: { ... } return;' => 'case X: { ... return; }'. +mod_move_case_return = false # true/false + # Add or remove braces around a fully braced case statement. Will only remove # braces if there are no variable declarations in the block. mod_case_brace = ignore # ignore/add/remove/force @@ -2936,6 +3340,49 @@ mod_remove_empty_return = true # true/false # Add or remove the comma after the last value of an enumeration. mod_enum_last_comma = add # ignore/add/remove/force +# Syntax to use for infinite loops. +# +# 0: Leave syntax alone (default) +# 1: Rewrite as `for(;;)` +# 2: Rewrite as `while(true)` +# 3: Rewrite as `do`...`while(true);` +# 4: Rewrite as `while(1)` +# 5: Rewrite as `do`...`while(1);` +# +# Infinite loops that do not already match one of these syntaxes are ignored. +# Other options that affect loop formatting will be applied after transforming +# the syntax. +mod_infinite_loop = 0 # unsigned number + +# Add or remove the 'int' keyword in 'int short'. +mod_int_short = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'short int'. +mod_short_int = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'int long'. +mod_int_long = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'long int'. +mod_long_int = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'int signed'. +mod_int_signed = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'signed int'. +mod_signed_int = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'int unsigned'. +mod_int_unsigned = ignore # ignore/add/remove/force + +# Add or remove the 'int' keyword in 'unsigned int'. +mod_unsigned_int = ignore # ignore/add/remove/force + +# If there is a situation where mod_int_* and mod_*_int would result in +# multiple int keywords, whether to keep the rightmost int (the default) or the +# leftmost int. +mod_int_prefer_int_on_left = false # true/false + # (OC) Whether to organize the properties. If true, properties will be # rearranged according to the mod_sort_oc_property_*_weight factors. mod_sort_oc_properties = false # true/false @@ -2967,6 +3414,16 @@ mod_sort_oc_property_nullability_weight = 0 # number # Preprocessor options # +# How to use tabs when indenting preprocessor code. +# +# -1: Use 'indent_with_tabs' setting (default) +# 0: Spaces only +# 1: Indent with tabs to brace level, align with spaces +# 2: Indent and align with tabs, using spaces when not on a tabstop +# +# Default: -1 +pp_indent_with_tabs = -1 # number + # Add or remove indentation of preprocessor directives inside #if blocks # at brace level 0 (file-level). pp_indent = ignore # ignore/add/remove/force @@ -2975,6 +3432,10 @@ pp_indent = ignore # ignore/add/remove/force # indented from column 1. pp_indent_at_level = false # true/false +# Whether to indent #if/#else/#endif at the parenthesis level if the brace +# level is 0. If false, these are indented from column 1. +pp_indent_at_level0 = false # true/false + # Specifies the number of columns to indent preprocessors per level # at brace level 0 (file-level). If pp_indent_at_level=false, also specifies # the number of columns to indent preprocessors per level @@ -2983,10 +3444,10 @@ pp_indent_at_level = false # true/false # Default: 1 pp_indent_count = 1 # unsigned number -# Add or remove space after # based on pp_level of #if blocks. -pp_space = ignore # ignore/add/remove/force +# Add or remove space after # based on pp level of #if blocks. +pp_space_after = ignore # ignore/add/remove/force -# Sets the number of spaces per level added with pp_space. +# Sets the number of spaces per level added with pp_space_after. pp_space_count = 0 # unsigned number # The indent for '#region' and '#endregion' in C# and '#pragma region' in @@ -3006,40 +3467,87 @@ pp_indent_if = 0 # number # Whether to indent the code between #if, #else and #endif. pp_if_indent_code = false # true/false +# Whether to indent the body of an #if that encompasses all the code in the file. +pp_indent_in_guard = false # true/false + # Whether to indent '#define' at the brace level. If false, these are # indented from column 1. pp_define_at_level = false # true/false +# Whether to indent '#include' at the brace level. +pp_include_at_level = false # true/false + # Whether to ignore the '#define' body while formatting. pp_ignore_define_body = false # true/false +# An offset value that controls the indentation of the body of a multiline #define. +# 'body' refers to all the lines of a multiline #define except the first line. +# Requires 'pp_ignore_define_body = false'. +# +# <0: Absolute column: the body indentation starts off at the specified column +# (ex. -3 ==> the body is indented starting from column 3) +# >=0: Relative to the column of the '#' of '#define' +# (ex. 3 ==> the body is indented starting 3 columns at the right of '#') +# +# Default: 8 +pp_multiline_define_body_indent = 8 # number + # Whether to indent case statements between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the case statements +# Only applies to the indent of the preprocessor that the case statements # directly inside of. # # Default: true pp_indent_case = true # true/false # Whether to indent whole function definitions between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the function definition +# Only applies to the indent of the preprocessor that the function definition # is directly inside of. # # Default: true pp_indent_func_def = true # true/false # Whether to indent extern C blocks between #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the extern block is +# Only applies to the indent of the preprocessor that the extern block is # directly inside of. # # Default: true pp_indent_extern = true # true/false -# Whether to indent braces directly inside #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the braces are directly -# inside of. +# How to indent braces directly inside #if, #else, and #endif. +# Requires pp_if_indent_code=true and only applies to the indent of the +# preprocessor that the braces are directly inside of. +# 0: No extra indent +# 1: Indent by one level +# -1: Preserve original indentation # -# Default: true -pp_indent_brace = true # true/false +# Default: 1 +pp_indent_brace = 1 # number + +# Action to perform when unbalanced #if and #else blocks are found. +# 0: do nothing +# 1: print a warning message +# 2: terminate the program with an error (EX_SOFTWARE) +# +# The action will be triggered in the following cases: +# - if an #ifdef block ends on a different indent level than +# where it started from. Example: +# +# #ifdef TEST +# int i; +# { +# int j; +# #endif +# +# - an #elif/#else block ends on a different indent level than +# the corresponding #ifdef block. Example: +# +# #ifdef TEST +# int i; +# #else +# } +# int j; +# #endif +pp_unbalanced_if_action = 0 # unsigned number # # Sort includes options @@ -3078,18 +3586,17 @@ use_indent_func_call_param = true # true/false # # true: indent_continue will be used only once # false: indent_continue will be used every time (default) +# +# Requires indent_ignore_first_continue=false. use_indent_continue_only_once = false # true/false -# The value might be used twice: -# - at the assignment -# - at the opening brace +# The indentation can be: +# - after the assignment, at the '[' character +# - at the beginning of the lambda body # -# To prevent the double use of the indentation value, use this option with the -# value 'true'. -# -# true: indentation will be used only once -# false: indentation will be used every time (default) -indent_cpp_lambda_only_once = false # true/false +# true: indentation will be at the beginning of the lambda body +# false: indentation will be after the assignment (default) +indent_cpp_lambda_only_once = true # true/false # Whether sp_after_angle takes precedence over sp_inside_fparen. This was the # historic behavior, but is probably not the desired behavior, so this is off @@ -3107,9 +3614,8 @@ use_sp_after_angle_always = false # true/false # Default: true use_options_overriding_for_qt_macros = true # true/false -# If true: the form feed character is removed from the list -# of whitespace characters. -# See https://en.cppreference.com/w/cpp/string/byte/isspace +# If true: the form feed character is removed from the list of whitespace +# characters. See https://en.cppreference.com/w/cpp/string/byte/isspace. use_form_feed_no_more_as_whitespace_character = false # true/false # @@ -3137,6 +3643,30 @@ debug_line_number_to_protocol = 0 # number # only for linux debug_timeout = 0 # number +# Set the number of characters to be printed if the text is too long, +# 0: do not truncate. +debug_truncate = 0 # unsigned number + +# sort (or not) the tracking info. +# +# Default: true +debug_sort_the_tracks = true # true/false + +# decode (or not) the flags as a new line. +# only if the -p option is set. +debug_decode_the_flags = false # true/false + +# use (or not) the exit(EX_SOFTWARE) function. +# +# Default: true +debug_use_the_exit_function_pop = true # true/false + +# print (or not) the version in the file defined at the command option -o. +debug_print_version = false # true/false + +# insert the number of the line at the beginning of each line +set_numbering_for_html_output = false # true/false + # Meaning of the settings: # Ignore - do not do any changes # Add - makes sure there is 1 or more space/brace/newline/etc @@ -3190,4 +3720,4 @@ debug_timeout = 0 # number # # # option(s) with 'not default' value: 0 -# +# \ No newline at end of file