diff --git a/.gitignore b/.gitignore index 6b0b9ff..15b281c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ scratch # gdb files .cache/ +.vscode/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 253e8ae..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "external/http-link-header-cpp"] - path = external/http-link-header-cpp - url = https://github.com/dcdpr/http-link-header-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a6196a8..cc598a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,19 +27,106 @@ set(JSONLDCPP_VERSION ${JSONLDCPP_VERSION_MAJOR}.${JSONLDCPP_VERSION_MINOR}.${JS set(JSONLDCPP_PROJECT "jsonld-cpp" CACHE STRING "Project Name") # Test settings +option(JSONLDCPP_BUILD_TESTS "Build test executables" ON) +# Examples settings +option(JSONLDCPP_BUILD_EXAMPLES "Build example executables" ON) +# Load conanbuildinfo.cmake +option(USE_CONAN "If Conan is installed, use Conan to pull the project dependencies" OFF) + +############### +# Conan support +############### + +find_program (CONAN_BIN conan) +if(CONAN_BIN AND USE_CONAN) + message (STATUS "Found conan C++ package manager: ${CONAN_BIN}") + find_file (CONANFILE NAMES "conanfile.txt" HINTS "${CMAKE_SOURCE_DIR}") + if (CONANFILE) + message (STATUS "Found ${CONANFILE}") + if (NOT EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") + message(STATUS "Trying to execute 'conan install'") + get_filename_component(CONANFILE_DIR ${CONANFILE} DIRECTORY) + execute_process(COMMAND conan install ${CONANFILE_DIR} --build=missing) + endif() + endif() + + if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + message(STATUS "conan_basic_setup()") + conan_basic_setup(TARGETS) + else() + message(WARNING "Please run 'conan install' if you plan to use conan") + endif() +endif() -set(JSONLDCPP_BUILD_TESTS ON CACHE BOOL "Build test executables") -set(JSONLDCPP_BUILD_GOOGLETEST ON CACHE BOOL "Build googletest for testing") -set(JSONLDCPP_BUILD_RAPIDCHECK ON CACHE BOOL "Build rapidcheck for testing") +########################################## +# Local CMake scripts and finders (if any) +########################################## -# Examples settings +if (EXISTS "${CMAKE_SOURCE_DIR}/cmake/Modules/") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +endif() + +############################### +# Check compiler's capabilities +############################### -set(JSONLDCPP_BUILD_EXAMPLES ON CACHE BOOL "Build example executables") +include (CheckCCompilerFlag) +include (CheckCXXCompilerFlag) -# Install +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set (CMAKE_COMPILER_IS_CLANG true) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set (CMAKE_COMPILER_IS_MSVC true) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + find_program (LINKER_BIN gold) + if(LINKER_BIN) + set(LINKER_BIN "gold") + else() + find_program (LINKER_BIN ld.gold) + if(LINKER_BIN) + set(LINKER_BIN "ld.gold") + else() + set(LINKER_BIN "ld") + endif() + endif() + + if (CMAKE_COMPILER_IS_GNUCXX) + add_compile_options(-fdiagnostics-color=always) + elseif (CMAKE_COMPILER_IS_CLANG) + add_compile_options(-fcolor-diagnostics) + endif() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + #set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address") + + CHECK_CXX_COMPILER_FLAG("-fuse-ld=${LINKER_BIN}" USE_LINKER_LD_GOLD) + if(USE_LINKER_LD_GOLD) + set (CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=${LINKER_BIN} ${CMAKE_SHARED_LINKER_FLAGS}") + endif() +endif() -set(INSTALL_JSONLDCPP ON CACHE BOOL "Enable installation") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_MACOSX_RPATH OFF) +endif() +message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") +set (CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") +set (CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") +set (CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +message(STATUS "CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}") +message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") +message(STATUS "CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR}") # Log settings @@ -51,21 +138,12 @@ message(STATUS "JSONLDCPP_VERSION : " ${JSONLDCPP_VERSION}) message(STATUS "JSONLDCPP_BUILD_TESTS : " ${JSONLDCPP_BUILD_TESTS}) message(STATUS "JSONLDCPP_BUILD_EXAMPLES : " ${JSONLDCPP_BUILD_EXAMPLES}) -message(STATUS "INSTALL_JSONLDCPP : " ${INSTALL_JSONLDCPP}) message(STATUS "CMAKE_BUILD_TYPE : " ${CMAKE_BUILD_TYPE}) message(STATUS "CMAKE_INSTALL_PREFIX : " ${CMAKE_INSTALL_PREFIX}) message(STATUS "CMAKE_TOOLCHAIN_FILE : " ${CMAKE_TOOLCHAIN_FILE}) message(STATUS "---------------------------------------------------") -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(installDir ${CMAKE_CURRENT_BINARY_DIR}/install) -else() - set(installDir ${CMAKE_INSTALL_PREFIX}) -endif() -message(STATUS "installDir : " ${installDir}) - - # Project project(${JSONLDCPP_PROJECT} VERSION ${JSONLDCPP_VERSION} @@ -73,79 +151,14 @@ project(${JSONLDCPP_PROJECT} VERSION ${JSONLDCPP_VERSION} HOMEPAGE_URL "https://github.com/dcdpr/jsonld-cpp" LANGUAGES CXX ) - -# Super build... -include(ExternalProject) - -# Add subdirectories for external dependencies - -ExternalProject_Add(cpr - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/external/cpr - INSTALL_DIR ${installDir} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= - -DCPR_BUILD_TESTS=OFF - ) - -ExternalProject_Add(uriparser - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/external/uriparser - INSTALL_DIR ${installDir} - CMAKE_ARGS -DCMAKE_PREFIX_PATH:PATH= - -DCMAKE_INSTALL_PREFIX:PATH= - -DURIPARSER_BUILD_DOCS=OFF - -DURIPARSER_BUILD_TESTS=OFF - -DURIPARSER_BUILD_TOOLS=OFF - -DURIPARSER_BUILD_CHAR=ON - -DURIPARSER_BUILD_WCHAR_T=ON - -DURIPARSER_ENABLE_INSTALL=ON - ) - -ExternalProject_Add(http-link-header-cpp - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/external/http-link-header-cpp - GIT_REPOSITORY https://github.com/dcdpr/http-link-header-cpp.git - GIT_TAG origin/main - INSTALL_DIR ${installDir} - CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_PREFIX_PATH:PATH= - -DCMAKE_INSTALL_PREFIX:PATH= - DEPENDS uriparser - ) - -# Add local subdirectories - -ExternalProject_Add(jsonld-cpp-library - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/jsonld-cpp - INSTALL_DIR ${installDir} - CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_PREFIX_PATH:PATH= - -DCMAKE_INSTALL_PREFIX:PATH= - -DJSONLDCPP_VERSION=${JSONLDCPP_VERSION} - -DINSTALL_JSONLDCPP=${INSTALL_JSONLDCPP} - -DJSONLDCPP_BUILD_TESTS=${JSONLDCPP_BUILD_TESTS} - -DJSONLDCPP_BUILD_GOOGLETEST=${JSONLDCPP_BUILD_GOOGLETEST} - -DJSONLDCPP_BUILD_RAPIDCHECK=${JSONLDCPP_BUILD_RAPIDCHECK} - DEPENDS uriparser http-link-header-cpp cpr - ) - +add_subdirectory(jsonld-cpp) if(JSONLDCPP_BUILD_EXAMPLES) - -ExternalProject_Add(jsonld-cpp-examples - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/examples - INSTALL_DIR ${installDir} - CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_PREFIX_PATH:PATH= - -DCMAKE_INSTALL_PREFIX:PATH= - -DJSONLDCPP_VERSION=${JSONLDCPP_VERSION} - INSTALL_COMMAND "" - DEPENDS jsonld-cpp-library - ) - + add_subdirectory(examples) endif() -add_custom_target( - test - COMMAND ctest - WORKING_DIRECTORY jsonld-cpp-library-prefix/src/jsonld-cpp-library-build/test/testjsonld-cpp - DEPENDS jsonld-cpp-library) +if(JSONLDCPP_BUILD_TESTS) + enable_testing() + add_subdirectory(test) +else() + message(STATUS "Skipping unit tests") +endif() \ No newline at end of file diff --git a/README.md b/README.md index 2a44a9d..5783d90 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,17 @@ To build jsonld-cpp, you will need: jsonld-cpp uses a pretty standard cmake build system: ``` -mkdir build -cd build -cmake .. -make +mkdir build-dir && cd build-dir +conan install .. --build=missing +cmake -GNinja -DCMAKE_PREFIX_PATH=$(pwd) -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/sysroot .. +ninja +ninja test +ninja install +``` + +To export the thirdparty with Conan: +``` +conan create . jsonld-cpp/0.5.0@amazon/testing --build-require ``` You may run into permission issues during the build when the dependencies are diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..9553faa --- /dev/null +++ b/conanfile.py @@ -0,0 +1,67 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps + +required_conan_version = ">=1.53.0" + + +class JsonLdCppConan(ConanFile): + name = "jsonld-cpp" + url = "https://github.com/dcdpr/jsonld-cpp" + description = "Open Source C library that provides a set of parsers and serializers that generate Resource Description Framework (RDF) triples by parsing syntaxes or serialize the triples into a syntax." + topics = "xml", "parser", "validation" + homepage = "https://librdf.org/raptor/" + license = "Apache License Version 2.0" + + settings = "os", "arch", "compiler", "build_type" + default_options = { + "shared": False, + "fPIC": True + } + options = {name: [True, False] for name in default_options.keys()} + exports_sources = "*" + + def configure(self): + #self.options["rapidcheck"].enable_gmock = True + self.options["rapidcheck"].enable_gtest = True + + def requirements(self): + #self.requires("boost/1.81.0") + self.requires("nlohmann_json/3.11.2") + + #self.requires("cpr/1.10.0", private=True) + #FIXME: Is this dependency just pulled for uriparser ? Is there a good reason to pull http-link-header-cpp ? + self.requires("http-link-header-cpp/0.9.0@amazon/testing", private=True) + + self.requires("gtest/1.13.0", private=True, override=True) + self.requires("rapidcheck/cci.20220514", private=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JSONLDCPP_BUILD_EXAMPLES"] = True + tc.variables["JSONLDCPP_BUILD_TESTS"] = True + tc.variables["CMAKE_VERBOSE_MAKEFILE"] = True + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + project_variables = { + "JSONLDCPP_BUILD_EXAMPLES": False, + "JSONLDCPP_BUILD_TESTS": False, + "CMAKE_VERBOSE_MAKEFILE": True, + } + cmake.configure(variables=project_variables) + cmake.build() + #FIXME: tests are failing + #cmake.test() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.includedirs = ['include'] # Ordered list of include paths + self.cpp_info.libs = ["jsonld-cpp", ] # The libs to link against + self.cpp_info.system_libs = [] # System libs to link against + self.cpp_info.libdirs = ['lib'] # Directories where libraries can be found diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..349e389 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,17 @@ +[requires] +nlohmann_json/3.11.2 +http-link-header-cpp/0.9.0@amazon/testing + +[build_requires] +gtest/1.13.0 +rapidcheck/cci.20220514 + +[generators] +cmake + +[imports] +bin, *.dll -> ./bin # Copies all dll files from packages bin folder to my local "bin" folder +lib, *.dylib* -> ./lib # Copies all dylib files from packages lib folder to my local "lib" folder + +[options] +rapidcheck:enable_gtest=True \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a062996..c4cce87 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,24 +1,17 @@ -cmake_minimum_required(VERSION 3.14 FATAL_ERROR) - -project("jsonld-cpp-examples" VERSION ${JSONLDCPP_VERSION} - LANGUAGES CXX ) - -find_package(jsonld-cpp ${JSONLDCPP_VERSION} CONFIG REQUIRED) - -add_executable(jsonld2rdf jsonld2rdf.cpp) - -# Misc properties - -target_compile_features(jsonld2rdf PRIVATE cxx_std_11) -set_target_properties(jsonld2rdf PROPERTIES CXX_EXTENSIONS OFF) - -# Set version - -target_compile_definitions(jsonld2rdf PRIVATE -DJSONLDCPP_VERSION_MAJOR=${JSONLDCPP_VERSION_MAJOR}) -target_compile_definitions(jsonld2rdf PRIVATE -DJSONLDCPP_VERSION_MINOR=${JSONLDCPP_VERSION_MINOR}) -target_compile_definitions(jsonld2rdf PRIVATE -DJSONLDCPP_VERSION_PATCH=${JSONLDCPP_VERSION_PATCH}) - -# Link - -target_link_libraries(jsonld2rdf jsonld-cpp::jsonld-cpp) - +set(TARGET_jsonld2rdf jsonld2rdf) + +set(jsonld2rdf_src jsonld2rdf.cpp) +set_source_files_properties(${jsonld2rdf_src} PROPERTIES LANGUAGE "CXX") + +add_executable(${TARGET_jsonld2rdf} ${jsonld2rdf_src}) +target_compile_definitions(${TARGET_jsonld2rdf} + PRIVATE + -DJSONLDCPP_VERSION_MAJOR=${JSONLDCPP_VERSION_MAJOR} + -DJSONLDCPP_VERSION_MINOR=${JSONLDCPP_VERSION_MINOR} + -DJSONLDCPP_VERSION_PATCH=${JSONLDCPP_VERSION_PATCH}) +target_link_libraries(${TARGET_jsonld2rdf} PRIVATE jsonld-cpp) + +install(TARGETS ${TARGET_jsonld2rdf} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) \ No newline at end of file diff --git a/external/cpr/.clang-format b/external/cpr/.clang-format deleted file mode 100644 index 784d9b4..0000000 --- a/external/cpr/.clang-format +++ /dev/null @@ -1,59 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -2 -AlignAfterOpenBracket: true -AlignEscapedNewlinesLeft: true -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty -AlwaysBreakAfterDefinitionReturnType: false -AlwaysBreakTemplateDeclarations: true -AlwaysBreakBeforeMultilineStrings: true -BreakBeforeBinaryOperators: None -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BinPackParameters: true -BinPackArguments: true -ColumnLimit: 500 -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 8 -DerivePointerAlignment: false -ExperimentalAutoDetectBinPacking: false -IndentCaseLabels: true -IndentWrappedFunctionNames: false -IndentFunctionDeclarationAfterType: false -MaxEmptyLinesToKeep: 2 -KeepEmptyLinesAtTheStartOfBlocks: false -NamespaceIndentation: None -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakString: 1000 -PenaltyBreakFirstLessLess: 120 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left -SpacesBeforeTrailingComments: 1 -Cpp11BracedListStyle: true -Standard: Auto -IndentWidth: 4 -TabWidth: 8 -UseTab: Never -BreakBeforeBraces: Attach -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpacesInAngles: false -SpaceInEmptyParentheses: false -SpacesInCStyleCastParentheses: false -SpaceAfterCStyleCast: true -SpacesInContainerLiterals: true -SpaceBeforeAssignmentOperators: true -ContinuationIndentWidth: 8 -CommentPragmas: '^ IWYU pragma:' -SpaceBeforeParens: ControlStatements -... diff --git a/external/cpr/.clang-tidy b/external/cpr/.clang-tidy deleted file mode 100644 index bef5503..0000000 --- a/external/cpr/.clang-tidy +++ /dev/null @@ -1,30 +0,0 @@ ---- -Checks: '*, --cppcoreguidelines-pro-type-static-cast-downcast, --fuchsia-default-arguments-calls, --fuchsia-default-arguments, --fuchsia-default-arguments-declarations, --fuchsia-overloaded-operator, --fuchsia-statically-constructed-objects, --hicpp-use-auto, --modernize-use-auto, --modernize-use-trailing-return-type, --readability-implicit-bool-conversion, --readability-const-return-type, --google-runtime-references, --misc-non-private-member-variables-in-classes, --llvm-include-order, --cppcoreguidelines-non-private-member-variables-in-classes, --cppcoreguidelines-pro-type-vararg, --hicpp-vararg, --cppcoreguidelines-owning-memory, --llvmlibc-callee-namespace, --cppcoreguidelines-pro-bounds-array-to-pointer-decay, --hicpp-no-array-decay, --modernize-pass-by-value, --cppcoreguidelines-pro-bounds-constant-array-index, --hicpp-signed-bitwise -' -WarningsAsErrors: '*' -HeaderFilterRegex: 'src/*.hpp' -FormatStyle: file diff --git a/external/cpr/.github/workflows/ci.yml b/external/cpr/.github/workflows/ci.yml deleted file mode 100644 index 57dfb74..0000000 --- a/external/cpr/.github/workflows/ci.yml +++ /dev/null @@ -1,464 +0,0 @@ -name: CI -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - ubuntu-20-shared-gcc-ssl: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - ubuntu-20-static-gcc-ssl: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - ubuntu-18-gcc-shared-ssl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - ubuntu-18-gcc-static-ssl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - ubuntu-18-gcc-shared-ssl-system-curl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libcurl4-openssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - configure-options: -DUSE_SYSTEM_CURL=ON -DBUILD_SHARED_LIBS=ON - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - - ubuntu-18-gcc-static-ssl-system-curl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libcurl4-openssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - configure-options: -DUSE_SYSTEM_CURL=ON -DBUILD_SHARED_LIBS=OFF - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - - ubuntu-18-gcc-ssl-address-leak-undefined-behavior-sanitizer: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: Install sanitizer - run: sudo apt install libasan5 libubsan1 liblsan0 libtsan0 - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: AllSan - run-test: true - ctest-options: -V - - ubuntu-18-gcc-ssl-thread-sanitizer: - runs-on: ubuntu-18.04 - if: ${{ false }} # Disabled for now until all problems are resolved - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: Install sanitizer - run: sudo apt install libasan5 libubsan1 liblsan0 libtsan0 - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: ThreadSan - run-test: true - ctest-options: -V - - ubuntu-18-clang-shared-ssl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: clang - cxx: clang++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - ubuntu-18-clang-static-ssl: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: clang - cxx: clang++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - ubuntu-16-gcc-shared-ssl: - runs-on: ubuntu-16.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - ubuntu-16-gcc-static-ssl: - runs-on: ubuntu-16.04 - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install libssl-dev - run: sudo apt install libssl-dev - - name: "[Release g++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - cc: gcc - cxx: g++ - build-type: Release - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - windows-msvc-shared-ssl: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: "[Release msvc] Build & Test" - env: - CMAKE_GENERATOR: "Visual Studio 16 2019" - CPR_BUILD_TESTS_SSL: OFF - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - target: ALL_BUILD - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - windows-msvc-shared-winssl: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: "[Release msvc] Build & Test" - env: - CMAKE_GENERATOR: "Visual Studio 16 2019" - CPR_BUILD_TESTS_SSL: OFF - CPR_FORCE_WINSSL_BACKEND: ON - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - target: ALL_BUILD - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - windows-msvc-static-ssl: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: "[Release msvc] Build & Test" - env: - CMAKE_GENERATOR: "Visual Studio 16 2019" - CPR_BUILD_TESTS_SSL: OFF - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - target: ALL_BUILD - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - windows-msvc-shared-openssl: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install OpenSSL - run: choco install openssl - - name: "[Release msvc] Build & Test" - env: - CMAKE_GENERATOR: "Visual Studio 16 2019" - CPR_FORCE_OPENSSL_BACKEND: ON - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - target: ALL_BUILD - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - windows-msvc-static-openssl: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install OpenSSL - run: choco install openssl - - name: "[Release msvc] Build & Test" - env: - CMAKE_GENERATOR: "Visual Studio 16 2019" - CPR_FORCE_OPENSSL_BACKEND: ON - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - target: ALL_BUILD - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - macos-clang-shared-openssl: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install OpenSSL - run: | - brew install openssl - echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile - source ~/.bash_profile - - name: "[Release clang++] Build & Test" - env: - OPENSSL_ROOT_DIR: "/usr/local/opt/openssl" - OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - cc: clang - cxx: clang++ - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=ON - - macos-clang-static-openssl: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: Install OpenSSL - run: | - brew install openssl - echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile - source ~/.bash_profile - - name: "[Release clang++] Build & Test" - env: - OPENSSL_ROOT_DIR: "/usr/local/opt/openssl" - OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - cc: clang - cxx: clang++ - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - macos-clang-static-autossl: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: "[Release clang++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - cc: clang - cxx: clang++ - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF - - macos-clang-static-darwinssl: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2.2.0 - with: - submodules: true - - name: "[Release clang++] Build & Test" - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{github.workspace}}/build - source-dir: ${{github.workspace}} - build-type: Release - cc: clang - cxx: clang++ - run-test: true - ctest-options: -V - configure-options: -DBUILD_SHARED_LIBS=OFF -DCPR_FORCE_DARWINSSL_BACKEND=ON diff --git a/external/cpr/.gitignore b/external/cpr/.gitignore deleted file mode 100644 index da8503a..0000000 --- a/external/cpr/.gitignore +++ /dev/null @@ -1,51 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# CMake -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt - -# Custom -build/ - -# Jekyll stuff -_includes/ -_site/ - -# Vim -.ycm_extra_conf.py* - -# VSCode -.vscode/ - -# clangd -.cache/ diff --git a/external/cpr/CMakeLists.txt b/external/cpr/CMakeLists.txt deleted file mode 100644 index 8575b2f..0000000 --- a/external/cpr/CMakeLists.txt +++ /dev/null @@ -1,275 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(cpr VERSION 1.6 LANGUAGES CXX) - -# Only change the folder behaviour if cpr is not a subproject -if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) - set_property(GLOBAL PROPERTY USE_FOLDERS ON) - set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") - set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) - set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) -endif() - -# Avoid the dll boilerplate code for windows -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CPR_LIBRARIES cpr CACHE INTERNAL "") - -macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT) - option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT}) - if(DEFINED ENV{${OPTION_NAME}}) - # Allow setting the option through an environment variable - set(${OPTION_NAME} $ENV{${OPTION_NAME}}) - endif() - if(${OPTION_NAME}) - add_definitions(-D${OPTION_NAME}) - endif() - message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") -endmacro() - -option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON) -message(STATUS "C++ Requests CMake Options") -message(STATUS "=======================================================") -cpr_option(CPR_GENERATE_COVERAGE "Set to ON to generate coverage reports." OFF) -cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." OFF) -cpr_option(CPR_USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library. If none is found it will use the build in one." OFF) -cpr_option(CPR_FORCE_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF) -cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON) -cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF) -cpr_option(CPR_FORCE_WINSSL_BACKEND "Force to use the WinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF) -cpr_option(CPR_FORCE_DARWINSSL_BACKEND "Force to use the DarwinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF) -cpr_option(CPR_BUILD_TESTS "Set to ON to build cpr tests." ON) -cpr_option(CPR_BUILD_TESTS_SSL "Set to ON to build cpr ssl tests" ${CPR_BUILD_TESTS}) -message(STATUS "=======================================================") - -include(GNUInstallDirs) -include(FetchContent) -include(cmake/code_coverage.cmake) -include(cmake/sanitizer.cmake) -include(cmake/gcc_analyze.cmake) - -# SSL -if(CPR_ENABLE_SSL) - if(CPR_FORCE_OPENSSL_BACKEND OR CPR_FORCE_WINSSL_BACKEND OR CPR_FORCE_DARWINSSL_BACKEND) - message(STATUS "Disabled SSL backend auto detect since either CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, or CPR_FORCE_WINSSL_BACKEND is enabled.") - set(DETECT_SSL_BACKEND OFF CACHE INTERNAL "" FORCE) - else() - message(STATUS "Automatically detecting SSL backend.") - set(DETECT_SSL_BACKEND ON CACHE INTERNAL "" FORCE) - endif() - - if(CPR_FORCE_WINSSL_BACKEND AND (NOT WIN32)) - message(FATAL_ERROR "WinSSL is only available on Windows! Use either OpenSSL (CPR_FORCE_OPENSSL_BACKEND) or DarwinSSL (CPR_FORCE_DARWINSSL_BACKEND) instead.") - endif() - - if(DETECT_SSL_BACKEND) - message(STATUS "Detecting SSL backend...") - if(WIN32) - message(STATUS "SSL auto detect: Using WinSSL.") - set(SSL_BACKEND_USED "WinSSL") - elseif(APPLE) - message(STATUS "SSL auto detect: Using DarwinSSL.") - set(CPR_BUILD_TESTS_SSL OFF) - set(SSL_BACKEND_USED "DarwinSSL") - else() - find_package(OpenSSL) - if(OPENSSL_FOUND) - message(STATUS "SSL auto detect: Using OpenSSL.") - set(SSL_BACKEND_USED "OpenSSL") - else() - message(FATAL_ERROR "No valid SSL backend found! Please install OpenSSL or disable SSL by setting CPR_ENABLE_SSL to OFF.") - endif() - endif() - else() - if(CPR_FORCE_OPENSSL_BACKEND) - find_package(OpenSSL) - if(OPENSSL_FOUND) - message(STATUS "Using OpenSSL.") - set(SSL_BACKEND_USED "OpenSSL") - else() - message(FATAL_ERROR "CPR_FORCE_OPENSSL_BACKEND enabled but we were not able to find OpenSSL!") - endif() - elseif(CPR_FORCE_WINSSL_BACKEND) - message(STATUS "Using WinSSL.") - set(SSL_BACKEND_USED "WinSSL") - elseif(CPR_FORCE_DARWINSSL_BACKEND) - message(STATUS "Using DarwinSSL.") - set(CPR_BUILD_TESTS_SSL OFF) - set(SSL_BACKEND_USED "DarwinSSL") - endif() - endif() -endif() - -get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (NOT isMultiConfig) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${ALLOWED_BUILD_TYPES}") - if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) - elseif(NOT CMAKE_BUILD_TYPE IN_LIST ALLOWED_BUILD_TYPES) - message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") - endif() -else () - unset(CMAKE_BUILD_TYPE) - foreach(TYPE ${ALLOWED_BUILD_TYPES}) - if (NOT ${TYPE} IN_LIST CMAKE_CONFIGURATION_TYPES) - list(APPEND CMAKE_CONFIGURATION_TYPES ${TYPE}) - endif() - endforeach() -endif() - -# Curl configuration -if(CPR_FORCE_USE_SYSTEM_CURL) - if(CPR_ENABLE_SSL) - find_package(CURL COMPONENTS HTTP HTTPS SSL) - if(CURL_FOUND) - message(STATUS "Curl ${CURL_VERSION_STRING} found on this system.") - # To be able to load certificates under Windows when using OpenSSL: - if(CMAKE_USE_OPENSSL AND WIN32 AND (NOT (CURL_VERSION_STRING VERSION_GREATER_EQUAL "7.71.0"))) - message(FATAL_ERROR "Your system curl version (${CURL_VERSION_STRING}) is too old to support OpenSSL on Windows which requires curl >= 7.71.0. Update your curl version, use WinSSL, disable SSL or use the build in version of curl.") - endif() - else() - find_package(CURL COMPONENTS HTTP) - if(CURL_FOUND) - message(FATAL_ERROR "Curl found on this system but WITHOUT HTTPS/SSL support. Either disable SSL by setting CPR_ENABLE_SSL to OFF or use the build in version of curl by setting CPR_FORCE_USE_SYSTEM_CURL to OFF.") - else() - message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") - endif() - endif() - else() - find_package(CURL COMPONENTS HTTP) - if(CURL_FOUND) - message(STATUS "Curl found on this system.") - else() - message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") - endif() - endif() -else() - message(STATUS "Configuring build in curl...") - - # ZLIB is required by curl: - include(cmake/zlib_external.cmake) - - # We only need HTTP (and HTTPS) support: - set(HTTP_ONLY ON CACHE INTERNAL "" FORCE) - set(BUILD_CURL_EXE OFF CACHE INTERNAL "" FORCE) - set(BUILD_TESTING OFF) - - if (CPR_ENABLE_SSL) - set(SSL_ENABLED ON CACHE INTERNAL "" FORCE) - set(CURL_CA_PATH "auto" CACHE INTERNAL "" FORCE) - message(STATUS "Enabled curl SSL") - else() - set(SSL_ENABLED OFF CACHE INTERNAL "" FORCE) - set(CURL_CA_PATH "none" CACHE INTERNAL "" FORCE) - message(STATUS "Disabled curl SSL") - endif() - - if(SSL_BACKEND_USED STREQUAL "WinSSL") - set(CMAKE_USE_SCHANNEL ON CACHE INTERNAL "" FORCE) - endif() - - if(SSL_BACKEND_USED STREQUAL "OpenSSL") - set(CMAKE_USE_OPENSSL ON CACHE INTERNAL "" FORCE) - endif() - - if(SSL_BACKEND_USED STREQUAL "DarwinSSL") - set(CMAKE_USE_SECTRANSP ON CACHE INTERNAL "" FORCE) - endif() - - # Show progress of FetchContent: - set(FETCHCONTENT_QUIET OFF CACHE INTERNAL "" FORCE) - FetchContent_Declare(curl - URL https://github.com/curl/curl/releases/download/curl-7_75_0/curl-7.75.0.tar.xz - URL_HASH SHA256=fe0c49d8468249000bda75bcfdf9e30ff7e9a86d35f1a21f428d79c389d55675 # the file hash for curl-7.75.0.tar.xz - USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress - FetchContent_MakeAvailable(curl) - - add_library(curl_int INTERFACE) - target_link_libraries(curl_int INTERFACE libcurl) - target_include_directories(curl_int INTERFACE ${curl_SOURCE_DIR}/include ${curl_BINARY_DIR}/include/curl) - add_library(CURL::libcurl ALIAS curl_int) - - # Group under the "external" project folder in IDEs such as Visual Studio. - if(BUILD_CURL_EXE) - set_property(TARGET curl PROPERTY FOLDER "external") - endif() - - set_property(TARGET libcurl PROPERTY FOLDER "external") -endif() - -# GTest configuration -if(CPR_BUILD_TESTS) - if(USE_SYSTEM_GTEST) - find_package(GTest) - endif() - if(NOT USE_SYSTEM_GTEST OR NOT GTEST_FOUND) - message(STATUS "Not using system gtest, using built-in googletest project instead.") - if(MSVC) - # By default, GTest compiles on Windows in CRT static linkage mode. We use this - # variable to force it into using the CRT in dynamic linkage (DLL), just as CPR - # does. - set(gtest_force_shared_crt ON CACHE BOOL "Force gtest to use the shared c runtime") - endif() - FetchContent_Declare(googletest - URL https://github.com/google/googletest/archive/release-1.10.0.tar.gz - URL_HASH SHA256=9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb # the file hash for release-1.10.0.tar.gz - USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress - FetchContent_MakeAvailable(googletest) - - add_library(gtest_int INTERFACE) - target_link_libraries(gtest_int INTERFACE gtest) - target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include) - - add_library(GTest::GTest ALIAS gtest_int) - - # Group under the "tests/gtest" project folder in IDEs such as Visual Studio. - set_property(TARGET gtest PROPERTY FOLDER "tests/gtest") - set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest") - endif() -endif() - - -# Mongoose configuration -if(CPR_BUILD_TESTS) - message(STATUS "Building mongoose project for test support.") - - if(CPR_BUILD_TESTS_SSL) - if(NOT CPR_ENABLE_SSL) - message(FATAL_ERROR "OpenSSL is required to build SSL test but CPR_ENABLE_SSL is disabled. Either set CPR_ENABLE_SSL to ON or disable CPR_BUILD_TESTS_SSL.") - endif() - - if(NOT(SSL_BACKEND_USED STREQUAL "OpenSSL")) - message(FATAL_ERROR "OpenSSL is required for SSL test, but it seams like OpenSSL is not being used as SSL backend. Either set CPR_BUILD_TESTS_SSL to OFF or set CPR_FORCE_OPENSSL_BACKEND to ON and try again.") - endif() - - set(ENABLE_SSL_TESTS ON CACHE INTERNAL "") - else() - set(ENABLE_SSL_TESTS OFF CACHE INTERNAL "") - endif() - - FetchContent_Declare(mongoose - URL https://github.com/cesanta/mongoose/archive/6.18.tar.gz - URL_HASH SHA256=f5c10346abc9c72f7cac7885d853ca064fb09aad57580433941a8fd7a3543769 # the hash for 6.18.tar.gz - USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress - # We can not use FetchContent_MakeAvailable, since we need to patch mongoose to use CMake - if (NOT mongoose_POPULATED) - FetchContent_POPULATE(mongoose) - - file(INSTALL cmake/mongoose.CMakeLists.txt DESTINATION ${mongoose_SOURCE_DIR}) - file(RENAME ${mongoose_SOURCE_DIR}/mongoose.CMakeLists.txt ${mongoose_SOURCE_DIR}/CMakeLists.txt) - add_subdirectory(${mongoose_SOURCE_DIR} ${mongoose_BINARY_DIR}) - - endif() - # Group under the "external" project folder in IDEs such as Visual Studio. - set_property(TARGET mongoose PROPERTY FOLDER "external") -endif() - - -add_subdirectory(cpr) -add_subdirectory(include) - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND CPR_BUILD_TESTS) - enable_testing() - add_subdirectory(test) -endif() diff --git a/external/cpr/CONTRIBUTING.md b/external/cpr/CONTRIBUTING.md deleted file mode 100644 index abfb97c..0000000 --- a/external/cpr/CONTRIBUTING.md +++ /dev/null @@ -1,27 +0,0 @@ -# Contributing to C++ Requests - -Please fork this repository and contribute back using [pull requests](https://github.com/whoshuu/cpr/pulls). Features can be requested using [issues](https://github.com/whoshuu/cpr/issues). All code, comments, and critiques are greatly appreciated. - -## Formatting - -To avoid unproductive debates on formatting, this project uses `clang-format` to ensure a consistent style across all source files. Currently, `clang-format` 3.8 is the version of `clang-format` we use. The format file can be found [here](https://github.com/whoshuu/cpr/blob/master/.clang-format). To install `clang-format` on Ubuntu, run this: - -``` -apt-get install clang-format-3.8 -``` - -To install `clang-format` on OS X, run this: - -``` -brew install clang-format -``` - -Note that `brew` might install a later version of `clang-format`, but it should be mostly compatible with what's run on the Travis servers. - -To run `clang-format` on every source file, run this in the root directory: - -``` -./format-check.sh -``` - -This should indicate which files need formatting and also show a diff of the requested changes. More specific usage instructions can be found on the official [LLVM website](http://releases.llvm.org/3.8.0/tools/clang/docs/ClangFormat.html). diff --git a/external/cpr/LICENSE b/external/cpr/LICENSE deleted file mode 100644 index d173854..0000000 --- a/external/cpr/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Huu Nguyen - -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. diff --git a/external/cpr/README.md b/external/cpr/README.md deleted file mode 100644 index ac951b4..0000000 --- a/external/cpr/README.md +++ /dev/null @@ -1,153 +0,0 @@ -# C++ Requests: Curl for People - -[![Documentation](https://img.shields.io/badge/docs-online-informational?style=flat&link=https://whoshuu.github.io/cpr/)](https://whoshuu.github.io/cpr/) -![CI](https://github.com/whoshuu/cpr/workflows/CI/badge.svg) - -## Announcements - -The cpr project has new maintainers: [Fabian Sauter](https://github.com/com8) and [Tim Stack](https://github.com/tstack). - -## TLDR - -C++ Requests is a simple wrapper around [libcurl](http://curl.haxx.se/libcurl) inspired by the excellent [Python Requests](https://github.com/kennethreitz/requests) project. - -Despite its name, libcurl's easy interface is anything but, and making mistakes misusing it is a common source of error and frustration. Using the more expressive language facilities of C++11, this library captures the essence of making network calls into a few concise idioms. - -Here's a quick GET request: - -```c++ -#include - -int main(int argc, char** argv) { - cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"}, - cpr::Authentication{"user", "pass"}, - cpr::Parameters{{"anon", "true"}, {"key", "value"}}); - r.status_code; // 200 - r.header["content-type"]; // application/json; charset=utf-8 - r.text; // JSON text string -} -``` - -And here's [less functional, more complicated code, without cpr](https://gist.github.com/whoshuu/2dc858b8730079602044). - -## Documentation - -[![Documentation](https://img.shields.io/badge/docs-online-informational?style=for-the-badge&link=https://whoshuu.github.io/cpr/)](https://whoshuu.github.io/cpr/) -You can find the latest documentation [here](https://whoshuu.github.io/cpr). It's a work in progress, but it should give you a better idea of how to use the library than the [tests](https://github.com/whoshuu/cpr/tree/master/test) currently do. - -## Features - -C++ Requests currently supports: - -* Custom headers -* Url encoded parameters -* Url encoded POST values -* Multipart form POST upload -* File POST upload -* Basic authentication -* Bearer authentication -* Digest authentication -* NTLM authentication -* Connection and request timeout specification -* Timeout for low speed connection -* Asynchronous requests -* :cookie: support! -* Proxy support -* Callback interfaces -* PUT methods -* DELETE methods -* HEAD methods -* OPTIONS methods -* PATCH methods -* Thread Safe access to [libCurl](https://curl.haxx.se/libcurl/c/threadsafe.html) -* OpenSSL and WinSSL support for HTTPS requests - -## Planned - -For a quick overview about the planed features, have a look at the next [Milestones](https://github.com/whoshuu/cpr/milestones). - -## Usage - -### CMake - -If you already have a CMake project you need to integrate C++ Requests with, the primary way is to use `fetch_content`. -Add the following to your `CMakeLists.txt`. - - -```cmake -include(FetchContent) -FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG c8d33915dbd88ad6c92b258869b03aba06587ff9) # the commit hash for 1.5.0 -FetchContent_MakeAvailable(cpr) -``` - -This will produce the target `cpr::cpr` which you can link against the typical way: - -```cmake -target_link_libraries(your_target_name PRIVATE cpr::cpr) -``` - -That should do it! -There's no need to handle `libcurl` yourself. All dependencies are taken care of for you. - -### Packages for Linux Distributions - -Alternatively, you may install a package specific to your Linux distribution. Since so few distributions currently have a package for cpr, most users will not be able to run your program with this approach. - -Currently, we are aware of packages for the following distributions: - -* [Arch Linux (AUR)](https://aur.archlinux.org/packages/cpr) - -If there's no package for your distribution, try making one! If you do, and it is added to your distribution's repositories, please submit a pull request to add it to the list above. However, please only do this if you plan to actively maintain the package. - -## Requirements - -The only explicit requirements are: - -* a `C++11` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let me know -* If you would like to perform https requests `OpenSSL` and its development libraries are required. - -## Building cpr - Using vcpkg - -You can download and install cpr using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: -```Bash -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -./bootstrap-vcpkg.sh -./vcpkg integrate install -./vcpkg install cpr -``` -The `cpr` port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. - -## Building cpr - Using Conan - -You can download and install `cpr` using the [Conan](https://conan.io/) package manager. Setup your CMakeLists.txt (see [Conan documentation](https://docs.conan.io/en/latest/integrations/build_system.html) on how to use MSBuild, Meson and others) like this: - -```CMake -project(myproject CXX) - -add_executable(${PROJECT_NAME} main.cpp) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) # Include Conan-generated file -conan_basic_setup(TARGETS) # Introduce Conan-generated targets - -target_link_libraries(${PROJECT_NAME} CONAN_PKG::cpr) -``` -Create `conanfile.txt` in your source dir: -``` -[requires] -cpr/1.5.0 - -[generators] -cmake -``` -Install and run Conan, then build your project as always: - -```Bash -pip install conan -mkdir build -cd build -conan install ../ --build=missing -cmake ../ -cmake --build . -``` -The `cpr` package in Conan is kept up to date by Conan contributors. If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the `conan-center-index` repository. diff --git a/external/cpr/cmake/code_coverage.cmake b/external/cpr/cmake/code_coverage.cmake deleted file mode 100644 index eefc4fb..0000000 --- a/external/cpr/cmake/code_coverage.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# Code coverage -if(CPR_BUILD_TESTS AND CPR_GENERATE_COVERAGE) - set(CMAKE_BUILD_TYPE COVERAGE CACHE INTERNAL "Coverage enabled build") - message(STATUS "Enabling gcov support") - if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(COVERAGE_FLAG "--coverage") - endif() - set(CMAKE_CXX_FLAGS_COVERAGE - "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE) - set(CMAKE_C_FLAGS_COVERAGE - "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during coverage builds." - FORCE) - set(CMAKE_EXE_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE) - set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE) - mark_as_advanced( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE) -endif() diff --git a/external/cpr/cmake/gcc_analyze.cmake b/external/cpr/cmake/gcc_analyze.cmake deleted file mode 100644 index a191683..0000000 --- a/external/cpr/cmake/gcc_analyze.cmake +++ /dev/null @@ -1,12 +0,0 @@ -include(CheckCXXCompilerFlag) - -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - check_cxx_compiler_flag("-fanalyzer" HAS_GCC_STATIC_ANALYZER) - if(HAS_GCC_STATIC_ANALYZER AND NOT ENABLE_LINTING) - option(ENABLE_GCC_STATIC_ANALYZER "Enable linting with the GCC static analyzer" OFF) - if(ENABLE_GCC_STATIC_ANALYZER) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fanalyzer") - set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fanalyzer") - endif() - endif() -endif() diff --git a/external/cpr/cmake/mongoose.CMakeLists.txt b/external/cpr/cmake/mongoose.CMakeLists.txt deleted file mode 100644 index 2a2c2a3..0000000 --- a/external/cpr/cmake/mongoose.CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(mongoose C) - - -add_library(mongoose STATIC mongoose.c) -target_include_directories(mongoose PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - -if(ENABLE_SSL_TESTS) - # Enable mongoose SSL - target_compile_definitions(mongoose PUBLIC MG_ENABLE_SSL) - target_link_libraries(mongoose PRIVATE OpenSSL::SSL) -endif() diff --git a/external/cpr/cmake/sanitizer.cmake b/external/cpr/cmake/sanitizer.cmake deleted file mode 100644 index 0afc97f..0000000 --- a/external/cpr/cmake/sanitizer.cmake +++ /dev/null @@ -1,70 +0,0 @@ -include(CheckCXXCompilerFlag) -include(CheckCXXSourceRuns) - -set(ALLOWED_BUILD_TYPES Debug Release RelWithDebInfo MinSizeRel) -set(ALL_SAN_FLAGS "") - -# Thread sanitizer -set(THREAD_SAN_FLAGS "-fsanitize=thread") -set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS}) -set(CMAKE_REQUIRED_FLAGS "${THREAD_SAN_FLAGS}") -check_cxx_source_runs("int main() { return 0; }" THREAD_SANITIZER_AVAILABLE) -set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG}) -if(THREAD_SANITIZER_AVAILABLE) - list(APPEND ALLOWED_BUILD_TYPES ThreadSan) - # Do not add Thread sanitizer to all sanitizer because it is incompatible with other sanitizer -endif() -set(CMAKE_C_FLAGS_THREADSAN "${CMAKE_C_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during thread sanitizer builds." FORCE) -set(CMAKE_CXX_FLAGS_THREADSAN "${CMAKE_CXX_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during thread sanitizer builds." FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_THREADSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Flags used for the linker during thread sanitizer builds" FORCE) - -# Address sanitizer -set(ADDR_SAN_FLAGS "-fsanitize=address") -set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS}) -set(CMAKE_REQUIRED_FLAGS "${ADDR_SAN_FLAGS}") -check_cxx_source_runs("int main() { return 0; }" ADDRESS_SANITIZER_AVAILABLE) -set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG}) -if(ADDRESS_SANITIZER_AVAILABLE) - list(APPEND ALLOWED_BUILD_TYPES AddrSan) - set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${ADDR_SAN_FLAGS}") -endif() -set(CMAKE_C_FLAGS_ADDRSAN "${CMAKE_C_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during address sanitizer builds." FORCE) -set(CMAKE_CXX_FLAGS_ADDRSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during address sanitizer builds." FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_ADDRSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Flags used for the linker during address sanitizer builds" FORCE) - -# Leak sanitizer -set(LEAK_SAN_FLAGS "-fsanitize=leak") -check_cxx_compiler_flag(${LEAK_SAN_FLAGS} LEAK_SANITIZER_AVAILABLE) -if(LEAK_SANITIZER_AVAILABLE) - list(APPEND ALLOWED_BUILD_TYPES LeakSan) - set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${LEAK_SAN_FLAGS}") -endif() -set(CMAKE_C_FLAGS_LEAKSAN "${CMAKE_C_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C compiler during leak sanitizer builds." FORCE) -set(CMAKE_CXX_FLAGS_LEAKSAN "${CMAKE_CXX_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C++ compiler during leak sanitizer builds." FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_LEAKSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Flags used for the linker during leak sanitizer builds" FORCE) - -# Undefined behavior sanitizer -set(UDEF_SAN_FLAGS "-fsanitize=undefined") -check_cxx_compiler_flag(${UDEF_SAN_FLAGS} UNDEFINED_BEHAVIOUR_SANITIZER_AVAILABLE) -if(UNDEFINED_BEHAVIOUR_SANITIZER_AVAILABLE) - list(APPEND ALLOWED_BUILD_TYPES UdefSan) - set(ALL_SAN_FLAGS "${ALL_SAN_FLAGS} ${UDEF_SAN_FLAGS}") -endif() -set(CMAKE_C_FLAGS_UDEFSAN "${CMAKE_C_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during undefined behaviour sanitizer builds." FORCE) -set(CMAKE_CXX_FLAGS_UDEFSAN "${CMAKE_CXX_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during undefined behaviour sanitizer builds." FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_UDEFSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Flags used for the linker during undefined behaviour sanitizer builds" FORCE) - -# All sanitizer (without thread sanitizer) -if(NOT ALL_SAN_FLAGS STREQUAL "") - set(PREV_FLAG ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "${ALL_SAN_FLAGS}") - check_cxx_source_runs("int main() { return 0; }" ALL_SANITIZERS_AVAILABLE) - set(CMAKE_REQUIRED_FLAGS ${PREV_FLAG}) - if(ALL_SANITIZERS_AVAILABLE) - list(APPEND ALLOWED_BUILD_TYPES AllSan) - endif() -endif() - -set(CMAKE_C_FLAGS_ALLSAN "${CMAKE_C_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during most possible sanitizer builds." FORCE) -set(CMAKE_CXX_FLAGS_ALLSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during most possible sanitizer builds." FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_ALLSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Flags used for the linker during most possible sanitizer builds" FORCE) diff --git a/external/cpr/cmake/zlib_external.cmake b/external/cpr/cmake/zlib_external.cmake deleted file mode 100644 index 35fdd3c..0000000 --- a/external/cpr/cmake/zlib_external.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# ZLIB - -# Fix Windows missing "zlib.dll": -if(WIN32 AND (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/$ CACHE INTERNAL "" FORCE) -endif() - -set(ZLIB_COMPAT ON CACHE INTERNAL "" FORCE) -set(ZLIB_ENABLE_TESTS OFF CACHE INTERNAL "" FORCE) -set(ZLIB_ENABLE_TESTS OFF CACHE INTERNAL "" FORCE) - -set(FETCHCONTENT_QUIET OFF CACHE INTERNAL "" FORCE) -FetchContent_Declare(zlib - GIT_REPOSITORY https://github.com/zlib-ng/zlib-ng - GIT_TAG v2.0.0-RC2 - USES_TERMINAL_DOWNLOAD TRUE) -FetchContent_MakeAvailable(zlib) - -# Fix Windows zlib dll names from "zlibd1.dll" to "zlib.dll": -if(WIN32) - set_target_properties(zlib PROPERTIES OUTPUT_NAME "zlib") - set_target_properties(zlib PROPERTIES DEBUG_POSTFIX "") - set_target_properties(zlib PROPERTIES SUFFIX ".dll") -endif() diff --git a/external/cpr/cpr-config.cmake b/external/cpr/cpr-config.cmake deleted file mode 100644 index 58ab483..0000000 --- a/external/cpr/cpr-config.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# - C++ Requests, Curl for People -# This module is a libcurl wrapper written in modern C++. -# It provides an easy, intuitive, and efficient interface to -# a host of networking methods. -# -# Finding this module will define the following variables: -# CPR_FOUND - True if the core library has been found -# CPR_LIBRARIES - Path to the core library archive -# CPR_INCLUDE_DIRS - Path to the include directories. Gives access -# to cpr.h, which must be included in every -# file that uses this interface - -find_path(CPR_INCLUDE_DIR - NAMES cpr.h) - -find_library(CPR_LIBRARY - NAMES cpr - HINTS ${CPR_LIBRARY_ROOT}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CPR REQUIRED_VARS CPR_LIBRARY CPR_INCLUDE_DIR) - -if(CPR_FOUND) - set(CPR_LIBRARIES ${CPR_LIBRARY}) - set(CPR_INCLUDE_DIRS ${CPR_INCLUDE_DIR}) -endif() diff --git a/external/cpr/cpr/CMakeLists.txt b/external/cpr/cpr/CMakeLists.txt deleted file mode 100644 index 8061a14..0000000 --- a/external/cpr/cpr/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -add_library(cpr - auth.cpp - bearer.cpp - cookies.cpp - cprtypes.cpp - curl_container.cpp - curlholder.cpp - error.cpp - multipart.cpp - parameters.cpp - payload.cpp - proxies.cpp - session.cpp - timeout.cpp - unix_socket.cpp - util.cpp - response.cpp - ) - -add_library(cpr::cpr ALIAS cpr) - -target_link_libraries(cpr PUBLIC CURL::libcurl) # todo should be private, but first dependencys in ssl_options need to be removed - -# Set version for shared libraries. -set_target_properties(cpr - PROPERTIES - VERSION ${${PROJECT_NAME}_VERSION} - SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) - -install(TARGETS cpr) diff --git a/external/cpr/cpr/auth.cpp b/external/cpr/cpr/auth.cpp deleted file mode 100644 index 7d55d4b..0000000 --- a/external/cpr/cpr/auth.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "cpr/auth.h" - -namespace cpr { -const char* Authentication::GetAuthString() const noexcept { - return auth_string_.c_str(); -} -} // namespace cpr diff --git a/external/cpr/cpr/bearer.cpp b/external/cpr/cpr/bearer.cpp deleted file mode 100644 index 5b7eb93..0000000 --- a/external/cpr/cpr/bearer.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "cpr/bearer.h" - -namespace cpr { -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 -const char* Bearer::GetToken() const noexcept { - return token_string_.c_str(); -} -#endif -} // namespace cpr diff --git a/external/cpr/cpr/cookies.cpp b/external/cpr/cpr/cookies.cpp deleted file mode 100644 index 4bd5855..0000000 --- a/external/cpr/cpr/cookies.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "cpr/cookies.h" - -namespace cpr { -std::string Cookies::GetEncoded(const CurlHolder& holder) const { - std::stringstream stream; - for (const std::pair& item : map_) { - // Depending on if encoding is set to "true", we will URL-encode cookies - stream << (encode ? holder.urlEncode(item.first) : item.first) << "="; - - // special case version 1 cookies, which can be distinguished by - // beginning and trailing quotes - if (!item.second.empty() && item.second.front() == '"' && item.second.back() == '"') { - stream << item.second; - } else { - // Depending on if encoding is set to "true", we will URL-encode cookies - stream << (encode ? holder.urlEncode(item.second) : item.second); - } - stream << "; "; - } - return stream.str(); -} - -std::string& Cookies::operator[](const std::string& key) { - return map_[key]; -} - -Cookies::iterator Cookies::begin() { - return map_.begin(); -} - -Cookies::iterator Cookies::end() { - return map_.end(); -} - -Cookies::const_iterator Cookies::begin() const { - return map_.begin(); -} - -Cookies::const_iterator Cookies::end() const { - return map_.end(); -} - -Cookies::const_iterator Cookies::cbegin() const { - return map_.cbegin(); -} - -Cookies::const_iterator Cookies::cend() const { - return map_.cend(); -} - -} // namespace cpr diff --git a/external/cpr/cpr/cprtypes.cpp b/external/cpr/cpr/cprtypes.cpp deleted file mode 100644 index c618b3f..0000000 --- a/external/cpr/cpr/cprtypes.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "cpr/cprtypes.h" - -#include -#include - -namespace cpr { -bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& b) const noexcept { - return std::lexicographical_compare( - a.begin(), a.end(), b.begin(), b.end(), - [](unsigned char ac, unsigned char bc) { return std::tolower(ac) < std::tolower(bc); }); -} -} // namespace cpr diff --git a/external/cpr/cpr/curl_container.cpp b/external/cpr/cpr/curl_container.cpp deleted file mode 100644 index 1276411..0000000 --- a/external/cpr/cpr/curl_container.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "cpr/curl_container.h" - - -namespace cpr { -template -CurlContainer::CurlContainer(const std::initializer_list& containerList) - : containerList_(containerList) {} - -template -void CurlContainer::Add(const std::initializer_list& containerList) { - for (const T& element : containerList) { - containerList_.push_back(std::move(element)); - } -} - -template -void CurlContainer::Add(const T& element) { - containerList_.push_back(std::move(element)); -} - -template <> -const std::string CurlContainer::GetContent(const CurlHolder& holder) const { - std::string content{}; - for (const Parameter& parameter : containerList_) { - if (!content.empty()) { - content += "&"; - } - - std::string escapedKey = encode ? holder.urlEncode(parameter.key) : parameter.key; - if (parameter.value.empty()) { - content += escapedKey; - } else { - std::string escapedValue = encode ? holder.urlEncode(parameter.value) : parameter.value; - content += escapedKey + "="; - content += escapedValue; - } - }; - - return content; -} - -template <> -const std::string CurlContainer::GetContent(const CurlHolder& holder) const { - std::string content{}; - for (const cpr::Pair& element : containerList_) { - if (!content.empty()) { - content += "&"; - } - std::string escaped = encode ? holder.urlEncode(element.value) : element.value; - content += element.key + "=" + escaped; - } - - return content; -} - -template class CurlContainer; -template class CurlContainer; - -} // namespace cpr diff --git a/external/cpr/cpr/curlholder.cpp b/external/cpr/cpr/curlholder.cpp deleted file mode 100644 index 3b27e5e..0000000 --- a/external/cpr/cpr/curlholder.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "cpr/curlholder.h" -#include - -namespace cpr { -// It does not make sense to make a std::mutex const. -// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) -std::mutex CurlHolder::curl_easy_init_mutex_{}; - -#ifndef _WIN32 // There is no thread sanitizer on windows -__attribute__((no_sanitize("thread"))) -#endif -CurlHolder::CurlHolder() { - /** - * Allow multithreaded access to CPR by locking curl_easy_init(). - * curl_easy_init() is not thread safe. - * References: - * https://curl.haxx.se/libcurl/c/curl_easy_init.html - * https://curl.haxx.se/libcurl/c/threadsafe.html - **/ - curl_easy_init_mutex_.lock(); - handle = curl_easy_init(); - curl_easy_init_mutex_.unlock(); - - assert(handle); -} // namespace cpr - -CurlHolder::~CurlHolder() { - curl_slist_free_all(chunk); - curl_formfree(formpost); - curl_easy_cleanup(handle); -} - -std::string CurlHolder::urlEncode(const std::string& s) const { - assert(handle); - char* output = curl_easy_escape(handle, s.c_str(), s.length()); - if (output) { - std::string result = output; - curl_free(output); - return result; - } - return ""; -} - -std::string CurlHolder::urlDecode(const std::string& s) const { - assert(handle); - char* output = curl_easy_unescape(handle, s.c_str(), s.length(), nullptr); - if (output) { - std::string result = output; - curl_free(output); - return result; - } - return ""; -} -} // namespace cpr diff --git a/external/cpr/cpr/error.cpp b/external/cpr/cpr/error.cpp deleted file mode 100644 index 7e713fd..0000000 --- a/external/cpr/cpr/error.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "cpr/error.h" - -#include - -namespace cpr { -ErrorCode Error::getErrorCodeForCurlError(std::int32_t curl_code) { - switch (curl_code) { - case CURLE_OK: - return ErrorCode::OK; - case CURLE_UNSUPPORTED_PROTOCOL: - return ErrorCode::UNSUPPORTED_PROTOCOL; - case CURLE_URL_MALFORMAT: - return ErrorCode::INVALID_URL_FORMAT; - case CURLE_COULDNT_RESOLVE_PROXY: - return ErrorCode::PROXY_RESOLUTION_FAILURE; - case CURLE_COULDNT_RESOLVE_HOST: - return ErrorCode::HOST_RESOLUTION_FAILURE; - case CURLE_COULDNT_CONNECT: - return ErrorCode::CONNECTION_FAILURE; - case CURLE_OPERATION_TIMEDOUT: - return ErrorCode::OPERATION_TIMEDOUT; - case CURLE_SSL_CONNECT_ERROR: - return ErrorCode::SSL_CONNECT_ERROR; -#if LIBCURL_VERSION_NUM < 0x073e00 - case CURLE_PEER_FAILED_VERIFICATION: - return ErrorCode::SSL_REMOTE_CERTIFICATE_ERROR; -#endif - case CURLE_ABORTED_BY_CALLBACK: - case CURLE_WRITE_ERROR: - return ErrorCode::REQUEST_CANCELLED; - case CURLE_GOT_NOTHING: - return ErrorCode::EMPTY_RESPONSE; - case CURLE_SSL_ENGINE_NOTFOUND: - case CURLE_SSL_ENGINE_SETFAILED: - return ErrorCode::GENERIC_SSL_ERROR; - case CURLE_SEND_ERROR: - return ErrorCode::NETWORK_SEND_FAILURE; - case CURLE_RECV_ERROR: - return ErrorCode::NETWORK_RECEIVE_ERROR; - case CURLE_SSL_CERTPROBLEM: - return ErrorCode::SSL_LOCAL_CERTIFICATE_ERROR; - case CURLE_SSL_CIPHER: - return ErrorCode::GENERIC_SSL_ERROR; -#if LIBCURL_VERSION_NUM >= 0x073e00 - case CURLE_PEER_FAILED_VERIFICATION: - return ErrorCode::SSL_REMOTE_CERTIFICATE_ERROR; -#else - case CURLE_SSL_CACERT: - return ErrorCode::SSL_CACERT_ERROR; -#endif - case CURLE_USE_SSL_FAILED: - case CURLE_SSL_ENGINE_INITFAILED: - return ErrorCode::GENERIC_SSL_ERROR; - case CURLE_SSL_CACERT_BADFILE: - return ErrorCode::SSL_CACERT_ERROR; - case CURLE_SSL_SHUTDOWN_FAILED: - return ErrorCode::GENERIC_SSL_ERROR; - case CURLE_SSL_CRL_BADFILE: - case CURLE_SSL_ISSUER_ERROR: - return ErrorCode::SSL_CACERT_ERROR; - case CURLE_TOO_MANY_REDIRECTS: - return ErrorCode::OK; - default: - return ErrorCode::INTERNAL_ERROR; - } -} - -} // namespace cpr diff --git a/external/cpr/cpr/multipart.cpp b/external/cpr/cpr/multipart.cpp deleted file mode 100644 index adbba99..0000000 --- a/external/cpr/cpr/multipart.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "cpr/multipart.h" - -namespace cpr { -Multipart::Multipart(const std::initializer_list& parts) : parts{parts} {} -} // namespace cpr diff --git a/external/cpr/cpr/parameters.cpp b/external/cpr/cpr/parameters.cpp deleted file mode 100644 index a24c393..0000000 --- a/external/cpr/cpr/parameters.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "cpr/parameters.h" - -#include -#include - -#include "cpr/util.h" - -namespace cpr { -Parameters::Parameters(const std::initializer_list& parameters) : CurlContainer(parameters) {} -} // namespace cpr diff --git a/external/cpr/cpr/payload.cpp b/external/cpr/cpr/payload.cpp deleted file mode 100644 index 78373fa..0000000 --- a/external/cpr/cpr/payload.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "cpr/payload.h" - -#include -#include - -#include "cpr/util.h" - -namespace cpr { -Payload::Payload(const std::initializer_list& pairs) : CurlContainer(pairs) {} -} // namespace cpr diff --git a/external/cpr/cpr/proxies.cpp b/external/cpr/cpr/proxies.cpp deleted file mode 100644 index 446f7d7..0000000 --- a/external/cpr/cpr/proxies.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "cpr/proxies.h" - -#include -#include -#include -#include - -namespace cpr { - -Proxies::Proxies(const std::initializer_list>& hosts) - : hosts_{hosts} {} - -bool Proxies::has(const std::string& protocol) const { - return hosts_.count(protocol) > 0; -} - -const std::string& Proxies::operator[](const std::string& protocol) { - return hosts_[protocol]; -} - -} // namespace cpr diff --git a/external/cpr/cpr/response.cpp b/external/cpr/cpr/response.cpp deleted file mode 100644 index 52c653b..0000000 --- a/external/cpr/cpr/response.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "cpr/response.h" - -namespace cpr { -Response::Response(std::shared_ptr curl, std::string&& p_text, - std::string&& p_header_string, Cookies&& p_cookies = Cookies{}, - Error&& p_error = Error{}) - : curl_(std::move(curl)), text(std::move(p_text)), cookies(std::move(p_cookies)), - error(std::move(p_error)) { - header = cpr::util::parseHeader(p_header_string, &status_line, &reason); - assert(curl_); - assert(curl_->handle); - curl_easy_getinfo(curl_->handle, CURLINFO_RESPONSE_CODE, &status_code); - curl_easy_getinfo(curl_->handle, CURLINFO_TOTAL_TIME, &elapsed); - char* url_string{nullptr}; - curl_easy_getinfo(curl_->handle, CURLINFO_EFFECTIVE_URL, &url_string); - url = Url(url_string); -#if LIBCURL_VERSION_NUM >= 0x073700 - curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_DOWNLOAD_T, &downloaded_bytes); - curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_UPLOAD_T, &uploaded_bytes); -#else - double downloaded_bytes_double, uploaded_bytes_double; - curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_DOWNLOAD, &downloaded_bytes_double); - curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_UPLOAD, &uploaded_bytes_double); - downloaded_bytes = downloaded_bytes_double; - uploaded_bytes = uploaded_bytes_double; -#endif - curl_easy_getinfo(curl_->handle, CURLINFO_REDIRECT_COUNT, &redirect_count); -} - -std::vector Response::GetCertInfo() { - assert(curl_); - assert(curl_->handle); - curl_certinfo* ci{nullptr}; - curl_easy_getinfo(curl_->handle, CURLINFO_CERTINFO, &ci); - - std::vector info; - info.resize(ci->num_of_certs); - for (size_t i = 0; i < ci->num_of_certs; i++) { - // No way around here. - // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic) - info[i] = std::string{ci->certinfo[i]->data}; - } - - return info; -} -} // namespace cpr diff --git a/external/cpr/cpr/session.cpp b/external/cpr/cpr/session.cpp deleted file mode 100644 index b5cc2e2..0000000 --- a/external/cpr/cpr/session.cpp +++ /dev/null @@ -1,799 +0,0 @@ -#include "cpr/session.h" - -#include -#include -#include -#include -#include - -#include - -#include "cpr/cprtypes.h" -#include "cpr/util.h" - - -namespace cpr { - -// Ignored here since libcurl reqires a long: -// NOLINTNEXTLINE(google-runtime-int) -constexpr long ON = 1L; -// Ignored here since libcurl reqires a long: -// NOLINTNEXTLINE(google-runtime-int) -constexpr long OFF = 0L; - -class Session::Impl { - public: - Impl(); - - void SetUrl(const Url& url); - void SetParameters(const Parameters& parameters); - void SetParameters(Parameters&& parameters); - void SetHeader(const Header& header); - void UpdateHeader(const Header& header); - void SetTimeout(const Timeout& timeout); - void SetConnectTimeout(const ConnectTimeout& timeout); - void SetAuth(const Authentication& auth); -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 - void SetBearer(const Bearer& token); -#endif - void SetDigest(const Digest& auth); - void SetUserAgent(const UserAgent& ua); - void SetPayload(Payload&& payload); - void SetPayload(const Payload& payload); - void SetProxies(Proxies&& proxies); - void SetProxies(const Proxies& proxies); - void SetMultipart(Multipart&& multipart); - void SetMultipart(const Multipart& multipart); - void SetNTLM(const NTLM& auth); - void SetRedirect(const bool& redirect); - void SetMaxRedirects(const MaxRedirects& max_redirects); - void SetCookies(const Cookies& cookies); - void SetBody(Body&& body); - void SetBody(const Body& body); - void SetReadCallback(const ReadCallback& read); - void SetHeaderCallback(const HeaderCallback& header); - void SetWriteCallback(const WriteCallback& write); - void SetProgressCallback(const ProgressCallback& progress); - void SetDebugCallback(const DebugCallback& debug); - void SetLowSpeed(const LowSpeed& low_speed); - void SetVerifySsl(const VerifySsl& verify); - void SetLimitRate(const LimitRate& limit_rate); - void SetUnixSocket(const UnixSocket& unix_socket); - void SetVerbose(const Verbose& verbose); - void SetSslOptions(const SslOptions& options); - - Response Delete(); - Response Download(const WriteCallback& write); - Response Download(std::ofstream& file); - Response Get(); - Response Head(); - Response Options(); - Response Patch(); - Response Post(); - Response Put(); - - std::shared_ptr GetCurlHolder(); - - void PrepareDelete(); - void PrepareGet(); - void PrepareHead(); - void PrepareOptions(); - void PreparePatch(); - void PreparePost(); - void PreparePut(); - Response Complete(CURLcode curl_error); - - private: - void SetHeaderInternal(); - bool hasBodyOrPayload_{false}; - - std::shared_ptr curl_; - Url url_; - Parameters parameters_; - Proxies proxies_; - Header header_; - /** - * Will be set by the read callback. - * Ensures that the "Transfer-Encoding" is set to "chunked", if not overriden in header_. - **/ - bool chunkedTransferEncoding{false}; - - ReadCallback readcb_; - HeaderCallback headercb_; - WriteCallback writecb_; - ProgressCallback progresscb_; - DebugCallback debugcb_; - std::string response_string_; - std::string header_string_; - - Response makeDownloadRequest(); - Response makeRequest(); - void prepareCommon(); -}; - -Session::Impl::Impl() : curl_(new CurlHolder()) { - // Set up some sensible defaults - curl_version_info_data* version_info = curl_version_info(CURLVERSION_NOW); - std::string version = "curl/" + std::string{version_info->version}; - curl_easy_setopt(curl_->handle, CURLOPT_USERAGENT, version.c_str()); - curl_easy_setopt(curl_->handle, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl_->handle, CURLOPT_NOPROGRESS, 1L); - curl_easy_setopt(curl_->handle, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(curl_->handle, CURLOPT_ERRORBUFFER, curl_->error.data()); - curl_easy_setopt(curl_->handle, CURLOPT_COOKIEFILE, ""); -#ifdef CPR_CURL_NOSIGNAL - curl_easy_setopt(curl_->handle, CURLOPT_NOSIGNAL, 1L); -#endif - -#if LIBCURL_VERSION_MAJOR >= 7 -#if LIBCURL_VERSION_MINOR >= 25 -#if LIBCURL_VERSION_PATCH >= 0 - curl_easy_setopt(curl_->handle, CURLOPT_TCP_KEEPALIVE, 1L); -#endif -#endif -#endif -} - -void Session::Impl::SetUrl(const Url& url) { - url_ = url; -} - -void Session::Impl::SetParameters(const Parameters& parameters) { - parameters_ = parameters; -} - -void Session::Impl::SetParameters(Parameters&& parameters) { - parameters_ = std::move(parameters); -} - -void Session::Impl::SetHeaderInternal() { - curl_slist* chunk = nullptr; - for (const std::pair& item : header_) { - std::string header_string = item.first; - if (item.second.empty()) { - header_string += ";"; - } else { - header_string += ": " + item.second; - } - - curl_slist* temp = curl_slist_append(chunk, header_string.c_str()); - if (temp) { - chunk = temp; - } - } - - // Set the chunked transfer encoding in case it does not already exist: - if (chunkedTransferEncoding && header_.find("Transfer-Encoding") == header_.end()) { - curl_slist* temp = curl_slist_append(chunk, "Transfer-Encoding:chunked"); - if (temp) { - chunk = temp; - } - } - - curl_easy_setopt(curl_->handle, CURLOPT_HTTPHEADER, chunk); - - curl_slist_free_all(curl_->chunk); - curl_->chunk = chunk; -} - -void Session::Impl::SetHeader(const Header& header) { - header_ = header; -} - -void Session::Impl::UpdateHeader(const Header& header) { - for (const std::pair& item : header) { - header_[item.first] = item.second; - } -} - -void Session::Impl::SetTimeout(const Timeout& timeout) { - curl_easy_setopt(curl_->handle, CURLOPT_TIMEOUT_MS, timeout.Milliseconds()); -} - -void Session::Impl::SetConnectTimeout(const ConnectTimeout& timeout) { - curl_easy_setopt(curl_->handle, CURLOPT_CONNECTTIMEOUT_MS, timeout.Milliseconds()); -} - -void Session::Impl::SetVerbose(const Verbose& verbose) { - curl_easy_setopt(curl_->handle, CURLOPT_VERBOSE, verbose.verbose ? ON : OFF); -} - -void Session::Impl::SetAuth(const Authentication& auth) { - // Ignore here since this has been defined by libcurl. - curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString()); -} - -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 -void Session::Impl::SetBearer(const Bearer& token) { - // Ignore here since this has been defined by libcurl. - curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); - curl_easy_setopt(curl_->handle, CURLOPT_XOAUTH2_BEARER, token.GetToken()); -} -#endif - -void Session::Impl::SetDigest(const Digest& auth) { - // Ignore here since this has been defined by libcurl. - curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString()); -} - -void Session::Impl::SetUserAgent(const UserAgent& ua) { - curl_easy_setopt(curl_->handle, CURLOPT_USERAGENT, ua.c_str()); -} - -void Session::Impl::SetPayload(Payload&& payload) { - hasBodyOrPayload_ = true; - const std::string content = payload.GetContent(*curl_); - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, - static_cast(content.length())); - curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str()); -} - -void Session::Impl::SetPayload(const Payload& payload) { - hasBodyOrPayload_ = true; - const std::string content = payload.GetContent(*curl_); - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, - static_cast(content.length())); - curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str()); -} - -void Session::Impl::SetProxies(const Proxies& proxies) { - proxies_ = proxies; -} - -void Session::Impl::SetProxies(Proxies&& proxies) { - proxies_ = std::move(proxies); -} - -void Session::Impl::SetMultipart(Multipart&& multipart) { - curl_httppost* formpost = nullptr; - curl_httppost* lastptr = nullptr; - - for (const Part& part : multipart.parts) { - std::vector formdata; - if (part.is_buffer) { - // Do not use formdata, to prevent having to use reinterpreter_cast: - curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, part.name.c_str(), CURLFORM_BUFFER, - part.value.c_str(), CURLFORM_BUFFERPTR, part.data, CURLFORM_BUFFERLENGTH, - part.datalen, CURLFORM_END); - } else { - formdata.push_back({CURLFORM_COPYNAME, part.name.c_str()}); - if (part.is_file) { - formdata.push_back({CURLFORM_FILE, part.value.c_str()}); - } else { - formdata.push_back({CURLFORM_COPYCONTENTS, part.value.c_str()}); - } - } - if (!part.content_type.empty()) { - formdata.push_back({CURLFORM_CONTENTTYPE, part.content_type.c_str()}); - } - - formdata.push_back({CURLFORM_END, nullptr}); - curl_formadd(&formpost, &lastptr, CURLFORM_ARRAY, formdata.data(), CURLFORM_END); - } - curl_easy_setopt(curl_->handle, CURLOPT_HTTPPOST, formpost); - hasBodyOrPayload_ = true; - - curl_formfree(curl_->formpost); - curl_->formpost = formpost; -} - -void Session::Impl::SetMultipart(const Multipart& multipart) { - curl_httppost* formpost = nullptr; - curl_httppost* lastptr = nullptr; - - for (const Part& part : multipart.parts) { - std::vector formdata; - if (part.is_buffer) { - // Do not use formdata, to prevent having to use reinterpreter_cast: - curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, part.name.c_str(), CURLFORM_BUFFER, - part.value.c_str(), CURLFORM_BUFFERPTR, part.data, CURLFORM_BUFFERLENGTH, - part.datalen, CURLFORM_END); - } else { - formdata.push_back({CURLFORM_COPYNAME, part.name.c_str()}); - if (part.is_file) { - formdata.push_back({CURLFORM_FILE, part.value.c_str()}); - } else { - formdata.push_back({CURLFORM_COPYCONTENTS, part.value.c_str()}); - } - } - if (!part.content_type.empty()) { - formdata.push_back({CURLFORM_CONTENTTYPE, part.content_type.c_str()}); - } - - formdata.push_back({CURLFORM_END, nullptr}); - curl_formadd(&formpost, &lastptr, CURLFORM_ARRAY, formdata.data(), CURLFORM_END); - } - curl_easy_setopt(curl_->handle, CURLOPT_HTTPPOST, formpost); - hasBodyOrPayload_ = true; - - curl_formfree(curl_->formpost); - curl_->formpost = formpost; -} - -void Session::Impl::SetLimitRate(const LimitRate& limit_rate) { - curl_easy_setopt(curl_->handle, CURLOPT_MAX_RECV_SPEED_LARGE, limit_rate.downrate); - curl_easy_setopt(curl_->handle, CURLOPT_MAX_SEND_SPEED_LARGE, limit_rate.uprate); -} - -void Session::Impl::SetNTLM(const NTLM& auth) { - // Ignore here since this has been defined by libcurl. - curl_easy_setopt(curl_->handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); - curl_easy_setopt(curl_->handle, CURLOPT_USERPWD, auth.GetAuthString()); -} - -void Session::Impl::SetRedirect(const bool& redirect) { - curl_easy_setopt(curl_->handle, CURLOPT_FOLLOWLOCATION, std::int32_t(redirect)); -} - -void Session::Impl::SetMaxRedirects(const MaxRedirects& max_redirects) { - curl_easy_setopt(curl_->handle, CURLOPT_MAXREDIRS, max_redirects.number_of_redirects); -} - -void Session::Impl::SetCookies(const Cookies& cookies) { - curl_easy_setopt(curl_->handle, CURLOPT_COOKIELIST, "ALL"); - curl_easy_setopt(curl_->handle, CURLOPT_COOKIE, cookies.GetEncoded(*curl_).c_str()); -} - -void Session::Impl::SetBody(Body&& body) { - hasBodyOrPayload_ = true; - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, - static_cast(body.str().length())); - curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, body.c_str()); -} - -void Session::Impl::SetBody(const Body& body) { - hasBodyOrPayload_ = true; - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, - static_cast(body.str().length())); - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, body.c_str()); -} - -void Session::Impl::SetReadCallback(const ReadCallback& read) { - readcb_ = read; - curl_easy_setopt(curl_->handle, CURLOPT_INFILESIZE_LARGE, read.size); - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, read.size); - curl_easy_setopt(curl_->handle, CURLOPT_READFUNCTION, cpr::util::readUserFunction); - curl_easy_setopt(curl_->handle, CURLOPT_READDATA, &readcb_); - chunkedTransferEncoding = read.size == -1; -} - -void Session::Impl::SetHeaderCallback(const HeaderCallback& header) { - curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::headerUserFunction); - headercb_ = header; - curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &headercb_); -} - -void Session::Impl::SetWriteCallback(const WriteCallback& write) { - curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeUserFunction); - writecb_ = write; - curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &writecb_); -} - -void Session::Impl::SetProgressCallback(const ProgressCallback& progress) { - progresscb_ = progress; -#if LIBCURL_VERSION_NUM < 0x072000 - curl_easy_setopt(curl_->handle, CURLOPT_PROGRESSFUNCTION, cpr::util::progressUserFunction); - curl_easy_setopt(curl_->handle, CURLOPT_PROGRESSDATA, &progresscb_); -#else - curl_easy_setopt(curl_->handle, CURLOPT_XFERINFOFUNCTION, cpr::util::progressUserFunction); - curl_easy_setopt(curl_->handle, CURLOPT_XFERINFODATA, &progresscb_); -#endif - curl_easy_setopt(curl_->handle, CURLOPT_NOPROGRESS, 0L); -} - -void Session::Impl::SetDebugCallback(const DebugCallback& debug) { - curl_easy_setopt(curl_->handle, CURLOPT_DEBUGFUNCTION, cpr::util::debugUserFunction); - debugcb_ = debug; - curl_easy_setopt(curl_->handle, CURLOPT_DEBUGDATA, &debugcb_); - curl_easy_setopt(curl_->handle, CURLOPT_VERBOSE, 1L); -} - -void Session::Impl::SetLowSpeed(const LowSpeed& low_speed) { - curl_easy_setopt(curl_->handle, CURLOPT_LOW_SPEED_LIMIT, low_speed.limit); - curl_easy_setopt(curl_->handle, CURLOPT_LOW_SPEED_TIME, low_speed.time); -} - -void Session::Impl::SetVerifySsl(const VerifySsl& verify) { - curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYPEER, verify ? ON : OFF); - curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYHOST, verify ? 2L : 0L); -} - -void Session::Impl::SetUnixSocket(const UnixSocket& unix_socket) { - curl_easy_setopt(curl_->handle, CURLOPT_UNIX_SOCKET_PATH, unix_socket.GetUnixSocketString()); -} - -void Session::Impl::SetSslOptions(const SslOptions& options) { - if (!options.cert_file.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_SSLCERT, options.cert_file.c_str()); - if (!options.cert_type.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_SSLCERTTYPE, options.cert_type.c_str()); - } - } - if (!options.key_file.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_SSLKEY, options.key_file.c_str()); - if (!options.key_type.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_SSLKEYTYPE, options.key_type.c_str()); - } - if (!options.key_pass.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_KEYPASSWD, options.key_pass.c_str()); - } - } -#if SUPPORT_ALPN - curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_ALPN, options.enable_alpn ? ON : OFF); -#endif -#if SUPPORT_NPN - curl_easy_setopt(curl_->handle, CURLOPT_SSL_ENABLE_NPN, options.enable_npn ? ON : OFF); -#endif - curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYPEER, options.verify_peer ? ON : OFF); - curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYHOST, options.verify_host ? 2L : 0L); -#if LIBCURL_VERSION_NUM >= 0x072900 - curl_easy_setopt(curl_->handle, CURLOPT_SSL_VERIFYSTATUS, options.verify_status ? ON : OFF); -#endif - curl_easy_setopt(curl_->handle, CURLOPT_SSLVERSION, - // Ignore here since this has been defined by libcurl. - options.ssl_version -#if SUPPORT_MAX_TLS_VERSION - | options.max_version -#endif - ); -#if SUPPORT_SSL_NO_REVOKE - if (options.ssl_no_revoke) { - curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE); - } -#endif - if (!options.ca_info.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_CAINFO, options.ca_info.c_str()); - } - if (!options.ca_path.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_CAPATH, options.ca_path.c_str()); - } - if (!options.crl_file.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_CRLFILE, options.crl_file.c_str()); - } - if (!options.ciphers.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_SSL_CIPHER_LIST, options.ciphers.c_str()); - } -#if SUPPORT_TLSv13_CIPHERS - if (!options.tls13_ciphers.empty()) { - curl_easy_setopt(curl_->handle, CURLOPT_TLS13_CIPHERS, options.ciphers.c_str()); - } -#endif -#if SUPPORT_SESSIONID_CACHE - curl_easy_setopt(curl_->handle, CURLOPT_SSL_SESSIONID_CACHE, - options.session_id_cache ? ON : OFF); -#endif -} - -void Session::Impl::PrepareDelete() { - curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "DELETE"); - prepareCommon(); -} - -Response Session::Impl::Delete() { - PrepareDelete(); - return makeRequest(); -} - -Response Session::Impl::Download(const WriteCallback& write) { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET"); - - SetWriteCallback(write); - - return makeDownloadRequest(); -} - -Response Session::Impl::Download(std::ofstream& file) { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET"); - curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFileFunction); - curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &file); - - return makeDownloadRequest(); -} - -void Session::Impl::PrepareGet() { - // In case there is a body or payload for this request, we create a custom GET-Request since a - // GET-Request with body is based on the HTTP RFC **not** a leagal request. - if (hasBodyOrPayload_) { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "GET"); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr); - curl_easy_setopt(curl_->handle, CURLOPT_HTTPGET, 1L); - } - prepareCommon(); -} - -Response Session::Impl::Get() { - PrepareGet(); - return makeRequest(); -} - -void Session::Impl::PrepareHead() { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 1L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr); - prepareCommon(); -} - -Response Session::Impl::Head() { - PrepareHead(); - return makeRequest(); -} - -void Session::Impl::PrepareOptions() { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "OPTIONS"); - prepareCommon(); -} - -Response Session::Impl::Options() { - PrepareOptions(); - return makeRequest(); -} - -void Session::Impl::PreparePatch() { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PATCH"); - prepareCommon(); -} - -Response Session::Impl::Patch() { - PreparePatch(); - return makeRequest(); -} - -void Session::Impl::PreparePost() { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - - // In case there is no body or payload set it to an empty post: - if (hasBodyOrPayload_) { - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, nullptr); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, readcb_.callback ? nullptr : ""); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "POST"); - } - prepareCommon(); -} - -Response Session::Impl::Post() { - PreparePost(); - return makeRequest(); -} - -void Session::Impl::PreparePut() { - curl_easy_setopt(curl_->handle, CURLOPT_NOBODY, 0L); - curl_easy_setopt(curl_->handle, CURLOPT_CUSTOMREQUEST, "PUT"); - prepareCommon(); -} - -Response Session::Impl::Put() { - PreparePut(); - return makeRequest(); -} - -std::shared_ptr Session::Impl::GetCurlHolder() { - return curl_; -} - -Response Session::Impl::makeDownloadRequest() { - assert(curl_->handle); - const std::string parametersContent = parameters_.GetContent(*curl_); - if (!parametersContent.empty()) { - Url new_url{url_ + "?" + parametersContent}; - curl_easy_setopt(curl_->handle, CURLOPT_URL, new_url.c_str()); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_URL, url_.c_str()); - } - - std::string protocol = url_.str().substr(0, url_.str().find(':')); - if (proxies_.has(protocol)) { - curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str()); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_PROXY, ""); - } - - curl_->error[0] = '\0'; - - std::string header_string; - if (headercb_.callback) { - curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::headerUserFunction); - curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &headercb_); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction); - curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string); - } - - CURLcode curl_error = curl_easy_perform(curl_->handle); - - curl_slist* raw_cookies{nullptr}; - curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies); - Cookies cookies = util::parseCookies(raw_cookies); - curl_slist_free_all(raw_cookies); - std::string errorMsg = curl_->error.data(); - - return Response(curl_, "", std::move(header_string), std::move(cookies), - Error(curl_error, std::move(errorMsg))); -} - -void Session::Impl::prepareCommon() { - assert(curl_->handle); - - // Set Header: - SetHeaderInternal(); - - const std::string parametersContent = parameters_.GetContent(*curl_); - if (!parametersContent.empty()) { - Url new_url{url_ + "?" + parametersContent}; - curl_easy_setopt(curl_->handle, CURLOPT_URL, new_url.c_str()); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_URL, url_.c_str()); - } - - // Proxy: - std::string protocol = url_.str().substr(0, url_.str().find(':')); - if (proxies_.has(protocol)) { - curl_easy_setopt(curl_->handle, CURLOPT_PROXY, proxies_[protocol].c_str()); - } else { - curl_easy_setopt(curl_->handle, CURLOPT_PROXY, nullptr); - } - -#if LIBCURL_VERSION_MAJOR >= 7 -#if LIBCURL_VERSION_MINOR >= 21 - /* enable all supported built-in compressions */ - curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, ""); -#endif -#endif - -#if LIBCURL_VERSION_MAJOR >= 7 -#if LIBCURL_VERSION_MINOR >= 71 - // Fix loading certs from Windows cert store when using OpenSSL: - curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); -#endif -#endif - - curl_->error[0] = '\0'; - - response_string_.clear(); - header_string_.clear(); - if (!this->writecb_.callback) { - curl_easy_setopt(curl_->handle, CURLOPT_WRITEFUNCTION, cpr::util::writeFunction); - curl_easy_setopt(curl_->handle, CURLOPT_WRITEDATA, &response_string_); - } - if (!this->headercb_.callback) { - curl_easy_setopt(curl_->handle, CURLOPT_HEADERFUNCTION, cpr::util::writeFunction); - curl_easy_setopt(curl_->handle, CURLOPT_HEADERDATA, &header_string_); - } - - // Enable so we are able to retrive certificate information: - curl_easy_setopt(curl_->handle, CURLOPT_CERTINFO, 1L); -} - -Response Session::Impl::makeRequest() -{ - CURLcode curl_error = curl_easy_perform(curl_->handle); - return Complete(curl_error); -} - -Response Session::Impl::Complete(CURLcode curl_error) -{ - curl_slist* raw_cookies{nullptr}; - curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies); - Cookies cookies = util::parseCookies(raw_cookies); - curl_slist_free_all(raw_cookies); - - // Reset the has no body property: - hasBodyOrPayload_ = false; - - std::string errorMsg = curl_->error.data(); - return Response(curl_, std::move(response_string_), std::move(header_string_), std::move(cookies), - Error(curl_error, std::move(errorMsg))); -} - -// clang-format off -Session::Session() : pimpl_(new Impl()) {} -Session::Session(Session&& old) noexcept = default; -Session::~Session() = default; -Session& Session::operator=(Session&& old) noexcept = default; -void Session::SetReadCallback(const ReadCallback& read) { pimpl_->SetReadCallback(read); } -void Session::SetHeaderCallback(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); } -void Session::SetWriteCallback(const WriteCallback& write) { pimpl_->SetWriteCallback(write); } -void Session::SetProgressCallback(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); } -void Session::SetDebugCallback(const DebugCallback& debug) { pimpl_->SetDebugCallback(debug); } -void Session::SetUrl(const Url& url) { pimpl_->SetUrl(url); } -void Session::SetParameters(const Parameters& parameters) { pimpl_->SetParameters(parameters); } -void Session::SetParameters(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); } -void Session::SetHeader(const Header& header) { pimpl_->SetHeader(header); } -void Session::UpdateHeader(const Header& header) { pimpl_->UpdateHeader(header); } -void Session::SetTimeout(const Timeout& timeout) { pimpl_->SetTimeout(timeout); } -void Session::SetConnectTimeout(const ConnectTimeout& timeout) { pimpl_->SetConnectTimeout(timeout); } -void Session::SetAuth(const Authentication& auth) { pimpl_->SetAuth(auth); } -void Session::SetDigest(const Digest& auth) { pimpl_->SetDigest(auth); } -void Session::SetUserAgent(const UserAgent& ua) { pimpl_->SetUserAgent(ua); } -void Session::SetPayload(const Payload& payload) { pimpl_->SetPayload(payload); } -void Session::SetPayload(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); } -void Session::SetProxies(const Proxies& proxies) { pimpl_->SetProxies(proxies); } -void Session::SetProxies(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); } -void Session::SetMultipart(const Multipart& multipart) { pimpl_->SetMultipart(multipart); } -void Session::SetMultipart(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); } -void Session::SetNTLM(const NTLM& auth) { pimpl_->SetNTLM(auth); } -void Session::SetRedirect(const bool& redirect) { pimpl_->SetRedirect(redirect); } -void Session::SetMaxRedirects(const MaxRedirects& max_redirects) { pimpl_->SetMaxRedirects(max_redirects); } -void Session::SetCookies(const Cookies& cookies) { pimpl_->SetCookies(cookies); } -void Session::SetBody(const Body& body) { pimpl_->SetBody(body); } -void Session::SetBody(Body&& body) { pimpl_->SetBody(std::move(body)); } -void Session::SetLowSpeed(const LowSpeed& low_speed) { pimpl_->SetLowSpeed(low_speed); } -void Session::SetVerifySsl(const VerifySsl& verify) { pimpl_->SetVerifySsl(verify); } -void Session::SetUnixSocket(const UnixSocket& unix_socket) { pimpl_->SetUnixSocket(unix_socket); } -void Session::SetSslOptions(const SslOptions& options) { pimpl_->SetSslOptions(options); } -void Session::SetVerbose(const Verbose& verbose) { pimpl_->SetVerbose(verbose); } -void Session::SetOption(const ReadCallback& read) { pimpl_->SetReadCallback(read); } -void Session::SetOption(const HeaderCallback& header) { pimpl_->SetHeaderCallback(header); } -void Session::SetOption(const WriteCallback& write) { pimpl_->SetWriteCallback(write); } -void Session::SetOption(const ProgressCallback& progress) { pimpl_->SetProgressCallback(progress); } -void Session::SetOption(const DebugCallback& debug) { pimpl_->SetDebugCallback(debug); } -void Session::SetOption(const Url& url) { pimpl_->SetUrl(url); } -void Session::SetOption(const Parameters& parameters) { pimpl_->SetParameters(parameters); } -void Session::SetOption(Parameters&& parameters) { pimpl_->SetParameters(std::move(parameters)); } -void Session::SetOption(const Header& header) { pimpl_->SetHeader(header); } -void Session::SetOption(const Timeout& timeout) { pimpl_->SetTimeout(timeout); } -void Session::SetOption(const ConnectTimeout& timeout) { pimpl_->SetConnectTimeout(timeout); } -void Session::SetOption(const Authentication& auth) { pimpl_->SetAuth(auth); } -void Session::SetOption(const LimitRate& limit_rate) { pimpl_->SetLimitRate(limit_rate); } -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 -void Session::SetOption(const Bearer& auth) { pimpl_->SetBearer(auth); } -#endif -void Session::SetOption(const Digest& auth) { pimpl_->SetDigest(auth); } -void Session::SetOption(const UserAgent& ua) { pimpl_->SetUserAgent(ua); } -void Session::SetOption(const Payload& payload) { pimpl_->SetPayload(payload); } -void Session::SetOption(Payload&& payload) { pimpl_->SetPayload(std::move(payload)); } -void Session::SetOption(const Proxies& proxies) { pimpl_->SetProxies(proxies); } -void Session::SetOption(Proxies&& proxies) { pimpl_->SetProxies(std::move(proxies)); } -void Session::SetOption(const Multipart& multipart) { pimpl_->SetMultipart(multipart); } -void Session::SetOption(Multipart&& multipart) { pimpl_->SetMultipart(std::move(multipart)); } -void Session::SetOption(const NTLM& auth) { pimpl_->SetNTLM(auth); } -void Session::SetOption(const bool& redirect) { pimpl_->SetRedirect(redirect); } -void Session::SetOption(const MaxRedirects& max_redirects) { pimpl_->SetMaxRedirects(max_redirects); } -void Session::SetOption(const Cookies& cookies) { pimpl_->SetCookies(cookies); } -void Session::SetOption(const Body& body) { pimpl_->SetBody(body); } -void Session::SetOption(Body&& body) { pimpl_->SetBody(std::move(body)); } -void Session::SetOption(const LowSpeed& low_speed) { pimpl_->SetLowSpeed(low_speed); } -void Session::SetOption(const VerifySsl& verify) { pimpl_->SetVerifySsl(verify); } -void Session::SetOption(const Verbose& verbose) { pimpl_->SetVerbose(verbose); } -void Session::SetOption(const UnixSocket& unix_socket) { pimpl_->SetUnixSocket(unix_socket); } -void Session::SetOption(const SslOptions& options) { pimpl_->SetSslOptions(options); } - -Response Session::Delete() { return pimpl_->Delete(); } -Response Session::Download(const WriteCallback& write) { return pimpl_->Download(write); } -Response Session::Download(std::ofstream& file) { return pimpl_->Download(file); } -Response Session::Get() { return pimpl_->Get(); } -Response Session::Head() { return pimpl_->Head(); } -Response Session::Options() { return pimpl_->Options(); } -Response Session::Patch() { return pimpl_->Patch(); } -Response Session::Post() { return pimpl_->Post(); } -Response Session::Put() { return pimpl_->Put(); } - -std::shared_ptr Session::GetCurlHolder() { return pimpl_->GetCurlHolder(); } - -void Session::PrepareDelete() { return pimpl_->PrepareDelete(); } -void Session::PrepareGet() { return pimpl_->PrepareGet(); } -void Session::PrepareHead() { return pimpl_->PrepareHead(); } -void Session::PrepareOptions() { return pimpl_->PrepareOptions(); } -void Session::PreparePatch() { return pimpl_->PreparePatch(); } -void Session::PreparePost() { return pimpl_->PreparePost(); } -void Session::PreparePut() { return pimpl_->PreparePut(); } -Response Session::Complete( CURLcode curl_error ) { return pimpl_->Complete(curl_error); } - -// clang-format on -} // namespace cpr diff --git a/external/cpr/cpr/timeout.cpp b/external/cpr/cpr/timeout.cpp deleted file mode 100644 index 431b740..0000000 --- a/external/cpr/cpr/timeout.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "cpr/timeout.h" - -#include -#include -#include -#include - -namespace cpr { - -// No way around since curl uses a long here. -// NOLINTNEXTLINE(google-runtime-int) -long Timeout::Milliseconds() const { - static_assert(std::is_same::value, - "Following casting expects milliseconds."); - - // No way around since curl uses a long here. - // NOLINTNEXTLINE(google-runtime-int) - if (ms.count() > std::numeric_limits::max()) { - throw std::overflow_error( - "cpr::Timeout: timeout value overflow: " + std::to_string(ms.count()) + " ms."); - } - // No way around since curl uses a long here. - // NOLINTNEXTLINE(google-runtime-int) - if (ms.count() < std::numeric_limits::min()) { - throw std::underflow_error( - "cpr::Timeout: timeout value underflow: " + std::to_string(ms.count()) + " ms."); - } - - // No way around since curl uses a long here. - // NOLINTNEXTLINE(google-runtime-int) - return static_cast(ms.count()); -} - -} // namespace cpr diff --git a/external/cpr/cpr/unix_socket.cpp b/external/cpr/cpr/unix_socket.cpp deleted file mode 100644 index 3171dbc..0000000 --- a/external/cpr/cpr/unix_socket.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "cpr/unix_socket.h" - -namespace cpr { -const char* UnixSocket::GetUnixSocketString() const noexcept { - return unix_socket_.data(); -} -} // namespace cpr diff --git a/external/cpr/cpr/util.cpp b/external/cpr/cpr/util.cpp deleted file mode 100644 index 26e9336..0000000 --- a/external/cpr/cpr/util.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include "cpr/util.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace cpr { -namespace util { - -Cookies parseCookies(curl_slist* raw_cookies) { - Cookies cookies; - for (curl_slist* nc = raw_cookies; nc; nc = nc->next) { - std::vector tokens = cpr::util::split(nc->data, '\t'); - std::string value = tokens.back(); - tokens.pop_back(); - cookies[tokens.back()] = value; - } - return cookies; -} - -Header parseHeader(const std::string& headers, std::string* status_line, std::string* reason) { - Header header; - std::vector lines; - std::istringstream stream(headers); - { - std::string line; - while (std::getline(stream, line, '\n')) { - lines.push_back(line); - } - } - - for (std::string& line : lines) { - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - if (line.substr(0, 5) == "HTTP/") { - // set the status_line if it was given - if ((status_line != nullptr) || (reason != nullptr)) { - line.resize(std::min(line.size(), line.find_last_not_of("\t\n\r ") + 1)); - if (status_line != nullptr) { - *status_line = line; - } - - // set the reason if it was given - if (reason != nullptr) { - size_t pos1 = line.find_first_of("\t "); - size_t pos2 = std::string::npos; - if (pos1 != std::string::npos) { - pos2 = line.find_first_of("\t ", pos1 + 1); - } - if (pos2 != std::string::npos) { - line.erase(0, pos2 + 1); - *reason = line; - } - } - } - header.clear(); - } - - if (line.length() > 0) { - size_t found = line.find(':'); - if (found != std::string::npos) { - std::string value = line.substr(found + 1); - value.erase(0, value.find_first_not_of("\t ")); - value.resize(std::min(value.size(), value.find_last_not_of("\t\n\r ") + 1)); - header[line.substr(0, found)] = value; - } - } - } - - return header; -} - -std::vector split(const std::string& to_split, char delimiter) { - std::vector tokens; - - std::stringstream stream(to_split); - std::string item; - while (std::getline(stream, item, delimiter)) { - tokens.push_back(item); - } - - return tokens; -} - -size_t readUserFunction(char* ptr, size_t size, size_t nitems, const ReadCallback* read) { - size *= nitems; - return read->callback(ptr, size) ? size : CURL_READFUNC_ABORT; -} - -size_t headerUserFunction(char* ptr, size_t size, size_t nmemb, const HeaderCallback* header) { - size *= nmemb; - return header->callback({ptr, size}) ? size : 0; -} - -size_t writeFunction(char* ptr, size_t size, size_t nmemb, std::string* data) { - size *= nmemb; - data->append(ptr, size); - return size; -} - -size_t writeFileFunction(char* ptr, size_t size, size_t nmemb, std::ofstream* file) { - size *= nmemb; - file->write(ptr, size); - return size; -} - -size_t writeUserFunction(char* ptr, size_t size, size_t nmemb, const WriteCallback* write) { - size *= nmemb; - return write->callback({ptr, size}) ? size : 0; -} - -#if LIBCURL_VERSION_NUM < 0x072000 -int progressUserFunction(const ProgressCallback* progress, double dltotal, double dlnow, - double ultotal, double ulnow) { -#else -int progressUserFunction(const ProgressCallback* progress, curl_off_t dltotal, curl_off_t dlnow, - curl_off_t ultotal, curl_off_t ulnow) { -#endif - return progress->callback(dltotal, dlnow, ultotal, ulnow) ? 0 : 1; -} - -int debugUserFunction(CURL* /*handle*/, curl_infotype type, char* data, size_t size, - const DebugCallback* debug) { - debug->callback(DebugCallback::InfoType(type), std::string(data, size)); - return 0; -} - -/** - * Creates a temporary CurlHolder object and uses it to escape the given string. - * If you plan to use this methode on a regular basis think about creating a CurlHolder - * object and calling urlEncode(std::string) on it. - * - * Example: - * CurlHolder holder; - * std::string input = "Hello World!"; - * std::string result = holder.urlEncode(input); - **/ -std::string urlEncode(const std::string& s) { - CurlHolder holder; // Create a temporary new holder for URL encoding - return holder.urlEncode(s); -} - -/** - * Creates a temporary CurlHolder object and uses it to unescape the given string. - * If you plan to use this methode on a regular basis think about creating a CurlHolder - * object and calling urlDecode(std::string) on it. - * - * Example: - * CurlHolder holder; - * std::string input = "Hello%20World%21"; - * std::string result = holder.urlDecode(input); - **/ -std::string urlDecode(const std::string& s) { - CurlHolder holder; // Create a temporary new holder for URL decoding - return holder.urlDecode(s); -} - -} // namespace util -} // namespace cpr diff --git a/external/cpr/include/CMakeLists.txt b/external/cpr/include/CMakeLists.txt deleted file mode 100644 index 941b197..0000000 --- a/external/cpr/include/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -target_include_directories(cpr PUBLIC - $ - $) - -target_sources(cpr PRIVATE - # Header files (useful in IDEs) - cpr/api.h - cpr/auth.h - cpr/bearer.h - cpr/body.h - cpr/cookies.h - cpr/cpr.h - cpr/cprtypes.h - cpr/curlholder.h - cpr/curlholder.h - cpr/digest.h - cpr/error.h - cpr/limit_rate.h - cpr/max_redirects.h - cpr/multipart.h - cpr/ntlm.h - cpr/parameters.h - cpr/payload.h - cpr/proxies.h - cpr/response.h - cpr/session.h - cpr/ssl_options.h - cpr/timeout.h - cpr/unix_socket.h - cpr/util.h - cpr/verbose.h -) - -install(DIRECTORY cpr DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/external/cpr/include/cpr/api.h b/external/cpr/include/cpr/api.h deleted file mode 100644 index f1f720f..0000000 --- a/external/cpr/include/cpr/api.h +++ /dev/null @@ -1,224 +0,0 @@ -#ifndef CPR_API_H -#define CPR_API_H - -#include -#include -#include -#include -#include - -#include "cpr/auth.h" -#include "cpr/bearer.h" -#include "cpr/cprtypes.h" -#include "cpr/digest.h" -#include "cpr/multipart.h" -#include "cpr/ntlm.h" -#include "cpr/payload.h" -#include "cpr/response.h" -#include "cpr/session.h" -#include - -namespace cpr { - -using AsyncResponse = std::future; - -namespace priv { - -template -void set_option(Session& session, Ts&&... ts) { - std::initializer_list ignore = { (session.SetOption(std::forward(ts)), 0)... }; - (void)ignore; -} - -} // namespace priv - -// Get methods -template -Response Get(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Get(); -} - -// Get async methods -template -AsyncResponse GetAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Get(std::move(ts)...); }, std::move(ts)...); -} - -// Get callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto GetCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Get(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Post methods -template -Response Post(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Post(); -} - -// Post async methods -template -AsyncResponse PostAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Post(std::move(ts)...); }, std::move(ts)...); -} - -// Post callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto PostCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Post(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Put methods -template -Response Put(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Put(); -} - -// Put async methods -template -AsyncResponse PutAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Put(std::move(ts)...); }, std::move(ts)...); -} - -// Put callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto PutCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Put(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Head methods -template -Response Head(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Head(); -} - -// Head async methods -template -AsyncResponse HeadAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Head(std::move(ts)...); }, std::move(ts)...); -} - -// Head callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto HeadCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Head(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Delete methods -template -Response Delete(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Delete(); -} - -// Delete async methods -template -AsyncResponse DeleteAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Delete(std::move(ts)...); }, - std::move(ts)...); -} - -// Delete callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto DeleteCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Delete(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Options methods -template -Response Options(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Options(); -} - -// Options async methods -template -AsyncResponse OptionsAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Options(std::move(ts)...); }, - std::move(ts)...); -} - -// Options callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto OptionsCallback(Then then, Ts... ts) - -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Options(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Patch methods -template -Response Patch(Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Patch(); -} - -// Patch async methods -template -AsyncResponse PatchAsync(Ts... ts) { - return std::async( - std::launch::async, [](Ts... ts) { return Patch(std::move(ts)...); }, std::move(ts)...); -} - -// Patch callback methods -template -// NOLINTNEXTLINE(fuchsia-trailing-return) -auto PatchCallback(Then then, Ts... ts) -> std::future { - return std::async( - std::launch::async, [](Then then, Ts... ts) { return then(Patch(std::move(ts)...)); }, - std::move(then), std::move(ts)...); -} - -// Download methods -template -Response Download(std::ofstream& file, Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Download(file); -} - -// Download with user callback -template -Response Download(const WriteCallback& write, Ts&&... ts) { - Session session; - priv::set_option(session, std::forward(ts)...); - return session.Download(write); -} - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/auth.h b/external/cpr/include/cpr/auth.h deleted file mode 100644 index 0da65e3..0000000 --- a/external/cpr/include/cpr/auth.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CPR_AUTH_H -#define CPR_AUTH_H - -#include - -#include - -namespace cpr { - -class Authentication { - public: - Authentication(const std::string& username, const std::string& password) - : auth_string_{username + ":" + password} {} - Authentication(std::string&& username, std::string&& password) - : auth_string_{std::move(username) + ":" + std::move(password)} {} - Authentication(const Authentication& other) = default; - Authentication(Authentication&& old) noexcept = default; - virtual ~Authentication() noexcept = default; - - Authentication& operator=(Authentication&& old) noexcept = default; - Authentication& operator=(const Authentication& other) = default; - - virtual const char* GetAuthString() const noexcept; - - protected: - std::string auth_string_; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/bearer.h b/external/cpr/include/cpr/bearer.h deleted file mode 100644 index c7e5d35..0000000 --- a/external/cpr/include/cpr/bearer.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CPR_BEARER_H -#define CPR_BEARER_H - -#include -#include - -#include - -namespace cpr { - -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 -class Bearer { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Bearer(const std::string& token) : token_string_{token} {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Bearer(std::string&& token) : token_string_{std::move(token)} {} - Bearer(const Bearer& other) = default; - Bearer(Bearer&& old) noexcept = default; - virtual ~Bearer() noexcept = default; - - Bearer& operator=(Bearer&& old) noexcept = default; - Bearer& operator=(const Bearer& other) = default; - - virtual const char* GetToken() const noexcept; - - protected: - std::string token_string_; -}; -#endif - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/body.h b/external/cpr/include/cpr/body.h deleted file mode 100644 index bafc89f..0000000 --- a/external/cpr/include/cpr/body.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef CPR_BODY_H -#define CPR_BODY_H - -#include -#include - -#include "cpr/cprtypes.h" - -namespace cpr { - -class Body : public StringHolder { - public: - Body() : StringHolder() {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Body(const std::string& body) : StringHolder(body) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Body(std::string&& body) : StringHolder(std::move(body)) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Body(const char* body) : StringHolder(body) {} - Body(const char* str, size_t len) : StringHolder(str, len) {} - Body(const std::initializer_list args) : StringHolder(args) {} - Body(const Body& other) = default; - Body(Body&& old) noexcept = default; - ~Body() override = default; - - Body& operator=(Body&& old) noexcept = default; - Body& operator=(const Body& other) = default; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/callback.h b/external/cpr/include/cpr/callback.h deleted file mode 100644 index 5b2fae2..0000000 --- a/external/cpr/include/cpr/callback.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef CPR_CALLBACK_H -#define CPR_CALLBACK_H - -#include "cprtypes.h" - -#include -#include - -namespace cpr { - -class ReadCallback { - public: - ReadCallback() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - ReadCallback(std::function callback) - : size{-1}, callback{std::move(callback)} {} - ReadCallback(cpr_off_t size, std::function callback) - : size{size}, callback{std::move(callback)} {} - - cpr_off_t size{}; - std::function callback; -}; - -class HeaderCallback { - public: - HeaderCallback() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - HeaderCallback(std::function callback) - : callback(std::move(callback)) {} - - std::function callback; -}; - -class WriteCallback { - public: - WriteCallback() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - WriteCallback(std::function callback) : callback(std::move(callback)) {} - - std::function callback; -}; - -class ProgressCallback { - public: - ProgressCallback() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - ProgressCallback(std::function - callback) - : callback(std::move(callback)) {} - - std::function - callback; -}; - -class DebugCallback { - public: - enum class InfoType { - TEXT = 0, - HEADER_IN = 1, - HEADER_OUT = 2, - DATA_IN = 3, - DATA_OUT = 4, - SSL_DATA_IN = 5, - SSL_DATA_OUT = 6, - }; - DebugCallback() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - DebugCallback(std::function callback) - : callback(std::move(callback)) {} - - std::function callback; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/connect_timeout.h b/external/cpr/include/cpr/connect_timeout.h deleted file mode 100644 index 546e8a5..0000000 --- a/external/cpr/include/cpr/connect_timeout.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CPR_CONNECT_TIMEOUT_H -#define CPR_CONNECT_TIMEOUT_H - -#include "cpr/timeout.h" - -namespace cpr { - -class ConnectTimeout : public Timeout { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - ConnectTimeout(const std::chrono::milliseconds& duration) : Timeout{duration} {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - ConnectTimeout(const std::int32_t& milliseconds) : Timeout{milliseconds} {} -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/cookies.h b/external/cpr/include/cpr/cookies.h deleted file mode 100644 index 03f7007..0000000 --- a/external/cpr/include/cpr/cookies.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CPR_COOKIES_H -#define CPR_COOKIES_H - -#include "cpr/curlholder.h" -#include -#include -#include -#include - -namespace cpr { - -class Cookies { - public: - /** - * Should we URL-encode cookies when making a request. - * Based on RFC6265, it is recommended but not mandatory to encode cookies. - * - * ------- - * To maximize compatibility with user agents, servers that wish to - * store arbitrary data in a cookie-value SHOULD encode that data, for - * example, using Base64 [RFC4648]. - * ------- - * Source: RFC6265 (https://www.ietf.org/rfc/rfc6265.txt) - **/ - bool encode{true}; - - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Cookies(bool encode = true) : encode(encode) {} - Cookies(const std::initializer_list>& pairs, - bool encode = true) - : encode(encode), map_{pairs} {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Cookies(const std::map& map, bool encode = true) - : encode(encode), map_{map} {} - - std::string& operator[](const std::string& key); - std::string GetEncoded(const CurlHolder& holder) const; - - using iterator = std::map::iterator; - using const_iterator = std::map::const_iterator; - - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; - const_iterator cbegin() const; - const_iterator cend() const; - - private: - std::map map_; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/cpr.h b/external/cpr/include/cpr/cpr.h deleted file mode 100644 index 9b7bb19..0000000 --- a/external/cpr/include/cpr/cpr.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef CPR_CPR_H -#define CPR_CPR_H - -#include "cpr/api.h" -#include "cpr/auth.h" -#include "cpr/cprtypes.h" -#include "cpr/response.h" -#include "cpr/session.h" -#include "cpr/status_codes.h" - -#define CPR_LIBCURL_VERSION_NUM LIBCURL_VERSION_NUM - -#endif diff --git a/external/cpr/include/cpr/cprtypes.h b/external/cpr/include/cpr/cprtypes.h deleted file mode 100644 index abd8dca..0000000 --- a/external/cpr/include/cpr/cprtypes.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef CPR_CPR_TYPES_H -#define CPR_CPR_TYPES_H - -#include -#include -#include -#include -#include -#include - -namespace cpr { - -/** - * Wrapper around "curl_off_t" to prevent applications from having to link against libcurl. - **/ -using cpr_off_t = curl_off_t; - -template -class StringHolder { - public: - StringHolder() = default; - explicit StringHolder(const std::string& str) : str_(str) {} - explicit StringHolder(std::string&& str) : str_(std::move(str)) {} - explicit StringHolder(const char* str) : str_(str) {} - StringHolder(const char* str, size_t len) : str_(str, len) {} - StringHolder(const std::initializer_list args) { - str_ = std::accumulate(args.begin(), args.end(), str_); - } - StringHolder(const StringHolder& other) = default; - StringHolder(StringHolder&& old) noexcept = default; - virtual ~StringHolder() = default; - - StringHolder& operator=(StringHolder&& old) noexcept = default; - - StringHolder& operator=(const StringHolder& other) = default; - - explicit operator std::string() const { - return str_; - } - - T operator+(const char* rhs) const { - return T(str_ + rhs); - } - - T operator+(const std::string& rhs) const { - return T(str_ + rhs); - } - - T operator+(const StringHolder& rhs) const { - return T(str_ + rhs.str_); - } - - void operator+=(const char* rhs) { - str_ += rhs; - } - void operator+=(const std::string& rhs) { - str_ += rhs; - } - void operator+=(const StringHolder& rhs) { - str_ += rhs; - } - - bool operator==(const char* rhs) const { - return str_ == rhs; - } - bool operator==(const std::string& rhs) const { - return str_ == rhs; - } - bool operator==(const StringHolder& rhs) const { - return str_ == rhs.str_; - } - - bool operator!=(const char* rhs) const { - return str_.c_str() != rhs; - } - bool operator!=(const std::string& rhs) const { - return str_ != rhs; - } - bool operator!=(const StringHolder& rhs) const { - return str_ != rhs.str_; - } - - const std::string& str() { - return str_; - } - const std::string& str() const { - return str_; - } - const char* c_str() const { - return str_.c_str(); - } - const char* data() const { - return str_.data(); - } - - protected: - std::string str_{}; -}; - -template -std::ostream& operator<<(std::ostream& os, const StringHolder& s) { - os << s.str(); - return os; -} - -class Url : public StringHolder { - public: - Url() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Url(const std::string& url) : StringHolder(url) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Url(std::string&& url) : StringHolder(std::move(url)) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Url(const char* url) : StringHolder(url) {} - Url(const char* str, size_t len) : StringHolder(std::string(str, len)) {} - Url(const std::initializer_list args) : StringHolder(args) {} - Url(const Url& other) = default; - Url(Url&& old) noexcept = default; - ~Url() override = default; - - Url& operator=(Url&& old) noexcept = default; - Url& operator=(const Url& other) = default; -}; - -struct CaseInsensitiveCompare { - bool operator()(const std::string& a, const std::string& b) const noexcept; -}; - -using Header = std::map; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/curl_container.h b/external/cpr/include/cpr/curl_container.h deleted file mode 100644 index ac67e94..0000000 --- a/external/cpr/include/cpr/curl_container.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CURL_CONTAINER_H -#define CURL_CONTAINER_H - -#include -#include -#include -#include - -#include "cpr/curlholder.h" - - -namespace cpr { - -struct Parameter { - Parameter(const std::string& key, const std::string& value) : key{key}, value{value} {} - Parameter(std::string&& key, std::string&& value) - : key{std::move(key)}, value{std::move(value)} {} - - std::string key; - std::string value; -}; - -struct Pair { - Pair(const std::string& p_key, const std::string& p_value) : key(p_key), value(p_value) {} - Pair(std::string&& p_key, std::string&& p_value) - : key(std::move(p_key)), value(std::move(p_value)) {} - - std::string key; - std::string value; -}; - - -template -class CurlContainer { - public: - /** - * Enables or disables URL encoding for keys and values when calling GetContent(...). - **/ - bool encode = true; - - CurlContainer() = default; - CurlContainer(const std::initializer_list&); - - void Add(const std::initializer_list&); - void Add(const T&); - - const std::string GetContent(const CurlHolder&) const; - - protected: - std::vector containerList_; -}; - -} // namespace cpr - -#endif // diff --git a/external/cpr/include/cpr/curlholder.h b/external/cpr/include/cpr/curlholder.h deleted file mode 100644 index a8a6e07..0000000 --- a/external/cpr/include/cpr/curlholder.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef CPR_CURL_HOLDER_H -#define CPR_CURL_HOLDER_H - -#include -#include -#include - -#include - -namespace cpr { -struct CurlHolder { - private: - /** - * Mutex for curl_easy_init(). - * curl_easy_init() is not thread save. - * References: - * https://curl.haxx.se/libcurl/c/curl_easy_init.html - * https://curl.haxx.se/libcurl/c/threadsafe.html - **/ - // It does not make sense to make a std::mutex const. - // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) - static std::mutex curl_easy_init_mutex_; - - public: - CURL* handle{nullptr}; - struct curl_slist* chunk{nullptr}; - struct curl_httppost* formpost{nullptr}; - std::array error{}; - - CurlHolder(); - CurlHolder(const CurlHolder& other) = default; - CurlHolder(CurlHolder&& old) noexcept = default; - ~CurlHolder(); - - CurlHolder& operator=(CurlHolder&& old) noexcept = default; - CurlHolder& operator=(const CurlHolder& other) = default; - - /** - * Uses curl_easy_escape(...) for escaping the given string. - **/ - std::string urlEncode(const std::string& s) const; - - /** - * Uses curl_easy_unescape(...) for unescaping the given string. - **/ - std::string urlDecode(const std::string& s) const; -}; -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/digest.h b/external/cpr/include/cpr/digest.h deleted file mode 100644 index 2a7ff38..0000000 --- a/external/cpr/include/cpr/digest.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CPR_DIGEST_H -#define CPR_DIGEST_H - -#include "cpr/auth.h" - -namespace cpr { -class Digest : public Authentication { - public: - Digest(const std::string& username, const std::string& password) - : Authentication{username, password} {} -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/error.h b/external/cpr/include/cpr/error.h deleted file mode 100644 index 6a2be06..0000000 --- a/external/cpr/include/cpr/error.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef CPR_ERROR_H -#define CPR_ERROR_H - -#include -#include - -#include "cpr/cprtypes.h" -#include - -namespace cpr { - -enum class ErrorCode { - OK = 0, - CONNECTION_FAILURE, - EMPTY_RESPONSE, - HOST_RESOLUTION_FAILURE, - INTERNAL_ERROR, - INVALID_URL_FORMAT, - NETWORK_RECEIVE_ERROR, - NETWORK_SEND_FAILURE, - OPERATION_TIMEDOUT, - PROXY_RESOLUTION_FAILURE, - SSL_CONNECT_ERROR, - SSL_LOCAL_CERTIFICATE_ERROR, - SSL_REMOTE_CERTIFICATE_ERROR, - SSL_CACERT_ERROR, - GENERIC_SSL_ERROR, - UNSUPPORTED_PROTOCOL, - REQUEST_CANCELLED, - UNKNOWN_ERROR = 1000, -}; - -class Error { - public: - ErrorCode code = ErrorCode::OK; - std::string message{}; - - Error() = default; - - Error(const std::int32_t& curl_code, std::string&& p_error_message) - : code{getErrorCodeForCurlError(curl_code)}, - message(std::move(p_error_message)) {} - - explicit operator bool() const { - return code != ErrorCode::OK; - } - - private: - static ErrorCode getErrorCodeForCurlError(std::int32_t curl_code); -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/limit_rate.h b/external/cpr/include/cpr/limit_rate.h deleted file mode 100644 index d258e63..0000000 --- a/external/cpr/include/cpr/limit_rate.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CPR_SPEED_LIMIT_H -#define CPR_SPEED_LIMIT_H - -#include - -namespace cpr { - -class LimitRate { - public: - LimitRate(const std::int64_t downrate, const std::int64_t uprate) - : downrate(downrate), uprate(uprate) {} - - std::int64_t downrate = 0; - std::int64_t uprate = 0; -}; - -} // namespace cpr - -#endif \ No newline at end of file diff --git a/external/cpr/include/cpr/low_speed.h b/external/cpr/include/cpr/low_speed.h deleted file mode 100644 index 394a438..0000000 --- a/external/cpr/include/cpr/low_speed.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CPR_LOW_SPEED_H -#define CPR_LOW_SPEED_H - -#include - -namespace cpr { - -class LowSpeed { - public: - LowSpeed(const std::int32_t limit, const std::int32_t time) : limit(limit), time(time) {} - - std::int32_t limit; - std::int32_t time; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/max_redirects.h b/external/cpr/include/cpr/max_redirects.h deleted file mode 100644 index 4d3dea4..0000000 --- a/external/cpr/include/cpr/max_redirects.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CPR_MAX_REDIRECTS_H -#define CPR_MAX_REDIRECTS_H - -#include - -namespace cpr { - -class MaxRedirects { - public: - explicit MaxRedirects(const std::int32_t number_of_redirects) - : number_of_redirects(number_of_redirects) {} - - std::int32_t number_of_redirects; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/multipart.h b/external/cpr/include/cpr/multipart.h deleted file mode 100644 index 4e0fb2f..0000000 --- a/external/cpr/include/cpr/multipart.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef CPR_MULTIPART_H -#define CPR_MULTIPART_H - -#include -#include -#include -#include -#include - -namespace cpr { - -struct File { - explicit File(std::string&& filepath) : filepath(std::move(filepath)) {} - explicit File(const std::string& filepath) : filepath(filepath) {} - const std::string filepath; -}; - -struct Buffer { - using data_t = const unsigned char*; - - template - Buffer(Iterator begin, Iterator end, std::string&& filename) - // Ignored here since libcurl reqires a long. - // There is also no way around the reinterpret_cast. - // NOLINTNEXTLINE(google-runtime-int, cppcoreguidelines-pro-type-reinterpret-cast) - : data{reinterpret_cast(&(*begin))}, datalen{static_cast( - std::distance(begin, end))}, - filename(std::move(filename)) { - is_random_access_iterator(begin, end); - static_assert(sizeof(*begin) == 1, "only byte buffers can be used"); - } - - template - typename std::enable_if::iterator_category, - std::random_access_iterator_tag>::value>::type - is_random_access_iterator(Iterator /* begin */, Iterator /* end */) {} - - data_t data; - // Ignored here since libcurl reqires a long: - // NOLINTNEXTLINE(google-runtime-int) - long datalen; - const std::string filename; -}; - -struct Part { - Part(const std::string& name, const std::string& value, const std::string& content_type = {}) - : name{name}, value{value}, - content_type{content_type}, is_file{false}, is_buffer{false} {} - Part(const std::string& name, const std::int32_t& value, const std::string& content_type = {}) - : name{name}, value{std::to_string(value)}, - content_type{content_type}, is_file{false}, is_buffer{false} {} - Part(const std::string& name, const File& file, const std::string& content_type = {}) - : name{name}, value{file.filepath}, - content_type{content_type}, is_file{true}, is_buffer{false} {} - Part(const std::string& name, const Buffer& buffer, const std::string& content_type = {}) - : name{name}, value{buffer.filename}, content_type{content_type}, data{buffer.data}, - datalen{buffer.datalen}, is_file{false}, is_buffer{true} {} - - std::string name; - std::string value; - std::string content_type; - Buffer::data_t data{nullptr}; - // Ignored here since libcurl reqires a long: - // NOLINTNEXTLINE(google-runtime-int) - long datalen{0}; - bool is_file; - bool is_buffer; -}; - -class Multipart { - public: - Multipart(const std::initializer_list& parts); - - std::vector parts; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/ntlm.h b/external/cpr/include/cpr/ntlm.h deleted file mode 100644 index e15833d..0000000 --- a/external/cpr/include/cpr/ntlm.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CPR_NTLM_H -#define CPR_NTLM_H - -#include "cpr/auth.h" - -namespace cpr { -class NTLM : public Authentication { - public: - NTLM(const std::string& username, const std::string& password) - : Authentication{username, password} {} -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/parameters.h b/external/cpr/include/cpr/parameters.h deleted file mode 100644 index 0e34d4d..0000000 --- a/external/cpr/include/cpr/parameters.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CPR_PARAMETERS_H -#define CPR_PARAMETERS_H - -#include - -#include "cpr/curl_container.h" - -namespace cpr { - -class Parameters : public CurlContainer { - public: - Parameters() = default; - Parameters(const std::initializer_list& parameters); -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/payload.h b/external/cpr/include/cpr/payload.h deleted file mode 100644 index 686b540..0000000 --- a/external/cpr/include/cpr/payload.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CPR_PAYLOAD_H -#define CPR_PAYLOAD_H - -#include - -#include "cpr/curl_container.h" - - -namespace cpr { -class Payload : public CurlContainer { - public: - template - Payload(const It begin, const It end) { - for (It pair = begin; pair != end; ++pair) { - Add(*pair); - } - } - Payload(const std::initializer_list& pairs); -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/proxies.h b/external/cpr/include/cpr/proxies.h deleted file mode 100644 index 223a4cb..0000000 --- a/external/cpr/include/cpr/proxies.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CPR_PROXIES_H -#define CPR_PROXIES_H - -#include -#include -#include - -namespace cpr { -class Proxies { - public: - Proxies() = default; - Proxies(const std::initializer_list>& hosts); - - bool has(const std::string& protocol) const; - const std::string& operator[](const std::string& protocol); - - private: - std::map hosts_; -}; -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/response.h b/external/cpr/include/cpr/response.h deleted file mode 100644 index 3eed7bc..0000000 --- a/external/cpr/include/cpr/response.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CPR_RESPONSE_H -#define CPR_RESPONSE_H - -#include -#include -#include -#include -#include -#include -#include - -#include "cpr/cookies.h" -#include "cpr/cprtypes.h" -#include "cpr/error.h" -#include "cpr/ssl_options.h" -#include "cpr/util.h" - -namespace cpr { - -class Response { - private: - std::shared_ptr curl_{nullptr}; - - public: - // Ignored here since libcurl uses a long for this. - // NOLINTNEXTLINE(google-runtime-int) - long status_code{}; - std::string text{}; - Header header{}; - Url url{}; - double elapsed{}; - Cookies cookies{}; - Error error{}; - std::string raw_header{}; - std::string status_line{}; - std::string reason{}; - cpr_off_t uploaded_bytes{}; - cpr_off_t downloaded_bytes{}; - // Ignored here since libcurl uses a long for this. - // NOLINTNEXTLINE(google-runtime-int) - long redirect_count{}; - - Response() = default; - Response(std::shared_ptr curl, std::string&& p_text, std::string&& p_header_string, - Cookies&& p_cookies, Error&& p_error); - std::vector GetCertInfo(); - Response(const Response& other) = default; - Response(Response&& old) noexcept = default; - ~Response() noexcept = default; - - Response& operator=(Response&& old) noexcept = default; - Response& operator=(const Response& other) = default; -}; -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/session.h b/external/cpr/include/cpr/session.h deleted file mode 100644 index 9cc5f36..0000000 --- a/external/cpr/include/cpr/session.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef CPR_SESSION_H -#define CPR_SESSION_H - -#include -#include -#include - -#include "cpr/auth.h" -#include "cpr/bearer.h" -#include "cpr/body.h" -#include "cpr/callback.h" -#include "cpr/connect_timeout.h" -#include "cpr/cookies.h" -#include "cpr/cprtypes.h" -#include "cpr/curlholder.h" -#include "cpr/digest.h" -#include "cpr/limit_rate.h" -#include "cpr/low_speed.h" -#include "cpr/max_redirects.h" -#include "cpr/multipart.h" -#include "cpr/ntlm.h" -#include "cpr/parameters.h" -#include "cpr/payload.h" -#include "cpr/proxies.h" -#include "cpr/response.h" -#include "cpr/ssl_options.h" -#include "cpr/timeout.h" -#include "cpr/unix_socket.h" -#include "cpr/user_agent.h" -#include "cpr/verbose.h" - -namespace cpr { - -class Session { - public: - Session(); - Session(Session&& old) noexcept; - Session(const Session& other) = delete; - - ~Session(); - - Session& operator=(Session&& old) noexcept; - Session& operator=(const Session& other) = delete; - - void SetUrl(const Url& url); - void SetParameters(const Parameters& parameters); - void SetParameters(Parameters&& parameters); - void SetHeader(const Header& header); - void UpdateHeader(const Header& header); - void SetTimeout(const Timeout& timeout); - void SetConnectTimeout(const ConnectTimeout& timeout); - void SetAuth(const Authentication& auth); - void SetDigest(const Digest& auth); - void SetUserAgent(const UserAgent& ua); - void SetPayload(Payload&& payload); - void SetPayload(const Payload& payload); - void SetProxies(Proxies&& proxies); - void SetProxies(const Proxies& proxies); - void SetMultipart(Multipart&& multipart); - void SetMultipart(const Multipart& multipart); - void SetNTLM(const NTLM& auth); - void SetRedirect(const bool& redirect); - void SetMaxRedirects(const MaxRedirects& max_redirects); - void SetCookies(const Cookies& cookies); - void SetBody(Body&& body); - void SetBody(const Body& body); - void SetLowSpeed(const LowSpeed& low_speed); - void SetVerifySsl(const VerifySsl& verify); - void SetUnixSocket(const UnixSocket& unix_socket); - void SetSslOptions(const SslOptions& options); - void SetReadCallback(const ReadCallback& read); - void SetHeaderCallback(const HeaderCallback& header); - void SetWriteCallback(const WriteCallback& write); - void SetProgressCallback(const ProgressCallback& progress); - void SetDebugCallback(const DebugCallback& debug); - void SetVerbose(const Verbose& verbose); - - // Used in templated functions - void SetOption(const Url& url); - void SetOption(const Parameters& parameters); - void SetOption(Parameters&& parameters); - void SetOption(const Header& header); - void SetOption(const Timeout& timeout); - void SetOption(const ConnectTimeout& timeout); - void SetOption(const Authentication& auth); -// Only supported with libcurl >= 7.61.0. -// As an alternative use SetHeader and add the token manually. -#if LIBCURL_VERSION_NUM >= 0x073D00 - void SetOption(const Bearer& auth); -#endif - void SetOption(const Digest& auth); - void SetOption(const UserAgent& ua); - void SetOption(Payload&& payload); - void SetOption(const Payload& payload); - void SetOption(const LimitRate& limit_rate); - void SetOption(Proxies&& proxies); - void SetOption(const Proxies& proxies); - void SetOption(Multipart&& multipart); - void SetOption(const Multipart& multipart); - void SetOption(const NTLM& auth); - void SetOption(const bool& redirect); - void SetOption(const MaxRedirects& max_redirects); - void SetOption(const Cookies& cookies); - void SetOption(Body&& body); - void SetOption(const Body& body); - void SetOption(const ReadCallback& read); - void SetOption(const HeaderCallback& header); - void SetOption(const WriteCallback& write); - void SetOption(const ProgressCallback& progress); - void SetOption(const DebugCallback& debug); - void SetOption(const LowSpeed& low_speed); - void SetOption(const VerifySsl& verify); - void SetOption(const Verbose& verbose); - void SetOption(const UnixSocket& unix_socket); - void SetOption(const SslOptions& options); - - Response Delete(); - Response Download(const WriteCallback& write); - Response Download(std::ofstream& file); - Response Get(); - Response Head(); - Response Options(); - Response Patch(); - Response Post(); - Response Put(); - - std::shared_ptr GetCurlHolder(); - - void PrepareDelete(); - void PrepareGet(); - void PrepareHead(); - void PrepareOptions(); - void PreparePatch(); - void PreparePost(); - void PreparePut(); - Response Complete(CURLcode curl_error); - - private: - class Impl; - std::unique_ptr pimpl_; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/ssl_options.h b/external/cpr/include/cpr/ssl_options.h deleted file mode 100644 index ea80525..0000000 --- a/external/cpr/include/cpr/ssl_options.h +++ /dev/null @@ -1,533 +0,0 @@ -#ifndef CPR_SSLOPTIONS_H -#define CPR_SSLOPTIONS_H - -#include - -#include - -#include - -#define __LIBCURL_VERSION_GTE(major, minor) \ - ((LIBCURL_VERSION_MAJOR > (major)) || \ - ((LIBCURL_VERSION_MAJOR == (major)) && (LIBCURL_VERSION_MINOR >= (minor)))) -#define __LIBCURL_VERSION_LT(major, minor) \ - ((LIBCURL_VERSION_MAJOR < (major)) || \ - ((LIBCURL_VERSION_MAJOR == (major)) && (LIBCURL_VERSION_MINOR < (minor)))) - -#ifndef SUPPORT_ALPN -#define SUPPORT_ALPN __LIBCURL_VERSION_GTE(7, 36) -#endif -#ifndef SUPPORT_NPN -#define SUPPORT_NPN __LIBCURL_VERSION_GTE(7, 36) -#endif - -#ifndef SUPPORT_SSLv2 -#define SUPPORT_SSLv2 __LIBCURL_VERSION_LT(7, 19) -#endif -#ifndef SUPPORT_SSLv3 -#define SUPPORT_SSLv3 __LIBCURL_VERSION_LT(7, 39) -#endif -#ifndef SUPPORT_TLSv1_0 -#define SUPPORT_TLSv1_0 __LIBCURL_VERSION_GTE(7, 34) -#endif -#ifndef SUPPORT_TLSv1_1 -#define SUPPORT_TLSv1_1 __LIBCURL_VERSION_GTE(7, 34) -#endif -#ifndef SUPPORT_TLSv1_2 -#define SUPPORT_TLSv1_2 __LIBCURL_VERSION_GTE(7, 34) -#endif -#ifndef SUPPORT_TLSv1_3 -#define SUPPORT_TLSv1_3 __LIBCURL_VERSION_GTE(7, 52) -#endif -#ifndef SUPPORT_MAX_TLS_VERSION -#define SUPPORT_MAX_TLS_VERSION __LIBCURL_VERSION_GTE(7, 54) -#endif -#ifndef SUPPORT_MAX_TLSv1_1 -#define SUPPORT_MAX_TLSv1_1 __LIBCURL_VERSION_GTE(7, 54) -#endif -#ifndef SUPPORT_MAX_TLSv1_2 -#define SUPPORT_MAX_TLSv1_2 __LIBCURL_VERSION_GTE(7, 54) -#endif -#ifndef SUPPORT_MAX_TLSv1_3 -#define SUPPORT_MAX_TLSv1_3 __LIBCURL_VERSION_GTE(7, 54) -#endif -#ifndef SUPPORT_TLSv13_CIPHERS -#define SUPPORT_TLSv13_CIPHERS __LIBCURL_VERSION_GTE(7, 61) -#endif -#ifndef SUPPORT_SESSIONID_CACHE -#define SUPPORT_SESSIONID_CACHE __LIBCURL_VERSION_GTE(7, 16) -#endif -#ifndef SUPPORT_SSL_FALSESTART -#define SUPPORT_SSL_FALSESTART __LIBCURL_VERSION_GTE(7, 42) -#endif -#ifndef SUPPORT_SSL_NO_REVOKE -#define SUPPORT_SSL_NO_REVOKE __LIBCURL_VERSION_GTE(7, 44) -#endif - -namespace cpr { - -class VerifySsl { - public: - VerifySsl() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - VerifySsl(bool verify) : verify(verify) {} - - explicit operator bool() const { - return verify; - } - - bool verify = true; -}; - -namespace ssl { - -// set SSL client certificate -class CertFile { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - CertFile(std::string&& p_filename) : filename(std::move(p_filename)) {} - - const std::string filename; - - virtual const char* GetCertType() const { - return "PEM"; - } -}; - -using PemCert = CertFile; - -class DerCert : public CertFile { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - DerCert(std::string&& p_filename) : CertFile(std::move(p_filename)) {} - - const char* GetCertType() const override { - return "DER"; - } -}; - -// specify private keyfile for TLS and SSL client cert -class KeyFile { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - KeyFile(std::string&& p_filename) : filename(std::move(p_filename)) {} - - template - KeyFile(FileType&& p_filename, PassType p_password) - : filename(std::forward(p_filename)), password(std::move(p_password)) {} - - std::string filename; - std::string password; - - virtual const char* GetKeyType() const { - return "PEM"; - } -}; - -using PemKey = KeyFile; - -class DerKey : public KeyFile { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - DerKey(std::string&& p_filename) : KeyFile(std::move(p_filename)) {} - - template - DerKey(FileType&& p_filename, PassType p_password) - : KeyFile(std::forward(p_filename), std::move(p_password)) {} - - const char* GetKeyType() const override { - return "DER"; - } -}; - -#if SUPPORT_ALPN -// This option enables/disables ALPN in the SSL handshake (if the SSL backend libcurl is built to -// use supports it), which can be used to negotiate http2. -class ALPN { - public: - ALPN() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - ALPN(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = true; -}; -#endif // SUPPORT_ALPN - -#if SUPPORT_NPN -// This option enables/disables NPN in the SSL handshake (if the SSL backend libcurl is built to -// use supports it), which can be used to negotiate http2. -class NPN { - public: - NPN() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - NPN(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = true; -}; -#endif // SUPPORT_NPN - -// This option determines whether libcurl verifies that the server cert is for the server it is -// known as. -class VerifyHost { - public: - VerifyHost() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - VerifyHost(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = true; -}; - -// This option determines whether libcurl verifies the authenticity of the peer's certificate. -class VerifyPeer { - public: - VerifyPeer() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - VerifyPeer(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = true; -}; - -// This option determines whether libcurl verifies the status of the server cert using the -// "Certificate Status Request" TLS extension (aka. OCSP stapling). -class VerifyStatus { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - VerifyStatus(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = false; -}; - -// TLS v1.0 or later -struct TLSv1 {}; -#if SUPPORT_SSLv2 -// SSL v2 (but not SSLv3) -struct SSLv2 {}; -#endif -#if SUPPORT_SSLv3 -// SSL v3 (but not SSLv2) -struct SSLv3 {}; -#endif -#if SUPPORT_TLSv1_0 -// TLS v1.0 or later (Added in 7.34.0) -struct TLSv1_0 {}; -#endif -#if SUPPORT_TLSv1_1 -// TLS v1.1 or later (Added in 7.34.0) -struct TLSv1_1 {}; -#endif -#if SUPPORT_TLSv1_2 -// TLS v1.2 or later (Added in 7.34.0) -struct TLSv1_2 {}; -#endif -#if SUPPORT_TLSv1_3 -// TLS v1.3 or later (Added in 7.52.0) -struct TLSv1_3 {}; -#endif -#if SUPPORT_MAX_TLS_VERSION -// The flag defines the maximum supported TLS version by libcurl, or the default value from the SSL -// library is used. -struct MaxTLSVersion {}; -#endif -#if SUPPORT_MAX_TLSv1_0 -// The flag defines maximum supported TLS version as TLSv1.0. (Added in 7.54.0) -struct MaxTLSv1_0 {}; -#endif -#if SUPPORT_MAX_TLSv1_1 -// The flag defines maximum supported TLS version as TLSv1.1. (Added in 7.54.0) -struct MaxTLSv1_1 {}; -#endif -#if SUPPORT_MAX_TLSv1_2 -// The flag defines maximum supported TLS version as TLSv1.2. (Added in 7.54.0) -struct MaxTLSv1_2 {}; -#endif -#if SUPPORT_MAX_TLSv1_3 -// The flag defines maximum supported TLS version as TLSv1.3. (Added in 7.54.0) -struct MaxTLSv1_3 {}; -#endif - -// path to Certificate Authority (CA) bundle -class CaInfo { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - CaInfo(std::string&& p_filename) : filename(std::move(p_filename)) {} - - std::string filename; -}; - -// specify directory holding CA certificates -class CaPath { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - CaPath(std::string&& p_filename) : filename(std::move(p_filename)) {} - - std::string filename; -}; - -// specify a Certificate Revocation List file -class Crl { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Crl(std::string&& p_filename) : filename(std::move(p_filename)) {} - - std::string filename; -}; - -// specify ciphers to use for TLS -class Ciphers { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Ciphers(std::string&& p_ciphers) : ciphers(std::move(p_ciphers)) {} - - std::string ciphers; -}; - -#if SUPPORT_TLSv13_CIPHERS -// specify ciphers suites to use for TLS 1.3 -class TLS13_Ciphers { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - TLS13_Ciphers(std::string&& p_ciphers) : ciphers(std::move(p_ciphers)) {} - - std::string ciphers; -}; -#endif - -#if SUPPORT_SESSIONID_CACHE -// enable/disable use of the SSL session-ID cache -class SessionIdCache { - public: - SessionIdCache() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - SessionIdCache(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = true; -}; -#endif - -#if SUPPORT_SSL_FALSESTART -class SslFastStart { - public: - SslFastStart() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - SslFastStart(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = false; -}; -#endif - -class NoRevoke { -public: - NoRevoke() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - NoRevoke(bool enabled) : enabled(enabled) {} - - explicit operator bool() const { - return enabled; - } - - bool enabled = false; -}; - -} // namespace ssl - -struct SslOptions { - std::string cert_file; - std::string cert_type; - std::string key_file; - std::string key_type; - std::string key_pass; -#if SUPPORT_ALPN - bool enable_alpn = true; -#endif // SUPPORT_ALPN -#if SUPPORT_NPN - bool enable_npn = true; -#endif // SUPPORT_ALPN - bool verify_host = true; - bool verify_peer = true; - bool verify_status = false; - int ssl_version = CURL_SSLVERSION_DEFAULT; -#if SUPPORT_SSL_NO_REVOKE - bool ssl_no_revoke = false; -#endif -#if SUPPORT_MAX_TLS_VERSION - int max_version = CURL_SSLVERSION_MAX_DEFAULT; -#endif - std::string ca_info; - std::string ca_path; - std::string crl_file; - std::string ciphers; -#if SUPPORT_TLSv13_CIPHERS - std::string tls13_ciphers; -#endif -#if SUPPORT_SESSIONID_CACHE - bool session_id_cache = true; -#endif - - void SetOption(const ssl::CertFile& opt) { - cert_file = opt.filename; - cert_type = opt.GetCertType(); - } - void SetOption(const ssl::KeyFile& opt) { - key_file = opt.filename; - key_type = opt.GetKeyType(); - key_pass = opt.password; - } -#if SUPPORT_ALPN - void SetOption(const ssl::ALPN& opt) { - enable_alpn = opt.enabled; - } -#endif // SUPPORT_ALPN -#if SUPPORT_NPN - void SetOption(const ssl::NPN& opt) { - enable_npn = opt.enabled; - } -#endif // SUPPORT_NPN - void SetOption(const ssl::VerifyHost& opt) { - verify_host = opt.enabled; - } - void SetOption(const ssl::VerifyPeer& opt) { - verify_peer = opt.enabled; - } - void SetOption(const ssl::VerifyStatus& opt) { - verify_status = opt.enabled; - } - void SetOption(const ssl::TLSv1& /*opt*/) { - ssl_version = CURL_SSLVERSION_TLSv1; - } -#if SUPPORT_SSL_NO_REVOKE - void SetOption(const ssl::NoRevoke& opt) { - ssl_no_revoke = opt.enabled; - } -#endif -#if SUPPORT_SSLv2 - void SetOption(const ssl::SSLv2& /*opt*/) { - ssl_version = CURL_SSLVERSION_SSLv2; - } -#endif -#if SUPPORT_SSLv3 - void SetOption(const ssl::SSLv3& /*opt*/) { - ssl_version = CURL_SSLVERSION_SSLv3; - } -#endif -#if SUPPORT_TLSv1_0 - void SetOption(const ssl::TLSv1_0& /*opt*/) { - ssl_version = CURL_SSLVERSION_TLSv1_0; - } -#endif -#if SUPPORT_TLSv1_1 - void SetOption(const ssl::TLSv1_1& /*opt*/) { - ssl_version = CURL_SSLVERSION_TLSv1_1; - } -#endif -#if SUPPORT_TLSv1_2 - void SetOption(const ssl::TLSv1_2& /*opt*/) { - ssl_version = CURL_SSLVERSION_TLSv1_2; - } -#endif -#if SUPPORT_TLSv1_3 - void SetOption(const ssl::TLSv1_3& /*opt*/) { - ssl_version = CURL_SSLVERSION_TLSv1_3; - } -#endif -#if SUPPORT_MAX_TLS_VERSION - void SetOption(const ssl::MaxTLSVersion& /*opt*/) { - max_version = CURL_SSLVERSION_DEFAULT; - } -#endif -#if SUPPORT_MAX_TLSv1_0 - void SetOption(const ssl::MaxTLSv1_0& opt) { - max_version = CURL_SSLVERSION_MAX_TLSv1_0; - } -#endif -#if SUPPORT_MAX_TLSv1_1 - void SetOption(const ssl::MaxTLSv1_1& /*opt*/) { - max_version = CURL_SSLVERSION_MAX_TLSv1_1; - } -#endif -#if SUPPORT_MAX_TLSv1_2 - void SetOption(const ssl::MaxTLSv1_2& /*opt*/) { - max_version = CURL_SSLVERSION_MAX_TLSv1_2; - } -#endif -#if SUPPORT_MAX_TLSv1_3 - void SetOption(const ssl::MaxTLSv1_3& /*opt*/) { - max_version = CURL_SSLVERSION_MAX_TLSv1_3; - } -#endif - void SetOption(const ssl::CaInfo& opt) { - ca_info = opt.filename; - } - void SetOption(const ssl::CaPath& opt) { - ca_path = opt.filename; - } - void SetOption(const ssl::Crl& opt) { - crl_file = opt.filename; - } - void SetOption(const ssl::Ciphers& opt) { - ciphers = opt.ciphers; - } -#if SUPPORT_TLSv13_CIPHERS - void SetOption(const ssl::TLS13_Ciphers& opt) { - tls13_ciphers = opt.ciphers; - } -#endif -#if SUPPORT_SESSIONID_CACHE - void SetOption(const ssl::SessionIdCache& opt) { - session_id_cache = opt.enabled; - } -#endif -}; - -namespace priv { - -template -void set_ssl_option(SslOptions& opts, T&& t) { - opts.SetOption(std::forward(t)); -} - -template -void set_ssl_option(SslOptions& opts, T&& t, Ts&&... ts) { - set_ssl_option(opts, std::forward(t)); - set_ssl_option(opts, std::move(ts)...); -} - -} // namespace priv - -template -SslOptions Ssl(Ts&&... ts) { - SslOptions opts; - priv::set_ssl_option(opts, std::move(ts)...); - return opts; -} - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/status_codes.h b/external/cpr/include/cpr/status_codes.h deleted file mode 100644 index 6c7acd6..0000000 --- a/external/cpr/include/cpr/status_codes.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _CPR_STATUS_CODES -#define _CPR_STATUS_CODES -#include -namespace cpr { -namespace status { -// Information responses -constexpr std::int32_t HTTP_CONTINUE = 100; -constexpr std::int32_t HTTP_SWITCHING_PROTOCOL = 101; -constexpr std::int32_t HTTP_PROCESSING = 102; -constexpr std::int32_t HTTP_EARLY_HINTS = 103; -// Successful responses -constexpr std::int32_t HTTP_OK = 200; -constexpr std::int32_t HTTP_CREATED = 201; -constexpr std::int32_t HTTP_ACCEPTED = 202; -constexpr std::int32_t HTTP_NON_AUTHORITATIVE_INFORMATION = 203; -constexpr std::int32_t HTTP_NO_CONTENT = 204; -constexpr std::int32_t HTTP_RESET_CONTENT = 205; -constexpr std::int32_t HTTP_PARTIAL_CONTENT = 206; -constexpr std::int32_t HTTP_MULTI_STATUS = 207; -constexpr std::int32_t HTTP_ALREADY_REPORTED = 208; -constexpr std::int32_t HTTP_IM_USED = 226; -// Redirection messages -constexpr std::int32_t HTTP_MULTIPLE_CHOICE = 300; -constexpr std::int32_t HTTP_MOVED_PERMANENTLY = 301; -constexpr std::int32_t HTTP_FOUND = 302; -constexpr std::int32_t HTTP_SEE_OTHER = 303; -constexpr std::int32_t HTTP_NOT_MODIFIED = 304; -constexpr std::int32_t HTTP_USE_PROXY = 305; -constexpr std::int32_t HTTP_UNUSED = 306; -constexpr std::int32_t HTTP_TEMPORARY_REDIRECT = 307; -constexpr std::int32_t HTTP_PERMANENT_REDIRECT = 308; -// Client error responses -constexpr std::int32_t HTTP_BAD_REQUEST = 400; -constexpr std::int32_t HTTP_UNAUTHORIZED = 401; -constexpr std::int32_t HTTP_PAYMENT_REQUIRED = 402; -constexpr std::int32_t HTTP_FORBIDDEN = 403; -constexpr std::int32_t HTTP_NOT_FOUND = 404; -constexpr std::int32_t HTTP_METHOD_NOT_ALLOWED = 405; -constexpr std::int32_t HTTP_NOT_ACCEPTABLE = 406; -constexpr std::int32_t HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; -constexpr std::int32_t HTTP_REQUEST_TIMEOUT = 408; -constexpr std::int32_t HTTP_CONFLICT = 409; -constexpr std::int32_t HTTP_GONE = 410; -constexpr std::int32_t HTTP_LENGTH_REQUIRED = 411; -constexpr std::int32_t HTTP_PRECONDITION_FAILED = 412; -constexpr std::int32_t HTTP_PAYLOAD_TOO_LARGE = 413; -constexpr std::int32_t HTTP_URI_TOO_LONG = 414; -constexpr std::int32_t HTTP_UNSUPPORTED_MEDIA_TYPE = 415; -constexpr std::int32_t HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; -constexpr std::int32_t HTTP_EXPECTATION_FAILED = 417; -constexpr std::int32_t HTTP_IM_A_TEAPOT = 418; -constexpr std::int32_t HTTP_MISDIRECTED_REQUEST = 421; -constexpr std::int32_t HTTP_UNPROCESSABLE_ENTITY = 422; -constexpr std::int32_t HTTP_LOCKED = 423; -constexpr std::int32_t HTTP_FAILED_DEPENDENCY = 424; -constexpr std::int32_t HTTP_TOO_EARLY = 425; -constexpr std::int32_t HTTP_UPGRADE_REQUIRED = 426; -constexpr std::int32_t HTTP_PRECONDITION_REQUIRED = 428; -constexpr std::int32_t HTTP_TOO_MANY_REQUESTS = 429; -constexpr std::int32_t HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; -constexpr std::int32_t HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; -// Server response errors -constexpr std::int32_t HTTP_INTERNAL_SERVER_ERROR = 500; -constexpr std::int32_t HTTP_NOT_IMPLEMENTED = 501; -constexpr std::int32_t HTTP_BAD_GATEWAY = 502; -constexpr std::int32_t HTTP_SERVICE_UNAVAILABLE = 503; -constexpr std::int32_t HTTP_GATEWAY_TIMEOUT = 504; -constexpr std::int32_t HTTP_HTTP_VERSION_NOT_SUPPORTED = 505; -constexpr std::int32_t HTTP_VARIANT_ALSO_NEGOTIATES = 506; -constexpr std::int32_t HTTP_INSUFFICIENT_STORAGE = 507; -constexpr std::int32_t HTTP_LOOP_DETECTED = 508; -constexpr std::int32_t HTTP_NOT_EXTENDED = 510; -constexpr std::int32_t HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; - -constexpr std::int32_t INFO_CODE_OFFSET = 100; -constexpr std::int32_t SUCCESS_CODE_OFFSET = 200; -constexpr std::int32_t REDIRECT_CODE_OFFSET = 300; -constexpr std::int32_t CLIENT_ERROR_CODE_OFFSET = 400; -constexpr std::int32_t SERVER_ERROR_CODE_OFFSET = 500; -constexpr std::int32_t MISC_CODE_OFFSET = 600; - -constexpr bool is_informational(const std::int32_t code) { - return (code >= INFO_CODE_OFFSET && code < SUCCESS_CODE_OFFSET); -} -constexpr bool is_success(const std::int32_t code) { - return (code >= SUCCESS_CODE_OFFSET && code < REDIRECT_CODE_OFFSET); -} -constexpr bool is_redirect(const std::int32_t code) { - return (code >= REDIRECT_CODE_OFFSET && code < CLIENT_ERROR_CODE_OFFSET); -} -constexpr bool is_client_error(const std::int32_t code) { - return (code >= CLIENT_ERROR_CODE_OFFSET && code < SERVER_ERROR_CODE_OFFSET); -} -constexpr bool is_server_error(const std::int32_t code) { - return (code >= SERVER_ERROR_CODE_OFFSET && code < MISC_CODE_OFFSET); -} - -} // namespace status -} // namespace cpr -#endif \ No newline at end of file diff --git a/external/cpr/include/cpr/timeout.h b/external/cpr/include/cpr/timeout.h deleted file mode 100644 index a01da43..0000000 --- a/external/cpr/include/cpr/timeout.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CPR_TIMEOUT_H -#define CPR_TIMEOUT_H - -#include -#include - -namespace cpr { - -class Timeout { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Timeout(const std::chrono::milliseconds& duration) : ms{duration} {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Timeout(const std::int32_t& milliseconds) : Timeout{std::chrono::milliseconds(milliseconds)} {} - - // No way around since curl uses a long here. - // NOLINTNEXTLINE(google-runtime-int) - long Milliseconds() const; - - std::chrono::milliseconds ms; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/unix_socket.h b/external/cpr/include/cpr/unix_socket.h deleted file mode 100644 index 9d4d77c..0000000 --- a/external/cpr/include/cpr/unix_socket.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CPR_UNIX_SOCKET_H -#define CPR_UNIX_SOCKET_H - -#include - -namespace cpr { - -class UnixSocket { - public: - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - UnixSocket(std::string&& unix_socket) : unix_socket_(std::move(unix_socket)) {} - - const char* GetUnixSocketString() const noexcept; - - private: - const std::string unix_socket_; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/user_agent.h b/external/cpr/include/cpr/user_agent.h deleted file mode 100644 index 71787c5..0000000 --- a/external/cpr/include/cpr/user_agent.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CPR_USERAGENT_H -#define CPR_USERAGENT_H - -#include -#include - -#include "cpr/cprtypes.h" - -namespace cpr { -class UserAgent : public StringHolder { - public: - UserAgent() : StringHolder() {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - UserAgent(const std::string& useragent) : StringHolder(useragent) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - UserAgent(std::string&& useragent) : StringHolder(std::move(useragent)) {} - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - UserAgent(const char* useragent) : StringHolder(useragent) {} - UserAgent(const char* str, size_t len) : StringHolder(str, len) {} - UserAgent(const std::initializer_list args) : StringHolder(args) {} - UserAgent(const UserAgent& other) = default; - UserAgent(UserAgent&& old) noexcept = default; - ~UserAgent() override = default; - - UserAgent& operator=(UserAgent&& old) noexcept = default; - UserAgent& operator=(const UserAgent& other) = default; -}; - -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/util.h b/external/cpr/include/cpr/util.h deleted file mode 100644 index 1c2e161..0000000 --- a/external/cpr/include/cpr/util.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef CPR_UTIL_H -#define CPR_UTIL_H - -#include -#include -#include - -#include "cpr/callback.h" -#include "cpr/cookies.h" -#include "cpr/cprtypes.h" -#include "cpr/curlholder.h" - -namespace cpr { -namespace util { - -Header parseHeader(const std::string& headers, std::string* status_line = nullptr, - std::string* reason = nullptr); -Cookies parseCookies(curl_slist* raw_cookies); -size_t readUserFunction(char* ptr, size_t size, size_t nitems, const ReadCallback* read); -size_t headerUserFunction(char* ptr, size_t size, size_t nmemb, const HeaderCallback* header); -size_t writeFunction(char* ptr, size_t size, size_t nmemb, std::string* data); -size_t writeFileFunction(char* ptr, size_t size, size_t nmemb, std::ofstream* file); -size_t writeUserFunction(char* ptr, size_t size, size_t nmemb, const WriteCallback* write); -#if LIBCURL_VERSION_NUM < 0x072000 -int progressUserFunction(const ProgressCallback* progress, double dltotal, double dlnow, - double ultotal, double ulnow); -#else -int progressUserFunction(const ProgressCallback* progress, curl_off_t dltotal, curl_off_t dlnow, - curl_off_t ultotal, curl_off_t ulnow); -#endif -int debugUserFunction(CURL* handle, curl_infotype type, char* data, size_t size, - const DebugCallback* debug); -std::vector split(const std::string& to_split, char delimiter); -std::string urlEncode(const std::string& s); -std::string urlDecode(const std::string& s); - -} // namespace util -} // namespace cpr - -#endif diff --git a/external/cpr/include/cpr/verbose.h b/external/cpr/include/cpr/verbose.h deleted file mode 100644 index 49bf029..0000000 --- a/external/cpr/include/cpr/verbose.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CPR_VERBOSE_H_ -#define CPR_VERBOSE_H_ - -namespace cpr { - -class Verbose { - public: - Verbose() = default; - // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) - Verbose(const bool verbose) : verbose{verbose} {} - - bool verbose = true; -}; - -} // namespace cpr - - -#endif /* CPR_VERBOSE_H_ */ diff --git a/external/cpr/test/CMakeLists.txt b/external/cpr/test/CMakeLists.txt deleted file mode 100644 index 831d669..0000000 --- a/external/cpr/test/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -find_package(Threads REQUIRED) - -if (ENABLE_SSL_TESTS) - add_library(test_server STATIC - abstractServer.cpp - httpServer.cpp - httpsServer.cpp) -else () - add_library(test_server STATIC - abstractServer.cpp - httpServer.cpp) -endif() -if(WIN32) - target_link_libraries(test_server PRIVATE Threads::Threads cpr::cpr GTest::GTest - PUBLIC mongoose ws2_32 wsock32) -else() - target_link_libraries(test_server PRIVATE Threads::Threads cpr::cpr GTest::GTest - PUBLIC mongoose) -endif() - -macro(add_cpr_test _TEST_NAME) - add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests.cpp) - target_link_libraries(${_TEST_NAME}_tests PRIVATE - test_server - GTest::GTest - cpr::cpr - CURL::libcurl) - add_test(NAME cpr_${_TEST_NAME}_tests COMMAND ${_TEST_NAME}_tests) - # Group under the "tests" project folder in IDEs such as Visual Studio. - set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") - if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $) - endif() -endmacro() - -add_cpr_test(get) -add_cpr_test(post) -add_cpr_test(session) -add_cpr_test(prepare) -add_cpr_test(async) -add_cpr_test(proxy) -add_cpr_test(head) -add_cpr_test(delete) -add_cpr_test(put) -add_cpr_test(callback) -add_cpr_test(raw_body) -add_cpr_test(options) -add_cpr_test(patch) -add_cpr_test(error) -add_cpr_test(alternating) -add_cpr_test(util) -add_cpr_test(structures) - -if (ENABLE_SSL_TESTS) - add_cpr_test(ssl) - # Install all ssl keys and certs: - - add_custom_command(TARGET ssl_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory $/data) - add_custom_command(TARGET ssl_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/server.key $) - add_custom_command(TARGET ssl_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/server.cer $) - add_custom_command(TARGET ssl_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/client.key $) - add_custom_command(TARGET ssl_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/client.cer $) -endif() diff --git a/external/cpr/test/abstractServer.cpp b/external/cpr/test/abstractServer.cpp deleted file mode 100644 index 7aabaf4..0000000 --- a/external/cpr/test/abstractServer.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "abstractServer.hpp" - -namespace cpr { -void AbstractServer::SetUp() { - Start(); -} - -void AbstractServer::TearDown() { - Stop(); -} - -void AbstractServer::Start() { - should_run = true; - serverThread = std::make_shared(&AbstractServer::Run, this); - serverThread->detach(); - std::unique_lock server_lock(server_mutex); - server_start_cv.wait(server_lock); -} - -void AbstractServer::Stop() { - should_run = false; - std::unique_lock server_lock(server_mutex); - server_stop_cv.wait(server_lock); -} - -static void EventHandler(mg_connection* conn, int event, void* event_data) { - switch (event) { - case MG_EV_RECV: - case MG_EV_SEND: - /** Do nothing. Just for housekeeping. **/ - break; - case MG_EV_POLL: - /** Do nothing. Just for housekeeping. **/ - break; - case MG_EV_CLOSE: - /** Do nothing. Just for housekeeping. **/ - break; - case MG_EV_ACCEPT: - /** Do nothing. Just for housekeeping. **/ - break; - case MG_EV_CONNECT: - /** Do nothing. Just for housekeeping. **/ - break; - case MG_EV_TIMER: - /** Do nothing. Just for housekeeping. **/ - break; - - case MG_EV_HTTP_CHUNK: { - /** Do nothing. Just for housekeeping. **/ - } break; - - case MG_EV_HTTP_REQUEST: { - AbstractServer* server = static_cast(conn->mgr->user_data); - server->OnRequest(conn, static_cast(event_data)); - } break; - - default: - break; - } -} - -void AbstractServer::Run() { - // Setup a new mongoose http server. - memset(&mgr, 0, sizeof(mg_mgr)); - mg_connection* c = initServer(&mgr, EventHandler); - - // Notify the main thread that the server is up and runing: - server_start_cv.notify_all(); - - // Main server loop: - while (should_run) { - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - mg_mgr_poll(&mgr, 1000); - } - - // Shutdown and cleanup: - mg_mgr_free(&mgr); - - // Notify the main thread that we have shut down everything: - server_stop_cv.notify_all(); -} - -static const std::string base64_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; -/** - * Decodes the given BASE64 string to a normal string. - * Source: https://gist.github.com/williamdes/308b95ac9ef1ee89ae0143529c361d37 - **/ -std::string AbstractServer::Base64Decode(const std::string& in) { - std::string out; - - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - std::vector T(256, -1); - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - for (size_t i = 0; i < 64; i++) - T[base64_chars[i]] = i; - - int val = 0; - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - int valb = -8; - for (unsigned char c : in) { - if (T[c] == -1) { - break; - } - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - val = (val << 6) + T[c]; - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - valb += 6; - if (valb >= 0) { - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - out.push_back(char((val >> valb) & 0xFF)); - // NOLINTNEXTLINE (cppcoreguidelines-avoid-magic-numbers) - valb -= 8; - } - } - return out; -} - -static int LowerCase(const char* s) { - return tolower(*s); -} - -static int StrnCaseCmp(const char* s1, const char* s2, size_t len) { - int diff = 0; - - if (len > 0) { - do { - // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic) - diff = LowerCase(s1++) - LowerCase(s2++); - // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic) - } while (diff == 0 && s1[-1] != '\0' && --len > 0); - } - - return diff; -} - -} // namespace cpr diff --git a/external/cpr/test/abstractServer.hpp b/external/cpr/test/abstractServer.hpp deleted file mode 100644 index aaa7fcc..0000000 --- a/external/cpr/test/abstractServer.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef CPR_TEST_ABSTRACT_SERVER_SERVER_H -#define CPR_TEST_ABSTRACT_SERVER_SERVER_H - -#include -#include -#include -#include -#include -#include - -#include "cpr/cpr.h" -#include "mongoose.h" - -namespace cpr { -class AbstractServer : public testing::Environment { - public: - ~AbstractServer() override = default; - - void SetUp() override; - void TearDown() override; - - void Start(); - void Stop(); - - virtual std::string GetBaseUrl() = 0; - virtual uint16_t GetPort() = 0; - - virtual void OnRequest(mg_connection* conn, http_message* msg) = 0; - - private: - std::shared_ptr serverThread{nullptr}; - std::mutex server_mutex; - std::condition_variable server_start_cv; - std::condition_variable server_stop_cv; - std::atomic should_run{false}; - mg_mgr mgr{}; - - void Run(); - - protected: - virtual mg_connection* initServer(mg_mgr* mgr, - MG_CB(mg_event_handler_t event_handler, void* user_data)) = 0; - - static std::string Base64Decode(const std::string& in); - static int LowerCase(const char* s); - static int StrnCaseCmp(const char* s1, const char* s2, size_t len); -}; -} // namespace cpr - -#endif diff --git a/external/cpr/test/alternating_tests.cpp b/external/cpr/test/alternating_tests.cpp deleted file mode 100644 index d0466f6..0000000 --- a/external/cpr/test/alternating_tests.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(AlternatingTests, PutGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Header reflect PUT"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Response response = cpr::Get(url); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(AlternatingTests, PutGetPutGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Header reflect PUT"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Response response = cpr::Get(url); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Header reflect PUT"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Response response = cpr::Get(url); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(AlternatingTests, HeadGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - - { - // Head shouldn't return a body - Response response = cpr::Head(url); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Response response = cpr::Get(url); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(AlternatingTests, PutHeadTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Header reflect PUT"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - // Head shouldn't return a body - Response response = cpr::Head(url); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(AlternatingTests, PutPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Header reflect PUT"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - - { - Payload payload{{"x", "5"}}; - Response response = cpr::Post(url, payload); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/async_tests.cpp b/external/cpr/test/async_tests.cpp deleted file mode 100644 index 9956063..0000000 --- a/external/cpr/test/async_tests.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include - -#include -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(UrlEncodedPostTests, AsyncGetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - cpr::AsyncResponse future = cpr::GetAsync(url); - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); -} - -TEST(UrlEncodedPostTests, AsyncGetMultipleTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::GetAsync(url)); - } - for (cpr::AsyncResponse& future : responses) { - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - } -} - -TEST(UrlEncodedPostTests, AsyncGetMultipleReflectTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector responses; - for (size_t i = 0; i < 100; ++i) { - Parameters p{{"key", std::to_string(i)}}; - responses.emplace_back(cpr::GetAsync(url, p)); - } - int i = 0; - for (cpr::AsyncResponse& future : responses) { - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - Url expected_url{url + "?key=" + std::to_string(i)}; - EXPECT_EQ(expected_url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - ++i; - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/callback_tests.cpp b/external/cpr/test/callback_tests.cpp deleted file mode 100644 index 3a18413..0000000 --- a/external/cpr/test/callback_tests.cpp +++ /dev/null @@ -1,938 +0,0 @@ -#include -#include - -#include -#include - -#include - -#include "cpr/cprtypes.h" -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); -std::chrono::milliseconds sleep_time{50}; -std::chrono::seconds zero{0}; - -int status_callback(int& status_code, Response r) { - status_code = r.status_code; - return r.status_code; -} - -int status_callback_ref(int& status_code, const Response& r) { - status_code = r.status_code; - return r.status_code; -} - -std::string text_callback(std::string& expected_text, Response r) { - expected_text = r.text; - return r.text; -} - -std::string text_callback_ref(std::string& expected_text, const Response& r) { - expected_text = r.text; - return r.text; -} - -TEST(CallbackGetTests, CallbackGetLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::GetCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackGetTests, CallbackGetLambdaTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::GetCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackGetTests, CallbackGetLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::GetCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackGetTests, CallbackGetLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::GetCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackGetTests, CallbackGetFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::GetCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackGetTests, CallbackGetFunctionTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::GetCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackGetTests, CallbackGetFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::GetCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackGetTests, CallbackGetFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::GetCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - int status_code = 0; - auto future = cpr::DeleteCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteLambdaTextTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - std::string expected_text{}; - auto future = cpr::DeleteCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - int status_code = 0; - auto future = cpr::DeleteCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - std::string expected_text{}; - auto future = cpr::DeleteCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::DeleteCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteFunctionTextTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::DeleteCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::DeleteCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackDeleteTests, CallbackDeleteFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::DeleteCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::HeadCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadLambdaTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::HeadCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::HeadCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::HeadCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::HeadCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadFunctionTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::HeadCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::HeadCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackHeadTests, CallbackHeadFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::HeadCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPostTests, CallbackPostLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PostCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPostTests, CallbackPostLambdaTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PostCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPostTests, CallbackPostLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PostCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPostTests, CallbackPostLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PostCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPostTests, CallbackPostFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PostCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPostTests, CallbackPostFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PostCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPostTests, CallbackPostFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PostCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPostTests, CallbackPostFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PostCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPutTests, CallbackPutLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PutCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPutTests, CallbackPutLambdaTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PutCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPutTests, CallbackPutLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PutCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPutTests, CallbackPutLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PutCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPutTests, CallbackPutFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PutCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPutTests, CallbackPutFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PutCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPutTests, CallbackPutFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PutCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPutTests, CallbackPutFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PutCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::OptionsCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsLambdaTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::OptionsCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto future = cpr::OptionsCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto future = cpr::OptionsCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::OptionsCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsFunctionTextTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::OptionsCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::OptionsCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackOptionsTests, CallbackOptionsFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::OptionsCallback(callback, url); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchLambdaStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PatchCallback( - [&status_code](Response r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchLambdaTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PatchCallback( - [&expected_text](Response r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchLambdaStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto future = cpr::PatchCallback( - [&status_code](const Response& r) { - status_code = r.status_code; - return r.status_code; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchLambdaTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto future = cpr::PatchCallback( - [&expected_text](const Response& r) { - expected_text = r.text; - return r.text; - }, - url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchFunctionStatusTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PatchCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PatchCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchFunctionStatusReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - int status_code = 0; - auto callback = std::function( - std::bind(status_callback_ref, std::ref(status_code), std::placeholders::_1)); - auto future = cpr::PatchCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(status_code, future.get()); -} - -TEST(CallbackPatchTests, CallbackPatchFunctionTextReferenceTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::string expected_text{}; - auto callback = std::function( - std::bind(text_callback_ref, std::ref(expected_text), std::placeholders::_1)); - auto future = cpr::PatchCallback(callback, url, payload); - std::this_thread::sleep_for(sleep_time); - EXPECT_EQ(future.wait_for(zero), std::future_status::ready); - EXPECT_EQ(expected_text, future.get()); -} - -TEST(CallbackDataTests, CallbackReadFunctionCancelTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, cpr::ReadCallback([](char* buffer, size_t & size) -> size_t { - return false; - })); - EXPECT_EQ(response.error.code, ErrorCode::REQUEST_CANCELLED); -} - -TEST(CallbackDataTests, CallbackReadFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - unsigned count = 0; - Response response = cpr::Post(url, cpr::ReadCallback{3, [&](char* buffer, size_t & size) -> size_t { - std::string data; - ++ count; - switch (count) { - case 1: - data = "x="; - break; - case 2: - data = "5"; - break; - default: - return false; - } - std::copy(data.begin(), data.end(), buffer); - size = data.size(); - return true; - }}); - EXPECT_EQ(2, count); - EXPECT_EQ(expected_text, response.text); -} - -/** - * Checks if the "Transfer-Encoding" header will be kept when using headers and a read callback. - * Issue: https://github.com/whoshuu/cpr/issues/517 - **/ -TEST(CallbackDataTests, CallbackReadFunctionHeaderTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - bool send = false; - std::string data = "Test"; - Response response = cpr::Post(url, - cpr::ReadCallback{-1, - [&](char* /*buffer*/, size_t& size) -> size_t { - size = 0; - return true; - }}, - Header{{"TestHeader", "42"}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - - // Check Header: - EXPECT_EQ(std::string{"42"}, response.header["TestHeader"]); // Set by us - EXPECT_TRUE(response.header.find("TestHeader") != response.header.end()); - EXPECT_EQ(std::string{"chunked"}, response.header["Transfer-Encoding"]); // Set by the read callback - EXPECT_TRUE(response.header.find("Transfer-Encoding") != response.header.end()); -} - -/* cesanta mongoose doesn't support chunked requests yet -TEST(CallbackDataTests, CallbackReadFunctionChunkedTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - unsigned count = 0; - Response response = cpr::Post(url, cpr::ReadCallback{[&count](char* buffer, size_t & size) -> size_t { - std::string data; - ++ count; - switch (count) { - case 1: - data = "x="; - break; - case 2: - data = "5"; - break; - default: - data = ""; - break; - } - std::copy(data.begin(), data.end(), buffer); - size = data.size(); - return true; - }}); - EXPECT_EQ(3, count); - EXPECT_EQ(expected_text, response.text); -} -*/ - -TEST(CallbackDataTests, CallbackHeaderFunctionCancelTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = Post(url, HeaderCallback{[](std::string header) -> bool { - return false; - }}); - EXPECT_EQ(response.error.code, ErrorCode::REQUEST_CANCELLED); -} - -TEST(CallbackDataTests, CallbackHeaderFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - std::vector expected_headers{ - "HTTP/1.1 201 OK\r\n", - "Content-Type: application/json\r\n", - "\r\n" - }; - std::set response_headers; - Post(url, HeaderCallback{[&response_headers](std::string header) -> bool { - response_headers.insert(header); - return true; - }}); - for (std::string & header : expected_headers) { - EXPECT_TRUE(response_headers.count(header)); - } -} - -TEST(CallbackDataTests, CallbackWriteFunctionCancelTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = Post(url, WriteCallback{[](std::string header) -> bool { - return false; - }}); - EXPECT_EQ(response.error.code, ErrorCode::REQUEST_CANCELLED); -} - -TEST(CallbackDataTests, CallbackWriteFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - std::string response_text; - Post(url, Payload{{"x", "5"}}, WriteCallback{[&response_text](std::string header) -> bool { - response_text.append(header); - return true; - }}); - EXPECT_EQ(expected_text, response_text); -} - -TEST(CallbackDataTests, CallbackProgressFunctionCancelTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = Post(url, ProgressCallback{[](size_t downloadTotal, size_t downloadNow, size_t uploadTotal, size_t uploadNow) -> bool { - return false; - }}); - EXPECT_EQ(response.error.code, ErrorCode::REQUEST_CANCELLED); -} - -TEST(CallbackDataTests, CallbackProgressFunctionTotalTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Body body{"x=5"}; - size_t response_upload = 0, response_download = 0; - Response response = Post(url, body, ProgressCallback{[&](size_t downloadTotal, size_t downloadNow, size_t uploadTotal, size_t uploadNow) -> bool { - response_upload = uploadTotal; - response_download = downloadTotal; - return true; - }}); - EXPECT_EQ(body.str().length(), response_upload); - EXPECT_EQ(response.text.length(), response_download); -} - -TEST(CallbackDataTests, CallbackDebugFunctionTextTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Body body{"x=5"}; - std::string debug_body; - Response response = Post(url, body, DebugCallback{[&](DebugCallback::InfoType type, std::string data) { - if (type == DebugCallback::InfoType::DATA_OUT) { - debug_body = data; - } - }}); - EXPECT_EQ(body.str(), debug_body); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/data/ca.cer b/external/cpr/test/data/ca.cer deleted file mode 100644 index 9076af6..0000000 --- a/external/cpr/test/data/ca.cer +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFZTCCA02gAwIBAgIUWr63iywc/E1roG2NLbLOTuoh3hQwDQYJKoZIhvcNAQEL -BQAwQjELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE -CgwTRGVmYXVsdCBDb21wYW55IEx0ZDAeFw0yMDA1MjQwOTEyMzRaFw0zMDA1MjIw -OTEyMzRaMEIxCzAJBgNVBAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAa -BgNVBAoME0RlZmF1bHQgQ29tcGFueSBMdGQwggIiMA0GCSqGSIb3DQEBAQUAA4IC -DwAwggIKAoICAQC/0V2ip8VG6R4UGP7aA5A44AKB2ATpTlx4EsGuhI/Ka/4psnda -AzllmJINse3krXU1+vdDVtWO2PSxGoGS32mKPkfVEJ+mPVNQovz/+4qTNoMYwysg -0WA4xXR6frcBwV3DXhQF1APFruc0Kzx3Lxa+aTN66OcfTr1MF+hcEqDH+c79JxSY -Cpi7ZWwNeZGZuDa1tY6rPDUcfavOghb+Uanug9IsfCt+rUOOjGfpjMGcxaTpByi3 -Y4Lrye/BzW0IdXJ+xX+8an4p9PR7bCVMIV0NcfhkqldlMeXGDR5Dday7H6M7OaDY -4JPTJYn3JfXzxQs7Ety6E9UjhnkjL+JnhAVzSe84rysfQdvjxWZggomlg7M/DTlT -K/AU7e9iGZtvQ4WGq7kw/UieQv1y7agJCJDXyLtG4JgCpN1qSvAA2I76CBf0hczY -sWQRCUxW4S6RIj6WDvRv7sFeFHDq132JjiBe79+tPZk3s/9J/pQduKfZRn2vCRr7 -VLwh4FysgmknHTqFFG6GARaTYOYxjk6FjbWLY3el5HgzMgNDRKSAelpYJv7KgVZe -q6Aa11FJYJjkBVTMIQ/uwVdDAMZpuCu132r42pO+FdWF0T3FcLXaWfI3/xDvcuGZ -Rh8E1UmM74GU5cywv9+6Wi/2Q8rrve9GfJS7WneK0VeR84qQI2zuB7WIXwIDAQAB -o1MwUTAdBgNVHQ4EFgQUDTJkFYrAhJiUjuwtYZO2jihFX78wHwYDVR0jBBgwFoAU -DTJkFYrAhJiUjuwtYZO2jihFX78wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B -AQsFAAOCAgEAi8SzJwG4w8fpQg+E2JXJtHZSrksaMAYJZvoxqWwQpOZTIU3U24uh -PWMGUrKP4IOzXho99C3Yz5vRHG+nfUcJz8nE+/7Ps3wx4uY6OXznRv6EvkHrokuV -OHT8dGWt+992RIJ8U/i5uwLAucquqW0yDz3/eAeLIvM7uax2ijeDMRtDZ8zorePY -ETL2WOPgibDPTTmcJRKut6kUJ6a3FJpWzEIgHXOhJI3ABx7apXkCzhu2zsTlYA6C -ygaWwO94kSaHDsTyWACjkMevm8AxlJJ5T/LqfFdwB65rKOQONVDpcrywPwbHX30H -rBf4X7+GCYrJG9oHxJj/atkAgSBLkjiIp/Eh0XAH4Ij/Ce+v3d8xTAV8aM9/6l7o -NlLMJ/DiL9ygFwv3hW3HbRIelXMJJtTJDtl1IikETObJp/3cmJOd0S+YMxvPdzgk -Cmn7fVPg5BOIv79pvnLI2aR0g1PGKmSznmFFYI0ngVvlC9UgYpdr+7mtsUfPkFTR -EdTjxlZ6YcYgd7mKTAUA/sumcufmEu5MT6hK/h1Ae853uxvrHtC2KWgHsHvBNXU+ -xyUgT1BmuJRIjh54OxqoQ08XVqa6n+vGuxSAIKLFcM79TIEGM268sexxd7f5kyZa -P8ZsfEV+ZIluxXqntc+CcnGeOZKj5nevXLpDy/U3EoihhjUOnaD+X00= ------END CERTIFICATE----- diff --git a/external/cpr/test/data/ca.key b/external/cpr/test/data/ca.key deleted file mode 100644 index 06d1842..0000000 --- a/external/cpr/test/data/ca.key +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIJnDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIob0N72+XHJ0CAggA -MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECK0yHDwNmbQIBIIJSK8lBByO2wQb -42mQyaZjrwHOlkeGUE1THPMd2AX1NYgTDJh46OtoyQYfIXhYf0K7MptmyA93X2q8 -f0MNyyIIsoKW8Gx35Y4N7dCjXihskagm6NIi5/89O8Lp5jL40W1Cp2tqVeuO4RiB -xZKSa8+fUc55fJZ0BjGAtIT5lQw6iQ4lAbRnEkDjJYZ6+N82uLYaf11JvKB+wux9 -9Z8AxURFP/VV/etHQlpPY5lWfleHdEBUOXpDMcNodqt1kDbOtfkp0lQV0ae6mNoY -zZW3dsX58f4w0GW6JN/30EFOJLkATVeEjwX91PLFFHBbDA734jpbnCUFCX6F7JIb -8VO8wkVUKMs8QOJoKrQlDTMIEKQOQoa8sM3h+rESgKX5AryQa3TKO+xQH7z37lI7 -XZKQ5hDhBI7l9yEAaPbCbzqh24TDeuPyPwYDWVRS2N+jniXTnk8eXPVg+Sesa1BI -zKQNpPFevyfCHfAIddPjSpOqMgUY2FpQJINuwHx69nqmekIYyH5tbrT0Uv9PPNw5 -FAfklr6SFmLbtOkq+C3yiwMKoAC5rt8rluH6juxThtozWsrOiS57vibrRKPiQLPr -YBysYy9QSZ9ZA0k4JR4BBG3Y2TlQUdmhzGgch599Y0BPhanemp/KKTg0P3Xp8+Hw -Tq1urZlwJo8VTKyi78XKL41ROBMD53fm0LcMfNNG66tsTiTaltDFtlCXrvWpICni -XZE9ijrI/VMphPUnujZXkDNaBL0HMTT9doEepRQNItYtL3wytp96gnewE6ceXduO -HpKUXBZ7Ho7XjD5sUTlk8IHFzE8cyZ5+YiKTCv8f1m5m0n6Yk9/zjtMFPq5/Z6bg -0/7GmzT2GO9THwRtclJLCVZaDxDiL3cG5cSzQsJWKhuHJ2oLCdAjmjixHY22VJAz -RAjT0z4+N1IP1uemYHYse/cARsfj/cFKL2s99pco9P+uJMcOHYYlPADbstMjOOAK -U7wcYGvsUL3pyZJEvUSUN813jtOB3xr3459Cq7kfoV+mzC8NoxzKXykfT1ozvC6h -8d47AvKFGEtQKcM8S256i4flZzojr6rP5Bdf+mGOUe3J31BYyAmXoWm3jUfBvxRF -kvTdVSw2qfWEWO/cTd5jS+sxu/lJfO9dP0xWERJSOSfO3I6dbEmuJUIJhP1EpPol -uIvOpGig3dgLHF6PLpee5QK2/AKkMLvKdkv2Gk/nsTmVZwWb401RTQKovjej111t -ie0NhDnJrpPTcUPbtB/SV9/brL0OlztbQU5ubPxXtaO9jOKQKS3vvpNmW2GB5mrt -vhVZyJjpab5sUg9BJM0dovTGzzFqF7WybsZJsiO8xhoCL5a3p2msCgVRpzlHEv+m -MkGLZuqtku74U5gOb1EcuCkWrmR+tNF0WO+0phAbAFIyvOZrIsUYSpxVyzif4FNd -R2qOI+OPD2nama9q+E3LnxkxGIwZDqH0X0kb4nJ+k+y/ZAUQltcF0jfq2zJ6kmko -xXjaBWOy2tUIYfUEkODtg2PvXTM5hDa2G0Kqc3mMOq50NCyMrFeMwZwfCCY+bwWj -qDqEUsikfvjaiy5sCkhGNOgGo/FX7LOmzWg8c489AmVHWqCMN74cGKBTDBVA+KDX -Qha+PnWP++XyRQY9DpNEw2bXgKfKpQJ4jyJmhXQRsCrj1KrBOeTract4VvN27WrA -Phq+eynHGKTIrDIpLpxTarQ/pneAkuZyZVAHAtVLLYCxfOxkCUvgBrl73nOWLKjC -JL3x8w1pPvJuUdO8KLYEa+RGa21cHbQa0h3baRfQwT9qXxTk7U+0nh6W78edGxbl -EKUEeFBzTfzrh2H3sTKambumA1gzMC2eaTqK0MiLGKrMVo9vG8aPIiLGhqa8aX4B -5MRI7Zs2NXSQu3IMWitLTKxEQBPjEVwBoL47K2mKKTwhV+3tq1ttBMaislMiiFma -meNP+BHrRVjNSWt2dJxhT4VARas0Rx8dBtVXkjmAL5spAEhD/nW4M4Y52z2NR39f -JAwyHyKxQF1N5KQtk85sR8qPu9B3MmHrqPKiOuaDdedrsCtWlTlXL5cbEhbCVfTs -ALwCz2S37Cb30tH6TuKv73vgjSMHwXbqYKIPJxm7+am9gZYXwoJJ0clmeOJ1xwrH -1nD0baCZdiTEzz5Ha84CgFv1ZM2EnDi6a7euNg3YYqKo4vA566jIwfOXkb4+J8an -hAqAqArnec8ELS2KJeHdhWAYgSVIh6TEvbaZR1M763BaFL1YS9WuUMzxnHDRHMZK -YIB5Lk1VtErvqFSfqPr62fXSLXCIgd1+iNpK6Wx+ZmMH6R7Eh4D8JvrLloeES2zo -xjDjO6nGE7+qHk7yCVzYCLv+Diov2UQ7D1h2z/x7HlcPeBpVZs4Dg1Vf2MfxiDQX -DBZ74DKLPK1Bd1HHpNLlXhD3K2BoNV4xGPKwRs0D/YfE3YN4d+RGsMeKsOltO5uR -JGKQIMaSjloExFMIwZOw9UcfapdclDZPGNi6vtznIs4pOkssRQZkvx/m3i+TPaB7 -nAuFie4WMla5q26o9I7LDNRw0GgKplDIOFSW7+z6UVoOnDQs502cYj1Ju0amJCdH -pMP2nHpsYWutkCmX5Rc/kl33bwEkwA6nrq5JdWg6NN5Jr5L+brsx2zWKC+tYtwtW -SC6xv7y8LIxfIEXdi0mRVH1NnKgfsN1d58hvPhHHk5kXmfnn2MGWt5xtPvjci6zQ -0sjr0jT8J3WCHJmwfcq6O9Ko7mol4q0wrnzSKRTRonui9A7yw4oc+DrhC+vsB5HD -YGtJzBhd5wvFg7xJOWeDift2Cf2dQWIHgugvb6S/7tCzDrMuR0UQFGLgyvWvJXEg -g0jq6ZAi3RLtsQtutKwhx4gx61l1MiGZq7yeDPq2ad6uRUElYuhBcAXbs4DTfYxL -aAKVJVUP2Vy20J2nqEnZtTs51ddYpqIiaSrWjkyTUaqAwxnxw+X0udfWo2V6nMNU -RnN1Bn2eO9Gpt64dxBjhwhnSb2lIgsIA0Ysqgi+zVa7lzbKl6BXZeI7ImF8h/AND -QWQlqWbglPB8VNq8X2jj0c3GHiTOfH4dPlvlebUm1H8Q/z77mTJMpS468ILrv+eu -dxAawZ27Y+Zmdaha7qGaFKSV0H+iGlsweAQA/V8qGtp5Smy8Aa+mYtdrrw+jeiYT -p3V6IbwNyHyve7QcFjZRJA== ------END ENCRYPTED PRIVATE KEY----- diff --git a/external/cpr/test/data/client.cer b/external/cpr/test/data/client.cer deleted file mode 100644 index 88c99cf..0000000 --- a/external/cpr/test/data/client.cer +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIE+DCCAuACAWUwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCWFgxFTATBgNV -BAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDAe -Fw0yMDA1MjQwOTEyNTRaFw0yMTA1MjQwOTEyNTRaMEIxCzAJBgNVBAYTAlhYMRUw -EwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBM -dGQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDVbkvqmEpUVRSTO6ao -jCz/ZaypjwSLJj2/Iow7/Rv6SHADnc/te4c3q+cHeU+ud2C2V1oWTmc+rQj5di9+ -WGJ6IFytOFgeX/B/W2TJMaeubLGqObICplUAhlljO9VW/AH9AjwRwGgscrTjkhP5 -LHVKEbZ4zWvEuTo5LQNaS2IonwSI+sYmKQbZgvYz0Tt5B9x+czM7HUxkv1gl1vkR -Fgix7xqoMxX49TkbqmtnJvxlLawS63pm1NUz6tmfNlhgUklTCqDjPV3ENO5myoX/ -14Tnk0vlOheWCE8/Atu5nF3+W6bKWKD5PbLvHvhEYzkuAzGrFsEcsrHRjJiahYni -MLyzdgZL6xe7VCSv3Tve7oY6bqRpbDIKsFZ43rmqJJj3jcxYkVqo7Gzcyy3Psd4c -qxgQdDZwoNO9a/J8BPjixc2DOSp52VaAgz+/d9IbpnUWMxRydZqOuhN+L5U8luQe -CujexMum4l6HHQF76nJNtigTJCtnE3YXtvYCg84dPPGkY/ltucReAjWHDRv+hBVz -Flg+ZORG1ajWLDBMJsWRI5eD+dLdX+cp3ilulhqfVmQyqYUdcyvCYF/ORjt9gJlO -uLeRN7Bpa6iUTYoUCb02nBSDNhYimIvSnSoK4aY7LS6TFCHKV/lb/2XvppzMCADX -UR9njZAW/yTF9yhhff5AFQ4aVwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQCTqOht -t/A3ea1sE5uEVp+mD+R9G1NHaWEsqDl/ZD8UsdpJGG/FvCwPEWDO5aH7UrN+u/KP -t7uaa6XaDKtD910vKtjBfyORAVeKpVzwtReJjctsssPMxwl8fhNRprTvFCeMLI0h -lJ7jfTYmI3/xbHDPeiq5O7qY5gmCkItQf6mg6gFa0He68ELqbi5Z6M/mVpE6he7A -scORH3szsPCV720iuoZawcCkXA/L6ipMAx6bj8YRGbPyHkomViWBXvPpbOzZSN9D -helOawk9j67T70SxxrUFllZE5Osuk5iMgvo2tQgW9unTACy7tp08ECzRKn0e0jOX -LeL2o6RnG/g4hqkQs90/5FT39XkC1WMRgPoCuMvNKP8dQNGSSQj1G8jlXfdT2HYy -m7PBubYz0kiszNpT56eZnDlgsr9kXgBDTwpS4yv+Fc1ocjJYFs9HIITXLAmkhUok -4TgV1GNen38JdjXWh92uvuXD/IleRR1lGLoSK0MRS7vsfu/rFtx/Jl46SAwM1yzz -TVQimJHf5PXtQFyvyULYE4KyxaFxohtJl6AzOIAsGLhqfdO3cAAOEDyMrVE/PgO4 -6caSY53tidJYijRT5t9hm5GiMZOyYmUTqTk5QpgyHxDUDrMH4tUEMeBbUuhdBEck -YFxK0i3939jK2uCBsJ3fv2UJQXb92rkuJfhUyw== ------END CERTIFICATE----- diff --git a/external/cpr/test/data/client.key b/external/cpr/test/data/client.key deleted file mode 100644 index 2fb7c9b..0000000 --- a/external/cpr/test/data/client.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJJwIBAAKCAgEA1W5L6phKVFUUkzumqIws/2WsqY8EiyY9vyKMO/0b+khwA53P -7XuHN6vnB3lPrndgtldaFk5nPq0I+XYvflhieiBcrThYHl/wf1tkyTGnrmyxqjmy -AqZVAIZZYzvVVvwB/QI8EcBoLHK045IT+Sx1ShG2eM1rxLk6OS0DWktiKJ8EiPrG -JikG2YL2M9E7eQfcfnMzOx1MZL9YJdb5ERYIse8aqDMV+PU5G6prZyb8ZS2sEut6 -ZtTVM+rZnzZYYFJJUwqg4z1dxDTuZsqF/9eE55NL5ToXlghPPwLbuZxd/lumylig -+T2y7x74RGM5LgMxqxbBHLKx0YyYmoWJ4jC8s3YGS+sXu1Qkr9073u6GOm6kaWwy -CrBWeN65qiSY943MWJFaqOxs3Mstz7HeHKsYEHQ2cKDTvWvyfAT44sXNgzkqedlW -gIM/v3fSG6Z1FjMUcnWajroTfi+VPJbkHgro3sTLpuJehx0Be+pyTbYoEyQrZxN2 -F7b2AoPOHTzxpGP5bbnEXgI1hw0b/oQVcxZYPmTkRtWo1iwwTCbFkSOXg/nS3V/n -Kd4pbpYan1ZkMqmFHXMrwmBfzkY7fYCZTri3kTewaWuolE2KFAm9NpwUgzYWIpiL -0p0qCuGmOy0ukxQhylf5W/9l76aczAgA11EfZ42QFv8kxfcoYX3+QBUOGlcCAwEA -AQKCAgBqSy8V29iQ3XqMxRWANaenXny6SVbq8hWoXk1XBvxrDq5yrqLCVFYIXN2H -dFxBuIR661AbcdqrdUPV8Y0/sEcDKaDeSARixEcjNmIgbVFkZg+phmhoN2x4AXD9 -IexjEMjwt68w7BE1qb7642J9Iy4awG2PBkdYxyL/HLLhwk9VibSZf8M1eBNIOpfh -QKAM6+RdOYRXOYU1W7JLzh9m6gFUlI9DG4Yi4gYaCCrLSbhDr5ZWKd5g3jh8Tccq -Ksei2PhZmh58bbCIKhBdMxm/TBeNuWb/94mNl//XktXZP830ArMzbSZmWtsFiff9 -Hyl4B/ExkviEEV7LzOindEAyXTFsihgRyYW5erV70kea9xElafo3cOFYOiHwWicz -wa4jB3i9Ekay3mHa9stGYwIVjxV5z01KiJDLqjTT5+4aCaFKbfulacxX2jCPj2SY -BRZPoy6DHCbtJpGYQv1di5BYvGtY7Nc8OFPfKnsa3+vYQzkfTWGS47Az/RKc0BCR -fb1NEf7vlDJxQgNpm5l6mditJ6CLBTTpffk9E9bSAEpzyj92HXTI+H4p1VYYpxoS -ByvtbaggDQA5+IkhgpmsB+bV1KD+gHT0Qyo9nkc/LqOIRLWzKCFLOLjGVwQvjrz1 -SP2pkmWsmgh2oB+LL6wooXcDpHGjcxpFjWQW7Kb/KZ8vKoF3SQKCAQEA9Hrg+mbi -ih8A6v43Swi1JLc9dGTV4mNN52d245jKkiZy7CVPzRtuwINLtlShJDeaB9BQo0tU -FWBYjqUfNTu6WPQGx/FXMc9QYXMUE/9MzU4wtdJ29lBqfwK2q+pJom06vFLmpXRT -YHilfPrG0iJPQBukt/x2VXm25LNyjvQUmXVnzaOFLPg8ho+ZxdAbeK6BMCk3s2yK -pmhwAkP0thPYsS+lIiOvh76xLG0GEWGTGRJ0wS52AOQRSP3MlCNjiCOrEIz0AzFp -kf0fyd4ShYeFclO/YJINW/2W4PMzI8x+BkBO0TM/PR4YRFGuykMcKyc2uOKNzhLj -k0hYBcm5Wxn53QKCAQEA33zghgJO4iwYmTEOc8MyjErLfF89xAbV0VLMCTYp+WYY -QjADdNInE9lKw03eUBkvzav0si/Rl6K59HrjDthj6eoTTf64xvQKOM9uBlnr3Yal -Dolj95HMXYWRyxXoGs0vhq2fZrIgPCzvGEY61z4doX7r2MO2sGiiCNZ21R9qSiCe -l7m+A0xeeqI2VNiJ9cspmHe13H6MMMxrDlBWm7/DHtNH0umGBzMLTcgJp8pDkI+q -g5H2QSr7gsnq+9OsNi3lFypzA9C5bFFfR/ffMqNck6cA6uATPC5eyXhW1udQM17F -zDX2KjY/CFG/UdayF+16Py9uyyPf498w/Mt1QvjzwwKCAQB8AKuGNpMnDYywpJq1 -E0iVw9+G3vJhbo8AFUmHLWNp99iIkHBGj2iAetf3Nju5m/4jgnS0LqwKX6DrUTNg -E9hz7+pUlcPtPsL9epovfmmdJNCuGH9Adg9eNqkiz6XjndWR2dalCziTEP6XQrd/ -s+lQkfTdYU9AEYlDvQUZHxInuBYbhpow8gP5GHMdk22rq49ZNz7KYf59YzGU5JUF -mVFqpcjzZPhOONmyt+XBASXULLlNltxBnWxrAlg2tzBvx++naGcIC5MJekMaZ+or -Ek8MaxAB0nK2OwzBMnm46aruTsXrdDvaKx6R4IBwlNN/y9cEtdzJLmmBtcr3vJao -b6d9AoIBAB90bAVwfbnHiw7EoMwaRRsJy+oNXZwheiakCKOjQ/UeMXvfVh0zFtzs -UGF8rDWJ1fiUozQRFubIuHN4eEy2mBlsIJtxpoAaCPZF+65ZKaFcOg75t2A43RKs -ogB7bNeY2X+TIERL/c16ZYx9FfsFexYnzvoLUcMydtvXk5IbgdI9FRU1x1Cfhwyr -mAoJECHQHmKfNrF5/jFAFDFHjWkObGACTLGavIp23Lht1y4OgcPu9IjgGlDBw/R8 -ht46xJo7i2rfRqDa174vFcIDWR6/b2A4uSBVuV9XB3BDx7UniVoxlJVRYvw99lEt -cEgMd7R2cCZEfsuImRJxb2ulFzP95hECggEAZiqYncDvxt3qJ9Tifx+SupeddnaZ -dbbUkPboBfASBT+ElFjYFsD2Us5iik+EkCVV07gPo+hz3+yPE/72Tnh3OWclKEz7 -4B5uDasIZ6ZDTKjU0l2aF2hCu8kcfLkHJeTuWZKxwjPwkAgrEqo5RNYqVAfPHoYx -0uy+SE54PeIs5BU4hDlOGFzDFtx/75/lHAfwt2ZrT/UMkH7GdBRDxtHWPXd7nsZD -FpaaSbmt/JGalPNMeRZ6O0uIsIIfSGykK7F8Y9B7ZgeBXJxAxYK2v5vub5lFVdz1 -IsB69E+k5oUpgzy/3uwdkO2kLYHdK+ZU8fSbtc0/mO5WI+woGUGFYtcNWQ== ------END RSA PRIVATE KEY----- diff --git a/external/cpr/test/data/generate.sh b/external/cpr/test/data/generate.sh deleted file mode 100755 index 154b062..0000000 --- a/external/cpr/test/data/generate.sh +++ /dev/null @@ -1,31 +0,0 @@ -#--------------------- -# Source: -# https://www.makethenmakeinstall.com/2014/05/ssl-client-authentication-step-by-step/ -#--------------------- - -# Generate a certificate authority (CA) cert -openssl req -newkey rsa:4096 -keyform PEM -keyout ca.key -x509 -days 3650 -outform PEM -out ca.cer - -# Generate a server private key -openssl genrsa -out server.key 4096 - -# Use the server private key to generate a certificate generation request -openssl req -new -key server.key -out server.req -sha256 - -# Use the certificate generation request and the CA cert to generate the server cert -openssl x509 -req -in server.req -CA ca.cer -CAkey ca.key -set_serial 100 -extensions server -days 1460 -outform PEM -out server.cer -sha256 - -# Clean up – now that the cert has been created, we no longer need the request -rm server.req - -# Generate a private key for the SSL client -openssl genrsa -out client.key 4096 - -# Use the client’s private key to generate a cert request -openssl req -new -key client.key -out client.req - -# Issue the client certificate using the cert request and the CA cert/key -openssl x509 -req -in client.req -CA ca.cer -CAkey ca.key -set_serial 101 -extensions client -days 365 -outform PEM -out client.cer - -# Clean up -rm client.req diff --git a/external/cpr/test/data/server.cer b/external/cpr/test/data/server.cer deleted file mode 100644 index e6028bf..0000000 --- a/external/cpr/test/data/server.cer +++ /dev/null @@ -1,29 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIE+DCCAuACAWQwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCWFgxFTATBgNV -BAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDAe -Fw0yMDA1MjQwOTEyNDVaFw0yNDA1MjMwOTEyNDVaMEIxCzAJBgNVBAYTAlhYMRUw -EwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBM -dGQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCXMCvv5pUuP+FbuZRZ -C77nZ8y3qdcLqX5Nbyc0RNap2Navb/+T+6QTK//LCuntG/scRfa0/HNr/DF2oDaE -KqOiNxD669edLysGQcCuo2vYikVTjqLolQU2PLA5Zix9KJvQi5frdHUrx0Ulj3St -s3eg3mIX3L9uNdOOQHVRSaYi6mokv0iBYJViPejE3ydJptUQxotpZeV1nd1wqFU6 -2WNJChsa/cWJH8AJz5deoSvhd4YRG4YCLe1g68EnG+Y0XCVQEgwN3Xp+l00xyIzH -QM1p4Foxbxkr16qjVt/3JXz3Lt1gDxXQaqQRDrt9s6OzkPoPaz2qphLxGM5aE9Co -9zmZan/0nEFh2o/nU/NsoWvJ9NCCPq+zLFrFBDIldhnkIFF5FjZI5+3n7NzzhfUU -kFURD0st96jkqU3Zf1CfUxyhHHXSa761t7FnSG+PQbLGZgn/LN3W+dr+YTKewJK/ -VcFAo00husTNNZDhkAFtUWKUfSzB0beya6rbwc31Xyh4FxYaBGY/bji/jnd7Se2c -NvD2KJXVOKjFSURU5Jt1UI5jVy/liSebsLLbl1Qt1LCKKcBeXaGbYzLm0qkTqjce -ZY7WE051gL3RfW66nFHTP0mV6Qeyg3dduPrMn3DYxPZKzkJ9CQk22P+Z7G0UOs9g -QQe4T4Kx5NYwzC3LzbnGwjVDhwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQClP7Pj -l7G8iOZvS1dosnWtpJWjUgF2aRw7Ulx8uu+yiKOfBIf3GY0XrBzk/4RDdhoXf118 -W+jjS2/CbOj10qrgUsZjL1lfnd6mF5dzNKYdptfuv/GFBzqDurVzB+JUEEOJybHJ -nem4BDdd0voO9SGu71NtlujuNYD1x9wNBv1dFlTuVeBrr6Fx8pcw5SFaaVNLfCbL -cSdq2c5JHEeo2vexYw8MF4yUC3vBC/znChGwkIwWf9e1IOmZE6vJrK6zumC1DzbZ -PQvLzGg8y2J9oyffr6kf9dmY/oq0PVP0cLTdaFjjwBp1CmuzR3fmjD6verrAzasO -T2Zho18bJS3qkfUsc257el1V0nF1t8Z+ZfwDyBfgfce72rx/4lWKJW0iwUBftvx5 -AH83NDIm6pdmxSgMQcxebakRVXX1A5BQhKtbIqprwgWNDC+loyA7hat9lk0fJ8s5 -U+00ODok65Og8F6lyxLU+RQ9l1rejQrdnCwKSqZdriIwpaGieIOv4WWm/WncNUXO -lOSXNPdr+/GDIBKq5U6HaNkipvIQ2gSXHhNNt5paUyO3LjovfAYiZODwgFT9SwU4 -9Qt5SG1/cLgXXMcQjgFc1MSLfq9uoeb6uFVB9sc8j2x6lAFs0Bavur6OrzpFYLbY -FffIvQhSoyeoWWNWFLmzV4xhEqmxjmA2pcNU0g== ------END CERTIFICATE----- diff --git a/external/cpr/test/data/server.key b/external/cpr/test/data/server.key deleted file mode 100644 index 7bec0cf..0000000 --- a/external/cpr/test/data/server.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKQIBAAKCAgEAlzAr7+aVLj/hW7mUWQu+52fMt6nXC6l+TW8nNETWqdjWr2// -k/ukEyv/ywrp7Rv7HEX2tPxza/wxdqA2hCqjojcQ+uvXnS8rBkHArqNr2IpFU46i -6JUFNjywOWYsfSib0IuX63R1K8dFJY90rbN3oN5iF9y/bjXTjkB1UUmmIupqJL9I -gWCVYj3oxN8nSabVEMaLaWXldZ3dcKhVOtljSQobGv3FiR/ACc+XXqEr4XeGERuG -Ai3tYOvBJxvmNFwlUBIMDd16fpdNMciMx0DNaeBaMW8ZK9eqo1bf9yV89y7dYA8V -0GqkEQ67fbOjs5D6D2s9qqYS8RjOWhPQqPc5mWp/9JxBYdqP51PzbKFryfTQgj6v -syxaxQQyJXYZ5CBReRY2SOft5+zc84X1FJBVEQ9LLfeo5KlN2X9Qn1McoRx10mu+ -tbexZ0hvj0GyxmYJ/yzd1vna/mEynsCSv1XBQKNNIbrEzTWQ4ZABbVFilH0swdG3 -smuq28HN9V8oeBcWGgRmP244v453e0ntnDbw9iiV1TioxUlEVOSbdVCOY1cv5Ykn -m7Cy25dULdSwiinAXl2hm2My5tKpE6o3HmWO1hNOdYC90X1uupxR0z9JlekHsoN3 -Xbj6zJ9w2MT2Ss5CfQkJNtj/mextFDrPYEEHuE+CseTWMMwty825xsI1Q4cCAwEA -AQKCAgEAh/U63b7W0sOBblIB1N3aLBDNKTDjgMpIGWxmrftlq1GjJhsqk7JMxyzf -F4FWAfMSq0dDZ1hKl4YwGQRUYiBSDJNGgs9Jk0GSiEri8mlll1Ioq85uM4enKzIC -K2v1gAvfqveNg6Czqc3GIdPS0k28u36gaeMKhxqCh77xgUsgyu9QyoD1u9rWG4We -6EPg+bu8iRxyzDJk2ZNASoomMwjA3zLmUyx40ioqMOhssB1x74zjlEjTBuy0Nl9r -0DanmthueYXxLxrHiEWZlrZJ2vksgBTQJvpIgYOtILwEJiWhLkwHqdWHAWiU5/3+ -nzjHcrhiFzGSP/6etA9hqeF92CSSt0ET+29BgSXxV84Ee/8nQZDlCkZbso2fdif1 -xHM5hu2Qtf+4axyk0T5OF5DzI9cyq8VofIYKJKHgfkeYEUmr3bUGn5xM5+yj4E5/ -9hyXt4ghMSHUkvMXgc0IK9GnRZ9ZSKchbQ7gGXoae8u9PL45mm1qJeE+ZeO73AEz -tbWdnzVX2e3Axa4adtH3RmQx3uwF6uUWdNjlGG1gpTHeP666bQ9oVn7pxjX4IJAN -aw9UquIVxcyuThmOp/NJqMW0YSFVLWsO4etFcYboVDloK4cGSXvHdhisUmVFqOs8 -Tnf6BdRL1tO8ONIjJWqZreirtz8maqIFE7RRVusjgUo3+kxiOfkCggEBAMZ7LhBA -D0+hz9HzWVdKl5saxx82GK8AcpU/cZf8u7rIC+dmF+dtBAoyo4VYK97qMREtwT9p -NztiTZIap7kDNeZdywrqh4OXKTcwwuR3rhFWlXyWptC7zawJ9vtxOYy4iLagLqGk -/0voiUqelmAJad9ENNUahpSC/fB/ay0OuQ1RJsITHL8P1+2CQkpvUHNOnl7FfBh4 -YwruEGUhS5vewCWvARE93CsFo5c9KD7e9SlV41LkZxzylaN1QtWOB9QJp2z2r/gz -flUiaw8Y3A/1iFyQsJjWYdV5qu/z/26I7p9e7ui5VhuBYLxMzoU/gNQw8XKHH2xN -iLsG11xigDLWVOsCggEBAMMAcU7fCQozSOmKnHD4dkgvOtG/a9ctc6uKJFhfqz5a -buNZ+xdX48xKAMa2NlqTG2pAfx86WECYv9R1YMdcVlXrUerqPLaz/8I7IkOe59Zz -TVHAEUYHEvn/vNnilIeZlUf6FvsPcbYE4E7nNIb6AlC1XMuZACrp0juFmPRUq5QG -4hOsiXwAqhoLXH0pafMSuaqcbWe/nSFCbVX5k4dfFUzw+9vHjJIlaJSNJDSejgtC -bV/eKC+x8qoKodjP/vqK5Bna+sY2KkoqxZ3OKUj5iQdZrukuOKWQ/oOzlyZ+9ASp -A4BEAh/2S7g4Yv5PCJ89vhCwFlvlKQ62pjH+nNsq1NUCggEALTsvESb4FkaizI6v -YnQuPnuIuzUhxOfONPLjWSaQRY2HIPGkKuouDIDjwOSKAt/N1MNfkarRmmfZk50d -cc0ogFoJhnBR94wAKYKkN1qKwYrAwEa4t0LFKRqQPVbdLZN0HGI+njmysELK3sVr -MXGTvfyWKaZE2x1K736qFveO9ljzAzFF0Mi0hXy0zK+3Xr+g2aoZkJ4GvBvqgpFm -4JuPoEbUcHBvdyJu2G1oeYNnzUa0alSApxklPr3fQDmA0TJuBCfnjCF3/cC9MxCQ -PdbPf4C9rebVHsf+S3aIVFFCR/Fjcoeh9tyyBddfDQCexDxvGZFveMfmi/CQLY6I -9ozfhwKCAQEAjRDa50Wt0nU7P8eIWKlFV/7ivC2QI/+7d9LdbBj5VogxQ8MqQ77P -ClBWs2nJdEiLQpgZ3ktk4IYf7+Bh/Jat1kX/4sNE3J7mXGpO5UAlUxviSUt6s4AW -mEgLJEwnStkuBv3Cdii8CAMLCcl0VFi0KBKraJXsax7veSOyfL5ryRAZqEXex5fr -dh/V7q1w+ekH64ZyFuWlFBRr6BA+S2XbkOecK2f2Jxtsxlo8YNx6wWZynTGnPKms -dJpwbto5CKJFVPb3B0DT4weCIiCr+SCboneccw9+5zc3B6t5ot2gRWbHI5kPOHQC -XuhbpMEj6Z7Oyl+4LQ5gX0Z+gBhC/MHFaQKCAQBfaikrx6op2+704h5Xw3TqwD83 -ihny5gsYlODFvbxxzNMdT5/0fgDHxRkKWtZF714xH0psgY/3ok2OHHq4D0kLbCfs -Wy8271GX7T7pg1J/9CWiwKv9z1NT1epc9/T2Y1/fajL6EnE9JwnFaEf0I55OHCKX -YNHWhUW0NxJD0EFnWaggOD2kULe1IFW4F9fLYcyRMHuXyiVWgt1Dh60RlNF1WOLL -naKAu+0MNJ87hlw+zb2WK38QGLZwLYvR6pojKhcmygdPAGZOESnorU0Sdyu2+e8/ -iaNViIWN9+kosQB6BPZDZCviBevV5vksRePYqAKRtaq876wUslbaDCN6WHtd ------END RSA PRIVATE KEY----- diff --git a/external/cpr/test/delete_tests.cpp b/external/cpr/test/delete_tests.cpp deleted file mode 100644 index 6aa1830..0000000 --- a/external/cpr/test/delete_tests.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(DeleteTests, DeleteTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - Response response = cpr::Delete(url); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, DeleteUnallowedTest) { - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - Response response = cpr::Delete(url); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, DeleteJsonBodyTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - Response response = cpr::Delete(url, cpr::Body{"'foo': 'bar'"}, - cpr::Header{{"Content-Type", "application/json"}}); - std::string expected_text{"'foo': 'bar'"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - Session session; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteUnallowedTest) { - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - Session session; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteJsonBodyTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - Session session; - session.SetUrl(url); - session.SetHeader(cpr::Header{{"Content-Type", "application/json"}}); - session.SetBody(cpr::Body{"{'foo': 'bar'}"}); - Response response = session.Delete(); - std::string expected_text{"{'foo': 'bar'}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/delete.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteUnallowedAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/delete.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteUnallowedAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, SessionDeleteUnallowedAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, AsyncDeleteTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - cpr::AsyncResponse future_response = cpr::DeleteAsync(url); - cpr::Response response = future_response.get(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, AsyncDeleteUnallowedTest) { - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - cpr::AsyncResponse future_response = cpr::DeleteAsync(url); - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DeleteTests, AsyncMultipleDeleteTest) { - Url url{server->GetBaseUrl() + "/delete.html"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::DeleteAsync(url)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{"Delete success"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(DeleteTests, AsyncMultipleDeleteUnallowedTest) { - Url url{server->GetBaseUrl() + "/delete_unallowed.html"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::DeleteAsync(url)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/error_tests.cpp b/external/cpr/test/error_tests.cpp deleted file mode 100644 index 0205032..0000000 --- a/external/cpr/test/error_tests.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include - -#include -#include - -#include -#include - -#include "httpServer.hpp" -#include "httpsServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(ErrorTests, UnsupportedProtocolFailure) { - Url url{"urk://wat.is.this"}; - Response response = cpr::Get(url); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::UNSUPPORTED_PROTOCOL, response.error.code); -} - -TEST(ErrorTests, InvalidURLFailure) { - Url url{"???"}; - Response response = cpr::Get(url); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::INVALID_URL_FORMAT, response.error.code); -} - -TEST(ErrorTests, TimeoutFailure) { - Url url{server->GetBaseUrl() + "/timeout.html"}; - Response response = cpr::Get(url, cpr::Timeout{1}); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::OPERATION_TIMEDOUT, response.error.code); -} - -TEST(ErrorTests, ChronoTimeoutFailure) { - Url url{server->GetBaseUrl() + "/timeout.html"}; - Response response = cpr::Get(url, cpr::Timeout{std::chrono::milliseconds{1}}); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::OPERATION_TIMEDOUT, response.error.code); -} - -TEST(ErrorTests, ConnectTimeoutFailure) { - Url url{"http://localhost:67"}; - Response response = cpr::Get(url, cpr::ConnectTimeout{1}); - EXPECT_EQ(0, response.status_code); - // Sometimes a CONNECTION_FAILURE happens before the OPERATION_TIMEDOUT: - EXPECT_TRUE(response.error.code == ErrorCode::OPERATION_TIMEDOUT || - response.error.code == ErrorCode::CONNECTION_FAILURE); -} - -TEST(ErrorTests, ChronoConnectTimeoutFailure) { - Url url{"http://localhost:67"}; - Response response = cpr::Get(url, cpr::ConnectTimeout{std::chrono::milliseconds{1}}); - EXPECT_EQ(0, response.status_code); - // Sometimes a CONNECTION_FAILURE happens before the OPERATION_TIMEDOUT: - EXPECT_TRUE(response.error.code == ErrorCode::OPERATION_TIMEDOUT || - response.error.code == ErrorCode::CONNECTION_FAILURE); -} - -TEST(ErrorTests, LowSpeedTimeFailure) { - Url url{server->GetBaseUrl() + "/low_speed.html"}; - Response response = cpr::Get(url, cpr::LowSpeed{1000, 1}); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::OPERATION_TIMEDOUT, response.error.code); -} - -TEST(ErrorTests, LowSpeedBytesFailure) { - Url url{server->GetBaseUrl() + "/low_speed_bytes.html"}; - Response response = cpr::Get(url, cpr::LowSpeed{1000, 1}); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::OPERATION_TIMEDOUT, response.error.code); -} - -TEST(ErrorTests, ProxyFailure) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url, cpr::Proxies{{"http", "http://bad_host/"}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::PROXY_RESOLUTION_FAILURE, response.error.code); -} - -TEST(ErrorTests, BoolFalseTest) { - Error error; - EXPECT_FALSE(error); -} - -TEST(ErrorTests, BoolTrueTest) { - Error error; - error.code = ErrorCode::UNSUPPORTED_PROTOCOL; - EXPECT_TRUE(error); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/get_tests.cpp b/external/cpr/test/get_tests.cpp deleted file mode 100644 index abefd6a..0000000 --- a/external/cpr/test/get_tests.cpp +++ /dev/null @@ -1,1308 +0,0 @@ -#include - -#include -#include - -#include "cpr/cpr.h" -#include "cpr/cprtypes.h" -#include "cpr/session.h" -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(BasicTests, HelloWorldTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicTests, TimeoutTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url, Timeout{0L}); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicTests, BasicJsonTest) { - Url url{server->GetBaseUrl() + "/basic.json"}; - Response response = cpr::Get(url); - std::string expected_text{ - "[\n" - " {\n" - " \"first_key\": \"first_value\",\n" - " \"second_key\": \"second_value\"\n" - " }\n" - "]"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicTests, ResourceNotFoundTest) { - Url url{server->GetBaseUrl() + "/error.html"}; - Response response = cpr::Get(url); - std::string expected_text{"Not Found"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(404, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicTests, BadHostTest) { - Url url{"http://bad_host/"}; - Response response = cpr::Get(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::HOST_RESOLUTION_FAILURE, response.error.code); -} - -TEST(CookiesTests, SingleCookieTest) { - Url url{server->GetBaseUrl() + "/basic_cookies.html"}; - Cookies cookies{{"hello", "world"}, {"my", "another; fake=cookie;"}}; - Response response = cpr::Get(url, cookies); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - cookies = response.cookies; - EXPECT_EQ(cookies["cookie"], response.cookies["cookie"]); - EXPECT_EQ(cookies["icecream"], response.cookies["icecream"]); - EXPECT_EQ(cookies["expires"], response.cookies["expires"]); -} - -TEST(CookiesTests, EmptyCookieTest) { - Url url{server->GetBaseUrl() + "/empty_cookies.html"}; - Response response = cpr::Get(url); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - EXPECT_EQ("", response.cookies["cookie"]); - EXPECT_EQ("", response.cookies["icecream"]); -} - -TEST(CookiesTests, CheckBasicCookieTest) { - // server validates whether the cookies are indeed present - Url url{server->GetBaseUrl() + "/check_cookies.html"}; - Cookies cookies{{"cookie", "chocolate"}, {"icecream", "vanilla"}}; - Response response = cpr::Get(url, cookies); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(CookiesTests, V1CookieTest) { - Url url{server->GetBaseUrl() + "/v1_cookies.html"}; - Response response = cpr::Get(url); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - Cookies cookies = response.cookies; - EXPECT_EQ("\"value with spaces (v1 cookie)\"", cookies["cookie"]); -} - -TEST(CookiesTests, CheckV1CookieTest) { - // server validates whether the cookie is indeed present - Url url{server->GetBaseUrl() + "/check_v1_cookies.html"}; - Cookies cookies{{"cookie", "\"value with spaces (v1 cookie)\""}}; - Response response = cpr::Get(url, cookies); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterTests, SingleParameterTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Parameters parameters{{"key", "value"}}; - Response response = cpr::Get(url, parameters); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterTests, SingleParameterOnlyKeyTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Parameters parameters{{"key", ""}}; - Response response = cpr::Get(url, parameters); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); -} - -TEST(ParameterTests, MultipleParametersTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = - cpr::Get(url, Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}}); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterTests, MultipleDynamicParametersTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Parameters parameters{{"key", "value"}}; - parameters.Add({"hello", "world"}); - parameters.Add({"test", "case"}); - Response response = cpr::Get(url, parameters); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationTests, BasicAuthenticationSuccessTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationTests, BasicBearerSuccessTest) { - Url url{server->GetBaseUrl() + "/bearer_token.html"}; -#if CPR_LIBCURL_VERSION_NUM >= 0x073D00 - Response response = cpr::Get(url, Bearer{"the_token"}); -#else - Response response = cpr::Get(url, Header{{"Authorization", "Bearer the_token"}}); -#endif - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationTests, BasicDigestSuccessTest) { - Url url{server->GetBaseUrl() + "/digest_auth.html"}; - Response response = cpr::Get(url, Digest{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAthenticationParameterTests, BasicAuthenticationSuccessSingleParameterTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "password"}, Parameters{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessMultipleParametersTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "password"}, - Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessSingleParameterReverseTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{{"hello", "world"}}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessMultipleParametersReverseTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}}, - Authentication{"user", "password"}); - - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessSingleHeaderTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "password"}, Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessMultipleHeadersTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, - Header{{"key", "value"}, {"hello", "world"}, {"test", "case"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(std::string{"case"}, response.header["test"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessSingleHeaderReverseTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{{"hello", "world"}}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessMultipleHeadersReverseTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{{"key", "value"}, {"hello", "world"}, {"test", "case"}}, - Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(std::string{"case"}, response.header["test"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationTests, BasicAuthenticationNullFailureTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationTests, BasicAuthenticationFailureTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterTests, BasicAuthenticationFailureSingleParameterTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "bad_password"}, Parameters{{"hello", "world"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterTests, BasicAuthenticationFailureMultipleParametersTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "bad_password"}, - Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderJsonTest) { - Url url{server->GetBaseUrl() + "/basic.json"}; - Response response = cpr::Get(url, Header{{"content-type", "application/json"}}); - std::string expected_text{ - "[\n" - " {\n" - " \"first_key\": \"first_value\",\n" - " \"second_key\": \"second_value\"\n" - " }\n" - "]"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectNoneTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectUpdateHeaderAddSessionTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetHeader(Header{{"Header1", "Value1"}}); - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"Value1"}, response.header["Header1"]); - EXPECT_EQ(std::string{}, response.header["Header2"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - - session.UpdateHeader(Header{{"Header2", "Value2"}}); - response = session.Get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"Value1"}, response.header["Header1"]); - EXPECT_EQ(std::string{"Value2"}, response.header["Header2"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -/** - * Test case for #532 - * https://github.com/whoshuu/cpr/issues/532 - **/ -TEST(HeaderTests, SessionHeaderReflectTest) { - std::unique_ptr session(new cpr::Session()); - session->SetUrl({server->GetBaseUrl() + "/header_reflect.html"}); - session->SetBody("Some Body to post"); - session->SetHeader({{"Content-Type", "application/json"}}); - cpr::Response response = session->Post(); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - EXPECT_EQ(std::string{"Header reflect POST"}, response.text); - EXPECT_EQ(std::string{"application/json"}, response.header["Content-Type"]); -} - -TEST(HeaderTests, HeaderReflectUpdateHeaderUpdateSessionTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetHeader(Header{{"Header1", "Value1"}}); - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"Value1"}, response.header["Header1"]); - EXPECT_EQ(std::string{}, response.header["Header2"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - - session.UpdateHeader(Header{{"Header1", "Value2"}}); - response = session.Get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"Value2"}, response.header["Header1"]); - EXPECT_EQ(std::string{}, response.header["Header2"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectEmptyTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectSingleTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectMultipleTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(std::string{"case"}, response.header["test"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, HeaderReflectCaseInsensitiveTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{{"HeLlO", "wOrLd"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeaderTests, SetEmptyHeaderTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{{"hello", ""}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectNoneParametersTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectEmptyParametersTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Header{}, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectSingleParametersTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, - Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectMultipleParametersTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}}, - Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(std::string{"case"}, response.header["test"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectCaseInsensitiveParametersTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Get(url, Header{{"HeLlO", "wOrLd"}}, - Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectEmptyParametersReverseTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectSingleParametersReverseTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}, - Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectMultipleParametersReverseTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}, - Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(std::string{"case"}, response.header["test"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterHeaderTests, HeaderReflectCaseInsensitiveParametersReverseTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}}, - Header{{"HeLlO", "wOrLd"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]); - EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, Parameters{}, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderABTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "bad_password"}, Parameters{}, Header{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderACTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "password"}, Parameters{{"one", "two"}}, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderADTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, - Parameters{{"one", "two"}}, Header{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, Parameters{}, - Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, Parameters{}, - Header{{"hello", "world"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, - Parameters{{"one", "two"}}, Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, - Parameters{{"one", "two"}}, Header{{"hello", "world"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Header{}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBBTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{}, Header{}, Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBCTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}}, Header{}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBDTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{{"one", "two"}}, Header{}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Header{{"hello", "world"}}, - Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Header{{"hello", "world"}}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{{"one", "two"}}, Header{{"hello", "world"}}, - Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{{"one", "two"}}, Header{{"hello", "world"}}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{}, Authentication{"user", "password"}, Parameters{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCBTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{}, Authentication{"user", "bad_password"}, Parameters{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCCTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{}, Authentication{"user", "password"}, Parameters{{"one", "two"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCDTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{}, Authentication{"user", "bad_password"}, - Parameters{{"one", "two"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, - Authentication{"user", "password"}, Parameters{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, - Authentication{"user", "bad_password"}, Parameters{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, - Authentication{"user", "password"}, Parameters{{"one", "two"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{{"hello", "world"}}, Authentication{"user", "bad_password"}, - Parameters{{"one", "two"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, Header{}, Parameters{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDBTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "bad_password"}, Header{}, Parameters{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDCTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Authentication{"user", "password"}, Header{}, Parameters{{"one", "two"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDDTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, Header{}, - Parameters{{"one", "two"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, - Header{{"hello", "world"}}, Parameters{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, - Header{{"hello", "world"}}, Parameters{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "password"}, - Header{{"hello", "world"}}, Parameters{{"one", "two"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Authentication{"user", "bad_password"}, - Header{{"hello", "world"}}, Parameters{{"one", "two"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{}, Parameters{}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEBTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{}, Parameters{}, Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderECTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Header{}, Parameters{{"one", "two"}}, Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEDTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{}, Parameters{{"one", "two"}}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{}, - Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{{"one", "two"}}, - Authentication{"user", "password"}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{{"one", "two"}}, - Authentication{"user", "bad_password"}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFATest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Authentication{"user", "password"}, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFBTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{}, Authentication{"user", "bad_password"}, Header{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFCTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "password"}, Header{}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFDTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{{"one", "two"}}, - Authentication{"user", "bad_password"}, Header{}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFETest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Authentication{"user", "password"}, - Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFFTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{}, Authentication{"user", "bad_password"}, - Header{{"hello", "world"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFGTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Get(url, Parameters{{"one", "two"}}, - Authentication{"user", "password"}, Header{{"hello", "world"}}); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFHTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = - cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "bad_password"}, - Header{{"hello", "world"}}); - EXPECT_EQ("Unauthorized", response.text); - EXPECT_EQ(Url{url + "?one=two"}, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(GetRedirectTests, RedirectTest) { - Url url{server->GetBaseUrl() + "/temporary_redirect.html"}; - Response response = cpr::Get(url, false); // This should be turned into an object - std::string expected_text{"Moved Temporarily"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(302, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(GetRedirectTests, ZeroMaxRedirectsTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url, MaxRedirects(0)); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BasicTests, RequestBodyTest) { - Url url{server->GetBaseUrl() + "/body_get.html"}; - Body body{"message=abc123"}; - Response response = cpr::Get(url, body); - std::string expected_text{"abc123"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(LimitRateTests, HelloWorldTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url, LimitRate(1024, 1024)); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/head_tests.cpp b/external/cpr/test/head_tests.cpp deleted file mode 100644 index 4ddb8f6..0000000 --- a/external/cpr/test/head_tests.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(HeadTests, BasicHeadTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, ComplexHeadTest) { - Url url{server->GetBaseUrl() + "/basic.json"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, ResourceNotFoundHeadTest) { - Url url{server->GetBaseUrl() + "/error.html"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(404, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, BadHostHeadTest) { - Url url{"http://bad_host/"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::HOST_RESOLUTION_FAILURE, response.error.code); -} - -TEST(HeadTests, CookieHeadTest) { - Url url{server->GetBaseUrl() + "/basic_cookies.html"}; - Cookies cookies{{"hello", "world"}, {"my", "another; fake=cookie;"}}; - Response response = cpr::Head(url, cookies); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - cookies = response.cookies; - EXPECT_EQ(cookies["cookie"], response.cookies["cookie"]); - EXPECT_EQ(cookies["icecream"], response.cookies["icecream"]); - EXPECT_EQ(cookies["expires"], response.cookies["expires"]); -} - -TEST(HeadTests, ParameterHeadTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Parameters parameters{{"key", "value"}}; - Response response = cpr::Head(url, parameters); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(Url{url + "?key=value"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, AuthenticationSuccessHeadTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Head(url, Authentication{"user", "password"}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, AuthenticationNullFailureHeadTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, AuthenticationFailureHeadTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Response response = cpr::Head(url, Authentication{"user", "bad_password"}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ("text/plain", response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, BearerSuccessHeadTest) { - Url url{server->GetBaseUrl() + "/bearer_token.html"}; -#if CPR_LIBCURL_VERSION_NUM >= 0x073D00 - Response response = cpr::Get(url, Bearer{"the_token"}); -#else - Response response = cpr::Get(url, Header{{"Authorization", "Bearer the_token"}}); -#endif - EXPECT_EQ(std::string{"Header reflect GET"}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, DigestSuccessHeadTest) { - Url url{server->GetBaseUrl() + "/digest_auth.html"}; - Response response = cpr::Head(url, Digest{"user", "password"}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, HeaderReflectNoneHeadTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Head(url); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, HeaderReflectEmptyHeadTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Head(url, Header{}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, HeaderReflectHeadTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Head(url, Header{{"hello", "world"}}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, SetEmptyHeaderHeadTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Head(url, Header{{"hello", ""}}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, RedirectHeadTest) { - Url url{server->GetBaseUrl() + "/temporary_redirect.html"}; - Response response = cpr::Head(url, false); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(302, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, ZeroMaxRedirectsHeadTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Head(url, 0L); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(HeadTests, BasicHeadAsyncTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::HeadAsync(url)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/httpServer.cpp b/external/cpr/test/httpServer.cpp deleted file mode 100644 index 15d7d35..0000000 --- a/external/cpr/test/httpServer.cpp +++ /dev/null @@ -1,646 +0,0 @@ -#include "httpServer.hpp" -#include -#include -#include - -namespace cpr { -std::string HttpServer::GetBaseUrl() { - return "http://127.0.0.1:" + std::to_string(GetPort()); -} - -uint16_t HttpServer::GetPort() { - // Unassigned port number in the ephemeral range - return 61936; -} - -mg_connection* HttpServer::initServer(mg_mgr* mgr, - MG_CB(mg_event_handler_t event_handler, void* user_data)) { - // Based on: https://cesanta.com/docs/http/server-example.html - mg_mgr_init(mgr, this); - std::string port = std::to_string(GetPort()); - mg_connection* c = mg_bind(mgr, port.c_str(), event_handler); - if (!c) { - throw std::system_error(errno, std::system_category(), "Failed to bind to port " + port); - } - mg_set_protocol_http_websocket(c); - return c; -} - -void HttpServer::OnRequestHello(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"OPTIONS"}) { - OnRequestOptions(conn, msg); - } else { - std::string response{"Hello world!"}; - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } -} - -void HttpServer::OnRequestRoot(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"OPTIONS"}) { - OnRequestOptions(conn, msg); - } else { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } -} - -void HttpServer::OnRequestNotFound(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"OPTIONS"}) { - OnRequestOptions(conn, msg); - } else { - mg_http_send_error(conn, 404, "Not Found"); - } -} - -void HttpServer::OnRequestOptions(mg_connection* conn, http_message* msg) { - std::string headers = - "Content-Type: text/plain\r\n" - "Access-Control-Allow-Origin: *\r\n" - "Access-Control-Allow-Credentials: true\r\n" - "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS\r\n" - "Access-Control-Max-Age: 3600"; - - mg_send_head(conn, 200, 0, headers.c_str()); - std::string response; - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestTimeout(mg_connection* conn, http_message* msg) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - OnRequestHello(conn, msg); -} - -void HttpServer::OnRequestLowSpeedTimeout(mg_connection* conn, http_message* /*msg*/) { - std::string response{"Hello world!"}; - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length() * 20, headers.c_str()); - for (size_t i = 0; i < 20; i++) - { - mg_send(conn, response.c_str(), response.length()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } -} - -void HttpServer::OnRequestLowSpeed(mg_connection* conn, http_message* /*msg*/) { - std::string response{"Hello world!"}; - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - std::this_thread::sleep_for(std::chrono::seconds(2)); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestLowSpeedBytes(mg_connection* conn, http_message* /*msg*/) { - std::string response{"a"}; - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - std::this_thread::sleep_for(std::chrono::seconds(2)); - for (size_t i = 0; i < 20; ++i) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - mg_send(conn, response.c_str(), response.length()); - } -} - -void HttpServer::OnRequestBasicCookies(mg_connection* conn, http_message* /*msg*/) { - time_t t = time(nullptr) + 5; // Valid for 1 hour - char expire[100], expire_epoch[100]; - snprintf(expire_epoch, sizeof(expire_epoch), "%lu", static_cast(t)); - strftime(expire, sizeof(expire), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t)); - std::string cookie{"cookie=chocolate; expires=\"" + std::string{expire} + "\"; http-only;"}; - std::string cookie2{"icecream=vanilla; expires=\"" + std::string{expire} + "\"; http-only;"}; - std::string headers = - "Content-Type: text/html\r\n" - "Set-Cookie: " + - cookie + - "\r\n" - "Set-Cookie: " + - cookie2; - std::string response{"Hello world!"}; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestEmptyCookies(mg_connection* conn, http_message* /*msg*/) { - time_t t = time(nullptr) + 5; // Valid for 1 hour - char expire[100]; - char expire_epoch[100]; - snprintf(expire_epoch, sizeof(expire_epoch), "%lu", static_cast(t)); - strftime(expire, sizeof(expire), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t)); - std::string cookie{"cookie=; expires=\"" + std::string{expire} + "\"; http-only;"}; - std::string cookie2{"icecream=; expires=\"" + std::string{expire} + "\"; http-only;"}; - std::string headers = - "Content-Type: text/html\r\n" - "Set-Cookie: " + - cookie + - "\r\n" - "Set-Cookie: " + - cookie2; - std::string response{"Hello world!"}; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestCheckCookies(mg_connection* conn, http_message* msg) { - mg_str* request_cookies; - if ((request_cookies = mg_get_http_header(msg, "Cookie")) == nullptr) { - mg_http_send_error(conn, 400, "Cookie not found"); - return; - } - std::string cookie_str{request_cookies->p, request_cookies->len}; - - if (cookie_str.find("cookie=chocolate;") == cookie_str.npos || - cookie_str.find("icecream=vanilla;") == cookie_str.npos) { - mg_http_send_error(conn, 400, "Cookies not found"); - } - - OnRequestHello(conn, msg); -} - -void HttpServer::OnRequestV1Cookies(mg_connection* conn, http_message* /*msg*/) { - time_t t = time(nullptr) + 5; // Valid for 1 hour - char expire[100], expire_epoch[100]; - snprintf(expire_epoch, sizeof(expire_epoch), "%lu", static_cast(t)); - strftime(expire, sizeof(expire), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t)); - std::string v1cookie{"cookie=\"value with spaces (v1 cookie)\"; expires=\"" + - std::string{expire} + "\"; http-only;"}; - - std::string headers = - "Content-Type: text/html\r\n" - "Set-Cookie: " + - v1cookie; - std::string response{"Hello world!"}; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestCheckV1Cookies(mg_connection* conn, http_message* msg) { - mg_str* request_cookies; - if ((request_cookies = mg_get_http_header(msg, "Cookie")) == nullptr) { - mg_http_send_error(conn, 400, "Cookie not found"); - return; - } - std::string cookie_str{request_cookies->p, request_cookies->len}; - - if (cookie_str.find("cookie=\"value with spaces (v1 cookie)\";") == std::string::npos) { - mg_http_send_error(conn, 400, "Cookie with space not found"); - return; - } - - OnRequestHello(conn, msg); -} - -void HttpServer::OnRequestBasicAuth(mg_connection* conn, http_message* msg) { - mg_str* requested_auth; - std::string auth{"Basic"}; - if ((requested_auth = mg_get_http_header(msg, "Authorization")) == nullptr || - mg_ncasecmp(requested_auth->p, auth.c_str(), auth.length()) != 0) { - mg_http_send_error(conn, 401, "Unauthorized"); - return; - } - std::string auth_string{requested_auth->p, requested_auth->len}; - size_t basic_token = auth_string.find(' ') + 1; - auth_string = auth_string.substr(basic_token, auth_string.length() - basic_token); - auth_string = Base64Decode(auth_string); - size_t colon = auth_string.find(':'); - std::string username = auth_string.substr(0, colon); - std::string password = auth_string.substr(colon + 1, auth_string.length() - colon - 1); - if (username == "user" && password == "password") { - OnRequestHeaderReflect(conn, msg); - } else { - mg_http_send_error(conn, 401, "Unauthorized"); - } -} - -void HttpServer::OnRequestBearerAuth(mg_connection* conn, http_message* msg) { - mg_str* requested_auth; - std::string auth{"Bearer"}; - if ((requested_auth = mg_get_http_header(msg, "Authorization")) == nullptr || - mg_ncasecmp(requested_auth->p, auth.c_str(), auth.length()) != 0) { - mg_http_send_error(conn, 401, "Unauthorized"); - return; - } - std::string auth_string{requested_auth->p, requested_auth->len}; - size_t basic_token = auth_string.find(' ') + 1; - auth_string = auth_string.substr(basic_token, auth_string.length() - basic_token); - if (auth_string == "the_token") { - OnRequestHeaderReflect(conn, msg); - } else { - mg_http_send_error(conn, 401, "Unauthorized"); - } -} - -void HttpServer::OnRequestBasicJson(mg_connection* conn, http_message* /*msg*/) { - std::string response = - "[\n" - " {\n" - " \"first_key\": \"first_value\",\n" - " \"second_key\": \"second_value\"\n" - " }\n" - "]"; - std::string headers = "Content-Type: application/json"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestHeaderReflect(mg_connection* conn, http_message* msg) { - std::string response = "Header reflect " + std::string{msg->method.p, msg->method.len}; - std::string headers; - bool hasContentTypeHeader = false; - for (size_t i = 0; i < sizeof(msg->header_names) / sizeof(mg_str); i++) { - if (!msg->header_names[i].p) { - continue; - } - - std::string name = std::string(msg->header_names[i].p, msg->header_names[i].len); - if (std::string{"Content-Type"} == name) { - hasContentTypeHeader = true; - } - - if (std::string{"Host"} != name && std::string{"Accept"} != name) { - if (!headers.empty()) { - headers.append("\r\n"); - } - if (msg->header_values[i].p) { - headers.append(name + ": " + - std::string(msg->header_values[i].p, msg->header_values[i].len)); - } - } - } - - if (!hasContentTypeHeader) { - if (!headers.empty()) { - headers.append("\r\n"); - } - headers.append("Content-Type: text/html"); - } - std::cout << "HEADERS: " << headers << '\n'; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestTempRedirect(mg_connection* conn, http_message* msg) { - std::string response = "Moved Temporarily"; - std::string headers = "Location: hello.html"; - mg_send_head(conn, 302, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestPermRedirect(mg_connection* conn, http_message* msg) { - std::string response = "Moved Permanently"; - std::string headers = "Location: hello.html"; - mg_send_head(conn, 301, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestTwoRedirects(mg_connection* conn, http_message* msg) { - std::string response = "Moved Permanently"; - std::string headers = "Location: permanent_redirect.html"; - mg_send_head(conn, 301, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestUrlPost(mg_connection* conn, http_message* msg) { - std::string headers = "Content-Type: application/json"; - - char x[100]; - char y[100]; - mg_get_http_var(&(msg->body), "x", x, sizeof(x)); - mg_get_http_var(&(msg->body), "y", y, sizeof(y)); - std::string x_string{x}; - std::string y_string{y}; - std::string response; - if (y_string.empty()) { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - "\n" - "}"}; - } else { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - ",\n" - " \"y\": " + - y_string + - ",\n" - " \"sum\": " + - std::to_string(atoi(x) + atoi(y)) + - "\n" - "}"}; - } - mg_send_head(conn, 201, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestBodyGet(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} != std::string{"GET"}) { - mg_http_send_error(conn, 405, "Method Not Allowed"); - return; - } - std::array message{}; - mg_get_http_var(&(msg->body), "message", message.data(), message.size()); - if (msg->body.len <= 0) { - mg_http_send_error(conn, 405, "No Content"); - return; - } - std::string response = message.data(); - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestJsonPost(mg_connection* conn, http_message* msg) { - mg_str* content_type{nullptr}; - if ((content_type = mg_get_http_header(msg, "Content-Type")) == nullptr || - std::string{content_type->p, content_type->len} != "application/json") { - mg_http_send_error(conn, 415, "Unsupported Media Type"); - return; - } - - std::string headers = "Content-Type: application/json"; - mg_send_head(conn, 201, msg->body.len, headers.c_str()); - mg_send(conn, msg->body.p, msg->body.len); -} - -void HttpServer::OnRequestFormPost(mg_connection* conn, http_message* msg) { - char var_name[100]; - char file_name[100]; - const char* chunk; - size_t chunk_len = 0; - size_t n1 = 0; - size_t n2 = 0; - std::map forms; - - while ((n2 = mg_parse_multipart(msg->body.p + n1, msg->body.len - n1, var_name, - sizeof(var_name), file_name, sizeof(file_name), &chunk, - &chunk_len)) > 0) { - n1 += n2; - forms[var_name] = std::string(chunk, chunk_len); - } - - std::string x = forms["x"]; - - std::string headers = "Content-Type: application/json"; - std::string response; - if (forms.find("y") == forms.end()) { - response = std::string{ - "{\n" - " \"x\": " + - forms["x"] + - "\n" - "}"}; - } else { - response = std::string{ - "{\n" - " \"x\": " + - forms["x"] + - ",\n" - " \"y\": " + - forms["y"] + - ",\n" - " \"sum\": " + - std::to_string(atoi(forms["x"].c_str()) + atoi(forms["y"].c_str())) + - "\n" - "}"}; - } - mg_send_head(conn, 201, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestDelete(mg_connection* conn, http_message* msg) { - bool has_json_header = false; - for (size_t i = 0; i < sizeof(msg->header_names) / sizeof(mg_str); i++) { - if (!msg->header_names[i].p) { - continue; - } - - std::string name = std::string(msg->header_names[i].p, msg->header_names[i].len); - std::string value = std::string(msg->header_values[i].p, msg->header_values[i].len); - if (std::string{"Content-Type"} == name && std::string{"application/json"} == value) { - has_json_header = true; - break; - } - } - if (std::string{msg->method.p, msg->method.len} == std::string{"DELETE"}) { - std::string headers; - std::string response = "Patch success"; - if (!has_json_header) { - headers = "Content-Type: text/html"; - response = "Delete success"; - } else { - headers = "Content-Type: application/json"; - response = std::string{msg->body.p, msg->body.len}; - } - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } else { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } -} - -void HttpServer::OnRequestDeleteNotAllowed(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"DELETE"}) { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } else { - std::string headers = "Content-Type: text/html"; - std::string response = "Delete success"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } -} - -void HttpServer::OnRequestPut(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"PUT"}) { - char x[100]; - char y[100]; - mg_get_http_var(&(msg->body), "x", x, sizeof(x)); - mg_get_http_var(&(msg->body), "y", y, sizeof(y)); - std::string x_string = std::string{x}; - std::string y_string = std::string{y}; - std::string headers = "Content-Type: application/json"; - std::string response; - if (y_string.empty()) { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - "\n" - "}"}; - } else { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - ",\n" - " \"y\": " + - y_string + - ",\n" - " \"sum\": " + - std::to_string(atoi(x) + atoi(y)) + - "\n" - "}"}; - } - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } else { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } -} - -void HttpServer::OnRequestReflectPost(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} != std::string{"POST"}) { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } - - std::string response = std::string{msg->body.p, msg->body.len}; - std::string headers; - for (size_t i = 0; i < sizeof(msg->header_names) / sizeof(mg_str); i++) { - if (!msg->header_names[i].p) { - continue; - } - - std::string name = std::string(msg->header_names[i].p, msg->header_names[i].len); - if (std::string{"Host"} != name && std::string{"Accept"} != name) { - if (!headers.empty()) { - headers.append("\r\n"); - } - if (msg->header_values[i].p) { - headers.append(name + ": " + - std::string(msg->header_values[i].p, msg->header_values[i].len)); - } - } - } - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -void HttpServer::OnRequestPutNotAllowed(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"PUT"}) { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } else { - std::string headers = "Content-Type: text/html"; - std::string response = "Delete success"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } -} - -void HttpServer::OnRequestPatch(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"PATCH"}) { - char x[100]; - char y[100]; - mg_get_http_var(&(msg->body), "x", x, sizeof(x)); - mg_get_http_var(&(msg->body), "y", y, sizeof(y)); - std::string x_string = std::string{x}; - std::string y_string = std::string{y}; - std::string headers = "Content-Type: application/json"; - std::string response; - if (y_string.empty()) { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - "\n" - "}"}; - } else { - response = std::string{ - "{\n" - " \"x\": " + - x_string + - ",\n" - " \"y\": " + - y_string + - ",\n" - " \"sum\": " + - std::to_string(atoi(x) + atoi(y)) + - "\n" - "}"}; - } - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } else { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } -} - -void HttpServer::OnRequestPatchNotAllowed(mg_connection* conn, http_message* msg) { - if (std::string{msg->method.p, msg->method.len} == std::string{"PATCH"}) { - mg_http_send_error(conn, 405, "Method Not Allowed"); - } else { - std::string headers = "Content-Type: text/html"; - std::string response = "Delete success"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); - } -} - -void HttpServer::OnRequest(mg_connection* conn, http_message* msg) { - std::string uri = std::string(msg->uri.p, msg->uri.len); - if (uri == "/") { - OnRequestRoot(conn, msg); - } else if (uri == "/hello.html") { - OnRequestHello(conn, msg); - } else if (uri == "/timeout.html") { - OnRequestTimeout(conn, msg); - } else if (uri == "/low_speed_timeout.html") { - OnRequestLowSpeedTimeout(conn, msg); - } else if (uri == "/low_speed.html") { - OnRequestLowSpeed(conn, msg); - } else if (uri == "/low_speed_bytes.html") { - OnRequestLowSpeedBytes(conn, msg); - } else if (uri == "/basic_cookies.html") { - OnRequestBasicCookies(conn, msg); - } else if (uri == "/empty_cookies.html") { - OnRequestEmptyCookies(conn, msg); - } else if (uri == "/check_cookies.html") { - OnRequestCheckCookies(conn, msg); - } else if (uri == "/v1_cookies.html") { - OnRequestV1Cookies(conn, msg); - } else if (uri == "/check_v1_cookies.html") { - OnRequestCheckV1Cookies(conn, msg); - } else if (uri == "/basic_auth.html") { - OnRequestBasicAuth(conn, msg); - } else if (uri == "/bearer_token.html") { - OnRequestBearerAuth(conn, msg); - } else if (uri == "/digest_auth.html") { - OnRequestHeaderReflect(conn, msg); - } else if (uri == "/basic.json") { - OnRequestBasicJson(conn, msg); - } else if (uri == "/header_reflect.html") { - OnRequestHeaderReflect(conn, msg); - } else if (uri == "/temporary_redirect.html") { - OnRequestTempRedirect(conn, msg); - } else if (uri == "/permanent_redirect.html") { - OnRequestPermRedirect(conn, msg); - } else if (uri == "/two_redirects.html") { - OnRequestTwoRedirects(conn, msg); - } else if (uri == "/url_post.html") { - OnRequestUrlPost(conn, msg); - } else if (uri == "/body_get.html") { - OnRequestBodyGet(conn, msg); - } else if (uri == "/json_post.html") { - OnRequestJsonPost(conn, msg); - } else if (uri == "/form_post.html") { - OnRequestFormPost(conn, msg); - } else if (uri == "/reflect_post.html") { - OnRequestReflectPost(conn, msg); - } else if (uri == "/delete.html") { - OnRequestDelete(conn, msg); - } else if (uri == "/delete_unallowed.html") { - OnRequestDeleteNotAllowed(conn, msg); - } else if (uri == "/put.html") { - OnRequestPut(conn, msg); - } else if (uri == "/put_unallowed.html") { - OnRequestPutNotAllowed(conn, msg); - } else if (uri == "/patch.html") { - OnRequestPatch(conn, msg); - } else if (uri == "/patch_unallowed.html") { - OnRequestPatchNotAllowed(conn, msg); - } else { - OnRequestNotFound(conn, msg); - } -} - -} // namespace cpr diff --git a/external/cpr/test/httpServer.hpp b/external/cpr/test/httpServer.hpp deleted file mode 100644 index 7733e69..0000000 --- a/external/cpr/test/httpServer.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef CPR_TEST_HTTP_SERVER_H -#define CPR_TEST_HTTP_SERVER_H - -#include -#include - -#include "abstractServer.hpp" -#include "cpr/cpr.h" -#include "mongoose.h" - -namespace cpr { -class HttpServer : public AbstractServer { - public: - ~HttpServer() override = default; - - std::string GetBaseUrl() override; - uint16_t GetPort() override; - - void OnRequest(mg_connection* conn, http_message* msg) override; - - private: - static void OnRequestHello(mg_connection* conn, http_message* msg); - static void OnRequestRoot(mg_connection* conn, http_message* msg); - static void OnRequestOptions(mg_connection* conn, http_message* msg); - static void OnRequestNotFound(mg_connection* conn, http_message* msg); - static void OnRequestTimeout(mg_connection* conn, http_message* msg); - static void OnRequestLowSpeedTimeout(mg_connection* conn, http_message* msg); - static void OnRequestLowSpeed(mg_connection* conn, http_message* msg); - static void OnRequestLowSpeedBytes(mg_connection* conn, http_message* msg); - static void OnRequestBasicCookies(mg_connection* conn, http_message* msg); - static void OnRequestEmptyCookies(mg_connection* conn, http_message* msg); - static void OnRequestCheckCookies(mg_connection* conn, http_message* msg); - static void OnRequestV1Cookies(mg_connection* conn, http_message* msg); - static void OnRequestCheckV1Cookies(mg_connection* conn, http_message* msg); - static void OnRequestBasicAuth(mg_connection* conn, http_message* msg); - static void OnRequestBearerAuth(mg_connection* conn, http_message* msg); - static void OnRequestBasicJson(mg_connection* conn, http_message* msg); - static void OnRequestHeaderReflect(mg_connection* conn, http_message* msg); - static void OnRequestTempRedirect(mg_connection* conn, http_message* msg); - static void OnRequestPermRedirect(mg_connection* conn, http_message* msg); - static void OnRequestTwoRedirects(mg_connection* conn, http_message* msg); - static void OnRequestUrlPost(mg_connection* conn, http_message* msg); - static void OnRequestReflectPost(mg_connection* conn, http_message* msg); - static void OnRequestBodyGet(mg_connection* conn, http_message* msg); - static void OnRequestJsonPost(mg_connection* conn, http_message* msg); - static void OnRequestFormPost(mg_connection* conn, http_message* msg); - static void OnRequestDelete(mg_connection* conn, http_message* msg); - static void OnRequestDeleteNotAllowed(mg_connection* conn, http_message* msg); - static void OnRequestPut(mg_connection* conn, http_message* msg); - static void OnRequestPutNotAllowed(mg_connection* conn, http_message* msg); - static void OnRequestPatch(mg_connection* conn, http_message* msg); - static void OnRequestPatchNotAllowed(mg_connection* conn, http_message* msg); - - protected: - mg_connection* initServer(mg_mgr* mgr, - MG_CB(mg_event_handler_t event_handler, void* user_data)) override; -}; -} // namespace cpr - -#endif diff --git a/external/cpr/test/httpsServer.cpp b/external/cpr/test/httpsServer.cpp deleted file mode 100644 index af08cdf..0000000 --- a/external/cpr/test/httpsServer.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "httpsServer.hpp" -#include - -namespace cpr { -HttpsServer::HttpsServer(std::string&& baseDirPath, std::string&& sslCertFileName, - std::string&& sslKeyFileName) - : baseDirPath(std::move(baseDirPath)), sslCertFileName(std::move(sslCertFileName)), - sslKeyFileName(std::move(sslKeyFileName)) {} - -std::string HttpsServer::GetBaseUrl() { - return "https://127.0.0.1:" + std::to_string(GetPort()); -} - -uint16_t HttpsServer::GetPort() { - // Unassigned port in the ephemeral range - return 61937; -} - -mg_connection* HttpsServer::initServer(mg_mgr* mgr, - MG_CB(mg_event_handler_t event_handler, void* user_data)) { - // https://cesanta.com/docs/http/ssl.html - mg_mgr_init(mgr, this); - - mg_bind_opts bind_opts{}; - bind_opts.ssl_cert = sslCertFileName.c_str(); - bind_opts.ssl_key = sslKeyFileName.c_str(); - std::string port = std::to_string(GetPort()); - mg_connection* c = mg_bind_opt(mgr, port.c_str(), event_handler, bind_opts); - if (!c) { - throw std::system_error(errno, std::system_category(), "Failed to bind to port " + port); - } - mg_set_protocol_http_websocket(c); - return c; -} - -void HttpsServer::OnRequest(mg_connection* conn, http_message* msg) { - std::string uri = std::string(msg->uri.p, msg->uri.len); - if (uri == "/hello.html") { - OnRequestHello(conn, msg); - } else { - OnRequestNotFound(conn, msg); - } -} - -void HttpsServer::OnRequestNotFound(mg_connection* conn, http_message* /*msg*/) { - mg_http_send_error(conn, 404, "Not Found"); -} - -void HttpsServer::OnRequestHello(mg_connection* conn, http_message* /*msg*/) { - std::string response{"Hello world!"}; - std::string headers = "Content-Type: text/html"; - mg_send_head(conn, 200, response.length(), headers.c_str()); - mg_send(conn, response.c_str(), response.length()); -} - -const std::string& HttpsServer::getBaseDirPath() const { - return baseDirPath; -} - -const std::string& HttpsServer::getSslCertFileName() const { - return sslCertFileName; -} - -const std::string& HttpsServer::getSslKeyFileName() const { - return sslKeyFileName; -} - -} // namespace cpr diff --git a/external/cpr/test/httpsServer.hpp b/external/cpr/test/httpsServer.hpp deleted file mode 100644 index 7612ec1..0000000 --- a/external/cpr/test/httpsServer.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef CPR_TEST_HTTPS_SERVER_H -#define CPR_TEST_HTTPS_SERVER_H - -#include -#include - -#include "abstractServer.hpp" -#include "cpr/cpr.h" -#include "mongoose.h" - -namespace cpr { -class HttpsServer : public AbstractServer { - private: - const std::string baseDirPath; - const std::string sslCertFileName; - const std::string sslKeyFileName; - - public: - explicit HttpsServer(std::string&& baseDirPath, std::string&& sslCertFileName, - std::string&& sslKeyFileName); - ~HttpsServer() override = default; - - std::string GetBaseUrl() override; - uint16_t GetPort() override; - - void OnRequest(mg_connection* conn, http_message* msg) override; - static void OnRequestHello(mg_connection* conn, http_message* msg); - static void OnRequestNotFound(mg_connection* conn, http_message* msg); - - const std::string& getBaseDirPath() const; - const std::string& getSslCertFileName() const; - const std::string& getSslKeyFileName() const; - - protected: - mg_connection* initServer(mg_mgr* mgr, - MG_CB(mg_event_handler_t event_handler, void* user_data)) override; -}; -} // namespace cpr - -#endif diff --git a/external/cpr/test/options_tests.cpp b/external/cpr/test/options_tests.cpp deleted file mode 100644 index 29bad48..0000000 --- a/external/cpr/test/options_tests.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(OptionsTests, BaseUrlTest) { - Url url{server->GetBaseUrl() + "/"}; - Response response = cpr::Options(url); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"GET, POST, PUT, DELETE, PATCH, OPTIONS"}, - response.header["Access-Control-Allow-Methods"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(OptionsTests, SpecificUrlTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Options(url); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"GET, POST, PUT, DELETE, PATCH, OPTIONS"}, - response.header["Access-Control-Allow-Methods"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(OptionsTests, AsyncBaseUrlTest) { - Url url{server->GetBaseUrl() + "/"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::OptionsAsync(url)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"GET, POST, PUT, DELETE, PATCH, OPTIONS"}, - response.header["Access-Control-Allow-Methods"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(OptionsTests, AsyncSpecificUrlTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::OptionsAsync(url)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"GET, POST, PUT, DELETE, PATCH, OPTIONS"}, - response.header["Access-Control-Allow-Methods"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/patch_tests.cpp b/external/cpr/test/patch_tests.cpp deleted file mode 100644 index 22d0b4f..0000000 --- a/external/cpr/test/patch_tests.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(PatchTests, PatchTest) { - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - Response response = cpr::Patch(url, payload); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, PatchUnallowedTest) { - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - Response response = cpr::Patch(url, payload); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchTest) { - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - Session session; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchUnallowedTest) { - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - Session session; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchUnallowedAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchUnallowedAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, SessionPatchUnallowedAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Patch(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, AsyncPatchTest) { - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - cpr::AsyncResponse future_response = cpr::PatchAsync(url, payload); - cpr::Response response = future_response.get(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, AsyncPatchUnallowedTest) { - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - cpr::AsyncResponse future_response = cpr::PatchAsync(url, payload); - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PatchTests, AsyncMultiplePatchTest) { - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::PatchAsync(url, payload)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(PatchTests, AsyncMultiplePatchUnallowedTest) { - Url url{server->GetBaseUrl() + "/patch_unallowed.html"}; - Payload payload{{"x", "5"}}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::PatchAsync(url, payload)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/post_tests.cpp b/external/cpr/test/post_tests.cpp deleted file mode 100644 index 3087712..0000000 --- a/external/cpr/test/post_tests.cpp +++ /dev/null @@ -1,454 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(UrlEncodedPostTests, UrlPostSingleTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Payload{{"x", "5"}}); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, UrlPostAddPayloadPair) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "1"}}; - payload.Add({"y", "2"}); - Response response = cpr::Post(url, payload); - std::string expected_text{ - "{\n" - " \"x\": 1,\n" - " \"y\": 2,\n" - " \"sum\": 3\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); -} - -TEST(UrlEncodedPostTests, UrlPostPayloadIteratorTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - std::vector payloadData; - payloadData.emplace_back("x", "1"); - payloadData.emplace_back("y", "2"); - Response response = cpr::Post(url, Payload(payloadData.begin(), payloadData.end())); - std::string expected_text{ - "{\n" - " \"x\": 1,\n" - " \"y\": 2,\n" - " \"sum\": 3\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); -} - -TEST(UrlEncodedPostTests, UrlPostEncodeTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Payload{{"x", "hello world!!~"}}); - std::string expected_text{ - "{\n" - " \"x\": hello world!!~\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, UrlPostEncodeNoCopyTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "hello world!!~"}}; - // payload lives through the lifetime of Post, so it doesn't need to be copied - Response response = cpr::Post(url, payload); - std::string expected_text{ - "{\n" - " \"x\": hello world!!~\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, UrlPostManyTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Payload{{"x", "5"}, {"y", "13"}}); - std::string expected_text{ - "{\n" - " \"x\": 5,\n" - " \"y\": 13,\n" - " \"sum\": 18\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, UrlPostBadHostTest) { - Url url{"http://bad_host/"}; - Response response = cpr::Post(url, Payload{{"hello", "world"}}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::HOST_RESOLUTION_FAILURE, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostSingleTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = cpr::Post(url, Multipart{{"x", 5}}); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileTest) { - std::string filename{"test_file"}; - std::string content{"hello world"}; - std::ofstream test_file; - test_file.open(filename); - test_file << content; - test_file.close(); - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = cpr::Post(url, Multipart{{"x", File{filename}}}); - std::string expected_text{ - "{\n" - " \"x\": " + - content + - "\n" - "}"}; - std::remove(filename.c_str()); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileNoCopyTest) { - std::string filename{"test_file"}; - std::string content{"hello world"}; - std::ofstream test_file; - test_file.open(filename); - test_file << content; - test_file.close(); - Url url{server->GetBaseUrl() + "/form_post.html"}; - Multipart multipart{{"x", File{filename}}}; - Response response = cpr::Post(url, multipart); - std::string expected_text{ - "{\n" - " \"x\": " + - content + - "\n" - "}"}; - std::remove(filename.c_str()); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, TimeoutPostTest) { - Url url{server->GetBaseUrl() + "/json_post.html"}; - std::string body{R"({"RegisterObject": {"DeviceID": "65010000005030000001"}})"}; - cpr::Response response = - cpr::Post(url, cpr::Header{{"Content-Type", "application/json"}}, cpr::Body{body}, - cpr::ConnectTimeout{3000}, cpr::Timeout{3000}); - std::string expected_text{R"({"RegisterObject": {"DeviceID": "65010000005030000001"}})"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferTest) { - std::string content{"hello world"}; - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = - cpr::Post(url, Multipart{{"x", Buffer{content.begin(), content.end(), "test_file"}}}); - std::string expected_text{ - "{\n" - " \"x\": " + - content + - "\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferNoCopyTest) { - std::string content{"hello world"}; - Url url{server->GetBaseUrl() + "/form_post.html"}; - Multipart multipart{{"x", Buffer{content.begin(), content.end(), "test_file"}}}; - Response response = cpr::Post(url, multipart); - std::string expected_text{ - "{\n" - " \"x\": " + - content + - "\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferPointerTest) { - const char* content = "hello world"; - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = - cpr::Post(url, Multipart{{"x", Buffer{content, 11 + content, "test_file"}}}); - std::string expected_text{ - "{\n" - " \"x\": " + - std::string(content) + - "\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferArrayTest) { - const char content[] = "hello world"; - Url url{server->GetBaseUrl() + "/form_post.html"}; - // We subtract 1 from std::end() because we don't want to include the terminating null - Response response = cpr::Post( - url, Multipart{{"x", Buffer{std::begin(content), std::end(content) - 1, "test_file"}}}); - std::string expected_text{ - "{\n" - " \"x\": " + - std::string(content) + - "\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferVectorTest) { - std::vector content{'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'}; - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = - cpr::Post(url, Multipart{{"x", Buffer{content.begin(), content.end(), "test_file"}}}); - std::string expected_text{ - "{\n" - " \"x\": hello world\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostFileBufferStdArrayTest) { - std::array content{{'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'}}; - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = - cpr::Post(url, Multipart{{"x", Buffer{content.begin(), content.end(), "test_file"}}}); - std::string expected_text{ - "{\n" - " \"x\": hello world\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostManyTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = cpr::Post(url, Multipart{{"x", 5}, {"y", 13}}); - std::string expected_text{ - "{\n" - " \"x\": 5,\n" - " \"y\": 13,\n" - " \"sum\": 18\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostManyNoCopyTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Multipart multipart{{"x", 5}, {"y", 13}}; - Response response = cpr::Post(url, multipart); - std::string expected_text{ - "{\n" - " \"x\": 5,\n" - " \"y\": 13,\n" - " \"sum\": 18\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostContentTypeTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = cpr::Post(url, Multipart{{"x", 5, "application/number"}}); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, FormPostContentTypeLValueTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Multipart multipart{{"x", 5, "application/number"}}; - Response response = cpr::Post(url, multipart); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, UrlPostAsyncSingleTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::PostAsync(url, payload)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(UrlEncodedPostTests, UrlReflectTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Response response = cpr::Post(url, Payload{{"x", "5"}}); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UrlEncodedPostTests, PostWithNoBodyTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Response response = cpr::Post(url); - std::string expected_text{ - "{\n" - " \"x\": \n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -static std::string getTimestamp() { - char buf[1000]; - time_t now = time(0); - struct tm* tm = gmtime(&now); - strftime(buf, sizeof buf, "%a, %d %b %Y %H:%M:%S GMT", tm); - return buf; -} - -TEST(UrlEncodedPostTests, PostReflectTest) { - std::string uri = server->GetBaseUrl() + "/reflect_post.html"; - std::string body = R"({"property1": "value1"})"; - std::string contentType = "application/json"; - std::string signature = "x-ms-date: something"; - std::string logType = "LoggingTest"; - std::string date = getTimestamp(); - Response response = cpr::Post(cpr::Url(uri), - cpr::Header{{"content-type", contentType}, - {"Authorization", signature}, - {"log-type", logType}, - {"x-ms-date", date}, - {"content-length", std::to_string(body.length())}}, - cpr::Body(body)); - EXPECT_EQ(ErrorCode::OK, response.error.code); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(body, response.text); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(signature, response.header["Authorization"]); - EXPECT_EQ(logType, response.header["log-type"]); - EXPECT_EQ(date, response.header["x-ms-date"]); - EXPECT_EQ(std::to_string(body.length()), response.header["content-length"]); -} - -TEST(UrlEncodedPostTests, PostReflectPayloadTest) { - std::string uri = server->GetBaseUrl() + "/header_reflect.html"; - cpr::Payload payload = cpr::Payload{{"email", ""}, {"password", ""}, {"devicetoken", ""}}; - cpr::Response response = cpr::Post(cpr::Url(uri), cpr::Timeout{10000}, payload); - - EXPECT_EQ(ErrorCode::OK, response.error.code); - EXPECT_EQ(200, response.status_code); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/prepare_tests.cpp b/external/cpr/test/prepare_tests.cpp deleted file mode 100644 index f7d0d16..0000000 --- a/external/cpr/test/prepare_tests.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include - -#include -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(PrepareTests, GetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.PrepareGet(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PrepareTests, OptionsTests) { - Url url{server->GetBaseUrl() + "/"}; - Session session; - session.SetUrl(url); - session.PrepareOptions(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{""}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"GET, POST, PUT, DELETE, PATCH, OPTIONS"}, - response.header["Access-Control-Allow-Methods"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PrepareTests, PatchTest) { - Url url{server->GetBaseUrl() + "/patch.html"}; - Payload payload{{"x", "5"}}; - Session session; - session.SetUrl(url); - session.SetPayload(payload); - session.PreparePatch(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PrepareTests, MultipleDeleteHeadPutGetPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Url urlPost{server->GetBaseUrl() + "/reflect_post.html"}; - Url urlPut{server->GetBaseUrl() + "/put.html"}; - Session session; - for (size_t i = 0; i < 3; ++i) { - { - session.SetUrl(url); - session.PrepareDelete(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{"Header reflect DELETE"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(urlPost); - std::string expectedBody = "a1b2c3Post"; - session.SetBody(expectedBody); - session.PreparePost(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - EXPECT_EQ(expectedBody, response.text); - EXPECT_EQ(urlPost, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(url); - session.PrepareGet(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(urlPut); - session.SetPayload({{"x", "5"}}); - session.PreparePut(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(urlPut, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(url); - session.PrepareHead(); - CURLcode curl_result = curl_easy_perform(session.GetCurlHolder()->handle); - Response response = session.Complete(curl_result); - std::string expected_text{"Header reflect HEAD"}; - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - } -} - - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/proxy_tests.cpp b/external/cpr/test/proxy_tests.cpp deleted file mode 100644 index e16bc3f..0000000 --- a/external/cpr/test/proxy_tests.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include - -#include - -#include - -// TODO: This uses public servers for proxies and endpoints. This should be replaced with a source -// code implementation inside server.cpp - -#define HTTP_PROXY "104.131.214.38:3128" -#define HTTPS_PROXY "104.131.214.38:3128" - -using namespace cpr; - -TEST(ProxyTests, SingleProxyTest) { - Url url{"http://www.httpbin.org/get"}; - Response response = cpr::Get(url, Proxies{{"http", HTTP_PROXY}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ProxyTests, MultipleProxyHttpTest) { - Url url{"http://www.httpbin.org/get"}; - Response response = cpr::Get(url, Proxies{{"http", HTTP_PROXY}, {"https", HTTPS_PROXY}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -// TODO: These should be fixed after a source code implementation of an HTTPS proxy -#if defined(false) -TEST(ProxyTests, ProxyHttpsTest) { - Url url{"https://www.httpbin.org/get"}; - Response response = cpr::Get(url, Proxies{{"https", HTTPS_PROXY}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ProxyTests, MultipleProxyHttpsTest) { - Url url{"https://www.httpbin.org/get"}; - Response response = cpr::Get(url, Proxies{{"http", HTTP_PROXY}, {"https", HTTPS_PROXY}}); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} -#endif - -TEST(ProxyTests, CopyProxyTest) { - Url url{"http://www.httpbin.org/get"}; - Proxies proxies{{"http", HTTP_PROXY}}; - Response response = cpr::Get(url, proxies); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ProxyTests, ProxySessionTest) { - Url url{"http://www.httpbin.org/get"}; - Session session; - session.SetUrl(url); - session.SetProxies(Proxies{{"http", HTTP_PROXY}}); - Response response = session.Get(); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ProxyTests, ReferenceProxySessionTest) { - Url url{"http://www.httpbin.org/get"}; - Proxies proxies{{"http", HTTP_PROXY}}; - Session session; - session.SetUrl(url); - session.SetProxies(proxies); - Response response = session.Get(); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/put_tests.cpp b/external/cpr/test/put_tests.cpp deleted file mode 100644 index 34e083f..0000000 --- a/external/cpr/test/put_tests.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#include - -#include - -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(PutTests, PutTest) { - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, PutUnallowedTest) { - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - Response response = cpr::Put(url, payload); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutTest) { - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - Session session; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutUnallowedTest) { - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - Session session; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutUnallowedAfterGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Get(); - } - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutUnallowedAfterHeadTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/get.html"}; - session.SetUrl(url); - Response response = session.Head(); - } - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, SessionPutUnallowedAfterPostTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - Response response = session.Post(); - } - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - session.SetUrl(url); - session.SetPayload(payload); - Response response = session.Put(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, AsyncPutTest) { - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - cpr::AsyncResponse future_response = cpr::PutAsync(url, payload); - cpr::Response response = future_response.get(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, AsyncPutUnallowedTest) { - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - cpr::AsyncResponse future_response = cpr::PutAsync(url, payload); - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PutTests, AsyncMultiplePutTest) { - Url url{server->GetBaseUrl() + "/put.html"}; - Payload payload{{"x", "5"}}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::PutAsync(url, payload)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(PutTests, AsyncMultiplePutUnallowedTest) { - Url url{server->GetBaseUrl() + "/put_unallowed.html"}; - Payload payload{{"x", "5"}}; - std::vector responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::PutAsync(url, payload)); - } - for (cpr::AsyncResponse& future_response : responses) { - cpr::Response response = future_response.get(); - std::string expected_text{"Method Not Allowed"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(405, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/raw_body_tests.cpp b/external/cpr/test/raw_body_tests.cpp deleted file mode 100644 index 53bc11c..0000000 --- a/external/cpr/test/raw_body_tests.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include - -#include -#include -#include - -#include -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(BodyPostTests, DefaultUrlEncodedPostTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Body{"x=5"}); - std::string expected_text = "{\n \"x\": 5\n}"; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, TextUrlEncodedPostTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Body{"x=hello world!!~"}); - std::string expected_text{ - "{\n" - " \"x\": hello world!!~\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, TextUrlEncodedNoCopyPostTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Body body{"x=hello world!!~"}; - // body lives through the lifetime of Post, so it doesn't need to be copied - Response response = cpr::Post(url, body); - std::string expected_text{ - "{\n" - " \"x\": hello world!!~\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, UrlEncodedManyPostTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Body{"x=5&y=13"}); - std::string expected_text{ - "{\n" - " \"x\": 5,\n" - " \"y\": 13,\n" - " \"sum\": 18\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, CustomHeaderNumberPostTest) { - Url url{server->GetBaseUrl() + "/json_post.html"}; - Response response = - cpr::Post(url, Body{"{\"x\":5}"}, Header{{"Content-Type", "application/json"}}); - std::string expected_text{"{\"x\":5}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, CustomHeaderTextPostTest) { - Url url{server->GetBaseUrl() + "/json_post.html"}; - Response response = cpr::Post(url, Body{"{\"x\":\"hello world!!~\"}"}, - Header{{"Content-Type", "application/json"}}); - std::string expected_text{"{\"x\":\"hello world!!~\"}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, CustomWrongHeaderPostTest) { - Url url{server->GetBaseUrl() + "/json_post.html"}; - Response response = cpr::Post(url, Body{"{\"x\":5}"}, Header{{"Content-Type", "text/plain"}}); - std::string expected_text{"Unsupported Media Type"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(415, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyPostTests, UrlPostBadHostTest) { - Url url{"http://bad_host/"}; - Response response = cpr::Post(url, Body{"hello=world"}); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(0, response.status_code); - EXPECT_EQ(ErrorCode::HOST_RESOLUTION_FAILURE, response.error.code); -} - -TEST(BodyPostTests, StringMoveBodyTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Response response = cpr::Post(url, Body{std::string{"x=5"}}); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/session_tests.cpp b/external/cpr/test/session_tests.cpp deleted file mode 100644 index 7304fcb..0000000 --- a/external/cpr/test/session_tests.cpp +++ /dev/null @@ -1,905 +0,0 @@ -#include - -#include -#include - -#include -#include - -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -TEST(RedirectTests, TemporaryDefaultRedirectTest) { - Url url{server->GetBaseUrl() + "/temporary_redirect.html"}; - Session session; - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{server->GetBaseUrl() + "/hello.html"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(RedirectTests, NoTemporaryRedirectTest) { - Url url{server->GetBaseUrl() + "/temporary_redirect.html"}; - Session session; - session.SetUrl(url); - session.SetRedirect(false); - Response response = session.Get(); - std::string expected_text{"Moved Temporarily"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(302, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(RedirectTests, PermanentDefaultRedirectTest) { - Url url{server->GetBaseUrl() + "/permanent_redirect.html"}; - Session session; - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{server->GetBaseUrl() + "/hello.html"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(RedirectTests, NoPermanentRedirectTest) { - Url url{server->GetBaseUrl() + "/permanent_redirect.html"}; - Session session; - session.SetUrl(url); - session.SetRedirect(false); - Response response = session.Get(); - std::string expected_text{"Moved Permanently"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(301, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MaxRedirectsTests, ZeroMaxRedirectsSuccessTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetMaxRedirects(MaxRedirects(0)); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MaxRedirectsTests, ZeroMaxRedirectsFailureTest) { - Url url{server->GetBaseUrl() + "/permanent_redirect.html"}; - Session session; - session.SetUrl(url); - session.SetMaxRedirects(MaxRedirects(0)); - Response response = session.Get(); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(301, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MaxRedirectsTests, OneMaxRedirectsSuccessTest) { - Url url{server->GetBaseUrl() + "/permanent_redirect.html"}; - Session session; - session.SetUrl(url); - session.SetMaxRedirects(MaxRedirects(1)); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{server->GetBaseUrl() + "/hello.html"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MaxRedirectsTests, OneMaxRedirectsFailureTest) { - Url url{server->GetBaseUrl() + "/two_redirects.html"}; - Session session; - session.SetUrl(url); - session.SetMaxRedirects(MaxRedirects(1)); - Response response = session.Get(); - EXPECT_EQ(std::string{}, response.text); - EXPECT_EQ(Url{server->GetBaseUrl() + "/permanent_redirect.html"}, response.url); - EXPECT_EQ(std::string{}, response.header["content-type"]); - EXPECT_EQ(301, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MaxRedirectsTests, TwoMaxRedirectsSuccessTest) { - Url url{server->GetBaseUrl() + "/two_redirects.html"}; - Session session; - session.SetUrl(url); - session.SetMaxRedirects(MaxRedirects(2)); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{server->GetBaseUrl() + "/hello.html"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MultipleGetTests, BasicMultipleGetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - for (size_t i = 0; i < 100; ++i) { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, UrlChangeMultipleGetTest) { - Session session; - { - Url url{server->GetBaseUrl() + "/hello.html"}; - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Url url{server->GetBaseUrl() + "/basic.json"}; - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{ - "[\n" - " {\n" - " \"first_key\": \"first_value\",\n" - " \"second_key\": \"second_value\"\n" - " }\n" - "]"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, HeaderMultipleGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - session.SetHeader(Header{{"hello", "world"}}); - for (size_t i = 0; i < 100; ++i) { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, HeaderChangeMultipleGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - session.SetHeader(Header{{"hello", "world"}}); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"world"}, response.header["hello"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - session.SetHeader(Header{{"key", "value"}}); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(std::string{"value"}, response.header["key"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, ParameterMultipleGetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetParameters({{"hello", "world"}}); - for (size_t i = 0; i < 100; ++i) { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, ParameterChangeMultipleGetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetParameters({{"hello", "world"}}); - { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - session.SetUrl(url); - session.SetParameters({{"key", "value"}}); - { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?key=value"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, BasicAuthenticationMultipleGetTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Session session; - session.SetUrl(url); - session.SetAuth(Authentication{"user", "password"}); - for (size_t i = 0; i < 100; ++i) { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(MultipleGetTests, BasicAuthenticationChangeMultipleGetTest) { - Url url{server->GetBaseUrl() + "/basic_auth.html"}; - Session session; - session.SetUrl(url); - session.SetAuth(Authentication{"user", "password"}); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - session.SetAuth(Authentication{"user", "bad_password"}); - { - Response response = session.Get(); - EXPECT_EQ(std::string{"Unauthorized"}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - session.SetAuth(Authentication{"bad_user", "password"}); - { - Response response = session.Get(); - EXPECT_EQ(std::string{"Unauthorized"}, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]); - EXPECT_EQ(401, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(ParameterTests, ParameterSingleTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - Parameters parameters{{"hello", "world"}}; - session.SetParameters(parameters); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ParameterTests, ParameterMultipleTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - Parameters parameters{{"hello", "world"}, {"key", "value"}}; - session.SetParameters(parameters); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(Url{url + "?hello=world&key=value"}, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(TimeoutTests, SetTimeoutTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetTimeout(0L); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(TimeoutTests, SetTimeoutLongTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetTimeout(10000L); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(TimeoutTests, SetTimeoutLowSpeed) { - Url url{server->GetBaseUrl() + "/low_speed_timeout.html"}; - Session session; - session.SetUrl(url); - session.SetTimeout(1000); - Response response = session.Get(); - EXPECT_EQ(url, response.url); - EXPECT_FALSE(response.status_code == 200); - EXPECT_EQ(ErrorCode::OPERATION_TIMEDOUT, response.error.code); -} - -TEST(TimeoutTests, SetChronoTimeoutTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetTimeout(std::chrono::milliseconds{0}); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(TimeoutTests, SetChronoTimeoutLongTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetTimeout(std::chrono::milliseconds{10000}); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ConnectTimeoutTests, SetConnectTimeoutTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetConnectTimeout(0L); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ConnectTimeoutTests, SetConnectTimeoutLongTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetConnectTimeout(10000L); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ConnectTimeoutTests, SetChronoConnectTimeoutTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetConnectTimeout(std::chrono::milliseconds{0}); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(ConnectTimeoutTests, SetChronoConnectTimeoutLongTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetConnectTimeout(std::chrono::milliseconds{10000}); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(LowSpeedTests, SetLowSpeedTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - Session session; - session.SetUrl(url); - session.SetLowSpeed({1, 1}); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PayloadTests, SetPayloadTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Session session; - session.SetUrl(url); - session.SetPayload({{"x", "5"}}); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(PayloadTests, SetPayloadLValueTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Session session; - session.SetUrl(url); - Payload payload{{"x", "5"}}; - session.SetPayload(payload); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MultipartTests, SetMultipartTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Session session; - session.SetUrl(url); - session.SetMultipart({{"x", "5"}}); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(MultipartTests, SetMultipartValueTest) { - Url url{server->GetBaseUrl() + "/form_post.html"}; - Session session; - session.SetUrl(url); - Multipart multipart{{"x", "5"}}; - session.SetMultipart(multipart); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyTests, SetBodyTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Session session; - session.SetUrl(url); - session.SetBody(Body{"x=5"}); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(BodyTests, SetBodyValueTest) { - Url url{server->GetBaseUrl() + "/url_post.html"}; - Session session; - session.SetUrl(url); - Body body{"x=5"}; - session.SetBody(body); - Response response = session.Post(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(201, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(DigestTests, SetDigestTest) { - Url url{server->GetBaseUrl() + "/digest_auth.html"}; - Session session; - session.SetUrl(url); - session.SetDigest({"user", "password"}); - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(UserAgentTests, SetUserAgentTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - UserAgent userAgent{"Test User Agent"}; - Session session; - session.SetUrl(url); - session.SetUserAgent(userAgent); - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(userAgent, response.header["User-Agent"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); -} - -TEST(CookiesTests, BasicCookiesTest) { - Url url{server->GetBaseUrl() + "/basic_cookies.html"}; - Session session{}; - session.SetUrl(url); - Cookies cookies; - - { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - cookies = response.cookies; - } - { - cookies["hello"] = "world"; - cookies["my"] = "another; fake=cookie;"; // This is url encoded - session.SetCookies(cookies); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - EXPECT_EQ(cookies["cookie"], response.cookies["cookie"]); - EXPECT_EQ(cookies["icecream"], response.cookies["icecream"]); - EXPECT_EQ(cookies["expires"], response.cookies["expires"]); - } -} - -TEST(CookiesTests, CookiesConstructorTest) { - Url url{server->GetBaseUrl() + "/basic_cookies.html"}; - Session session{}; - session.SetUrl(url); - Cookies cookies; - - { - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - cookies = response.cookies; - } - { - cookies = Cookies{{"hello", "world"}, {"my", "another; fake=cookie;"}}; - session.SetCookies(cookies); - Response response = session.Get(); - std::string expected_text{"Hello world!"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - cookies = response.cookies; - EXPECT_EQ(cookies["cookie"], response.cookies["cookie"]); - EXPECT_EQ(cookies["icecream"], response.cookies["icecream"]); - EXPECT_EQ(cookies["expires"], response.cookies["expires"]); - } -} - -TEST(DifferentMethodTests, GetPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(DifferentMethodTests, PostGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(DifferentMethodTests, GetPostGetTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(DifferentMethodTests, PostGetPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -TEST(DifferentMethodTests, MultipleGetPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - for (size_t i = 0; i < 100; ++i) { - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - } -} - -TEST(DifferentMethodTests, MultipleDeleteHeadPutGetPostTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Url urlPost{server->GetBaseUrl() + "/reflect_post.html"}; - Url urlPut{server->GetBaseUrl() + "/put.html"}; - Session session; - for (size_t i = 0; i < 10; ++i) { - { - session.SetUrl(url); - Response response = session.Delete(); - std::string expected_text{"Header reflect DELETE"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(urlPost); - std::string expectedBody = "a1b2c3Post"; - session.SetBody(expectedBody); - Response response = session.Post(); - EXPECT_EQ(expectedBody, response.text); - EXPECT_EQ(urlPost, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(url); - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(urlPut); - session.SetPayload({{"x", "5"}}); - Response response = session.Put(); - std::string expected_text{ - "{\n" - " \"x\": 5\n" - "}"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(urlPut, response.url); - EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - session.SetUrl(url); - Response response = session.Head(); - std::string expected_text{"Header reflect HEAD"}; - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - } -} - -TEST(CurlHolderManipulateTests, CustomOptionTest) { - Url url{server->GetBaseUrl() + "/header_reflect.html"}; - Session session; - session.SetUrl(url); - curl_easy_setopt(session.GetCurlHolder()->handle, CURLOPT_SSL_OPTIONS, - CURLSSLOPT_ALLOW_BEAST | CURLSSLOPT_NO_REVOKE); - { - Response response = session.Get(); - std::string expected_text{"Header reflect GET"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } - { - Response response = session.Post(); - std::string expected_text{"Header reflect POST"}; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/ssl_tests.cpp b/external/cpr/test/ssl_tests.cpp deleted file mode 100644 index 12e0312..0000000 --- a/external/cpr/test/ssl_tests.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#include -#include -#include - -#include -#include - -#include "httpsServer.hpp" - -using namespace cpr; - -static HttpsServer* server; - -TEST(SslTests, HelloWorldTestSimpel) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string baseDirPath = server->getBaseDirPath(); - SslOptions sslOpts = - Ssl(ssl::CaPath{baseDirPath + "ca.cer"}, ssl::CertFile{baseDirPath + "client.cer"}, - ssl::KeyFile{baseDirPath + "client.key"}, ssl::VerifyPeer{false}, - ssl::VerifyHost{false}, ssl::VerifyStatus{false}); - Response response = cpr::Get(url, sslOpts, Timeout{5000}, Verbose{}); - std::string expected_text = "Hello world!"; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code) << response.error.message; -} - -TEST(SslTests, HelloWorldTestFull) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string baseDirPath = server->getBaseDirPath(); - SslOptions sslOpts = Ssl( - ssl::TLSv1{}, ssl::ALPN{false}, ssl::NPN{false}, ssl::CaPath{baseDirPath + "ca.cer"}, - ssl::CertFile{baseDirPath + "client.cer"}, ssl::KeyFile{baseDirPath + "client.key"}, - ssl::VerifyPeer{false}, ssl::VerifyHost{false}, ssl::VerifyStatus{false}); - Response response = cpr::Get(url, sslOpts, Timeout{5000}, Verbose{}); - std::string expected_text = "Hello world!"; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code) << response.error.message; -} - -TEST(SslTests, GetCertInfo) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - - Url url{server->GetBaseUrl() + "/hello.html"}; - std::string baseDirPath = server->getBaseDirPath(); - SslOptions sslOpts = - Ssl(ssl::CaPath{baseDirPath + "ca.cer"}, ssl::CertFile{baseDirPath + "client.cer"}, - ssl::KeyFile{baseDirPath + "client.key"}, ssl::VerifyPeer{false}, - ssl::VerifyHost{false}, ssl::VerifyStatus{false}); - Response response = cpr::Get(url, sslOpts, Timeout{5000}, Verbose{}); - std::string expected_text = "Hello world!"; - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(ErrorCode::OK, response.error.code) << response.error.message; - - std::vector certInfo = response.GetCertInfo(); - EXPECT_EQ(certInfo.size(), 1); - std::string expected_certInfo = "Subject:C = XX, L = Default City, O = Default Company Ltd"; - EXPECT_EQ(certInfo[0], expected_certInfo); -} - -/** - * We should replace this with a C++17 filesystem call, - * once we have updated to >= C++17. - **/ -std::string getBasePath(const std::string& execPath) { - std::string path = execPath.substr(0, execPath.find_last_of("\\/") + 1); - - // If Windows convert paths from "D:/cpr/build/bin/Release/client.cer" to - // "D:\cpr\build\bin\Release\client.cer": -#ifdef _WIN32 - std::cout << "Converting Unix path to Windows path...\n"; - std::replace(path.begin(), path.end(), '\\', '/'); - std::cout << "Result path: " << path << '\n'; -#endif - return path; -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - - std::string baseDirPath = getBasePath(argv[0]); - std::string serverCertPath = baseDirPath + "server.cer"; - std::string serverKeyPath = baseDirPath + "server.key"; - server = new HttpsServer(std::move(baseDirPath), std::move(serverCertPath), - std::move(serverKeyPath)); - ::testing::AddGlobalTestEnvironment(server); - - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/structures_tests.cpp b/external/cpr/test/structures_tests.cpp deleted file mode 100644 index 501e491..0000000 --- a/external/cpr/test/structures_tests.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "cpr/cprtypes.h" -#include - -#include - -#include -#include - -using namespace cpr; - -TEST(PayloadTests, UseStringVariableTest) { - std::string value1 = "hello"; - std::string key2 = "key2"; - Payload payload {{"key1", value1}, {key2, "world"}}; - - std::string expected = "key1=hello&key2=world"; - EXPECT_EQ(payload.GetContent(CurlHolder()), expected); -} - -TEST(PayloadTests, DisableEncodingTest) { - std::string key1 = "key1"; - std::string key2 = "key2§$%&/"; - std::string value1 = "hello.,.,"; - std::string value2 = "hello"; - Payload payload{{key1, value1}, {key2, value2}}; - payload.encode = false; - - std::string expected = key1 + '=' + value1 + '&' + key2 + '=' + value2; - EXPECT_EQ(payload.GetContent(CurlHolder()), expected); -} - -TEST(ParametersTests, UseStringVariableTest) { - std::string value1 = "hello"; - std::string key2 = "key2"; - Parameters parameters {{"key1", value1}, {key2, "world"}}; - - std::string expected = "key1=hello&key2=world"; - EXPECT_EQ(parameters.GetContent(CurlHolder()), expected); -} - -TEST(ParametersTests, DisableEncodingTest) { - std::string key1 = "key1"; - std::string key2 = "key2§$%&/"; - std::string value1 = "hello.,.,"; - std::string value2 = "hello"; - Parameters parameters{{key1, value1}, {key2, value2}}; - parameters.encode = false; - - std::string expected = key1 + '=' + value1 + '&' + key2 + '=' + value2; - EXPECT_EQ(parameters.GetContent(CurlHolder()), expected); -} - -TEST(UrlToAndFromString, UrlTests) { - std::string s{"https://github.com/whoshuu/cpr"}; - cpr::Url url = s; - EXPECT_EQ(s, url.str()); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/external/cpr/test/util_tests.cpp b/external/cpr/test/util_tests.cpp deleted file mode 100644 index 73c94d0..0000000 --- a/external/cpr/test/util_tests.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include - -#include - -#include -#include - -using namespace cpr; - -TEST(UtilParseHeaderTests, BasicParseTest) { - std::string header_string{ - "HTTP/1.1 200 OK\r\n" - "Server: nginx\r\n" - "Date: Sun, 05 Mar 2017 00:34:54 GMT\r\n" - "Content-Type: application/json\r\n" - "Content-Length: 351\r\n" - "Connection: keep-alive\r\n" - "Access-Control-Allow-Origin: *\r\n" - "Access-Control-Allow-Credentials: true\r\n" - "\r\n"}; - Header header = util::parseHeader(header_string); - EXPECT_EQ(std::string{"nginx"}, header["Server"]); - EXPECT_EQ(std::string{"Sun, 05 Mar 2017 00:34:54 GMT"}, header["Date"]); - EXPECT_EQ(std::string{"application/json"}, header["Content-Type"]); - EXPECT_EQ(std::string{"351"}, header["Content-Length"]); - EXPECT_EQ(std::string{"keep-alive"}, header["Connection"]); - EXPECT_EQ(std::string{"*"}, header["Access-Control-Allow-Origin"]); - EXPECT_EQ(std::string{"true"}, header["Access-Control-Allow-Credentials"]); -} - -TEST(UtilParseHeaderTests, NewlineTest) { - std::string header_string{ - "HTTP/1.1 200 OK\r\n" - "Auth:\n" - "Access-Control-Allow-Credentials: true\r\n" - "\r\n"}; - Header header = util::parseHeader(header_string); - EXPECT_EQ(std::string{""}, header["Server"]); - EXPECT_EQ(std::string{"true"}, header["Access-Control-Allow-Credentials"]); -} - -TEST(UtilParseHeaderTests, SpaceNewlineTest) { - std::string header_string{ - "HTTP/1.1 200 OK\r\n" - "Auth: \n" - "Access-Control-Allow-Credentials: true\r\n" - "\r\n"}; - Header header = util::parseHeader(header_string); - EXPECT_EQ(std::string{""}, header["Server"]); - EXPECT_EQ(std::string{"true"}, header["Access-Control-Allow-Credentials"]); -} - -TEST(UtilParseHeaderTests, CarriageReturnNewlineTest) { - std::string header_string{ - "HTTP/1.1 200 OK\n" - "Auth:\r\n" - "Access-Control-Allow-Credentials: true\r\n" - "\r\n"}; - Header header = util::parseHeader(header_string); - EXPECT_EQ(std::string{""}, header["Server"]); - EXPECT_EQ(std::string{"true"}, header["Access-Control-Allow-Credentials"]); -} - -TEST(UtilParseHeaderTests, SpaceCarriageReturnNewlineTest) { - std::string header_string{ - "HTTP/1.1 200 OK\n" - "Auth: \r\n" - "Access-Control-Allow-Credentials: true\r\n" - "\r\n"}; - Header header = util::parseHeader(header_string); - EXPECT_EQ(std::string{""}, header["Server"]); - EXPECT_EQ(std::string{"true"}, header["Access-Control-Allow-Credentials"]); -} - -TEST(UtilParseHeaderTests, BasicStatusLineTest) { - std::string header_string{ - "HTTP/1.1 200 OK\r\n" - "Server: nginx\r\n" - "Content-Type: application/json\r\n" - "\r\n"}; - std::string status_line; - std::string reason; - Header header = util::parseHeader(header_string, &status_line, &reason); - EXPECT_EQ(std::string{"HTTP/1.1 200 OK"}, status_line); - EXPECT_EQ(std::string{"OK"}, reason); - EXPECT_EQ(std::string{"nginx"}, header["Server"]); - EXPECT_EQ(std::string{"application/json"}, header["Content-Type"]); -} - -TEST(UtilParseHeaderTests, NewlineStatusLineTest) { - std::string header_string{ - "HTTP/1.1 407 Proxy Authentication Required\n" - "Server: nginx\r\n" - "Content-Type: application/json\r\n" - "\r\n"}; - std::string status_line; - std::string reason; - Header header = util::parseHeader(header_string, &status_line, &reason); - EXPECT_EQ(std::string{"HTTP/1.1 407 Proxy Authentication Required"}, status_line); - EXPECT_EQ(std::string{"Proxy Authentication Required"}, reason); - EXPECT_EQ(std::string{"nginx"}, header["Server"]); - EXPECT_EQ(std::string{"application/json"}, header["Content-Type"]); -} - -TEST(UtilParseHeaderTests, NoReasonSpaceTest) { - std::string header_string{ - "HTTP/1.1 200 \n" - "Server: nginx\r\n" - "Content-Type: application/json\r\n" - "\r\n"}; - std::string status_line; - std::string reason; - Header header = util::parseHeader(header_string, &status_line, &reason); - EXPECT_EQ(std::string{"HTTP/1.1 200"}, status_line); - EXPECT_EQ(std::string{""}, reason); - EXPECT_EQ(std::string{"nginx"}, header["Server"]); - EXPECT_EQ(std::string{"application/json"}, header["Content-Type"]); -} - -TEST(UtilParseHeaderTests, NoReasonTest) { - std::string header_string{ - "HTTP/1.1 200\n" - "Server: nginx\r\n" - "Content-Type: application/json\r\n" - "\r\n"}; - std::string status_line; - std::string reason; - Header header = util::parseHeader(header_string, &status_line, &reason); - EXPECT_EQ(std::string{"HTTP/1.1 200"}, status_line); - EXPECT_EQ(std::string{""}, reason); - EXPECT_EQ(std::string{"nginx"}, header["Server"]); - EXPECT_EQ(std::string{"application/json"}, header["Content-Type"]); -} - -TEST(UtilUrlEncodeTests, UnicodeEncoderTest) { - std::string input = "一二三"; - std::string result = util::urlEncode(input); - std::string expected = "%E4%B8%80%E4%BA%8C%E4%B8%89"; - EXPECT_EQ(result, expected); -} - -TEST(UtilUrlEncodeTests, AsciiEncoderTest) { - std::string input = "Hello World!"; - std::string result = util::urlEncode(input); - std::string expected = "Hello%20World%21"; - EXPECT_EQ(result, expected); -} - -TEST(UtilUrlDecodeTests, UnicodeDecoderTest) { - std::string input = "%E4%B8%80%E4%BA%8C%E4%B8%89"; - std::string result = util::urlDecode(input); - std::string expected = "一二三"; - EXPECT_EQ(result, expected); -} - -TEST(UtilUrlDecodeTests, AsciiDecoderTest) { - std::string input = "Hello%20World%21"; - std::string result = util::urlDecode(input); - std::string expected = "Hello World!"; - EXPECT_EQ(result, expected); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/external/http-link-header-cpp b/external/http-link-header-cpp deleted file mode 160000 index e1100f1..0000000 --- a/external/http-link-header-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e1100f1235a49efdc0c421dbe3f90bfd77836b16 diff --git a/external/uriparser/.github/dependabot.yml b/external/uriparser/.github/dependabot.yml deleted file mode 100644 index b149019..0000000 --- a/external/uriparser/.github/dependabot.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2021 Sebastian Pipping -# Licensed under the MIT license - -version: 2 -updates: - - - package-ecosystem: "github-actions" - commit-message: - include: "scope" - prefix: "Actions" - directory: "/" - labels: - - "enhancement" - schedule: - interval: "weekly" diff --git a/external/uriparser/.github/workflows/build-and-test.yml b/external/uriparser/.github/workflows/build-and-test.yml deleted file mode 100644 index ba5cb84..0000000 --- a/external/uriparser/.github/workflows/build-and-test.yml +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (C) 2021 Sebastian Pipping -# Licensed under the MIT license - -name: Build and test - -on: - pull_request: - push: - schedule: - - cron: '0 4 * * 5' # Every Friday at 4am - -jobs: - build_and_test: - name: Build and test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.3.4 - - - name: Add Clang/LLVM repositories - run: |- - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' - - - name: Install build dependencies - run: |- - sudo apt-get install --yes --no-install-recommends -V \ - clang-11 \ - cmake \ - doxygen \ - graphviz \ - llvm-11 \ - lzip \ - qhelpgenerator-qt5 \ - qtchooser - - - name: Build, test and install - run: |- - sed 's,:,\n,g' <<<"${PATH}" - clang --version - - GTEST_VERSION=1.8.1 - GTEST_PREFIX=~/.local/ - - wget https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz - tar xf release-${GTEST_VERSION}.tar.gz - ( - cd googletest-release-${GTEST_VERSION}/ - cmake \ - -DBUILD_SHARED_LIBS=ON \ - -DCVF_VERSION=${GTEST_VERSION} \ - -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} \ - . - make - make install - ) - - mkdir build - pushd build - compile_flags=( - -pipe - - -O1 - -g - -fsanitize=address,undefined,leak - -fno-sanitize-recover=all - -fno-omit-frame-pointer - - -Wall - -Wextra - -pedantic - ) - CFLAGS="${compile_flags[*]} -std=c89" - CXXFLAGS="${compile_flags[*]} -std=c++98" - LDFLAGS='-g -fsanitize=address' - cmake_args=( - -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} - - -Wdev - -Werror=dev - -Wdeprecated - -Werror=deprecated - - -DCMAKE_C_COMPILER=clang-11 - -DCMAKE_CXX_COMPILER=clang++-11 - -DCMAKE_C_FLAGS="${CFLAGS}" - -DCMAKE_CXX_FLAGS="${CXXFLAGS}" - -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" - -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" - -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" - - -DURIPARSER_WARNINGS_AS_ERRORS=ON - ) - cmake "${cmake_args[@]}" -DCMAKE_INSTALL_INCLUDEDIR=include123 .. - - make VERBOSE=1 all - - make VERBOSE=1 test ARGS=--verbose - cat Testing/Temporary/LastTest.log - - make install - make DESTDIR="${PWD}"/ROOT/ install - find ROOT | sort - - ./doc/release.sh - popd - pushd cmake/test_find_package - cmake "${cmake_args[@]}" . - make VERBOSE=1 - ./hello - popd - - git fetch --tags --unshallow origin # for "git describe" in make-distcheck.sh - - ./make-distcheck.sh -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} # without AddressSanitizer - - ! git status | fgrep -A100 'Untracked files:' # works best at the very end diff --git a/external/uriparser/.gitignore b/external/uriparser/.gitignore deleted file mode 100644 index d0bcb73..0000000 --- a/external/uriparser/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/config.h -/build/ -/CMakeCache.txt -/CMakeDoxyfile.in -/CMakeDoxygenDefaults.cmake -/CMakeFiles/ -/cmake_install.cmake -/CTestTestfile.cmake -/googletest-release-1.8.1/ -/install_manifest.txt -/liburiparser.a -/liburiparser.pc -/liburiparser.so* -/Makefile -/release-1.8.1.tar.gz -/Testing/ -/testrunner -/uriparser-*.tar.* -/uriparser-*.zip -/uriparse diff --git a/external/uriparser/.travis.yml b/external/uriparser/.travis.yml deleted file mode 100644 index 0096384..0000000 --- a/external/uriparser/.travis.yml +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (C) 2018 Sebastian Pipping -# Licensed under the MIT license - -language: cpp -dist: xenial - -addons: - apt: - sources: - # Clang 8: - - llvm-toolchain-xenial-8 - - ubuntu-toolchain-r-test - packages: - - clang-8 - - cmake - - lzip - # Documentation: - - doxygen - - graphviz - - qt4-dev-tools - - qtchooser - -script: - - set -e - - GTEST_VERSION=1.8.1 - ; GTEST_PREFIX=~/.local/ - ; wget https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz - && tar xf release-${GTEST_VERSION}.tar.gz - && ( cd googletest-release-${GTEST_VERSION}/ - && cmake - -DBUILD_SHARED_LIBS=ON - -DCVF_VERSION=${GTEST_VERSION} - -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} - . - && make - && make install ) - - mkdir build - - pushd build - - compile_flags=( - -pipe - - -O1 - -g - -fsanitize=address - -fno-omit-frame-pointer - - -Wall - -Wextra - -pedantic - ) - && CFLAGS="${compile_flags[*]} -std=c89" - && CXXFLAGS="${compile_flags[*]} -std=c++98" - && LDFLAGS='-g -fsanitize=address' - && cmake_args=( - -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} - - -Wdev - -Werror=dev - -Wdeprecated - -Werror=deprecated - - -DCMAKE_C_COMPILER=clang-8 - -DCMAKE_CXX_COMPILER=clang++-8 - -DCMAKE_C_FLAGS="${CFLAGS}" - -DCMAKE_CXX_FLAGS="${CXXFLAGS}" - -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" - -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" - -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" - ) - && cmake "${cmake_args[@]}" -DCMAKE_INSTALL_INCLUDEDIR=include123 .. # -Werror would fail checks! - - make VERBOSE=1 C_FLAGS="${CFLAGS} -fPIC -Werror" CXX_FLAGS="${CXXFLAGS} -Werror" all - - make VERBOSE=1 C_FLAGS="${CFLAGS} -fPIC -Werror" CXX_FLAGS="${CXXFLAGS} -Werror" test ARGS=--verbose - - cat Testing/Temporary/LastTest.log - - make install - - ./doc/release.sh - - make DESTDIR="${PWD}"/ROOT/ install - - find ROOT | sort - - popd - - pushd cmake/test_find_package - - cmake "${cmake_args[@]}" . - - make VERBOSE=1 - - ./hello - - popd - - git fetch --tags --unshallow origin # for "git describe" in make-distcheck.sh - - ./make-distcheck.sh -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_PREFIX} # without AddressSanitizer - - "! git status | fgrep -A100 'Untracked files:' # works best at the very end" diff --git a/external/uriparser/AUTHORS b/external/uriparser/AUTHORS deleted file mode 100644 index 5c59de2..0000000 --- a/external/uriparser/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Weijia Song -Sebastian Pipping diff --git a/external/uriparser/CMakeLists.txt b/external/uriparser/CMakeLists.txt deleted file mode 100644 index 4b1ce44..0000000 --- a/external/uriparser/CMakeLists.txt +++ /dev/null @@ -1,468 +0,0 @@ -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -cmake_minimum_required(VERSION 3.3) - -project(uriparser - VERSION - 0.9.5 - LANGUAGES - C -) - -# See https://verbump.de/ for what these numbers do -set(URIPARSER_SO_CURRENT 1) -set(URIPARSER_SO_REVISION 28) -set(URIPARSER_SO_AGE 0) - -include(CheckCCompilerFlag) -include(CheckFunctionExists) -include(CheckLibraryExists) -include(CheckSymbolExists) -include(CMakePackageConfigHelpers) -include(GNUInstallDirs) - -# -# Configuration -# -option(BUILD_SHARED_LIBS "Build shared libraries (rather than static ones)" ON) -option(URIPARSER_BUILD_DOCS "Build API documentation (requires Doxygen, Graphviz, and (optional) Qt's qhelpgenerator)" ON) -option(URIPARSER_BUILD_TESTS "Build test suite (requires GTest >=1.8.0)" ON) -option(URIPARSER_BUILD_TOOLS "Build tools (e.g. CLI \"uriparse\")" ON) -option(URIPARSER_BUILD_CHAR "Build code supporting data type 'char'" ON) -option(URIPARSER_BUILD_WCHAR_T "Build code supporting data type 'wchar_t'" ON) -option(URIPARSER_ENABLE_INSTALL "Enable installation of uriparser" ON) -option(URIPARSER_WARNINGS_AS_ERRORS "Treat all compiler warnings as errors" OFF) -set(URIPARSER_MSVC_RUNTIME "" CACHE STRING "Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC") - -if(NOT URIPARSER_BUILD_CHAR AND NOT URIPARSER_BUILD_WCHAR_T) - message(SEND_ERROR "One or more of URIPARSER_BUILD_CHAR and URIPARSER_BUILD_WCHAR_T needs to be enabled.") -endif() -if(URIPARSER_BUILD_TESTS AND NOT (URIPARSER_BUILD_CHAR AND URIPARSER_BUILD_WCHAR_T)) - message(SEND_ERROR "URIPARSER_BUILD_TESTS=ON requires both URIPARSER_BUILD_CHAR=ON and URIPARSER_BUILD_WCHAR_T=ON.") -endif() -if(URIPARSER_BUILD_TOOLS AND NOT URIPARSER_BUILD_CHAR) - message(SEND_ERROR "URIPARSER_BUILD_TOOLS=ON requires URIPARSER_BUILD_CHAR=ON.") -endif() - -macro(uriparser_apply_msvc_runtime_to ref) - string(REGEX REPLACE "/M[DT]d?" ${URIPARSER_MSVC_RUNTIME} ${ref} "${${ref}}") -endmacro() - -if(MSVC AND URIPARSER_MSVC_RUNTIME) - uriparser_apply_msvc_runtime_to(CMAKE_C_FLAGS) - uriparser_apply_msvc_runtime_to(CMAKE_C_FLAGS_DEBUG) - uriparser_apply_msvc_runtime_to(CMAKE_C_FLAGS_RELEASE) -endif() - -macro(uriparser_install) - if(URIPARSER_ENABLE_INSTALL) - install(${ARGN}) - endif() -endmacro() - -# -# Compiler checks -# -set(URIPARSER_EXTRA_COMPILE_FLAGS) - -check_c_compiler_flag("-fvisibility=hidden" URIPARSER_COMPILER_SUPPORTS_VISIBILITY) -if(URIPARSER_COMPILER_SUPPORTS_VISIBILITY) - set(URIPARSER_EXTRA_COMPILE_FLAGS "${URIPARSER_EXTRA_COMPILE_FLAGS} -fvisibility=hidden") -endif() - -if(URIPARSER_WARNINGS_AS_ERRORS) - if(MSVC) - add_definitions(/WX) - else() - set(URIPARSER_EXTRA_COMPILE_FLAGS "${URIPARSER_EXTRA_COMPILE_FLAGS} -Werror") - endif() -endif() - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${URIPARSER_EXTRA_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${URIPARSER_EXTRA_COMPILE_FLAGS}") - -# -# config.h -# -check_symbol_exists(wprintf wchar.h HAVE_WPRINTF) -check_function_exists(reallocarray HAVE_REALLOCARRAY) # no luck with CheckSymbolExists -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/UriConfig.h.in config.h) - -# -# C library -# -set(API_HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/UriBase.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/UriDefsAnsi.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/UriDefsConfig.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/UriDefsUnicode.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/Uri.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/uriparser/UriIp4.h -) -set(LIBRARY_CODE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriCommon.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriCommon.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriCompare.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriEscape.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriFile.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriIp4Base.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriIp4Base.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriIp4.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriMemory.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriMemory.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriNormalizeBase.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriNormalizeBase.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriNormalize.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriParseBase.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriParseBase.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriParse.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriQuery.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriRecompose.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriResolve.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/UriShorten.c -) - -add_library(uriparser - ${API_HEADER_FILES} - ${LIBRARY_CODE_FILES} -) - -if(NOT MSVC) - math(EXPR URIPARSER_SO_CURRENT_MINUS_AGE "${URIPARSER_SO_CURRENT} - ${URIPARSER_SO_AGE}") - set_property(TARGET uriparser PROPERTY VERSION ${URIPARSER_SO_CURRENT_MINUS_AGE}.${URIPARSER_SO_AGE}.${URIPARSER_SO_REVISION}) - set_property(TARGET uriparser PROPERTY SOVERSION ${URIPARSER_SO_CURRENT_MINUS_AGE}) - if(WIN32) - set_target_properties(uriparser PROPERTIES - OUTPUT_NAME uriparser - RUNTIME_OUTPUT_NAME uriparser-${URIPARSER_SO_CURRENT_MINUS_AGE} - ARCHIVE_OUTPUT_NAME uriparser) - endif() -endif() - -set_property( - TARGET - uriparser - PROPERTY - PUBLIC_HEADER "${API_HEADER_FILES}" -) - -target_compile_definitions(uriparser PRIVATE URI_LIBRARY_BUILD) -if (NOT BUILD_SHARED_LIBS) - target_compile_definitions(uriparser PUBLIC URI_STATIC_BUILD) -endif() -if(NOT URIPARSER_BUILD_CHAR) - target_compile_definitions(uriparser PUBLIC URI_NO_ANSI) -endif() -if(NOT URIPARSER_BUILD_WCHAR_T) - target_compile_definitions(uriparser PUBLIC URI_NO_UNICODE) -endif() -if(URIPARSER_COMPILER_SUPPORTS_VISIBILITY) - target_compile_definitions(uriparser PRIVATE URI_VISIBILITY) -endif() - -target_include_directories(uriparser - PUBLIC - $ - $ - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} # for config.h -) - -uriparser_install( - TARGETS - uriparser - EXPORT - uriparser - ARCHIVE - DESTINATION - ${CMAKE_INSTALL_LIBDIR} - LIBRARY - DESTINATION - ${CMAKE_INSTALL_LIBDIR} - RUNTIME - DESTINATION - ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER - DESTINATION - ${CMAKE_INSTALL_INCLUDEDIR}/uriparser -) - -# -# C command line tool -# -if(URIPARSER_BUILD_TOOLS) - add_executable(uriparse - ${CMAKE_CURRENT_SOURCE_DIR}/tool/uriparse.c - ) - - target_link_libraries(uriparse PUBLIC uriparser) - - if(HAIKU) - # Function inet_ntop needs -lsocket or -lnetwork (see pull request #45) - check_library_exists(socket inet_ntop "" HAVE_LIBSOCKET__INET_NTOP) - check_library_exists(network inet_ntop "" HAVE_LIBNETWORK__INET_NTOP) - if(HAVE_LIBSOCKET__INET_NTOP) - target_link_libraries(uriparse PUBLIC socket) - endif() - if(HAVE_LIBNETWORK__INET_NTOP) - target_link_libraries(uriparse PUBLIC network) - endif() - endif() - - if(WIN32) - target_link_libraries(uriparse PUBLIC ws2_32) - endif() - - uriparser_install( - TARGETS - uriparse - DESTINATION - ${CMAKE_INSTALL_BINDIR} - ) -endif() - -# -# C++ test runner -# -if(URIPARSER_BUILD_TESTS) - enable_language(CXX) - - if(MSVC AND URIPARSER_MSVC_RUNTIME) - uriparser_apply_msvc_runtime_to(CMAKE_CXX_FLAGS) - uriparser_apply_msvc_runtime_to(CMAKE_CXX_FLAGS_DEBUG) - uriparser_apply_msvc_runtime_to(CMAKE_CXX_FLAGS_RELEASE) - endif() - - enable_testing() - - find_package(GTest 1.8.0 REQUIRED) - - add_executable(testrunner - ${CMAKE_CURRENT_SOURCE_DIR}/test/FourSuite.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test/MemoryManagerSuite.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test/VersionSuite.cpp - - # These library code files have non-public symbols that the test suite - # needs to link to, so they appear here as well: - ${API_HEADER_FILES} - ${LIBRARY_CODE_FILES} - ) - - target_compile_definitions(testrunner PRIVATE URI_STATIC_BUILD) - - if(MSVC) - target_compile_definitions(testrunner PRIVATE -D_CRT_SECURE_NO_WARNINGS) - endif() - - target_include_directories(testrunner SYSTEM PRIVATE - ${GTEST_INCLUDE_DIRS} - ) - - target_include_directories(testrunner PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_BINARY_DIR} # for config.h - ) - - target_link_libraries(testrunner PUBLIC - ${GTEST_BOTH_LIBRARIES} - ) - - # NOTE: uriparser does not use pthreads itself but gtest does - find_package(Threads REQUIRED) - target_link_libraries(testrunner PRIVATE Threads::Threads) - - if(MSVC) - # Specify unwind semantics so that MSVC knowns how to handle exceptions - target_compile_options(testrunner PRIVATE /EHsc) - endif() - - add_test( - NAME - test - COMMAND - testrunner - ) - - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) -endif() - -# -# Doxygen API documentation -# -if(URIPARSER_BUILD_DOCS) - find_package(Doxygen REQUIRED dot doxygen) - - set(QHG_LOCATION "" CACHE FILEPATH "Path to qhelpgenerator program (default: auto-detect)") - if(NOT QHG_LOCATION) - find_package(Qt5Help QUIET) - if(TARGET Qt5::qhelpgenerator) - get_target_property(QHG_LOCATION Qt5::qhelpgenerator LOCATION) - mark_as_advanced(Qt5Core_DIR) - mark_as_advanced(Qt5Gui_DIR) - mark_as_advanced(Qt5Help_DIR) - mark_as_advanced(Qt5Sql_DIR) - mark_as_advanced(Qt5Widgets_DIR) - endif() - endif() - - include(FindHTMLHelp) - - # Generate Doxyfile - if(HTML_HELP_COMPILER) - set(GENERATE_HTMLHELP YES) - else() - set(GENERATE_HTMLHELP NO) - endif() - if(QHG_LOCATION) - set(GENERATE_QHP YES) - else() - set(GENERATE_QHP NO) - endif() - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in doc/Doxyfile @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/release.sh.in doc/release.sh @ONLY) - - add_custom_target(doc - ALL - COMMAND - ${DOXYGEN_EXECUTABLE} - Doxyfile - WORKING_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/doc - COMMENT - "Generating API documentation with Doxygen" - VERBATIM - ) - - uriparser_install( - DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/doc/html - DESTINATION - ${CMAKE_INSTALL_DOCDIR} - ) - if(QHG_LOCATION) - uriparser_install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/doc/uriparser-${PROJECT_VERSION}.qch - DESTINATION - ${CMAKE_INSTALL_DOCDIR} - ) - endif() -endif() - -# -# CMake files for find_package(uriparser [..] CONFIG [..]) -# -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/uriparser-config.cmake.in - cmake/uriparser-config.cmake - INSTALL_DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/uriparser-${PROJECT_VERSION}/ -) -write_basic_package_version_file( - cmake/uriparser-config-version.cmake - COMPATIBILITY SameMajorVersion # i.e. semver -) -export( - TARGETS - uriparser - FILE - cmake/uriparser-targets.cmake # not going to be installed -) -uriparser_install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/cmake/uriparser-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/cmake/uriparser-config-version.cmake - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/uriparser-${PROJECT_VERSION}/ -) -uriparser_install( - EXPORT - uriparser - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/uriparser-${PROJECT_VERSION}/ - NAMESPACE - uriparser:: -) - -# -# pkg-config file -# -if(NOT MSVC) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/liburiparser.pc.in liburiparser.pc @ONLY) - uriparser_install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/liburiparser.pc - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ - ) -endif() - -# -# Summary -# -message(STATUS "===========================================================================") -message(STATUS "") -message(STATUS "Configuration") -message(STATUS " Build type ............. ${CMAKE_BUILD_TYPE}") -message(STATUS " Shared libraries ....... ${BUILD_SHARED_LIBS}") -message(STATUS " Compiler flags") -message(STATUS " C .................... ${CMAKE_C_FLAGS}") -message(STATUS " C++ .................. ${CMAKE_CXX_FLAGS}") -message(STATUS " Linker flags") -message(STATUS " Executable ........... ${CMAKE_EXE_LINKER_FLAGS}") -message(STATUS " Module ............... ${CMAKE_MODULE_LINKER_FLAGS}") -message(STATUS " Shared ............... ${CMAKE_SHARED_LINKER_FLAGS}") -message(STATUS " Paths") -message(STATUS " Prefix ............... ${CMAKE_INSTALL_PREFIX}") -message(STATUS " qhelpgenerator ....... ${QHG_LOCATION}") -message(STATUS "") -message(STATUS " Features") -message(STATUS " Code for char * ...... ${URIPARSER_BUILD_CHAR}") -message(STATUS " Code for wchar_t * ... ${URIPARSER_BUILD_WCHAR_T}") -message(STATUS " Tools ................ ${URIPARSER_BUILD_TOOLS}") -message(STATUS " Test suite ........... ${URIPARSER_BUILD_TESTS}") -message(STATUS " Documentation ........ ${URIPARSER_BUILD_DOCS}") -message(STATUS "") -if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") - message(STATUS "Continue with") - message(STATUS " make") - message(STATUS " make test") - message(STATUS " sudo make install") - message(STATUS "") -endif() -message(STATUS "===========================================================================") diff --git a/external/uriparser/COPYING b/external/uriparser/COPYING deleted file mode 100644 index 261c741..0000000 --- a/external/uriparser/COPYING +++ /dev/null @@ -1,36 +0,0 @@ -uriparser - RFC 3986 URI parsing library - -Copyright (C) 2007, Weijia Song -Copyright (C) 2007, Sebastian Pipping -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - 2. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/external/uriparser/ChangeLog b/external/uriparser/ChangeLog deleted file mode 100644 index a3d7844..0000000 --- a/external/uriparser/ChangeLog +++ /dev/null @@ -1,533 +0,0 @@ -NOTE: uriparser is looking for help with a few things: - https://github.com/uriparser/uriparser/labels/help%20wanted - If you can help, please get in touch. Thanks! - -2021-03-18 -- 0.9.5 - - * Fixed: Fix a bug regarding section "5.2.4. Remove Dot Segments" - of RFC 3986 that affected both normalization and reference resolution - with regard to trailing slashes (GitHub #92, #97) - Thanks to Dan Pape for the report! - * Fixed: MinGW: Fix name of static library (GitHub #90) - Thanks to SpaceIm for the patch and Sandro Mani for review! - * Fixed: Use correct inline marker "__forceinline" for Intel C++ Compiler - (GitHub #93) - Thanks to jensenrichardson for the patch! - * Fixed: Link against pthreads for (default) -DURIPARSER_BUILD_TESTS=ON - (GitHub #99, #100) - * Fixed: When integrated using CMake function add_subdirectory, installation - could fail due to lack of prefix ${CMAKE_CURRENT_SOURCE_DIR} (GitHub #98) - Thanks for the patch to Shehzan Mohammed! - * Fixed: Addressed MSVC compile warning about lack of /EHsc when compiling - the C++ test suite code (GitHub #102) - * Fixed: Stopped misadvertising wide characters as Unicode support - (GitHub #104) - * Added: CMake option URIPARSER_WARNINGS_AS_ERRORS=(ON|OFF) - to turn compile warnings into errors, defaults to "OFF" (GitHub #102) - * Improved: pkg-config: Use ${prefix} and ${exec_prefix} to ease - overriding variables using --define-variable=NAME=VALUE, - e.g. as done on OpenWRT (GitHub #91) - Thanks to Karel KoÄí for the pull request! - * Improved: Auto-detection of the qhelpgenerator command based on CMake - package "Qt5Help" when available. CMake option "QHG_LOCATION" can still - be used to enforce a specific location (GitHub #103) - Thanks for his help to Andreas Sturmlechner! - * Improved: Make documentation use pkg-config in example on how to - check for uriparser from within configure.ac (GNU Autoconf) - (GitHub #37, #106) - * Improved: In testing code, add a missing 'extern "C"' (GitHub #109) - Thanks to Jørgen Ibsen for the patch! - * Soname: 1:28:0 — see https://verbump.de/ for what these numbers do - -2020-05-31 -- 0.9.4 - - * Fixed: testrunner: No longer crashes when compiled with NDEBUG (GitHub #67) - * Fixed: CMake: Support GTest 1.8.0 (GitHub #68) - Thanks to Ryan Schmidt for the related report! - * Fixed: CMake: Use variable GTEST_INCLUDE_DIRS (with plural "S") rather than - GTEST_INCLUDE_DIR (GitHub #79, #81) - Thanks to Wouter Beek for the related report! - * Improved: CMake: Send config summary to stdout, not stderr (GitHub #72) - Thanks to Scott Donelan for the patch! - * Improved: Make -DURIPARSER_BUILD_TESTS=OFF unlock compilation without - a C++ compiler; thanks to Fabrice Fontaine for the patch! (GitHub #69) - * Added: Functions to make UriUri[AW] instances independent of the original - URI string (GitHub #77 and #78) - New functions: - uriMakeOwner[AW] - uriMakeOwnerMm[AW] - * Added: CMake option URIPARSER_ENABLE_INSTALL to toggle installation of - files, defaults to "ON" (GitHub #74, #75) - Thanks to Scott Donelan for the patch! - * Soname: 1:27:0 - -2019-04-28 -- 0.9.3 - - * Fixed: pkg-config: Fix version line in liburiparser.pc (GitHub #65) - * Changed: MinGW: Add library version suffix to DLL name - Thanks to Sandro Mani for the patch! (GitHub #63, #64) - * Soname: 1:26:0 - -2019-04-22 -- 0.9.2 - - * Fixed: Add missing extern "C" wrapper to UriIp4.h for use from C++ - * Fixed: Linking error for symbol defaultMemoryManager from mixing C and C++ - Thanks to Jørgen Ibsen for the report! (GitHub #52) - * Fixed: Link errors on Haiku regarding function inet_ntop (GitHub #45) - Thanks to Schrijvers Luc for the patch! - * Fixed: Mark API functions with __declspec(dllexport) and - __declspec(dllimport) in *.h files for Visual Studio (GitHub #60) - * Improved: Use -fvisibility=hidden by default with supporting compilers, - e.g. GCC and Clang (GitHub #60) - * Changed: Migrated from GNU Autotools to CMake (GitHub #17, #47, #56, #59) - Thanks for their support with the CMake migration to: - - David Demelier - - Jørgen Ibsen - - KangLin - - Kouhei Sutou - - myd7349 - - Richard Hodges - - Zachary Lund - * Removed: All Windows-related build systems other than CMake - * Soname: 1:25:0 - -2019-01-02 -- 0.9.1 - ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: [CVE-2018-20721] - Out-of-bounds read in uriParse*Ex* for incomplete URIs with IPv6 - addresses with embedded IPv4 address, e.g. "//[::44.1"; - mitigated if passed parameter points to readable memory - containing a '\0' byte. - Commit cef25028de5ff872c2e1f0a6c562eb3ea9ecbce4 - Thanks to Joergen Ibsen for the report! ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: When parsing a malformed URI with an IPvFuture address - (e.g. "http://[vA.123456" missing "]"), errorPos would point to the first - character after "v" than the actual position of the error (here: the end - of the string) - * Fixed: uriToStringCharsRequired* reported 1 more byte than actually needed - for IPv4 address URIs (GitHub #41); Thanks to @gyh007 for the patch! - * Fixed: Compilation with MinGW - Thanks to Sandro Mani for the patch! - * Fixed: Drop use of asprintf from the test suite for MinGW (GitHub #40) - * Improved: For parse errors, waterproof errorPos <= afterLast - * Soname: 1:24:0 - -2018-10-27 -- 0.9.0 - ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: [CVE-2018-19198] - Out-of-bounds write in uriComposeQuery* and uriComposeQueryEx* - Commit 864f5d4c127def386dd5cc926ad96934b297f04e - Thanks to Google Autofuzz team for the report! - * Fixed: [CVE-2018-19199] - Detect integer overflow in uriComposeQuery* and uriComposeQueryEx* - Commit f76275d4a91b28d687250525d3a0c5509bbd666f - Thanks to Google Autofuzz team for the report! - * Fixed: [CVE-2018-19200] - Protect uriResetUri* against acting on NULL input - Commit f58c25069cf4a986fe17a80c5b38687e31feb539 ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: Be fully compliant to C89 (Gitub #28) and C++98 in test code - * Fixed: Fix off-by-one in uriComposeQueryCharsRequired* and ...Ex* - Reported space requirements were 1 byte bigger than necessary - * Changed: Marked as deprecated: - Deprecated functions: - uriNormalizeSyntaxMaskRequired[AW] - uriParseUri[AW] - uriParseUriEx[AW] - * Added: Add convenience functions to ease user code to parse a single URI - New functions: - uriParseSingleUri[AW] - uriParseSingleUriEx[AW] - uriParseSingleUriExMm[AW] - * Added: Support for custom memory managers (GitHub #26, #35), see Doxygen - New functions (as extension of existing ones): - uriAddBaseUriExMm[AW] - uriComposeQueryMallocExMm[AW] - uriDissectQueryMallocExMm[AW] - uriFreeQueryListMm[AW] - uriFreeUriMembersMm[AW] - uriNormalizeSyntaxExMm[AW] - uriParseSingleUriExMm[AW] - uriRemoveBaseUriMm[AW] - New functions (for convenience): - uriCompleteMemoryManager - uriEmulateCalloc - uriEmulateReallocarray - uriTestMemoryManager - New error codes: - URI_ERROR_MEMORY_MANAGER_FAULTY - URI_ERROR_MEMORY_MANAGER_INCOMPLETE - New types: - UriFuncCalloc - UriFuncFree - UriFuncMalloc - UriFuncRealloc - UriFuncReallocarray - UriMemoryManager - * Added: Add non-void versions of uriNormalizeSyntaxMaskRequired* - New functions: - uriNormalizeSyntaxMaskRequiredEx[AW] - * Changed: Migrate test suite from CppTest to GoogleTest 1.8.1 - * Improved: Make test suite free of memory leaks (GitHub #31) - Thanks to AddressSanitizer! - * Removed: Support for pointless define URI_SIZEDOWN (GitHub #29) - Related configure option --enable-sizedown has also been removed. - * Soname: 1:23:0 - -2018-08-18 -- 0.8.6 - - * Fixed: Bad/NULL .hostText.afterLast when parsing certain rather pathologic - but well-formed URIs with empty host (e.g. "//:%aa@") (GitHub #15) - Thanks to Kurt Schwehr for the report! - * Fixed: Fix uriRemoveBaseUri for case where scheme, host name, - IPvFuture address or path segments of the source address were - string prefixes of the related counterpart in the base URI. - Thanks to Yang Yu for the patch! (GitHub #19, #20) - * Fixed: Make UriStringToUnixFilename and UriStringToWindowsFilename - support minimal representation a la RFC 8089, e.g. file:/bin/bash - (compare to file:///bin/bash with three slashes) (GitHub #12, #14) - Thanks to Zane van Iperen for the report! - * Fixed: Documentation typos (GitHub #10, #11) - Thanks to Graham Percival! - * Improved: Made API docs of uriRemoveBaseUri more clear - (related to GitHub #19) - * Soname: 1:22:0 - -2018-02-07 -- 0.8.5 - - * Changed: The uriparser project has moved from SourceForge to GitHub: - Code + issue tracker: https://github.com/uriparser/uriparser - New website: https://uriparser.github.io/ - Please update any links of yours, accordingly. Thank you! - * Fixed: Memleak in out-of-memory clean-up code - of URI normalization, related to SF.net bug #28. - Thanks to Chris Hills for the report! - * Fixed: Fix compilation of uriparse(1) on FreeBSD - Thanks to Ed Schouten for the patch! - * Fixed: Fix C90 compilation errors - Thanks to Joel Cunningham for the patches! - * Fixed: Space requirements documented for uriWindowsFilenameToUriStringA - given URI "file://server1/file1.txt" (SF.net bug #31) - Thanks to threedyd for the report! - * Fixed: Compiler warnings - Thanks to Joel Cunningham for the patches! - * Fixed: Stop exporting internal function RemoveBaseUriImpl - Thanks to Joel Cunningham for the report! - * Fixed: API documentation front page no longer empty with Doxygen 1.8.13 - * Fixed: "make -C doc install" fixed for lack of .map files - * Improved: Communicate that absolutePath is always URI_FALSE for URIs - with a host in uriparse CLI tool output and Uri.h header - (GitHub #2, SF.net #30) - * Soname: 1:21:0 - -2015-10-12 -- 0.8.4 - - * Fixed: Stack overflow on parsing malformed IPv6 addresses with - more than eigtht quads. Thanks to Alexander Klink for the report! - * Soname: 1:20:0 - -2015-10-04 -- 0.8.3 - - * Fixed: uriCompareRange reported NULL pointer and range of - length zero as equal, by mistake. - Thanks to Robert Kausch and his Coverity report. - * Fixed: Use-after-free in out-of-memory code of uriMakeOwner. - Thanks to Chris Hills and his Klocwork-based report (SF.net bug #28) - * Soname: 1:19:0 - -2015-04-27 -- 0.8.2 - - * Fixed: Broken conversion from/to Windows network shares (SF.net bug #21) - Thanks to Adam Gross and Dmitry Repkin! - * Fixed: Limit uriCompareRange return values to -1/0/1 (SF.net bug #24) - As a side effect, this fixes the test suite for AArch64. - Thanks to Marcin Juszkiewicz for the patch! - * Fixed: MinGW Makefile: - LIB_DIR fixed from ../../lib leftover to ../../src (SF.net bug #27) - Thanks to Dmytro Zagashev for the report! - * Fixed: Add missing NULL checks to UriStringToFilename (SF.net bug #25) - Thanks to Jerome Custodio for the report! - * Changed: Leave inlining decisions to GCC - * Soname: 1:18:0 - -2014-10-20 -- 0.8.1 - - * Fixed: Sync URI_VER_* preprocessor defines (were at 0.7.6, SF.net bug #23) - * Fixed: Bug in internal function that may flip uriEqualsUri results around - * Added: Function uriAddBaseUriEx allowing to resolve URIs with - a scheme identical to that of the base URI to resolve against - as if the URI to resolve had no scheme specified, when flag - URI_RESOLVE_IDENTICAL_SCHEME_COMPAT is specified - (SF.net feature request #4) - * Soname: 1:17:0 - -2014-07-12 -- 0.8.0.1 - - * Fixed: ISO C90 warnings (SF.net bug #20) - * Changed: No longer ship RFC documents (to make things easier for Debian) - * Soname: 1:16:0 - -2013-12-20 -- 0.8.0 - - * Fixed: Resolution of relative URI "/" broken - Thanks to Mo McRoberts for the patch! - * Fixed: uriAddBaseUri produced uriUri objects with both host - and the absolutePath flag set (while the absolutePath flag - should only be true for URI objects without a host) when - resolving absolute URIs like "/" or "/foo/bar". - Now the absolutePath flag is set to URI_FALSE and an empty - segment is added as necessary - * Fixed: .errorCode could end up unset, previously - Thanks to Radu Hociung for the patch! (SF.net bug #16) - * Fixed: Resolve use of non-POSIX "sed -r" used when building - documentation (SF.net bug #18) - Thanks to Ryan Schmidt for reporting! - * Fixed: Build DLL with -no-undefined on Windows - Thanks to Michel Zou for the patch! (SF.net bug #19) - * Added: Command line tool "uriparse" - Thanks to Radu Hociung for coding! (SF.net feature request #3) - * Soname: 1:15:0 - -2013-08-24 -- 0.7.9 - - * Fixed: Error position ended up as NULL for some syntax errors. - Thanks to Daniel Solano Gómez for the patch! (SF.net bug #14) - * Soname: 1:14:0 - -2013-05-13 -- 0.7.8 - - * Fixed: Fix dissection of query string "q=hello&x=&y=" (SF.net bug #12) - Thanks to Marc Novakowski for reporting! - * Soname: 1:13:0 - -2012-04-05 -- 0.7.7 - - * Fixed: Fix rejection of some valid characters for userinfo - section, e.g. "http://%2Fuser:%2F21@host/" (SF.net bug #11) - * Fixed: Fix rejection of valid double colon in userinfo - section, e.g. "http://::@host/" - * Soname: 1:12:0 - -2012-01-20 -- 0.7.6 - - * Fixed: Qt Compressed Help file was not installed - * Fixed: Shadow/VPATH build doc generation - * Fixed: Compile error from Doxygen when configuring with - neither --enable-doc nor --disable-doc - * Fixed: Code documentation errors - Thanks to Valentin Haenel for the patch! - * Fixed: Fix include path in pkg-config, i.e. remove - "/uriparser" suffix as uriparser's headers are meant to - be included by statements like #include . - Thanks to Philip de Nier for reporting! - * Fixed: Compilation in context of Eclipse + Cygwin + wchar_t - (SF.net bug #10) - Thanks to Gary Mazzaferro for reporting! - * Fixed: Selection of supported character widths at build - time: or or both - * Added: configure parameters to disable either character - widths: --disable-char, --disable-wchar_t - * Soname: 1:11:0 - -2009-03-04 -- 0.7.5 - - * Added: pkg-config file - * Fixed: File Doxyfile.in was missing from release archives - Thanks to Rakesh Pandit for reporting! - * Fixed: Doc generation troubles - * Changed: No longer shipping bundled libcpptest - * Changed: New dependencies: - - libcpptest 1.1.0 or later - - pkg-config - The libcpptest dependency can be disabled through - configuring with --disable-test, which excludes the - test suite from compilation. - * Soname: 1:10:0 - -2008-12-23 -- 0.7.4 - - * Fixed: Null pointer de-referencing when dissecting query - strings starting with "&" right after "?" (SF.net bug #7). - Thanks to Harvey Vrsalovic for reporting! - * Fixed: Memory leak in uriFreeQueryList function (SF.net bug #6) - Thanks to Daniel Chapiesky for reporting! - * Fixed: Memory leak in uriNormalizeSyntax(Ex) functions (SF.net bug #6) - Thanks to Daniel Chapiesky for reporting! - * Improved: Nested configure hacks resolved - * Soname: 1:9:0 - -2008-11-08 -- 0.7.3 - - * Fixed: Missing NULL check in parsing routines - Thanks to Sezai Tekin for reporting! - * Fixed: uriparser now builds on Cygwin - * Fixed: Now shipping gnulib's config.guess from HEAD - which is suitable for Haiku (SF.net bug #5) - * Changed: swprintf requirement resolved - * Changed: Build system changes: - - configure option --enable-doc added - - configure.in renamed to configure.ac - - some Autotools files moved to build-aux directory - * Added: Qt Assistant documentation output: - - Qt Compressed Help (.qch) at - - Qt Help Project (.qhp) at - Generation requires Doxygen 1.5.7.1-20081103 or later. - * Soname: 1:8:0 - -2008-09-01 -- 0.7.2 - - * Fixed: Bad cleanup logic in functions - - uriAddBaseUri(..) - - uriRemoveBaseUri(..) - Previously you needed to call uriFreeUriMembers on return code - URI_ERROR_MALLOC and only then. So that's why these functions now - take cleanup off your shoulders. An extra call to uriFreeUriMembers - from your side is still needed in case of success. - * Soname: 1:7:0 - -2008-04-27 -- 0.7.1 - - * Fixed: Bogus syntax error when parsing URIs with port-like - passwords, e.g. "http://user:21@host/" (SF.net bug #1) - Thanks to Friedrich Delgado Friedrichs for reporting! - * Fixed: Parser did not handle trailing slashes correctly in some cases, - which also made the structures produced from parsing "http://e.com/" - and "http://e.com" indistinguishable. (SF.net bug #2) - Thanks to Edward Z. Yang for reporting! - -2008-04-04 -- 0.7.0 - - * Added: Dissection and composition of query strings - * Added: Documentation improvements - (in|out|inout indicators, addition of \since and \see) - * Changed: Code::Blocks project files updated from file format - version 1.4 to 1.6, which is produced by Code::Blocks 8.02 - * Added: Code::Blocks workspace file - * Soname: 1:5:0 - -2008-02-25 -- 0.6.4 - - * Added: Syntax-based normalization can now handle relative URIs, - e.g. "../../a/b/.././c" is normalized to "../../a/c" - * Fixed: Normalization code could free foreign memory - * Fixed: Normalization processed the path segment even when asked not to - * Added: MinGW Makefile and related readme - Thanks to Michael Anthony Puls II! - * Fixed: Documentation bug not requiring enough memory for the output - buffer when converting a relative file URI back to a filename - * Soname: 1:4:0 - -2008-02-11 -- 0.6.3 - - * Fixed: Two major crash bugs in normalization code - Thanks to Adrian Manrique for the patch! - * Added: Brief usage tutorial - * Soname: 1:3:0 - -2008-02-08 -- 0.6.2 - - * Fixed: Freeing a normalized URI like "http://test?" - caused a crash. Thanks to Adrian Manrique for reporting! - * Fixed: Filename <--> URI string conversion helpers can - now handle relative URIs and filenames - * Soname: 1:2:0 - -2007-12-23 -- 0.6.1 - - * Fixed: Percent-encodings in hostnames were not repaired during normalization. - Thanks to Adrian Manrique for reporting! - * Fixed: Percent-encodings were fixed after dot removal not before during - normalization. - Thanks to Adrian Manrique for reporting! - * Fixed: Include path order bug - Thanks to Ed Schouten for reporting this! - * Fixed: Shadow builds now possible - Thanks to Adeodato Simó for the patch! - * Added: Version guards for Autoconf/Automake - Thanks to Martin Michlmayr for reporting! - * Soname: 1:1:0 - -2007-09-17 -- 0.6.0 - - * Fixed: Proper soname updates from now on, starting at 1:0:0 - * Removed: Visual Studio 2003 project files - -2007-09-13 -- 0.5.2 - - * Added: RemoveBaseUri function to create URI references - * Added: Unix/Windows filename <--> URI string conversion helpers - * Added: EscapeEx function to escape text blocks without zero termination - * Fixed: Bug in ToString for URIs with scheme, path, but no host (e.g. "f:/.//g") - * Fixed: AddBase now resolves ".//g" with base "f:/a" to "f:/.//g" instead of - "f://g" which would result in "g" becoming the authority part when parsing - a recomposition (ToString) of that URI structure. This is a whole in RFC 3986, - see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html for details. - -2007-08-09 -- 0.5.1 - - * Fixed: Empty host bug (URIs like "///g") - * Fixed: Relative URIs are no longer touched by normalization - * Fixed: MergePath failed for empty paths - * Fixed: Bug with "." segments in AddBase - All of the above revealed by test cases from 4Suite (http://4suite.org/) - -2007-07-28 -- 0.5.0 - - * Added: Syntax-based normalization - * Added: Percent-encoding function Escape - * Improved: Malloc/NULL checks added - * Added: New function UnescapeInPlaceEx can also decode '+' to ' ' - and convert line breaks - * Added: Exact space computation for ToString, see ToStringCharsRequired - * Added: --enable-sizedown for saving space and slower code - * Fixed: Two internal functions were exposed in the API by mistake: - uriPushToStack and uriStackToOctet - * Added: Visual Studio 2005 project files - * Removed: Legacy code (removal was announced for 0.5.0) - -2007-07-06 -- 0.4.1 - - * Fixed: ToString did not work for IPv4 and IPv6 hosts - -2007-07-03 -- 0.4.0 - - * Added: References resolution (think relative to absolute) - * Added: Naive URI equality check - * Added: URIs can now be converted back to strings - * Fixed: The first path segment of a relative URI was eaten - (functions ParseSegmentNz and ParseMustBeSegmentNzNc) - * Fixed: uri->scheme.first was not reset in some cases - (function ParseMustBeSegmentNzNc) - * Improved: Test suite now built on "make check", not before - * Fixed: Test suite always returned 0 (success) - -2007-04-23 -- 0.3.4 - - * Added: Shared library support (moved to libtool) - -2007-04-03 -- 0.3.3 - - * Fixed: Now unix EOLs constantly - * Fixed: Added forgotten files to release package - -2007-03-31 -- 0.3.2 - - * Fixed: Now compiles on FreeBSD - -2007-03-28 -- 0.3.1 - - * Fixed: Now compiles on Mac OS X - -2007-03-26 -- 0.3.0 - - * Added: New API, old marked deprecated - * Added: Added support for wide strings (think wchar_t) - * Added: Doxygen code documentation - * Added: Test suite using CppTest - * Changed: Library code is now licensed under the new BSD license. - The test suite code is licensed under LGPL. - -2006-12-08 -- 0.2.1 diff --git a/external/uriparser/GOALS.txt b/external/uriparser/GOALS.txt deleted file mode 100644 index a906a2a..0000000 --- a/external/uriparser/GOALS.txt +++ /dev/null @@ -1,46 +0,0 @@ -== Requirements == - (1) URI parser fully conforming to the - latest URI RFC. Currently this is RFC 3986: - http://tools.ietf.org/html/rfc3986 - - (2) Based on an LL(1) grammar, at least mainly. - Not using a jump table but one function per - rule instead. - - (3) Library licensed under "New BSD license". - http://www.opensource.org/licenses/bsd-license.php - Test suite code licensed under LGPL. - http://www.opensource.org/licenses/lgpl-license.php - - (4) Written in ANSI/ISO C. - - (5) Portable. Must compile with GCC, MinGW, - Visual Studio 200[35]. - - (6) "OOP-C" -> thread safe, no shared globals - between two parser "instances" - - (7) Support for and without internal - conversion. Two versions of all functions - from the public interface. - - (8) Doxygen Code documentation at least for all - interface functions and structures. - http://www.stack.nl/~dimitri/doxygen/index.html - - (9) Sun Java code conventions for all C/C++ code. - http://java.sun.com/docs/codeconv/ - -(10) #include "xxx" for files in same folder. - #include for files from include folders. - -(11) Use GoogleTest for unit testing. - https://github.com/google/googletest - -(12) Implement algorithm for reference resolution - -(13) Implement algorithm for normalization and - comparison - -== Optional goals == - (A) C++ Wrapper classes (uriparser++?) diff --git a/external/uriparser/README.md b/external/uriparser/README.md deleted file mode 100644 index 3f92bfc..0000000 --- a/external/uriparser/README.md +++ /dev/null @@ -1,84 +0,0 @@ -[![Build and test](https://github.com/uriparser/uriparser/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/uriparser/uriparser/actions/workflows/build-and-test.yml) -[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/uriparseradmin/uriparser?svg=true)](https://ci.appveyor.com/project/uriparseradmin/uriparser) - - -# uriparser - -uriparser is a -strictly [RFC 3986](http://tools.ietf.org/html/rfc3986) compliant -URI parsing and handling library -written in C89 ("ANSI C"). -uriparser is cross-platform, -fast, -supports both `char` and `wchar_t`, and -is licensed under the [New BSD license](https://github.com/uriparser/uriparser/blob/master/COPYING). - -To learn more about uriparser, -please check out [https://uriparser.github.io/](https://uriparser.github.io/). - - -# Example use from an existing CMake project -```cmake -project(hello VERSION 1.0) - -find_package(uriparser 0.9.2 CONFIG REQUIRED char wchar_t) - -add_executable(hello - hello.c -) - -target_link_libraries(hello PUBLIC uriparser::uriparser) -``` - - -# Compilation - -## Compilation (standalone, GNU make, Linux) -```console -# mkdir build -# cd build -# cmake -DCMAKE_BUILD_TYPE=Release .. # see CMakeLists.txt for options -# make -# make test -# make install -``` - -## Available CMake options (and defaults) -```console -# rm -f CMakeCache.txt ; cmake -LH . | grep -B1 ':.*=' | sed 's,--,,' -// Build shared libraries (rather than static ones) -BUILD_SHARED_LIBS:BOOL=ON - -// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ... -CMAKE_BUILD_TYPE:STRING= - -// Install path prefix, prepended onto install directories. -CMAKE_INSTALL_PREFIX:PATH=/usr/local - -// Path to qhelpgenerator program (default: auto-detect) -QHG_LOCATION:FILEPATH= - -// Build code supporting data type 'char' -URIPARSER_BUILD_CHAR:BOOL=ON - -// Build API documentation (requires Doxygen, Graphviz, and (optional) Qt's qhelpgenerator) -URIPARSER_BUILD_DOCS:BOOL=ON - -// Build test suite (requires GTest >=1.8.0) -URIPARSER_BUILD_TESTS:BOOL=ON - -// Build tools (e.g. CLI "uriparse") -URIPARSER_BUILD_TOOLS:BOOL=ON - -// Build code supporting data type 'wchar_t' -URIPARSER_BUILD_WCHAR_T:BOOL=ON - -// Enable installation of uriparser -URIPARSER_ENABLE_INSTALL:BOOL=ON - -// Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC -URIPARSER_MSVC_RUNTIME:STRING= - -// Treat all compiler warnings as errors -URIPARSER_WARNINGS_AS_ERRORS:BOOL=OFF -``` diff --git a/external/uriparser/THANKS b/external/uriparser/THANKS deleted file mode 100644 index 90e371b..0000000 --- a/external/uriparser/THANKS +++ /dev/null @@ -1,65 +0,0 @@ -Adam Frisby -Adam Gross -Adeodato Simó -Adrian Manrique -Alexander Klink -Arkadiusz Miskiewicz -Andreas Sturmlechner -Blair Sadewitz -Chris Hills -Cristian Rodriguez -Dan Pape -Daniel Chapiesky -Daniel Solano Gómez -David Demelier -Dennis Veatch -Dmitry Repkin -Dmytro Zagashev -Dr. Michael Lauer -Ed Schouten -Edward Z. Yang -Eren Türkay -Fabrice Fontaine -Friedrich Delgado Friedrichs -Gary Mazzaferro -Graham Percival -Harvey Vrsalovic -jensenrichardson -Jerome Custodio -Joel Cunningham -Jørgen Ibsen -Juan Pablo González Tognarelli -KangLin -Karel KoÄí -Kouhei Sutou -Kurt Schwehr -Marc Novakowski -Marcin Juszkiewicz -Martin Michlmayr -Michael Anthony Puls II -Michelino Chionchio -Michel Zou -Mo McRoberts -myd7349 -Periklis Akritidis -Philip de Nier -Radu Hociung -Ralf S. Engelschall -Rakesh Pandit -René Rebe -Richard Hodges -Robert Buchholz -Robert Kausch -Ryan Schmidt -Sandro Mani -Schrijvers Luc -Scott Donelan -Sezai Tekin -Shehzan Mohammed -SpaceIm -Valentin Haenel -Vitaly Lipatov -Yang Yu -Wouter Beek -Zachary Lund -Zane van Iperen diff --git a/external/uriparser/TODO.txt b/external/uriparser/TODO.txt deleted file mode 100644 index d3df73b..0000000 --- a/external/uriparser/TODO.txt +++ /dev/null @@ -1,30 +0,0 @@ -== BEFORE NEXT RELEASE == - * Look for more bad cleanup logic - -== SOON == - * migrate structures to d-pointers to - - hide low-level details - - improve ABI compatibility - * try to remove need for free after parser fail? - * add more responsibility/ownership/init info to docs - * samba filename conversion? - * (g/s)etters for single components? - * Add example "uritool": - * uritool check - * uritool getHost - * uritool setHost - * ... - * Filename helpers - * samba shares - * pipe characters? C:/C| - * Test owner code - * Implement CleanBase (strips off last component, query and stuff) - * Implement Clone - * Test Equals - * Code TODOs - * Make hostText from hostData? - -== LATER == - * Enable/disable single components/algorithms? - * Pretty/smarter IPv6 stringification - * Reduce recursion, replace some by loops diff --git a/external/uriparser/appveyor.yml b/external/uriparser/appveyor.yml deleted file mode 100644 index 7e36cdb..0000000 --- a/external/uriparser/appveyor.yml +++ /dev/null @@ -1,99 +0,0 @@ -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -version: '{build}-{branch}' - -configuration: - - Debug -# - Release - -environment: - GTEST_VERSION: 1.8.1 - - # https://www.appveyor.com/docs/windows-images-software/ - matrix: - # Visual Studio 2015, 32 bit - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - CMAKE_GENERATOR: Visual Studio 14 2015 - PLATFORM: Win32 - - # Visual Studio 2015, 64 bit - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - CMAKE_GENERATOR: Visual Studio 14 2015 Win64 - PLATFORM: x64 - - # Visual Studio 2017, 32 bit - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - CMAKE_GENERATOR: Visual Studio 15 2017 - PLATFORM: Win32 - - # Visual Studio 2017, 64 bit - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - CMAKE_GENERATOR: Visual Studio 15 2017 Win64 - PLATFORM: x64 - -before_build: - - curl -fsSL -o release-%GTEST_VERSION%.zip https://github.com/google/googletest/archive/release-%GTEST_VERSION%.zip - - unzip -q release-%GTEST_VERSION%.zip - - cd googletest-release-%GTEST_VERSION% - - cmake - -G "%CMAKE_GENERATOR%" - -DCVF_VERSION=%GTEST_VERSION% - . - - cmake --build . --config Release -- /m -# BEGIN Enrich folder to make FindGTest.cmake happy - - md googletest\lib - - copy googlemock\gtest\Release\gtest.lib googletest\lib - - copy googlemock\gtest\Release\gtest_main.lib googletest\lib -# END - - cd .. - - mkdir build - - cd build -# NOTE: GTEST_ROOT is relative to source CMakeLists.txt, not the build directory - - cmake - -G "%CMAKE_GENERATOR%" - -DGTEST_ROOT=googletest-release-%GTEST_VERSION%/googletest - -DURIPARSER_BUILD_DOCS=OFF - -DURIPARSER_MSVC_RUNTIME=/MT - -DURIPARSER_WARNINGS_AS_ERRORS=ON - .. - -build: - parallel: true - project: $(APPVEYOR_BUILD_FOLDER)\build\$(APPVEYOR_PROJECT_NAME).sln - -test_script: - - '%APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%\testrunner.exe' diff --git a/external/uriparser/cmake/.gitignore b/external/uriparser/cmake/.gitignore deleted file mode 100644 index 3142a21..0000000 --- a/external/uriparser/cmake/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/uriparser-config.cmake -/uriparser-config-version.cmake -/uriparser-targets.cmake diff --git a/external/uriparser/cmake/test_find_package/.gitignore b/external/uriparser/cmake/test_find_package/.gitignore deleted file mode 100644 index e41efe9..0000000 --- a/external/uriparser/cmake/test_find_package/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/CMakeCache.txt -/CMakeFiles/ -/Makefile -/cmake_install.cmake -/hello diff --git a/external/uriparser/cmake/test_find_package/CMakeLists.txt b/external/uriparser/cmake/test_find_package/CMakeLists.txt deleted file mode 100644 index a9609c5..0000000 --- a/external/uriparser/cmake/test_find_package/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -cmake_minimum_required(VERSION 3.0) - -project(test-find-package VERSION 1.0) - - -# Cover version mismatch -find_package(uriparser 9999 CONFIG QUIET) -if (uriparser_FOUND) - message(SEND_ERROR "Was not expecting for find uriparser 9999.x.x") -endif() - - -# Cover invalid required component -find_package(uriparser 0.9.1 CONFIG QUIET - COMPONENTS - invalid123 -) -if (uriparser_FOUND) - message(SEND_ERROR "Was not expecting for find uriparser with component \"invalid123\"") -endif() - - -# Cover invalid optional component -find_package(uriparser 0.9.1 CONFIG REQUIRED - COMPONENTS - char - wchar_t - OPTIONAL_COMPONENTS - invalid123 -) -if (NOT uriparser_FOUND) - message(SEND_ERROR "Was expecting to find uriparser. Something is off.") -endif() - - -# Compile and link some hello world using uriparser -add_executable(hello - hello.c -) - -target_link_libraries(hello PUBLIC uriparser::uriparser) diff --git a/external/uriparser/cmake/test_find_package/hello.c b/external/uriparser/cmake/test_find_package/hello.c deleted file mode 100644 index fbd3ddf..0000000 --- a/external/uriparser/cmake/test_find_package/hello.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -int main() { - char toUnescape[] = "one%20two"; - - printf("original: \"%s\"\n", toUnescape); - uriUnescapeInPlaceA(toUnescape); - printf("unescaped: \"%s\"\n", toUnescape); - - return 0; -} diff --git a/external/uriparser/cmake/uriparser-config.cmake.in b/external/uriparser/cmake/uriparser-config.cmake.in deleted file mode 100644 index 64938cf..0000000 --- a/external/uriparser/cmake/uriparser-config.cmake.in +++ /dev/null @@ -1,57 +0,0 @@ -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -if(NOT _uriparser_config_included) - # Protect against multiple inclusion - set(_uriparser_config_included TRUE) - - -include("${CMAKE_CURRENT_LIST_DIR}/uriparser.cmake") - -@PACKAGE_INIT@ - -# -# Supported components -# -macro(_register_component _NAME _AVAILABE) - set(uriparser_${_NAME}_FOUND ${_AVAILABE}) -endmacro() -_register_component(char @URIPARSER_BUILD_CHAR@) -_register_component(wchar_t @URIPARSER_BUILD_WCHAR_T@) -check_required_components(uriparser) - - -endif(NOT _uriparser_config_included) diff --git a/external/uriparser/configure b/external/uriparser/configure deleted file mode 100755 index a603b45..0000000 --- a/external/uriparser/configure +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/bin/env bash -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -set -e -set -u - -PS4='# ' -top_srcdir="$(dirname "$(type -P "$0")")" - -if [[ $* =~ --help ]]; then - set -x - exec cmake --help -else - set -x - exec cmake "$@" "${top_srcdir}" -fi diff --git a/external/uriparser/doc/.gitignore b/external/uriparser/doc/.gitignore deleted file mode 100644 index ba9a3b7..0000000 --- a/external/uriparser/doc/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/Doxyfile -/html -/release.sh -/uriparser-*.qch -/uriparser-*-doc.zip diff --git a/external/uriparser/doc/Doxyfile.in b/external/uriparser/doc/Doxyfile.in deleted file mode 100644 index da4132f..0000000 --- a/external/uriparser/doc/Doxyfile.in +++ /dev/null @@ -1,918 +0,0 @@ -# Doxyfile for Doxygen 1.5.7 - -# .qhp output -GENERATE_QHP = @GENERATE_QHP@ -QHP_NAMESPACE = "io.github.uriparser" -QHP_VIRTUAL_FOLDER = "uriparser-@PROJECT_VERSION@" - -# .qch output -QCH_FILE = "../@PROJECT_NAME@-@PROJECT_VERSION@.qch" -QHG_LOCATION = "@QHG_LOCATION@" - - -############################################################### -# Project related options -############################################################### - - -PROJECT_NAME = "uriparser" -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by double-quotes) that should identify the project for which the documentation is generated. This name is used in the title of most generated pages and in a few other places. - - -PROJECT_NUMBER = "@PROJECT_VERSION@" -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This could be handy for archiving the generated documentation or if some version control system is used. - - -CHM_FILE = "..\@PROJECT_NAME@-@PROJECT_VERSION@.chm" -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can be used to specify the file name of the resulting .chm file. You can add a path in front of the file if the result should not be written to the html output directory. - - -OUTPUT_DIRECTORY = . -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path into which the generated documentation will be written. If a relative path is entered, it will be relative to the location where doxygen was started. If left blank the current directory will be used. - - -# CREATE_SUBDIRS = -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-directories (in 2 levels) under the output directory of each output format and will distribute the generated files over these directories. Enabling this option can be useful when feeding doxygen a huge amount of source files, where putting all generated files in the same directory would otherwise causes performance problems for the file system. - - -# OUTPUT_LANGUAGE = -# The OUTPUT_LANGUAGE tag is used to specify the language in which all documentation generated by doxygen is written. Doxygen will use this information to generate all constant output in the proper language. The default language is English, other supported languages are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, Korean, Lithuanian, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - - -# USE_WINDOWS_ENCODING = -# This tag can be used to specify the encoding used in the generated output. The encoding is not always determined by the language that is chosen, but also whether or not the output is meant for Windows or non-Windows users. In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES forces the Windows encoding, (this is the default for the Windows binary), whereas setting the tag to NO uses a Unix-style encoding (the default for all platforms other than Windows). - - -# BRIEF_MEMBER_DESC = -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) doxygen will include brief member descriptions after the members that are listed in the file and class documentation (similar to JavaDoc). Set to NO to disable this. - - -# REPEAT_BRIEF = -# If the REPEAT_BRIEF tag is set to YES (the default) doxygen will prepend the brief description of a member or function before the detailed description -# -# Note: -# If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the brief descriptions will be completely suppressed. - - -# ABBREVIATE_BRIEF = -# This tag implements a quasi-intelligent brief description abbreviator that is used to form the text in various listings. Each string in this list, if found as the leading text of the brief description, will be stripped from the text and the result after processing the whole list, is used as the annotated text. Otherwise, the brief description is used as-is. If left blank, the following values are used ("\$name" is automatically replaced with the name of the entity): "The $name class" "The $name widget" "The $name file" "is" "provides" "specifies" "contains" "represents" "a" "an" "the". - - -# ALWAYS_DETAILED_SEC = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then doxygen will generate a detailed section even if there is only a brief description. - - -# INLINE_INHERITED_MEMB = -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited members of a class in the documentation of that class as if those members were ordinary class members. Constructors, destructors and assignment operators of the base classes will not be shown. - - -FULL_PATH_NAMES = NO -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path before files name in the file list and in the header files. If set to NO the shortest path that makes the file name unique will be used - - -# STRIP_FROM_PATH = -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. Stripping is only done if one of the specified strings matches the left-hand part of the path. The tag can be used to show relative paths in the file list. If left blank the directory from which doxygen is run is used as the path to strip. - - -# STRIP_FROM_INC_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the path mentioned in the documentation of a class, which tells the reader which header file to include in order to use a class. If left blank only the name of the header file containing the class definition is used. Otherwise one should specify the include paths that are normally passed to the compiler using the -I flag. - - -# CASE_SENSE_NAMES = -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file names in lower-case letters. If set to YES upper-case letters are also allowed. This is useful if you have classes or files whose names only differ in case and if your file system supports case sensitive file names. Windows users are advised to set this option to NO. - - -# SHORT_NAMES = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but less readable) file names. This can be useful is your file systems doesn't support long names like on DOS, Mac, or CD-ROM. - - -# JAVADOC_AUTOBRIEF = -# If the JAVADOC_AUTOBRIEF is set to YES then doxygen will interpret the first line (until the first dot) of a JavaDoc-style comment as the brief description. If set to NO (the default), the Javadoc-style will behave just like the Qt-style comments. - - -BUILTIN_STL_SUPPORT = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to include (a tag file for) the STL sources as input, then you should set this tag to YES in order to let doxygen match functions declarations and definitions whose arguments contain STL classes (e.g. func(std::string); v.s. func(std::string) {}). This also make the inheritance and collaboration diagrams that involve STL classes more complete and accurate. - - -# DISTRIBUTE_GROUP_DOC = -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC tag is set to YES, then doxygen will reuse the documentation of the first member in the group (if any) for the other members of the group. By default all members of a group must be documented explicitly. - - -# MULTILINE_CPP_IS_BRIEF = -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen treat a multi-line C++ special comment block (i.e. a block of //! or /// comments) as a brief description. This used to be the default behaviour. The new default is to treat a multi-line C++ comment block as a detailed description. Set this tag to YES if you prefer the old behaviour instead. Note that setting this tag to YES also means that rational rose comments are not recognized any more. - - -# INHERIT_DOCS = -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented member inherits the documentation from any documented member that it re-implements. - - -# SEPARATE_MEMBER_PAGES = -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a new page for each member. If set to NO, the documentation of a member will be part of the file/class/namespace that contains it. - - -# TAB_SIZE = -# the TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen uses this value to replace tabs by spaces in code fragments. - - -# ALIASES = -# This tag can be used to specify a number of aliases that acts as commands in the documentation. An alias has the form -# -# name=value -# -# For example adding -# -# "sideeffect=\par Side Effects:\n" -# -# will allow you to put the command \sideeffect (or @sideeffect) in the documentation, which will result in a user-defined paragraph with heading "Side Effects:". You can put \n's in the value part of an alias to insert newlines. - - -OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources only. Doxygen will then generate output that is more tailored for C. For instance, some of the names that are used will be different. The list of all members will be omitted, etc. - - -# OPTIMIZE_OUTPUT_JAVA = -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or Python sources only. Doxygen will then generate output that is more tailored for that language. For instance, namespaces will be presented as packages, qualified scopes will look different, etc. - - -# SUBGROUPING = -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of the same type (for instance a group of public functions) to be put as a subgroup of that type (e.g. under the Public Functions section). Set it to NO to prevent subgrouping. Alternatively, this can be done per class using the \nosubgrouping command. - - - - -############################################################### -# Build related options -############################################################### - - -EXTRACT_ALL = NO -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in documentation are documented, even if no documentation was available. Private class members and static file members will be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -# -# Note: -# This will also disable the warnings about undocumented members that are normally produced when WARNINGS is set to YES - - -EXTRACT_PRIVATE = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will be included in the documentation. - - -EXTRACT_STATIC = YES -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be included in the documentation. - - -# EXTRACT_LOCAL_CLASSES = -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined locally in source files will be included in the documentation. If set to NO only classes defined in header files are included. Does not have any effect for Java sources. - - -# EXTRACT_LOCAL_METHODS = -# This flag is only useful for Objective-C code. When set to YES local methods, which are defined in the implementation section but not in the interface are included in the documentation. If set to NO (the default) only methods in the interface are included. - - -HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all undocumented members inside documented classes or files. If set to NO (the default) these members will be included in the various overviews, but no documentation section is generated. This option has no effect if EXTRACT_ALL is enabled. - - -HIDE_UNDOC_CLASSES = NO -# If the HIDE_UNDOC_CLASSESS tag is set to YES, doxygen will hide all undocumented classes. If set to NO (the default) these classes will be included in the various overviews. This option has no effect if EXTRACT_ALL is enabled. - - -HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all friend (class|struct|union) declarations. If set to NO (the default) these declarations will be included in the documentation. - - -# HIDE_IN_BODY_DOCS = -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any documentation blocks found inside the body of a function. If set to NO (the default) these blocks will be appended to the function's detailed documentation block. - - -# INTERNAL_DOCS = -# The INTERNAL_DOCS tag determines if documentation that is typed after a \internal command is included. If the tag is set to NO (the default) then the documentation will be excluded. Set it to YES to include the internal documentation. - - -HIDE_SCOPE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then doxygen will show members with their full class and namespace scopes in the documentation. If set to YES the scope will be hidden. - - -SHOW_INCLUDE_FILES = YES -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then doxygen will put a list of the files that are included by a file in the documentation of that file. - - -# INLINE_INFO = -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] is inserted in the documentation for inline members. - - -# SORT_MEMBER_DOCS = -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen will sort the (detailed) documentation of file and class members alphabetically by member name. If set to NO the members will appear in declaration order. - - -# SORT_BRIEF_DOCS = -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief descriptions of file, namespace and class members alphabetically by member name. If set to NO (the default) the members will appear in declaration order. - - -# GENERATE_DEPRECATEDLIST = -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) the deprecated list. This list is created by putting \deprecated commands in the documentation. - - -# GENERATE_TODOLIST = -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo list. This list is created by putting \todo commands in the documentation. - - -# GENERATE_TESTLIST = -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test list. This list is created by putting \test commands in the documentation. - - -# GENERATE_BUGLIST = -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug list. This list is created by putting \bug commands in the documentation. - - -# ENABLED_SECTIONS = -# The ENABLED_SECTIONS tag can be used to enable conditional documentation sections, marked by \if ... \endif and \cond ... \endcond blocks. - - -# MAX_INITIALIZER_LINES = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the initial value of a variable or define can be. If the initializer consists of more lines than specified here it will be hidden. Use a value of 0 to hide initializers completely. The appearance of the value of individual variables and defines can be controlled using \showinitializer or \hideinitializer command in the documentation. - - -SHOW_USED_FILES = YES -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at the bottom of the documentation of classes and structs. If set to YES the list will mention the files that were used to generate the documentation. - - - - -############################################################### -# Options related to warning and progress messages -############################################################### - - -QUIET = YES -# The QUIET tag can be used to turn on/off the messages that are generated to standard output by doxygen. Possible values are YES and NO, where YES implies that the messages are off. If left blank NO is used. - - -# WARNINGS = -# The WARNINGS tag can be used to turn on/off the warning messages that are generated to standard error by doxygen. Possible values are YES and NO, where YES implies that the warnings are on. If left blank NO is used. -# -# Tip: Turn warnings on while writing the documentation. - - -WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag will automatically be disabled. - - -WARN_IF_DOC_ERROR = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for potential errors in the documentation, such as not documenting some parameters in a documented function, or documenting parameters that don't exist or using markup commands wrongly. - - -WARN_NO_PARAMDOC = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for functions that are documented, but have no documentation for their parameters or return value. If set to NO (the default) doxygen will only warn about wrong or incomplete parameter documentation, but not about the absence of documentation. - - -WARN_FORMAT = "WARNING: $text ($line, $file)" -# The WARN_FORMAT tag determines the format of the warning messages that doxygen can produce. The string should contain the $file, $line, and $text tags, which will be replaced by the file and line number from which the warning originated and the warning text. - - -# WARN_LOGFILE = -# The WARN_LOGFILE tag can be used to specify a file to which warning and error messages should be written. If left blank the output is written to stderr. - - - - -############################################################### -# Input related options -############################################################### - - -INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/doc/Mainpage.txt -# The INPUT tag is used to specify the files and/or directories that contain documented source files. You may enter file names like myfile.cpp or directories like /usr/src/myproject. Separate the files or directories with spaces. -# -# Note: If this tag is empty the current directory is searched. - - -# FILE_PATTERNS = -# If the value of the INPUT tag contains directories, you can use the FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and *.h ) to filter out the source-files in the directories. If left blank the following patterns are tested: .c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp .h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm - - -# FILE_VERSION_FILTER = -# The FILE_VERSION_FILTER tag can be used to specify a program or script that doxygen should invoke to get the current version for each file (typically from the version control system). Doxygen will invoke the program by executing (via popen()) the command command input-file, where command is the value of the FILE_VERSION_FILTER tag, and input-file is the name of an input file provided by doxygen. Whatever the program writes to standard output is used as the file version. -# -# Example of using a shell script as a filter for Unix: -# -# FILE_VERSION_FILTER = "/bin/sh versionfilter.sh" -# -# Example shell script for CVS: -# -# #!/bin/sh -# cvs status $1 | sed -n 's/^[ \]*Working revision:[ \t]*\([0-9][0-9\.]*\).*/\1/p' -# -# Example shell script for Subversion: -# -# #!/bin/sh -# svn stat -v $1 | sed -n 's/^[ A-Z?\*|!]\{1,15\}/r/;s/ \{1,15\}/\/r/;s/ .*//p' -# -# Example filter for ClearCase: -# -# FILE_VERSION_INFO = "cleartool desc -fmt \%Vn" - - -RECURSIVE = YES -# The RECURSIVE tag can be used to specify whether or not subdirectories should be searched for input files as well. Possible values are YES and NO. If left blank NO is used. - - -# EXCLUDE = -# The EXCLUDE tag can be used to specify files and/or directories that should excluded from the INPUT source files. This way you can easily exclude a subdirectory from a directory tree whose root is specified with the INPUT tag. - - -# EXCLUDE_SYMLINKS = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories that are symbolic links (a Unix filesystem feature) are excluded from the input. - - -# EXCLUDE_PATTERNS = -# If the value of the INPUT tag contains directories, you can use the EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude certain files from those directories. - -# Note that the wildcards are matched against the file with absolute path, so to exclude all test directories use the pattern */test/* - - -# EXAMPLE_PATH = -# The EXAMPLE_PATH tag can be used to specify one or more files or directories that contain example code fragments that are included (see the \include command in section \include). - - -# EXAMPLE_RECURSIVE = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be searched for input files to be used with the \include or \dontinclude commands irrespective of the value of the RECURSIVE tag. Possible values are YES and NO. If left blank NO is used. - - -# EXAMPLE_PATTERNS = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and *.h) to filter out the source-files in the directories. If left blank all files are included. - - -# IMAGE_PATH = -# The IMAGE_PATH tag can be used to specify one or more files or directories that contain images that are to be included in the documentation (see the \image command). - - -INPUT_FILTER = "bash @CMAKE_CURRENT_SOURCE_DIR@/doc/preprocess.sh" -# The INPUT_FILTER tag can be used to specify a program that doxygen should invoke to filter for each input file. Doxygen will invoke the filter program by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the name of an input file. Doxygen will then use the output that the filter program writes to standard output. - - -# FILTER_PATTERNS = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern basis. Doxygen will compare the file name with each pattern and apply the filter if there is a match. The filters are a list of the form: pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER is applied to all files. - - -# FILTER_SOURCE_FILES = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using INPUT_FILTER ) will also be used to filter the input files that are used for producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). - - - - -############################################################### -# Source browsing related options -############################################################### - - -# SOURCE_BROWSER = -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be generated. Documented entities will be cross-referenced with these sources. - - -# INLINE_SOURCES = -# Setting the INLINE_SOURCES tag to YES will include the body of functions, classes and enums directly into the documentation. - - -STRIP_CODE_COMMENTS = YES -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct doxygen to hide any special comment blocks from generated source code fragments. Normal C and C++ comments will always remain visible. - - -# REFERENCED_BY_RELATION = -# If the REFERENCED_BY_RELATION tag is set to YES (the default) then for each documented function all documented functions referencing it will be listed. - - -# REFERENCES_RELATION = -# If the REFERENCES_RELATION tag is set to YES (the default) then for each documented function all documented entities called/used by that function will be listed. - - -# REFERENCES_LINK_SOURCE = -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) and SOURCE_BROWSER tag is set to YES, then the hyperlinks from functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will link to the documentstion. - - -VERBATIM_HEADERS = NO -# If the VERBATIM_HEADERS tag is set the YES (the default) then doxygen will generate a verbatim copy of the header file for each class for which an include is specified. Set to NO to disable this. -# -# See also: -# Section \class. - - -# USE_HTAGS = -# If the USE_HTAGS tag is set to YES then the references to source code will point to the HTML generated by the htags(1) tool instead of doxygen built-in source browser. The htags tool is part of GNU's global source tagging system (see http://www.gnu.org/software/global/global.html). The use it do the following: -# -# 1. Install the latest version of global (i.e. 4.8.6 or better) -# 2. Enable SOURCE_BROWSER and USE_HTAGS in the config file -# 3. Make sure the INPUT points to the root of the source tree -# 4. Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to source code will now point to the output of htags. - - - - -############################################################### -# Alphabetical index options -############################################################### - - -# COLS_IN_ALPHA_INDEX = -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in which this list will be split (can be a number in the range [1..20]) - - -# IGNORE_PREFIX = -# In case all classes in a project start with a common prefix, all classes will be put under the same header in the alphabetical index. The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) that should be ignored while generating the index headers. - - - - -############################################################### -# HTML related options -############################################################### - - -GENERATE_HTML = YES -# If the GENERATE_HTML tag is set to YES (the default) doxygen will generate HTML output - - -# HTML_OUTPUT = TODO -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put in front of it. If left blank `html' will be used as the default path. - - -# HTML_FILE_EXTENSION = -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each generated HTML page (for example: .htm, .php, .asp). If it is left blank doxygen will generate files with .html extension. - - -# HTML_HEADER = TODO -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for each generated HTML page. To get valid HTML the header file should contain at least a and a tag, but it is good idea to include the style sheet that is generated by doxygen as well. Minimal example: -# -# -# -# My title -# -# -# -# -# If the tag is left blank doxygen will generate a standard header. -# -# The following commands have a special meaning inside the header: $title, $datetime, $date, $doxygenversion, $projectname, and $projectnumber. Doxygen will replace them by respectively the title of the page, the current date and time, only the current date, the version number of doxygen, the project name (see PROJECT_NAME), or the project number (see PROJECT_NUMBER). -# -# If CREATE_SUBDIRS is enabled, the command $relpath$ can be used to produce a relative path to the root of the HTML output directory, e.g. use $relpath$doxygen.css, to refer to the standard style sheet. -# -# See also section Doxygen usage for information on how to generate the default header that doxygen normally uses. - - -# HTML_FOOTER = -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each generated HTML page. To get valid HTML the footer file should contain at least a and a tag. A minimal example: -# -# -# -# -# If the tag is left blank doxygen will generate a standard footer. -# -# The following commands have a special meaning inside the footer: $title, $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will replace them by respectively the title of the page, the current date and time, only the current date, the version number of doxygen, the project name (see PROJECT_NAME), or the project number (see PROJECT_NUMBER). -# -# See also section Doxygen usage for information on how to generate the default footer that doxygen normally uses. - - -# HTML_STYLESHEET = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style sheet that is used by each HTML page. It can be used to fine-tune the look of the HTML output. If the tag is left blank doxygen will generate a default style sheet. -# -# See also section Doxygen usage for information on how to generate the style sheet that doxygen normally uses. - - -# HTML_ALIGN_MEMBERS = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, files or namespaces will be aligned in HTML using tables. If set to NO a bullet list will be used. -# -# Note: Setting this tag to NO will become obsolete in the future, since I only intent to support and test the aligned representation. - - -GENERATE_HTMLHELP = @GENERATE_HTMLHELP@ -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three additional HTML index files: index.hhp, index.hhc, and index.hhk. The index.hhp is a project file that can be read by Microsoft's HTML Help Workshop on Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output generated by doxygen into a single compressed HTML file (.chm). Compressed HTML files are now used as the Windows 98 help format, and will replace the old Windows help format (.hlp) on all Windows platforms in the future. Compressed HTML files also contain an index, a table of contents, and you can search for words in the documentation. The HTML workshop also contains a viewer for compressed HTML files. - - -HHC_LOCATION = "@HTML_HELP_COMPILER@" -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can be used to specify the location (absolute path including file name) of the HTML help compiler (hhc.exe). If non empty doxygen will try to run the HTML help compiler on the generated index.hhp. - - -# GENERATE_CHI = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag controls if a separate .chi index file is generated (YES) or that it should be included in the master .chm file (NO). - - -# BINARY_TOC = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag controls whether a binary table of contents is generated (YES) or a normal table of contents (NO) in the .chm file. - - -# TOC_EXPAND = -# The TOC_EXPAND flag can be set to YES to add extra items for group members to the table of contents of the HTML help documentation and to the tree view. - - -# DISABLE_INDEX = -# If you want full control over the layout of the generated HTML pages it might be necessary to disable the index and replace it with your own. The DISABLE_INDEX tag can be used to turn on/off the condensed index at top of each page. A value of NO (the default) enables the index and the value YES disables it. - - -# ENUM_VALUES_PER_LINE = -# This tag can be used to set the number of enum values (range [1..20]) that doxygen will group on one line in the generated HTML documentation. - - -# GENERATE_TREEVIEW = -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be generated containing a tree-like index structure (just like the one that is generated for HTML Help). For this to work a browser that supports JavaScript and frames is required (for instance Mozilla 1.0+, Netscape 6.0+ or Internet explorer 5.0+ or Konqueror). - - -# TREEVIEW_WIDTH = -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used to set the initial width (in pixels) of the frame in which the tree is shown. - - - - -############################################################### -# LaTeX related options -############################################################### - - -GENERATE_LATEX = NO -# If the GENERATE_LATEX tag is set to YES (the default) doxygen will generate $\mbox{\LaTeX}$ output. - - -# LATEX_OUTPUT = -# The LATEX_OUTPUT tag is used to specify where the $\mbox{\LaTeX}$ docs will be put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put in front of it. If left blank `latex' will be used as the default path. - - -# LATEX_CMD_NAME = -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name. - - -# MAKEINDEX_CMD_NAME = -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate index for LaTeX. If left blank `makeindex' will be used as the default command name. - - -# COMPACT_LATEX = -# If the COMPACT_LATEX tag is set to YES doxygen generates more compact $\mbox{\LaTeX}$ documents. This may be useful for small projects and may help to save some trees in general. - - -# PAPER_TYPE = -# The PAPER_TYPE tag can be used to set the paper type that is used by the printer. Possible values are: -# -# * a4 (210 x 297 mm). -# * a4wide (same as a4, but including the a4wide package). -# * letter (8.5 x 11 inches). -# * legal (8.5 x 14 inches). -# * executive (7.25 x 10.5 inches) -# -# If left blank a4wide will be used. - - -# EXTRA_PACKAGES = -# The EXTRA_PACKAGES tag can be used to specify one or more $\mbox{\LaTeX}$ package names that should be included in the $\mbox{\LaTeX}$ output. To get the times font for instance you can specify -# -# EXTRA_PACKAGES = times -# -# If left blank no extra packages will be included. - - -# LATEX_HEADER = -# The LATEX_HEADER tag can be used to specify a personal $\mbox{\LaTeX}$ header for the generated $\mbox{\LaTeX}$ document. The header should contain everything until the first chapter. -# -# If it is left blank doxygen will generate a standard header. See section Doxygen usage for information on how to let doxygen write the default header to a separate file. -# -# Note: -# Only use a user-defined header if you know what you are doing! -# -# The following commands have a special meaning inside the header: $title, $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will replace them by respectively the title of the page, the current date and time, only the current date, the version number of doxygen, the project name (see PROJECT_NAME), or the project number (see PROJECT_NUMBER). - - -# PDF_HYPERLINKS = -# If the PDF_HYPERLINKS tag is set to YES, the $\mbox{\LaTeX}$ that is generated is prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will contain links (just like the HTML output) instead of page references. This makes the output suitable for online browsing using a PDF viewer. - - -# USE_PDFLATEX = -# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate the PDF file directly from the $\mbox{\LaTeX}$ files. - - -# LATEX_BATCHMODE = -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode. command to the generated $\mbox{\LaTeX}$ files. This will instruct $\mbox{\LaTeX}$ to keep running if errors occur, instead of asking the user for help. This option is also used when generating formulas in HTML. - - -# LATEX_HIDE_INDICES = -# If LATEX_HIDE_INDICES is set to YES then doxygen will not include the index chapters (such as File Index, Compound Index, etc.) in the output. - - - - -############################################################### -# RTF related options -############################################################### - - -# GENERATE_RTF = -# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The RTF output is optimized for Word 97 and may not look too pretty with other readers/editors. - - -# RTF_OUTPUT = -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put in front of it. If left blank rtf will be used as the default path. - - -# COMPACT_RTF = -# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF documents. This may be useful for small projects and may help to save some trees in general. - - -# RTF_HYPERLINKS = -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will contain hyperlink fields. The RTF file will contain links (just like the HTML output) instead of page references. This makes the output suitable for online browsing using Word or some other Word compatible reader that support those fields. -# -# note: -# WordPad (write) and others do not support links. - - -# RTF_STYLESHEET_FILE = -# Load stylesheet definitions from file. Syntax is similar to doxygen's config file, i.e. a series of assignments. You only have to provide replacements, missing definitions are set to their default value. -# -# See also section Doxygen usage for information on how to generate the default style sheet that doxygen normally uses. - - -# RTF_EXTENSIONS_FILE = -# Set optional variables used in the generation of an RTF document. Syntax is similar to doxygen's config file. A template extensions file can be generated using doxygen -e rtf extensionFile. - - - - -############################################################### -# Man page related options -############################################################### - - -# GENERATE_MAN = -# If the GENERATE_MAN tag is set to YES (the default) doxygen will generate man pages for classes and files. - - -# MAN_OUTPUT = -# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put in front of it. If left blank `man' will be used as the default path. A directory man3 will be created inside the directory specified by MAN_OUTPUT. - - -# MAN_EXTENSION = -# The MAN_EXTENSION tag determines the extension that is added to the generated man pages (default is the subroutine's section .3) - - -# MAN_LINKS = -# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it will generate one additional man file for each entity documented in the real man page(s). These additional files only source the real man page, but without them the man command would be unable to find the correct page. The default is NO. - - - - -############################################################### -# XML related options -############################################################### - - -# GENERATE_XML = -# If the GENERATE_XML tag is set to YES Doxygen will generate an XML file that captures the structure of the code including all documentation. - - -# XML_OUTPUT = -# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put in front of it. If left blank xml will be used as the default path. - - -# XML_SCHEMA = -# The XML_SCHEMA tag can be used to specify an XML schema, which can be used by a validating XML parser to check the syntax of the XML files. - - -# XML_DTD = -# The XML_DTD tag can be used to specify an XML DTD, which can be used by a validating XML parser to check the syntax of the XML files. - - -# XML_PROGRAMLISTING = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will dump the program listings (including syntax highlighting and cross-referencing information) to the XML output. Note that enabling this will significantly increase the size of the XML output. - - - - -############################################################### -# AUTOGEN_DEF related options -############################################################### - - -# GENERATE_AUTOGEN_DEF = -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will generate an AutoGen Definitions (see http://autogen.sf.net) file that captures the structure of the code including all documentation. Note that this feature is still experimental and incomplete at the moment. - - - - -############################################################### -# PERLMOD related options -############################################################### - - -# GENERATE_PERLMOD = -# If the GENERATE_PERLMOD tag is set to YES Doxygen will generate a Perl module file that captures the structure of the code including all documentation. Note that this feature is still experimental and incomplete at the moment. - - -# PERLMOD_LATEX = -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate the necessary Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI output from the Perl module output. - - -# PERLMOD_PRETTY = -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely formatted so it can be parsed by a human reader. This is useful if you want to understand what is going on. On the other hand, if this tag is set to NO the size of the Perl module output will be much smaller and Perl will parse it just the same. - - -# PERLMOD_MAKEVAR_PREFIX = -# The names of the make variables in the generated doxyrules.make file are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful so different doxyrules.make files included by the same Makefile don't overwrite each other's variables. - - - - -############################################################### -# Preprocessor related options -############################################################### - - -ENABLE_PREPROCESSING = YES -# If the ENABLE_PREPROCESSING tag is set to YES (the default) doxygen will evaluate all C-preprocessor directives found in the sources and include files. - - -MACRO_EXPANSION = NO -# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names in the source code. If set to NO (the default) only conditional compilation will be performed. Macro expansion can be done in a controlled way by setting EXPAND_ONLY_PREDEF to YES. - - -EXPAND_ONLY_PREDEF = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then the macro expansion is limited to the macros specified with the PREDEFINED and EXPAND_AS_DEFINED tags. - - -SEARCH_INCLUDES = YES -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files in the INCLUDE_PATH (see below) will be searched if a #include is found. - - -INCLUDE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/include -# The INCLUDE_PATH tag can be used to specify one or more directories that contain include files that are not input files but should be processed by the preprocessor. - - -# PREDEFINED = -# The PREDEFINED tag can be used to specify one or more macro names that are defined before the preprocessor is started (similar to the -D option of gcc). The argument of the tag is a list of macros of the form: name or name=definition (no spaces). If the definition and the "=" are omitted, "=1" is assumed. To prevent a macro definition from being undefined via #undef or recursively expanded use the := operator instead of the = operator. - - -# EXPAND_AS_DEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this tag can be used to specify a list of macro names that should be expanded. The macro definition that is found in the sources will be used. Use the PREDEFINED tag if you want to use a different macro definition. - - -# SKIP_FUNCTION_MACROS = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then doxygen's preprocessor will remove all function-like macros that are alone on a line, have an all uppercase name, and do not end with a semicolon. Such function macros are typically used for boiler-plate code, and will confuse the parser if not removed. - - - - -############################################################### -# External reference options -############################################################### - - -# TAGFILES = -# The TAGFILES tag can be used to specify one or more tagfiles. -# -# See section Doxytag usage for more information about the usage of tag files. -# -# Optionally an initial location of the external documentation can be added for each tagfile. The format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# -# where loc1 and loc2 can be relative or absolute paths or URLs, If a location is present for each tag, the installdox tool (see section Installdox usage for more information) does not have to be run to correct the links. -# -# Note: -# Each tag file must have a unique name (where the name does not include the path) If a tag file is not located in the directory in which doxygen is run, you must also specify the path to the tagfile here. - - -# GENERATE_TAGFILE = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create a tag file that is based on the input files it reads. See section Doxytag usage for more information about the usage of tag files. - - -# ALLEXTERNALS = -# If the ALLEXTERNALS tag is set to YES all external class will be listed in the class index. If set to NO only the inherited external classes will be listed. - - -# EXTERNAL_GROUPS = -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in the modules index. If set to NO, only the current project's groups will be listed. - - -# PERL_PATH = -# The PERL_PATH should be the absolute path and name of the perl script interpreter (i.e. the result of `which perl'). - - - - -############################################################### -# Dot options -############################################################### - - -# CLASS_DIAGRAMS = -# If the CLASS_DIAGRAMS tag is set to YES (the default) doxygen will generate a class diagram (in HTML and $\mbox{\LaTeX}$) for classes with base or super classes. Setting the tag to NO turns the diagrams off. Note that this option is superseded by the HAVE_DOT option below. This is only a fallback. It is recommended to install and use dot, since it yields more powerful graphs. - - -HAVE_DOT = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is available from the path. This tool is part of Graphviz, a graph visualization toolkit from AT&T and Lucent Bell Labs. The other options in this section have no effect if this option is set to NO (the default) - - -CLASS_GRAPH = NO -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a graph for each documented class showing the direct and indirect inheritance relations. Setting this tag to YES will force the the CLASS_DIAGRAMS tag to NO. - - -COLLABORATION_GRAPH = NO -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a graph for each documented class showing the direct and indirect implementation dependencies (inheritance, containment, and class references variables) of the class with other documented classes. - - -# GROUP_GRAPHS -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen will generate a graph for groups, showing the direct groups dependencies. - - -UML_LOOK = NO -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and collaboration diagrams in a style similar to the OMG's Unified Modeling Language. - - -# TEMPLATE_RELATIONS = -# If the TEMPLATE_RELATIONS and HAVE_DOT tags are set to YES then doxygen will show the relations between templates and their instances. - - -HIDE_UNDOC_RELATIONS = NO -# If set to YES, the inheritance and collaboration graphs will hide inheritance and usage relations if the target is undocumented or is not a class. - - -INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT tags are set to YES then doxygen will generate a graph for each documented file showing the direct and indirect include dependencies of the file with other documented files. - - -INCLUDED_BY_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to YES then doxygen will generate a graph for each documented header file showing the documented files that directly or indirectly include this file. - - -CALL_GRAPH = NO -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a call dependency graph for every global function or class method. Note that enabling this option will significantly increase the time of a run. So in most cases it will be better to enable call graphs for selected functions only using the \callgraph command. - - -CALLER_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a caller dependency graph for every global function or class method. Note that enabling this option will significantly increase the time of a run. So in most cases it will be better to enable caller graphs for selected functions only using the \callergraph command. - - -GRAPHICAL_HIERARCHY = YES -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen will graphical hierarchy of all classes instead of a textual one. - - -# DIRECTORY_GRAPH -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT options are set to YES then doxygen will show the dependencies a directory has on other directories in a graphical way. The dependency relations are determined by the #include relations between the files in the directories. - - -# DOT_IMAGE_FORMAT = -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images generated by dot. Possible values are gif, jpg, and png. If left blank png will be used. - - -# DOT_PATH = -# This tag can be used to specify the path where the dot tool can be found. If left blank, it is assumed the dot tool can be found on the path. - - -# DOTFILE_DIRS = -# This tag can be used to specify one or more directories that contain dot files that are included in the documentation (see the \dotfile command). - - -# MAX_DOT_GRAPH_HEIGHT = -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height (in pixels) of the graphs generated by dot. If a graph becomes larger than this value, doxygen will try to truncate the graph, so that it fits within the specified constraint. Beware that most browsers cannot cope with very large images. - - -# MAX_DOT_GRAPH_DEPTH = -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs generated by dot. A depth value of 3 means that only nodes reachable from the root by following a path via at most 3 edges will be shown. Nodes that lay further from the root node will be omitted. Note that setting this option to 1 or 2 may greatly reduce the computation time needed for large code bases. Also note that a graph may be further truncated if the graph's image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), the graph is not depth-constraint. - - -# MAX_DOT_GRAPH_WIDTH = -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width (in pixels) of the graphs generated by dot. If a graph becomes larger than this value, doxygen will try to truncate the graph, so that it fits within the specified constraint. Beware that most browsers cannot cope with very large images. - - -# DOT_TRANSPARENT = -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent background. This is disabled by default, which results in a white background. Warning: Depending on the platform used, enabling this option may lead to badly anti-aliased labels on the edges of a graph (i.e. they become hard to read). - - -DOT_MULTI_TARGETS = YES -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output files in one run (i.e. multiple -o and -T options on the command line). This makes dot run faster, but since only newer versions of dot (>1.8.10) support this, this feature is disabled by default. - - -GENERATE_LEGEND = YES -# If the GENERATE_LEGEND tag is set to YES (the default) doxygen will generate a legend page explaining the meaning of the various boxes and arrows in the dot generated graphs. - - -# DOT_CLEANUP = -# If the DOT_CLEANUP tag is set to YES (the default) doxygen will remove the intermediate dot files that are used to generate the various graphs. - - - - -############################################################### -# Search engine options -############################################################### - - -# SEARCHENGINE = -# The SEARCHENGINE tag specifies whether or not the HTML output should contain a search facility. Possible values are YES and NO. If set to YES, doxygen will produce a search index and a PHP script to search through the index. For this to work the documentation should be viewed via a web-server running PHP version 4.1.0 or higher. (See http://www.php.net/manual/en/installation.php for installation instructions). diff --git a/external/uriparser/doc/Mainpage.txt b/external/uriparser/doc/Mainpage.txt deleted file mode 100644 index 19d8115..0000000 --- a/external/uriparser/doc/Mainpage.txt +++ /dev/null @@ -1,300 +0,0 @@ -/** - * @mainpage - * - * @section SEC_TOC Table of Contents - * - Introduction - * - Algorithms and Examples - * - Parsing URIs (from string to object) - * - Recomposing URIs (from object back to string) - * - Resolving References - * - Creating References - * - Filenames and URIs - * - Normalizing URIs - * - Working with Query Strings - * - Narrow Strings and Wide Strings - * - Autoconf Check - * - * - * @section intro Introduction - * Welcome to the short uriparser integration tutorial. - * It is intended to answer upcoming questions and to shed light - * where function prototypes alone are not enough. - * Please drop me a line if you need further assistance and I will - * see what I can do for you. Good luck with uriparser! - * - * - * @subsection parsing Parsing URIs (from string to object) - * Parsing a URI with uriparser looks like this: - * - * @code - * UriUriA uri; - * const char * const uriString = "file:///home/user/song.mp3"; - * const char * errorPos; - * - * if (uriParseSingleUriA(&uri, uriString, &errorPos) != URI_SUCCESS) { - * /COMMENT_HACK* Failure (no need to call uriFreeUriMembersA) *COMMENT_HACK/ - * ... - * return ...; - * } - * - * /COMMENT_HACK* Success *COMMENT_HACK/ - * ... - * uriFreeUriMembersA(&uri); - * @endcode - * - * While the URI object (::UriUriA) holds information about the recognized - * parts of the given URI string, in case of URI_ERROR_SYNTAX, - * errorPos points to the first character starting invalid syntax. - * - * @subsection recomposition Recomposing URIs (from object back to string) - * According to RFC 3986 - * gluing parts of a URI together to form a string is called recomposition. - * Before we can recompose a URI object we have to know how much - * space the resulting string will take: - * - * @code - * UriUriA uri; - * char * uriString; - * int charsRequired; - * ... - * if (uriToStringCharsRequiredA(&uri, &charsRequired) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * charsRequired++; - * @endcode - * - * Now we can tell uriToStringA() to write the string to a given buffer: - * - * @code - * uriString = malloc(charsRequired * sizeof(char)); - * if (uriString == NULL) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * if (uriToStringA(uriString, &uri, charsRequired, NULL) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * @endcode - * - * @remarks - * Incrementing charsRequired by 1 is required since - * uriToStringCharsRequiredA() returns the length of the string - * as strlen() does, but uriToStringA() works with the number - * of maximum characters to be written including the - * zero-terminator. - * - * - * @subsection resolution Resolving References - * Reference Resolution - * is the process of turning a (relative) URI reference into an absolute URI by applying a base - * URI to it. In code it looks like this: - * - * @code - * UriUriA absoluteDest; - * UriUriA relativeSource; - * UriUriA absoluteBase; - * ... - * /COMMENT_HACK* relativeSource holds "../TWO" now *COMMENT_HACK/ - * /COMMENT_HACK* absoluteBase holds "file:///one/two/three" now *COMMENT_HACK/ - * if (uriAddBaseUriA(&absoluteDest, &relativeSource, &absoluteBase) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * uriFreeUriMembersA(&absoluteDest); - * ... - * } - * /COMMENT_HACK* absoluteDest holds "file:///one/TWO" now *COMMENT_HACK/ - * ... - * uriFreeUriMembersA(&absoluteDest); - * @endcode - * - * @remarks - * uriAddBaseUriA() does not normalize the resulting URI. - * Usually you might want to pass it through uriNormalizeSyntaxA() after. - * - * - * @subsection shortening Creating References - * Reference Creation is the inverse process of Reference Resolution: A common base URI - * is "subtracted" from an absolute URI to make a (relative) reference. - * If the base URI is not common the remaining URI will still be absolute, i.e. will - * carry a scheme - * - * @code - * UriUriA dest; - * UriUriA absoluteSource; - * UriUriA absoluteBase; - * ... - * /COMMENT_HACK* absoluteSource holds "file:///one/TWO" now *COMMENT_HACK/ - * /COMMENT_HACK* absoluteBase holds "file:///one/two/three" now *COMMENT_HACK/ - * if (uriRemoveBaseUriA(&dest, &absoluteSource, &absoluteBase, URI_FALSE) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * uriFreeUriMembersA(&dest); - * ... - * } - * /COMMENT_HACK* dest holds "../TWO" now *COMMENT_HACK/ - * ... - * uriFreeUriMembersA(&dest); - * @endcode - * - * The fourth parameter is the domain root mode. With URI_FALSE as above this will produce - * URIs relative to the base URI. With URI_TRUE the resulting URI will be relative to the - * domain root instead, e.g. "/one/TWO" in this case. - * - * - * @subsection filenames Filenames and URIs - * Converting filenames to and from URIs works on strings directly, - * i.e. without creating an URI object. - * - * @code - * const char * const absFilename = "E:\\Documents and Settings"; - * const int bytesNeeded = 8 + 3 * strlen(absFilename) + 1; - * char * absUri = malloc(bytesNeeded * sizeof(char)); - * if (uriWindowsFilenameToUriStringA(absFilename, absUri) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * free(absUri); - * ... - * } - * /COMMENT_HACK* absUri is "file:///E:/Documents%20and%20Settings" now *COMMENT_HACK/ - * ... - * free(absUri); - * @endcode - * - * Conversion works .. - * - for relative or absolute values, - * - in both directions (filenames <--> URIs) and - * - with Unix and Windows filenames. - * - * All you have to do is to choose the right function for the task and allocate - * the required space (in characters) for the target buffer. - * Let me present you an overview: - * - * - Filename --> URI - * - uriUnixFilenameToUriStringA()\n - * Space required: [7 +] 3 * len(filename) + 1 - * - uriWindowsFilenameToUriStringA()\n - * Space required: [8 +] 3 * len(filename) + 1 - * - URI --> filename - * - uriUriStringToUnixFilenameA()\n - * Space required: len(uriString) + 1 [- 7] - * - uriUriStringToWindowsFilenameA()\n - * Space required: len(uriString) + 1 [- 8] - * - * - * @subsection normalization Normalizing URIs - * Sometimes we come across unnecessarily long URIs like "http://example.org/one/two/../../one". - * The algorithm we can use to shorten this URI down to "http://example.org/one" is called - * Syntax-Based Normalization. - * Note that normalizing a URI does more than just "stripping dot segments". Please have a look at - * Section 6.2.2 of RFC 3986 - * for the full description. - * - * As we asked uriToStringCharsRequiredA() for the required space when converting - * a URI object back to a string, we can ask uriNormalizeSyntaxMaskRequiredA() for - * the parts of a URI that require normalization and then pass this normalization - * mask to uriNormalizeSyntaxExA(): - * - * @code - * const unsigned int dirtyParts = uriNormalizeSyntaxMaskRequiredA(&uri); - * if (uriNormalizeSyntaxExA(&uri, dirtyParts) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * @endcode - * - * If you don't want to normalize all parts of the URI you can pass a custom - * mask as well: - * - * @code - * const unsigned int normMask = URI_NORMALIZE_SCHEME | URI_NORMALIZE_USER_INFO; - * if (uriNormalizeSyntaxExA(&uri, normMask) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * @endcode - * - * Please see ::UriNormalizationMaskEnum for the complete set of flags. - * - * On the other hand calling plain uriNormalizeSyntaxA() (without the "Ex") - * saves you thinking about single parts, as it queries uriNormalizeSyntaxMaskRequiredA() - * internally: - * - * @code - * if (uriNormalizeSyntaxA(&uri) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * @endcode - * - * - * @section querystrings Working with Query Strings - * RFC 3986 - * itself does not understand the query part of a URI as a list of key/value pairs. - * But HTML 2.0 does and defines a media type application/x-www-form-urlencoded - * in in section 8.2.1 - * of RFC 1866. - * uriparser allows you to dissect (or parse) a query string into unescaped key/value pairs - * and back. - * - * To dissect the query part of a just-parsed URI you could write code like this: - * - * @code - * UriUriA uri; - * UriQueryListA * queryList; - * int itemCount; - * ... - * if (uriDissectQueryMallocA(&queryList, &itemCount, uri.query.first, - * uri.query.afterLast) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * ... - * uriFreeQueryListA(queryList); - * @endcode - * - * @remarks - * - NULL in the value member means there was no '=' in the item text as with "?abc&def". - * - An empty string in the value member means there was '=' in the item as with "?abc=&def". - * - * - * To compose a query string from a query list you could write code like this: - * - * @code - * int charsRequired; - * int charsWritten; - * char * queryString; - * ... - * if (uriComposeQueryCharsRequiredA(queryList, &charsRequired) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * queryString = malloc((charsRequired + 1) * sizeof(char)); - * if (queryString == NULL) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * if (uriComposeQueryA(queryString, queryList, charsRequired + 1, &charsWritten) != URI_SUCCESS) { - * /COMMENT_HACK* Failure *COMMENT_HACK/ - * ... - * } - * ... - * free(queryString); - * @endcode - * - * - * @section chartypes Narrow Strings and Wide Strings - * uriparser comes with two versions of every structure and function: - * one handling narrow strings (char *) and one working with wide strings (wchar_t *), - * for instance - * - uriParseSingleUriA() for char * - * - uriParseSingleUriW() for wchar_t *. - * - * This tutorial only shows the usage of the narrow string editions but - * their wide string counterparts work in the very same way. - * - * - * @section autoconf Autoconf Check - * You can use the code below to make ./configure test for presence - * of uriparser 0.9.0 or later. - * - *
PKG_CHECK_MODULES([URIPARSER], [liburiparser >= 0.9.0], [], [])
- */ diff --git a/external/uriparser/doc/preprocess.sh b/external/uriparser/doc/preprocess.sh deleted file mode 100755 index a663cd1..0000000 --- a/external/uriparser/doc/preprocess.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -# Run GCC preprocessor and delete empty lines -cpp -DURI_DOXYGEN -DURI_NO_UNICODE -C -I ../include $1 | sed -e '/^$/d' -e 's/COMMENT_HACK//g' diff --git a/external/uriparser/doc/release.sh.in b/external/uriparser/doc/release.sh.in deleted file mode 100755 index 6a7d09a..0000000 --- a/external/uriparser/doc/release.sh.in +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env bash -( -cd $(dirname $(which "$0")) || exit 1 - -distdir="@PROJECT_NAME@-@PROJECT_VERSION@-doc" -[ -z $MAKE ] && MAKE=make - -# Clean up -rm -Rf "${distdir}" "${distdir}.zip" - -# Generate -"${MAKE}" -C .. doc || exit 1 - -# Copy -mkdir -p "${distdir}/html/search" -cp \ - html/*.css \ - html/*.html \ - html/*.js \ - html/*.md5 \ - html/*.png \ - \ - "${distdir}/html/" || exit 1 -cp -R html/search/ "${distdir}/html/" || exit 1 - -# Package -zip -r "${distdir}.zip" "${distdir}" || exit 1 - -cat < - - - - - - - - RFC 1866 - Hypertext Markup Language - 2.0 - - - - - - -
-
- -
-[RFCs/IDs] [Plain Text] [From draft-ietf-html-spec]
-
-Obsoleted by: 2854 HISTORIC
-
-
-Network Working Group                                    T. Berners-Lee
-Request for Comments: 1866                                      MIT/W3C
-Category: Standards Track                                   D. Connolly
-                                                          November 1995
-
-
-                    Hypertext Markup Language - 2.0
-
-Status of this Memo
-
-   This document specifies an Internet standards track protocol for the
-   Internet community, and requests discussion and suggestions for
-   improvements.  Please refer to the current edition of the "Internet
-   Official Protocol Standards" (STD 1) for the standardization state
-   and status of this protocol.  Distribution of this memo is unlimited.
-
-Abstract
-
-   The Hypertext Markup Language (HTML) is a simple markup language used
-   to create hypertext documents that are platform independent. HTML
-   documents are SGML documents with generic semantics that are
-   appropriate for representing information from a wide range of
-   domains. HTML markup can represent hypertext news, mail,
-   documentation, and hypermedia; menus of options; database query
-   results; simple structured documents with in-lined graphics; and
-   hypertext views of existing bodies of information.
-
-   HTML has been in use by the World Wide Web (WWW) global information
-   initiative since 1990. This specification roughly corresponds to the
-   capabilities of HTML in common use prior to June 1994. HTML is an
-   application of ISO Standard 8879:1986 Information Processing Text and
-   Office Systems; Standard Generalized Markup Language (SGML).
-
-   The "text/html" Internet Media Type (RFC 1590) and MIME Content Type
-   (RFC 1521) is defined by this specification.
-
-Table of Contents
-
-    1.     Introduction ........................................... 2
-    1.1    Scope .................................................. 3
-    1.2    Conformance ............................................ 3
-    2.     Terms .................................................. 6
-    3.     HTML as an Application of SGML .........................10
-    3.1    SGML Documents .........................................10
-    3.2    HTML Lexical Syntax ................................... 12
-    3.3    HTML Public Text Identifiers .......................... 17
-    3.4    Example HTML Document ................................. 17
-    4.     HTML as an Internet Media Type ........................ 18
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 1]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    4.1    text/html media type .................................. 18
-    4.2    HTML Document Representation .......................... 19
-    5.     Document Structure .................................... 20
-    5.1    Document Element: HTML ................................ 21
-    5.2    Head: HEAD ............................................ 21
-    5.3    Body: BODY ............................................ 24
-    5.4    Headings: H1 ... H6 ................................... 24
-    5.5    Block Structuring Elements ............................ 25
-    5.6    List Elements ......................................... 28
-    5.7    Phrase Markup ......................................... 30
-    5.8    Line Break: BR ........................................ 34
-    5.9    Horizontal Rule: HR ................................... 34
-    5.10   Image: IMG ............................................ 34
-    6.     Characters, Words, and Paragraphs ..................... 35
-    6.1    The HTML Document Character Set ....................... 36
-    7.     Hyperlinks ............................................ 36
-    7.1    Accessing Resources ................................... 37
-    7.2    Activation of Hyperlinks .............................. 38
-    7.3    Simultaneous Presentation of Image Resources .......... 38
-    7.4    Fragment Identifiers .................................. 38
-    7.5    Queries and Indexes ................................... 39
-    7.6    Image Maps ............................................ 39
-    8.     Forms ................................................. 40
-    8.1    Form Elements ......................................... 40
-    8.2    Form Submission ....................................... 45
-    9.     HTML Public Text ...................................... 49
-    9.1    HTML DTD .............................................. 49
-    9.2    Strict HTML DTD ....................................... 61
-    9.3    Level 1 HTML DTD ...................................... 62
-    9.4    Strict Level 1 HTML DTD ............................... 63
-    9.5    SGML Declaration for HTML ............................. 64
-    9.6    Sample SGML Open Entity Catalog for HTML .............. 65
-    9.7    Character Entity Sets ................................. 66
-    10.    Security Considerations ............................... 69
-    11.    References ............................................ 69
-    12.    Acknowledgments ....................................... 71
-    12.1   Authors' Addresses .................................... 71
-    13.    The HTML Coded Character Set .......................... 72
-    14.    Proposed Entities ..................................... 75
-
-1. Introduction
-
-   The HyperText Markup Language (HTML) is a simple data format used to
-   create hypertext documents that are portable from one platform to
-   another. HTML documents are SGML documents with generic semantics
-   that are appropriate for representing information from a wide range
-   of domains.
-
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 2]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   As HTML is an application of SGML, this specification assumes a
-   working knowledge of [SGML].
-
-1.1. Scope
-
-   HTML has been in use by the World-Wide Web (WWW) global information
-   initiative since 1990. Previously, informal documentation on HTML has
-   been available from a number of sources on the Internet. This
-   specification brings together, clarifies, and formalizes a set of
-   features that roughly corresponds to the capabilities of HTML in
-   common use prior to June 1994. A number of new features to HTML are
-   being proposed and experimented in the Internet community.
-
-   This document thus defines a HTML 2.0 (to distinguish it from the
-   previous informal specifications). Future (generally upwardly
-   compatible) versions of HTML with new features will be released with
-   higher version numbers.
-
-   HTML is an application of ISO Standard 8879:1986, "Information
-   Processing Text and Office Systems; Standard Generalized Markup
-   Language" (SGML). The HTML Document Type Definition (DTD) is a formal
-   definition of the HTML syntax in terms of SGML.
-
-   This specification also defines HTML as an Internet Media
-   Type[IMEDIA] and MIME Content Type[MIME] called `text/html'. As such,
-   it defines the semantics of the HTML syntax and how that syntax
-   should be interpreted by user agents.
-
-1.2. Conformance
-
-   This specification governs the syntax of HTML documents and aspects
-   of the behavior of HTML user agents.
-
-1.2.1. Documents
-
-   A document is a conforming HTML document if:
-
-        * It is a conforming SGML document, and it conforms to the
-        HTML DTD (see 9.1, "HTML DTD").
-
-            NOTE - There are a number of syntactic idioms that
-            are not supported or are supported inconsistently in
-            some historical user agent implementations. These
-            idioms are identified in notes like this throughout
-            this specification.
-
-        * It conforms to the application conventions in this
-        specification. For example, the value of the HREF attribute
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 3]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        of the <A> element must conform to the URI syntax.
-
-        * Its document character set includes [ISO-8859-1] and
-        agrees with [ISO-10646]; that is, each code position listed
-        in 13, "The HTML Coded Character Set" is included, and each
-        code position in the document character set is mapped to the
-        same character as [ISO-10646] designates for that code
-        position.
-
-            NOTE - The document character set is somewhat
-            independent of the character encoding scheme used to
-            represent a document. For example, the `ISO-2022-JP'
-            character encoding scheme can be used for HTML
-            documents, since its repertoire is a subset of the
-            [ISO-10646] repertoire. The critical distinction is
-            that numeric character references agree with
-            [ISO-10646] regardless of how the document is
-            encoded.
-
-1.2.2. Feature Test Entities
-
-   The HTML DTD defines a standard HTML document type and several
-   variations, by way of feature test entities. Feature test entities
-   are declarations in the HTML DTD that control the inclusion or
-   exclusion of portions of the DTD.
-
-    HTML.Recommended
-            Certain features of the language are necessary for
-            compatibility with widespread usage, but they may
-            compromise the structural integrity of a document. This
-            feature test entity selects a more prescriptive document
-            type definition that eliminates those features. It is
-            set to `IGNORE' by default.
-
-            For example, in order to preserve the structure of a
-            document, an editing user agent may translate HTML
-            documents to the recommended subset, or it may require
-            that the documents be in the recommended subset for
-            import.
-
-    HTML.Deprecated
-            Certain features of the language are necessary for
-            compatibility with earlier versions of the
-            specification, but they tend to be used and implemented
-            inconsistently, and their use is deprecated. This
-            feature test entity enables a document type definition
-            that allows these features. It is set to `INCLUDE' by
-            default.
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 4]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-            Documents generated by translation software or editing
-            software should not contain deprecated idioms.
-
-1.2.3. User Agents
-
-   An HTML user agent conforms to this specification if:
-
-        * It parses the characters of an HTML document into data
-        characters and markup according to [SGML].
-
-            NOTE - In the interest of robustness and
-            extensibility, there are a number of widely deployed
-            conventions for handling non-conforming documents.
-            See 4.2.1, "Undeclared Markup Error Handling" for
-            details.
-
-        * It supports the `ISO-8859-1' character encoding scheme and
-        processes each character in the ISO Latin Alphabet No. 1 as
-        specified in 6.1, "The HTML Document Character Set".
-
-            NOTE - To support non-western writing systems, HTML
-            user agents are encouraged to support
-            `ISO-10646-UCS-2' or similar character encoding
-            schemes and as much of the character repertoire of
-            [ISO-10646] as is practical.
-
-        * It behaves identically for documents whose parsed token
-        sequences are identical.
-
-        For example, comments and the whitespace in tags disappear
-        during tokenization, and hence they do not influence the
-        behavior of conforming user agents.
-
-        * It allows the user to traverse (or at least attempt to
-        traverse, resources permitting) all hyperlinks from <A>
-        elements in an HTML document.
-
-   An HTML user agent is a level 2 user agent if, additionally:
-
-        * It allows the user to express all form field values
-        specified in an HTML document and to (attempt to) submit the
-        values as requests to information services.
-
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 5]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-2. Terms
-
-    absolute URI
-            a URI in absolute form; for example, as per [URL]
-
-    anchor
-            one of two ends of a hyperlink; typically, a phrase
-            marked as an <A> element.
-
-    base URI
-            an absolute URI used in combination with a relative URI
-            to determine another absolute URI.
-
-    character
-            An atom of information, for example a letter or a digit.
-            Graphic characters have associated glyphs, whereas
-            control characters have associated processing semantics.
-
-    character encoding
-    scheme
-            A function whose domain is the set of sequences of
-            octets, and whose range is the set of sequences of
-            characters from a character repertoire; that is, a
-            sequence of octets and a character encoding scheme
-            determines a sequence of characters.
-
-    character repertoire
-            A finite set of characters; e.g. the range of a coded
-            character set.
-
-    code position
-            An integer. A coded character set and a code position
-            from its domain determine a character.
-
-    coded character set
-            A function whose domain is a subset of the integers and
-            whose range is a character repertoire. That is, for some
-            set of integers (usually of the form {0, 1, 2, ..., N}
-            ), a coded character set and an integer in that set
-            determine a character. Conversely, a character and a
-            coded character set determine the character's code
-            position (or, in rare cases, a few code positions).
-
-    conforming HTML user
-    agent
-            A user agent that conforms to this specification in its
-            processing of the Internet Media Type `text/html'.
-
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 6]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    data character
-            Characters other than markup, which make up the content
-            of elements.
-
-    document character set
-            a coded character set whose range includes all
-            characters used in a document. Every SGML document has
-            exactly one document character set. Numeric character
-            references are resolved via the document character set.
-
-    DTD
-            document type definition. Rules that apply SGML to the
-            markup of documents of a particular type, including a
-            set of element and entity declarations. [SGML]
-
-    element
-            A component of the hierarchical structure defined by a
-            document type definition; it is identified in a document
-            instance by descriptive markup, usually a start-tag and
-            end-tag. [SGML]
-
-    end-tag
-            Descriptive markup that identifies the end of an
-            element. [SGML]
-
-    entity
-            data with an associated notation or interpretation; for
-            example, a sequence of octets associated with an
-            Internet Media Type. [SGML]
-
-    fragment identifier
-            the portion of an HREF attribute value following the `#'
-            character which modifies the presentation of the
-            destination of a hyperlink.
-
-    form data set
-            a sequence of name/value pairs; the names are given by
-            an HTML document and the values are given by a user.
-
-    HTML document
-            An SGML document conforming to this document type
-            definition.
-
-    hyperlink
-            a relationship between two anchors, called the head and
-            the tail. The link goes from the tail to the head. The
-            head and tail are also known as destination and source,
-            respectively.
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 7]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    markup
-            Syntactically delimited characters added to the data of
-            a document to represent its structure. There are four
-            different kinds of markup: descriptive markup (tags),
-            references, markup declarations, and processing
-            instructions. [SGML]
-
-    may
-            A document or user interface is conforming whether this
-            statement applies or not.
-
-    media type
-            an Internet Media Type, as per [IMEDIA].
-
-    message entity
-            a head and body. The head is a collection of name/value
-            fields, and the body is a sequence of octets. The head
-            defines the content type and content transfer encoding
-            of the body. [MIME]
-
-    minimally conforming
-    HTML user agent
-            A user agent that conforms to this specification except
-            for form processing. It may only process level 1 HTML
-            documents.
-
-    must
-            Documents or user agents in conflict with this statement
-            are not conforming.
-
-    numeric character
-    reference
-            markup that refers to a character by its code position
-            in the document character set.
-
-    SGML document
-            A sequence of characters organized physically as a set
-            of entities and logically into a hierarchy of elements.
-            An SGML document consists of data characters and markup;
-            the markup describes the structure of the information
-            and an instance of that structure. [SGML]
-
-    shall
-            If a document or user agent conflicts with this
-            statement, it does not conform to this specification.
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 8]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    should
-            If a document or user agent conflicts with this
-            statement, undesirable results may occur in practice
-            even though it conforms to this specification.
-
-    start-tag
-            Descriptive markup that identifies the start of an
-            element and specifies its generic identifier and
-            attributes. [SGML]
-
-    syntax-reference
-    character set
-            A coded character set whose range includes all
-            characters used for markup; e.g. name characters and
-            delimiter characters.
-
-    tag
-            Markup that delimits an element. A tag includes a name
-            which refers to an element declaration in the DTD, and
-            may include attributes. [SGML]
-
-    text entity
-            A finite sequence of characters. A text entity typically
-            takes the form of a sequence of octets with some
-            associated character encoding scheme, transmitted over
-            the network or stored in a file. [SGML]
-
-    typical
-            Typical processing is described for many elements. This
-            is not a mandatory part of the specification but is
-            given as guidance for designers and to help explain the
-            uses for which the elements were intended.
-
-    URI
-            A Uniform Resource Identifier is a formatted string that
-            serves as an identifier for a resource, typically on the
-            Internet. URIs are used in HTML to identify the anchors
-            of hyperlinks. URIs in common practice include Uniform
-            Resource Locators (URLs)[URL] and Relative URLs
-            [RELURL].
-
-    user agent
-            A component of a distributed system that presents an
-            interface and processes requests on behalf of a user;
-            for example, a www browser or a mail user agent.
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                     [Page 9]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    WWW
-            The World-Wide Web is a hypertext-based, distributed
-            information system created by researchers at CERN in
-            Switzerland. <URL:http://www.w3.org/>
-
-3. HTML as an Application of SGML
-
-   HTML is an application of ISO 8879:1986 -- Standard Generalized
-   Markup Language (SGML). SGML is a system for defining structured
-   document types and markup languages to represent instances of those
-   document types[SGML]. The public text -- DTD and SGML declaration --
-   of the HTML document type definition are provided in 9, "HTML Public
-   Text".
-
-   The term "HTML" refers to both the document type defined here and the
-   markup language for representing instances of this document type.
-
-3.1. SGML Documents
-
-   An HTML document is an SGML document; that is, a sequence of
-   characters organized physically into a set of entities, and logically
-   as a hierarchy of elements.
-
-   In the SGML specification, the first production of the SGML syntax
-   grammar separates an SGML document into three parts: an SGML
-   declaration, a prologue, and an instance. For the purposes of this
-   specification, the prologue is a DTD. This DTD describes another
-   grammar: the start symbol is given in the doctype declaration, the
-   terminals are data characters and tags, and the productions are
-   determined by the element declarations. The instance must conform to
-   the DTD, that is, it must be in the language defined by this grammar.
-
-   The SGML declaration determines the lexicon of the grammar. It
-   specifies the document character set, which determines a character
-   repertoire that contains all characters that occur in all text
-   entities in the document, and the code positions associated with
-   those characters.
-
-   The SGML declaration also specifies the syntax-reference character
-   set of the document, and a few other parameters that bind the
-   abstract syntax of SGML to a concrete syntax. This concrete syntax
-   determines how the sequence of characters of the document is mapped
-   to a sequence of terminals in the grammar of the prologue.
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 10]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   For example, consider the following document:
-
-    <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
-    <title>Parsing Example</title>
-    <p>Some text. <em>&#42;wow&#42;</em></p>
-
-   An HTML user agent should use the SGML declaration that is given in
-   9.5, "SGML Declaration for HTML". According to its document character
-   set, `&#42;' refers to an asterisk character, `*'.
-
-   The instance above is regarded as the following sequence of
-   terminals:
-
-        1. start-tag: TITLE
-
-        2. data characters: "Parsing Example"
-
-        3. end-tag: TITLE
-
-        4. start-tag: P
-
-        5. data characters "Some text."
-
-        6. start-tag: EM
-
-        7. data characters: "*wow*"
-
-        8. end-tag: EM
-
-        9. end-tag: P
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 11]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   The start symbol of the DTD grammar is HTML, and the productions are
-   given in the public text identified by `-//IETF//DTD HTML 2.0//EN'
-   (9.1, "HTML DTD"). The terminals above parse as:
-
-       HTML
-        |
-        \-HEAD
-        |  |
-        |  \-TITLE
-        |      |
-        |      \-<TITLE>
-        |      |
-        |      \-"Parsing Example"
-        |      |
-        |      \-</TITLE>
-        |
-        \-BODY
-          |
-          \-P
-            |
-            \-<P>
-            |
-            \-"Some text. "
-            |
-            \-EM
-            |  |
-            |  \-<EM>
-            |  |
-            |  \-"*wow*"
-            |  |
-            |  \-</EM>
-            |
-            \-</P>
-
-   Some of the elements are delimited explicitly by tags, while the
-   boundaries of others are inferred. The <HTML> element contains a
-   <HEAD> element and a <BODY> element. The <HEAD> contains <TITLE>,
-   which is explicitly delimited by start- and end-tags.
-
-3.2. HTML Lexical Syntax
-
-   SGML specifies an abstract syntax and a reference concrete syntax.
-   Aside from certain quantities and capacities (e.g. the limit on the
-   length of a name), all HTML documents use the reference concrete
-   syntax. In particular, all markup characters are in the repertoire of
-   [ISO-646]. Data characters are drawn from the document character set
-   (see 6, "Characters, Words, and Paragraphs").
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 12]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   A complete discussion of SGML parsing, e.g. the mapping of a sequence
-   of characters to a sequence of tags and data, is left to the SGML
-   standard[SGML]. This section is only a summary.
-
-3.2.1. Data Characters
-
-   Any sequence of characters that do not constitute markup (see 9.6
-   "Delimiter Recognition" of [SGML]) are mapped directly to strings of
-   data characters. Some markup also maps to data character strings.
-   Numeric character references map to single-character strings, via the
-   document character set. Each reference to one of the general entities
-   defined in the HTML DTD maps to a single-character string.
-
-   For example,
-
-    abc&lt;def    => "abc","<","def"
-    abc&#60;def   => "abc","<","def"
-
-   The terminating semicolon on entity or numeric character references
-   is only necessary when the character following the reference would
-   otherwise be recognized as part of the name (see 9.4.5 "Reference
-   End" in [SGML]).
-
-    abc &lt def     => "abc ","<"," def"
-    abc &#60 def    => "abc ","<"," def"
-
-   An ampersand is only recognized as markup when it is followed by a
-   letter or a `#' and a digit:
-
-    abc & lt def    => "abc & lt def"
-    abc &# 60 def    => "abc &# 60 def"
-
-   A useful technique for translating plain text to HTML is to replace
-   each '<', '&', and '>' by an entity reference or numeric character
-   reference as follows:
-
-                     ENTITY      NUMERIC
-           CHARACTER REFERENCE   CHAR REF     CHARACTER DESCRIPTION
-           --------- ----------  -----------  ---------------------
-             &       &amp;       &#38;        Ampersand
-             <       &lt;        &#60;        Less than
-             >       &gt;        &#62;        Greater than
-
-        NOTE - There are SGML mechanisms, CDATA and RCDATA
-        declared content, that allow most `<', `>', and `&'
-        characters to be entered without the use of entity
-        references. Because these mechanisms tend to be used and
-        implemented inconsistently, and because they conflict
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 13]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        with techniques for reducing HTML to 7 bit ASCII for
-        transport, they are deprecated in this version of HTML.
-        See 5.5.2.1, "Example and Listing: XMP, LISTING".
-
-3.2.2. Tags
-
-   Tags delimit elements such as headings, paragraphs, lists, character
-   highlighting, and links. Most HTML elements are identified in a
-   document as a start-tag, which gives the element name and attributes,
-   followed by the content, followed by the end tag. Start-tags are
-   delimited by `<' and `>'; end tags are delimited by `</' and `>'. An
-   example is:
-
-   <H1>This is a Heading</H1>
-
-   Some elements only have a start-tag without an end-tag. For example,
-   to create a line break, use the `<BR>' tag.  Additionally, the end
-   tags of some other elements, such as Paragraph (`</P>'), List Item
-   (`</LI>'), Definition Term (`</DT>'), and Definition Description
-   (`</DD>') elements, may be omitted.
-
-   The content of an element is a sequence of data character strings and
-   nested elements. Some elements, such as anchors, cannot be nested.
-   Anchors and character highlighting may be put inside other
-   constructs. See the HTML DTD, 9.1, "HTML DTD" for full details.
-
-      NOTE - The SGML declaration for HTML specifies SHORTTAG YES, which
-      means that there are other valid syntaxes for tags, such as NET
-      tags, `<EM/.../'; empty start tags, `<>'; and empty end-tags,
-      `</>'. Until support for these idioms is widely deployed, their
-      use is strongly discouraged.
-
-3.2.3. Names
-
-   A name consists of a letter followed by letters, digits, periods, or
-   hyphens. The length of a name is limited to 72 characters by the
-   `NAMELEN' parameter in the SGML declaration for HTML, 9.5, "SGML
-   Declaration for HTML". Element and attribute names are not case
-   sensitive, but entity names are.  For example, `<BLOCKQUOTE>',
-   `<BlockQuote>', and `<blockquote>' are equivalent, whereas `&amp;' is
-   different from `&AMP;'.
-
-   In a start-tag, the element name must immediately follow the tag open
-   delimiter `<'.
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 14]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-3.2.4. Attributes
-
-   In a start-tag, white space and attributes are allowed between the
-   element name and the closing delimiter. An attribute specification
-   typically consists of an attribute name, an equal sign, and a value,
-   though some attribute specifications may be just a name token. White
-   space is allowed around the equal sign.
-
-   The value of the attribute may be either:
-
-        * A string literal, delimited by single quotes or double
-        quotes and not containing any occurrences of the delimiting
-        character.
-
-            NOTE - Some historical implementations consider any
-            occurrence of the `>' character to signal the end of
-            a tag. For compatibility with such implementations,
-            when `>' appears in an attribute value, it should be
-            represented with a numeric character reference. For
-            example, `<IMG SRC="eq1.jpg" alt="a>b">' should be
-            written `<IMG SRC="eq1.jpg" alt="a&#62;b">' or `<IMG
-            SRC="eq1.jpg" alt="a&gt;b">'.
-
-        * A name token (a sequence of letters, digits, periods, or
-        hyphens). Name tokens are not case sensitive.
-
-            NOTE - Some historical implementations allow any
-            character except space or `>' in a name token.
-
-   In this example, <img> is the element name, src is the attribute
-   name, and `http://host/dir/file.gif' is the attribute value:
-
-   <img src='http://host/dir/file.gif'>
-
-   A useful technique for computing an attribute value literal for a
-   given string is to replace each quote and white space character by an
-   entity reference or numeric character reference as follows:
-
-                     ENTITY      NUMERIC
-           CHARACTER REFERENCE   CHAR REF     CHARACTER DESCRIPTION
-           --------- ----------  -----------  ---------------------
-             HT                  &#9;         Tab
-             LF                  &#10;        Line Feed
-             CR                  &#13;        Carriage Return
-             SP                  &#32;        Space
-             "       &quot;      &#34;        Quotation mark
-             &       &amp;       &#38;        Ampersand
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 15]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   For example:
-
-   <IMG SRC="image.jpg" alt="First &quot;real&quot; example">
-
-   The `NAMELEN' parameter in the SGML declaration (9.5, "SGML
-   Declaration for HTML") limits the length of an attribute value to
-   1024 characters.
-
-   Attributes such as ISMAP and COMPACT may be written using a minimized
-   syntax (see 7.9.1.2 "Omitted Attribute Name" in [SGML]). The markup:
-
-   <UL COMPACT="compact">
-
-   can be written using a minimized syntax:
-
-   <UL COMPACT>
-
-   NOTE - Some historical implementations only understand the minimized
-   syntax.
-
-3.2.5. Comments
-
-   To include comments in an HTML document, use a comment declaration. A
-   comment declaration consists of `<!' followed by zero or more
-   comments followed by `>'. Each comment starts with `--' and includes
-   all text up to and including the next occurrence of `--'. In a
-   comment declaration, white space is allowed after each comment, but
-   not before the first comment.  The entire comment declaration is
-   ignored.
-
-      NOTE - Some historical HTML implementations incorrectly consider
-      any `>' character to be the termination of a comment.
-
-   For example:
-
-    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-    <HEAD>
-    <TITLE>HTML Comment Example</TITLE>
-    <!-- Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp  -->
-    <!-- another -- -- comment -->
-    <!>
-    </HEAD>
-    <BODY>
-    <p> <!- not a comment, just regular old data characters ->
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 16]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-3.3. HTML Public Text Identifiers
-
-   To identify information as an HTML document conforming to this
-   specification, each document must start with one of the following
-   document type declarations.
-
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-
-   This document type declaration refers to the HTML DTD in 9.1, "HTML
-   DTD".
-
-      NOTE - If the body of a `text/html' message entity does not begin
-      with a document type declaration, an HTML user agent should infer
-      the above document type declaration.
-
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Level 2//EN">
-
-   This document type declaration also refers to the HTML DTD which
-   appears in 9.1, "HTML DTD".
-
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Level 1//EN">
-
-   This document type declaration refers to the level 1 HTML DTD in 9.3,
-   "Level 1 HTML DTD". Form elements must not occur in level 1
-   documents.
-
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict//EN">
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 1//EN">
-
-   These two document type declarations refer to the HTML DTD in 9.2,
-   "Strict HTML DTD" and 9.4, "Strict Level 1 HTML DTD". They refer to
-   the more structurally rigid definition of HTML.
-
-   HTML user agents may support other document types. In particular,
-   they may support other formal public identifiers, or other document
-   types altogether. They may support an internal declaration subset
-   with supplemental entity, element, and other markup declarations.
-
-3.4. Example HTML Document
-
-    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-    <HTML>
-    <!-- Here's a good place to put a comment. -->
-    <HEAD>
-    <TITLE>Structural Example</TITLE>
-    </HEAD><BODY>
-    <H1>First Header</H1>
-    <P>This is a paragraph in the example HTML file. Keep in mind
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 17]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    that the title does not appear in the document text, but that
-    the header (defined by H1) does.</P>
-    <OL>
-    <LI>First item in an ordered list.
-    <LI>Second item in an ordered list.
-      <UL COMPACT>
-      <LI> Note that lists can be nested;
-      <LI> Whitespace may be used to assist in reading the
-           HTML source.
-      </UL>
-    <LI>Third item in an ordered list.
-    </OL>
-    <P>This is an additional paragraph. Technically, end tags are
-    not required for paragraphs, although they are allowed. You can
-    include character highlighting in a paragraph. <EM>This sentence
-    of the paragraph is emphasized.</EM> Note that the &lt;/P&gt;
-    end tag has been omitted.
-    <P>
-    <IMG SRC ="triangle.xbm" alt="Warning: ">
-    Be sure to read these <b>bold instructions</b>.
-    </BODY></HTML>
-
-4. HTML as an Internet Media Type
-
-   An HTML user agent allows users to interact with resources which have
-   HTML representations. At a minimum, it must allow users to examine
-   and navigate the content of HTML level 1 documents. HTML user agents
-   should be able to preserve all formatting distinctions represented in
-   an HTML document, and be able to simultaneously present resources
-   referred to by IMG elements (they may ignore some formatting
-   distinctions or IMG resources at the request of the user). Level 2
-   HTML user agents should support form entry and submission.
-
-4.1. text/html media type
-
-   This specification defines the Internet Media Type [IMEDIA] (formerly
-   referred to as the Content Type [MIME]) called `text/html'. The
-   following is to be registered with [IANA].
-
-    Media Type name
-            text
-
-    Media subtype name
-            html
-
-    Required parameters
-            none
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 18]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    Optional parameters
-            level, charset
-
-    Encoding considerations
-            any encoding is allowed
-
-    Security considerations
-            see 10, "Security Considerations"
-
-    The optional parameters are defined as follows:
-
-    Level
-            The level parameter specifies the feature set used in
-            the document. The level is an integer number, implying
-            that any features of same or lower level may be present
-            in the document. Level 1 is all features defined in this
-            specification except those that require the <FORM>
-            element. Level 2 includes form processing. Level 2 is
-            the default.
-
-    Charset
-            The charset parameter (as defined in section 7.1.1 of
-            RFC 1521[MIME]) may be given to specify the character
-            encoding scheme used to represent the HTML document as a
-            sequence of octets. The default value is outside the
-            scope of this specification; but for example, the
-            default is `US-ASCII' in the context of MIME mail, and
-            `ISO-8859-1' in the context of HTTP [HTTP].
-
-4.2. HTML Document Representation
-
-   A message entity with a content type of `text/html' represents an
-   HTML document, consisting of a single text entity. The `charset'
-   parameter (whether implicit or explicit) identifies a character
-   encoding scheme. The text entity consists of the characters
-   determined by this character encoding scheme and the octets of the
-   body of the message entity.
-
-4.2.1. Undeclared Markup Error Handling
-
-   To facilitate experimentation and interoperability between
-   implementations of various versions of HTML, the installed base of
-   HTML user agents supports a superset of the HTML 2.0 language by
-   reducing it to HTML 2.0: markup in the form of a start-tag or end-
-   tag, whose generic identifier is not declared is mapped to nothing
-   during tokenization. Undeclared attributes are treated similarly. The
-   entire attribute specification of an unknown attribute (i.e., the
-   unknown attribute and its value, if any) should be ignored. On the
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 19]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   other hand, references to undeclared entities should be treated as
-   data characters.
-
-   For example:
-
-    <div class=chapter><h1>foo</h1><p>...</div>
-      => <H1>,"foo",</H1>,<P>,"..."
-    xxx <P ID=z23> yyy
-      => "xxx ",<P>," yyy
-    Let &alpha; &amp; &beta; be finite sets.
-      => "Let &alpha; & &beta; be finite sets."
-
-   Support for notifying the user of such errors is encouraged.
-
-   Information providers are warned that this convention is not binding:
-   unspecified behavior may result, as such markup does not conform to
-   this specification.
-
-4.2.2. Conventional Representation of Newlines
-
-   SGML specifies that a text entity is a sequence of records, each
-   beginning with a record start character and ending with a record end
-   character (code positions 10 and 13 respectively) (section 7.6.1,
-   "Record Boundaries" in [SGML]).
-
-   [MIME] specifies that a body of type `text/*' is a sequence of lines,
-   each terminated by CRLF, that is, octets 13, 10.
-
-   In practice, HTML documents are frequently represented and
-   transmitted using an end of line convention that depends on the
-   conventions of the source of the document; frequently, that
-   representation consists of CR only, LF only, or a CR LF sequence.
-   Hence the decoding of the octets will often result in a text entity
-   with some missing record start and record end characters.
-
-   Since there is no ambiguity, HTML user agents are encouraged to infer
-   the missing record start and end characters.
-
-   An HTML user agent should treat end of line in any of its variations
-   as a word space in all contexts except preformatted text. Within
-   preformatted text, an HTML user agent should treat any of the three
-   common representations of end-of-line as starting a new line.
-
-5. Document Structure
-
-   An HTML document is a tree of elements, including a head and body,
-   headings, paragraphs, lists, etc. Form elements are discussed in 8,
-   "Forms".
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 20]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.1. Document Element: HTML
-
-   The HTML document element consists of a head and a body, much like a
-   memo or a mail message. The head contains the title and optional
-   elements. The body is a text flow consisting of paragraphs, lists,
-   and other elements.
-
-5.2. Head: HEAD
-
-   The head of an HTML document is an unordered collection of
-   information about the document. For example:
-
-    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-    <HEAD>
-    <TITLE>Introduction to HTML</TITLE>
-    </HEAD>
-    ...
-
-5.2.1. Title: TITLE
-
-   Every HTML document must contain a <TITLE> element.
-
-   The title should identify the contents of the document in a global
-   context. A short title, such as "Introduction" may be meaningless out
-   of context. A title such as "Introduction to HTML Elements" is more
-   appropriate.
-
-      NOTE - The length of a title is not limited; however, long titles
-      may be truncated in some applications. To minimize this
-      possibility, titles should be fewer than 64 characters.
-
-   A user agent may display the title of a document in a history list or
-   as a label for the window displaying the document. This differs from
-   headings (5.4, "Headings: H1 ... H6"), which are typically displayed
-   within the body text flow.
-
-5.2.2. Base Address: BASE
-
-   The optional <BASE> element provides a base address for interpreting
-   relative URLs when the document is read out of context (see 7,
-   "Hyperlinks"). The value of the HREF attribute must be an absolute
-   URI.
-
-5.2.3. Keyword Index: ISINDEX
-
-   The <ISINDEX> element indicates that the user agent should allow the
-   user to search an index by giving keywords. See 7.5, "Queries and
-   Indexes" for details.
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 21]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.2.4. Link: LINK
-
-   The <LINK> element represents a hyperlink (see 7, "Hyperlinks").  Any
-   number of LINK elements may occur in the <HEAD> element of an HTML
-   document. It has the same attributes as the <A> element (see 5.7.3,
-   "Anchor: A").
-
-   The <LINK> element is typically used to indicate authorship, related
-   indexes and glossaries, older or more recent versions, document
-   hierarchy, associated resources such as style sheets, etc.
-
-5.2.5. Associated Meta-information: META
-
-   The <META> element is an extensible container for use in identifying
-   specialized document meta-information.  Meta-information has two main
-   functions:
-
-        * to provide a means to discover that the data set exists
-        and how it might be obtained or accessed; and
-
-        * to document the content, quality, and features of a data
-        set, indicating its fitness for use.
-
-   Each <META> element specifies a name/value pair. If multiple META
-   elements are provided with the same name, their combined contents--
-   concatenated as a comma-separated list--is the value associated with
-   that name.
-
-        NOTE - The <META> element should not be used where a
-        specific element, such as <TITLE>, would be more
-        appropriate. Rather than a <META> element with a URI as
-        the value of the CONTENT attribute, use a <LINK>
-        element.
-
-   HTTP servers may read the content of the document <HEAD> to generate
-   header fields corresponding to any elements defining a value for the
-   attribute HTTP-EQUIV.
-
-        NOTE - The method by which the server extracts document
-        meta-information is unspecified and not mandatory. The
-        <META> element only provides an extensible mechanism for
-        identifying and embedding document meta-information --
-        how it may be used is up to the individual server
-        implementation and the HTML user agent.
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 22]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    Attributes of the META element:
-
-    HTTP-EQUIV
-            binds the element to an HTTP header field. An HTTP
-            server may use this information to process the document.
-            In particular, it may include a header field in the
-            responses to requests for this document: the header name
-            is taken from the HTTP-EQUIV attribute value, and the
-            header value is taken from the value of the CONTENT
-            attribute. HTTP header names are not case sensitive.
-
-    NAME
-            specifies the name of the name/value pair. If not
-            present, HTTP-EQUIV gives the name.
-
-    CONTENT
-            specifies the value of the name/value pair.
-
-    Examples
-
-    If the document contains:
-
-    <META HTTP-EQUIV="Expires"
-          CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">
-    <meta http-equiv="Keywords" CONTENT="Fred">
-    <META HTTP-EQUIV="Reply-to"
-          content="fielding@ics.uci.edu (Roy Fielding)">
-    <Meta Http-equiv="Keywords" CONTENT="Barney">
-
-    then the server may include the following header fields:
-
-    Expires: Tue, 04 Dec 1993 21:29:02 GMT
-    Keywords: Fred, Barney
-    Reply-to: fielding@ics.uci.edu (Roy Fielding)
-
-    as part of the HTTP response to a `GET' or `HEAD' request for
-    that document.
-
-    An HTTP server must not use the <META> element to form an HTTP
-    response header unless the HTTP-EQUIV attribute is present.
-
-    An HTTP server may disregard any <META> elements that specify
-    information controlled by the HTTP server, for example `Server',
-
-    `Date', and `Last-modified'.
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 23]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.2.6. Next Id: NEXTID
-
-   The <NEXTID> element is included for historical reasons only.  HTML
-   documents should not contain <NEXTID> elements.
-
-   The <NEXTID> element gives a hint for the name to use for a new <A>
-   element when editing an HTML document. It should be distinct from all
-   NAME attribute values on <A> elements. For example:
-
-   <NEXTID N=Z27>
-
-5.3. Body: BODY
-
-   The <BODY> element contains the text flow of the document, including
-   headings, paragraphs, lists, etc.
-
-   For example:
-
-    <BODY>
-    <h1>Important Stuff</h1>
-    <p>Explanation about important stuff...
-    </BODY>
-
-5.4. Headings: H1 ... H6
-
-   The six heading elements, <H1> through <H6>, denote section headings.
-   Although the order and occurrence of headings is not constrained by
-   the HTML DTD, documents should not skip levels (for example, from H1
-   to H3), as converting such documents to other representations is
-   often problematic.
-
-   Example of use:
-
-    <H1>This is a heading</H1>
-    Here is some text
-    <H2>Second level heading</H2>
-    Here is some more text.
-
-    Typical renderings are:
-
-    H1
-            Bold, very-large font, centered. One or two blank lines
-            above and below.
-
-    H2
-            Bold, large font, flush-left. One or two blank lines
-            above and below.
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 24]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    H3
-            Italic, large font, slightly indented from the left
-            margin. One or two blank lines above and below.
-
-    H4
-            Bold, normal font, indented more than H3. One blank line
-            above and below.
-
-    H5
-            Italic, normal font, indented as H4. One blank line
-            above.
-
-    H6
-            Bold, indented same as normal text, more than H5. One
-            blank line above.
-
-5.5. Block Structuring Elements
-
-   Block structuring elements include paragraphs, lists, and block
-   quotes. They must not contain heading elements, but they may contain
-   phrase markup, and in some cases, they may be nested.
-
-5.5.1. Paragraph: P
-
-   The <P> element indicates a paragraph. The exact indentation, leading
-   space, etc. of a paragraph is not specified and may be a function of
-   other tags, style sheets, etc.
-
-   Typically, paragraphs are surrounded by a vertical space of one line
-   or half a line. The first line in a paragraph is indented in some
-   cases.
-
-   Example of use:
-
-    <H1>This Heading Precedes the Paragraph</H1>
-    <P>This is the text of the first paragraph.
-    <P>This is the text of the second paragraph. Although you do not
-    need to start paragraphs on new lines, maintaining this
-    convention facilitates document maintenance.</P>
-    <P>This is the text of a third paragraph.</P>
-
-5.5.2. Preformatted Text: PRE
-
-   The <PRE> element represents a character cell block of text and is
-   suitable for text that has been formatted for a monospaced font.
-
-   The <PRE> tag may be used with the optional WIDTH attribute. The
-   WIDTH attribute specifies the maximum number of characters for a line
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 25]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   and allows the HTML user agent to select a suitable font and
-   indentation.
-
-   Within preformatted text:
-
-        * Line breaks within the text are rendered as a move to the
-        beginning of the next line.
-
-            NOTE - References to the "beginning of a new line"
-            do not imply that the renderer is forbidden from
-            using a constant left indent for rendering
-            preformatted text. The left indent may be
-            constrained by the width required.
-
-        * Anchor elements and phrase markup may be used.
-
-            NOTE - Constraints on the processing of <PRE>
-            content may limit or prevent the ability of the HTML
-            user agent to faithfully render phrase markup.
-
-        * Elements that define paragraph formatting (headings,
-        address, etc.) must not be used.
-
-            NOTE - Some historical documents contain <P> tags in
-            <PRE> elements. User agents are encouraged to treat
-            this as a line break. A <P> tag followed by a
-            newline character should produce only one line
-            break, not a line break plus a blank line.
-
-        * The horizontal tab character (code position 9 in the HTML
-        document character set) must be interpreted as the smallest
-        positive nonzero number of spaces which will leave the
-        number of characters so far on the line as a multiple of 8.
-        Documents should not contain tab characters, as they are not
-        supported consistently.
-
-    Example of use:
-
-    <PRE>
-    Line 1.
-           Line 2 is to the right of line 1.     <a href="abc">abc</a>
-           Line 3 aligns with line 2.            <a href="def">def</a>
-    </PRE>
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 26]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.5.2.1. Example and Listing: XMP, LISTING
-
-   The <XMP> and <LISTING> elements are similar to the <PRE> element,
-   but they have a different syntax. Their content is declared as CDATA,
-   which means that no markup except the end-tag open delimiter-in-
-   context is recognized (see 9.6 "Delimiter Recognition" of [SGML]).
-
-      NOTE - In a previous draft of the HTML specification, the syntax
-      of <XMP> and <LISTING> elements allowed closing tags to be treated
-      as data characters, as long as the tag name was not <XMP> or
-      <LISTING>, respectively.
-
-   Since CDATA declared content has a number of unfortunate interactions
-   with processing techniques and tends to be used and implemented
-   inconsistently, HTML documents should not contain <XMP> nor <LISTING>
-   elements -- the <PRE> tag is more expressive and more consistently
-   supported.
-
-   The <LISTING> element should be rendered so that at least 132
-   characters fit on a line. The <XMP> element should be rendered so
-   that at least 80 characters fit on a line but is otherwise identical
-   to the <LISTING> element.
-
-      NOTE - In a previous draft, HTML included a <PLAINTEXT> element
-      that is similar to the <LISTING> element, except that there is no
-      closing tag: all characters after the <PLAINTEXT> start-tag are
-      data.
-
-5.5.3. Address: ADDRESS
-
-   The <ADDRESS> element contains such information as address, signature
-   and authorship, often at the beginning or end of the body of a
-   document.
-
-   Typically, the <ADDRESS> element is rendered in an italic typeface
-   and may be indented.
-
-   Example of use:
-
-    <ADDRESS>
-    Newsletter editor<BR>
-    J.R. Brown<BR>
-    JimquickPost News, Jimquick, CT 01234<BR>
-    Tel (123) 456 7890
-    </ADDRESS>
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 27]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.5.4. Block Quote: BLOCKQUOTE
-
-   The <BLOCKQUOTE> element contains text quoted from another source.
-
-   A typical rendering might be a slight extra left and right indent,
-   and/or italic font. The <BLOCKQUOTE> typically provides space above
-   and below the quote.
-
-   Single-font rendition may reflect the quotation style of Internet
-   mail by putting a vertical line of graphic characters, such as the
-   greater than symbol (>), in the left margin.
-
-   Example of use:
-
-    I think the play ends
-    <BLOCKQUOTE>
-    <P>Soft you now, the fair Ophelia. Nymph, in thy orisons, be all
-    my sins remembered.
-    </BLOCKQUOTE>
-    but I am not sure.
-
-5.6. List Elements
-
-   HTML includes a number of list elements. They may be used in
-   combination; for example, a <OL> may be nested in an <LI> element of
-   a <UL>.
-
-   The COMPACT attribute suggests that a compact rendering be used.
-
-5.6.1. Unordered List: UL, LI
-
-   The <UL> represents a list of items -- typically rendered as a
-   bulleted list.
-
-   The content of a <UL> element is a sequence of <LI> elements.  For
-   example:
-
-    <UL>
-    <LI>First list item
-    <LI>Second list item
-     <p>second paragraph of second item
-    <LI>Third list item
-    </UL>
-
-5.6.2. Ordered List: OL
-
-   The <OL> element represents an ordered list of items, sorted by
-   sequence or order of importance. It is typically rendered as a
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 28]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   numbered list.
-
-   The content of a <OL> element is a sequence of <LI> elements.  For
-   example:
-
-    <OL>
-    <LI>Click the Web button to open URI window.
-    <LI>Enter the URI number in the text field of the Open URI
-    window. The Web document you specified is displayed.
-      <ol>
-       <li>substep 1
-       <li>substep 2
-      </ol>
-    <LI>Click highlighted text to move from one link to another.
-    </OL>
-
-5.6.3. Directory List: DIR
-
-   The <DIR> element is similar to the <UL> element. It represents a
-   list of short items, typically up to 20 characters each. Items in a
-   directory list may be arranged in columns, typically 24 characters
-   wide.
-
-   The content of a <DIR> element is a sequence of <LI> elements.
-   Nested block elements are not allowed in the content of <DIR>
-   elements. For example:
-
-    <DIR>
-    <LI>A-H<LI>I-M
-    <LI>M-R<LI>S-Z
-    </DIR>
-
-5.6.4. Menu List: MENU
-
-   The <MENU> element is a list of items with typically one line per
-   item. The menu list style is typically more compact than the style of
-   an unordered list.
-
-   The content of a <MENU> element is a sequence of <LI> elements.
-   Nested block elements are not allowed in the content of <MENU>
-   elements. For example:
-
-    <MENU>
-    <LI>First item in the list.
-    <LI>Second item in the list.
-    <LI>Third item in the list.
-    </MENU>
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 29]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.6.5. Definition List: DL, DT, DD
-
-   A definition list is a list of terms and corresponding definitions.
-   Definition lists are typically formatted with the term flush-left and
-   the definition, formatted paragraph style, indented after the term.
-
-   The content of a <DL> element is a sequence of <DT> elements and/or
-   <DD> elements, usually in pairs. Multiple <DT> may be paired with a
-   single <DD> element. Documents should not contain multiple
-   consecutive <DD> elements.
-
-   Example of use:
-
-    <DL>
-    <DT>Term<DD>This is the definition of the first term.
-    <DT>Term<DD>This is the definition of the second term.
-    </DL>
-
-   If the DT term does not fit in the DT column (typically one third of
-   the display area), it may be extended across the page with the DD
-   section moved to the next line, or it may be wrapped onto successive
-   lines of the left hand column.
-
-   The optional COMPACT attribute suggests that a compact rendering be
-   used, because the list items are small and/or the entire list is
-   large.
-
-   Unless the COMPACT attribute is present, an HTML user agent may leave
-   white space between successive DT, DD pairs. The COMPACT attribute
-   may also reduce the width of the left-hand (DT) column.
-
-    <DL COMPACT>
-    <DT>Term<DD>This is the first definition in compact format.
-    <DT>Term<DD>This is the second definition in compact format.
-    </DL>
-
-5.7. Phrase Markup
-
-   Phrases may be marked up according to idiomatic usage, typographic
-   appearance, or for use as hyperlink anchors.
-
-   User agents must render highlighted phrases distinctly from plain
-   text. Additionally, <EM> content must be rendered as distinct from
-   <STRONG> content, and <B> content must rendered as distinct from <I>
-   content.
-
-   Phrase elements may be nested within the content of other phrase
-   elements; however, HTML user agents may render nested phrase elements
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 30]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   indistinctly from non-nested elements:
-
-   plain <B>bold <I>italic</I></B> may be rendered
-   the same as plain <B>bold </B><I>italic</I>
-
-5.7.1. Idiomatic Elements
-
-   Phrases may be marked up to indicate certain idioms.
-
-      NOTE - User agents may support the <DFN> element, not included in
-      this specification, as it has been deployed to some extent. It is
-      used to indicate the defining instance of a term, and it is
-      typically rendered in italic or bold italic.
-
-5.7.1.1. Citation: CITE
-
-      The <CITE> element is used to indicate the title of a book or
-      other citation. It is typically rendered as italics. For example:
-
-      He just couldn't get enough of <cite>The Grapes of Wrath</cite>.
-
-5.7.1.2. Code: CODE
-
-      The <CODE> element indicates an example of code, typically
-      rendered in a mono-spaced font. The <CODE> element is intended for
-      short words or phrases of code; the <PRE> block structuring
-      element (5.5.2, "Preformatted Text: PRE") is more appropriate
-       for multiple-line listings. For example:
-
-      The expression <code>x += 1</code>
-      is short for <code>x = x + 1</code>.
-
-5.7.1.3. Emphasis: EM
-
-      The <EM> element indicates an emphasized phrase, typically
-      rendered as italics. For example:
-
-      A singular subject <em>always</em> takes a singular verb.
-
-5.7.1.4. Keyboard: KBD
-
-      The <KBD> element indicates text typed by a user, typically
-      rendered in a mono-spaced font. This is commonly used in
-      instruction manuals. For example:
-
-      Enter <kbd>FIND IT</kbd> to search the database.
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 31]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.7.1.5. Sample: SAMP
-
-      The <SAMP> element indicates a sequence of literal characters,
-      typically rendered in a mono-spaced font. For example:
-
-      The only word containing the letters <samp>mt</samp> is dreamt.
-
-5.7.1.6. Strong Emphasis: STRONG
-
-      The <STRONG> element indicates strong emphasis, typically rendered
-      in bold. For example:
-
-      <strong>STOP</strong>, or I'll say "<strong>STOP</strong>" again!
-
-5.7.1.7. Variable: VAR
-
-      The <VAR> element indicates a placeholder variable, typically
-      rendered as italic. For example:
-
-      Type <SAMP>html-check <VAR>file</VAR> | more</SAMP>
-      to check <VAR>file</VAR> for markup errors.
-
-5.7.2. Typographic Elements
-
-      Typographic elements are used to specify the format of marked
-      text.
-
-      Typical renderings for idiomatic elements may vary between user
-      agents. If a specific rendering is necessary -- for example, when
-      referring to a specific text attribute as in "The italic parts are
-      mandatory" -- a typographic element can be used to ensure that the
-      intended typography is used where possible.
-
-      NOTE - User agents may support some typographic elements not
-      included in this specification, as they have been deployed to some
-      extent. The <STRIKE> element indicates horizontal line through the
-      characters, and the <U> element indicates an underline.
-
-5.7.2.1. Bold: B
-
-   The <B> element indicates bold text. Where bold typography is
-   unavailable, an alternative representation may be used.
-
-5.7.2.2. Italic: I
-
-   The <I> element indicates italic text. Where italic typography is
-   unavailable, an alternative representation may be used.
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 32]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-5.7.2.3. Teletype: TT
-
-   The <TT> element indicates teletype (monospaced )text. Where a
-   teletype font is unavailable, an alternative representation may be
-   used.
-
-5.7.3. Anchor: A
-
-   The <A> element indicates a hyperlink anchor (see 7, "Hyperlinks").
-   At least one of the NAME and HREF attributes should be present.
-   Attributes of the <A> element:
-
-    HREF
-            gives the URI of the head anchor of a hyperlink.
-
-    NAME
-            gives the name of the anchor, and makes it available as
-            a head of a hyperlink.
-
-    TITLE
-            suggests a title for the destination resource --
-            advisory only. The TITLE attribute may be used:
-
-                * for display prior to accessing the destination
-                resource, for example, as a margin note or on a
-                small box while the mouse is over the anchor, or
-                while the document is being loaded;
-
-                * for resources that do not include a title, such as
-                graphics, plain text and Gopher menus, for use as a
-                window title.
-
-    REL
-            The REL attribute gives the relationship(s) described by
-            the hyperlink. The value is a whitespace separated list
-            of relationship names. The semantics of link
-            relationships are not specified in this document.
-
-    REV
-            same as the REL attribute, but the semantics of the
-            relationship are in the reverse direction. A link from A
-            to B with REL="X" expresses the same relationship as a
-            link from B to A with REV="X". An anchor may have both
-            REL and REV attributes.
-
-    URN
-            specifies a preferred, more persistent identifier for
-            the head anchor of the hyperlink. The syntax and
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 33]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-            semantics of the URN attribute are not yet specified.
-
-    METHODS
-            specifies methods to be used in accessing the
-            destination, as a whitespace-separated list of names.
-            The set of applicable names is a function of the scheme
-            of the URI in the HREF attribute. For similar reasons as
-            for the TITLE attribute, it may be useful to include the
-            information in advance in the link. For example, the
-            HTML user agent may chose a different rendering as a
-            function of the methods allowed; for example, something
-            that is searchable may get a different icon.
-
-5.8. Line Break: BR
-
-   The <BR> element specifies a line break between words (see 6,
-   "Characters, Words, and Paragraphs"). For example:
-
-    <P> Pease porridge hot<BR>
-    Pease porridge cold<BR>
-    Pease porridge in the pot<BR>
-    Nine days old.
-
-5.9. Horizontal Rule: HR
-
-   The <HR> element is a divider between sections of text; typically a
-   full width horizontal rule or equivalent graphic.  For example:
-
-    <HR>
-    <ADDRESS>February 8, 1995, CERN</ADDRESS>
-    </BODY>
-
-5.10. Image: IMG
-
-   The <IMG> element refers to an image or icon via a hyperlink (see
-   7.3, "Simultaneous Presentation of Image Resources").
-
-   HTML user agents may process the value of the ALT attribute as an
-   alternative to processing the image resource indicated by the SRC
-   attribute.
-
-      NOTE - Some HTML user agents can process graphics linked via
-      anchors, but not <IMG> graphics. If a graphic is essential, it
-      should be referenced from an <A> element rather than an <IMG>
-      element. If the graphic is not essential, then the <IMG> element
-      is appropriate.
-
-   Attributes of the <IMG> element:
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 34]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    ALIGN
-            alignment of the image with respect to the text
-            baseline.
-
-                * `TOP' specifies that the top of the image aligns
-                with the tallest item on the line containing the
-                image.
-
-                * `MIDDLE' specifies that the center of the image
-                aligns with the baseline of the line containing the
-                image.
-
-                * `BOTTOM' specifies that the bottom of the image
-                aligns with the baseline of the line containing the
-                image.
-
-    ALT
-            text to use in place of the referenced image resource,
-            for example due to processing constraints or user
-            preference.
-
-    ISMAP
-            indicates an image map (see 7.6, "Image Maps").
-
-    SRC
-            specifies the URI of the image resource.
-
-                NOTE - In practice, the media types of image
-                resources are limited to a few raster graphic
-                formats: typically `image/gif', `image/jpeg'. In
-                particular, `text/html' resources are not
-                intended to be used as image resources.
-
-    Examples of use:
-
-    <IMG SRC="triangle.xbm" ALT="Warning:"> Be sure
-    to read these instructions.
-
-    <a href="http://machine/htbin/imagemap/sample">
-    <IMG SRC="sample.xbm" ISMAP>
-    </a>
-
-6. Characters, Words, and Paragraphs
-
-   An HTML user agent should present the body of an HTML document as a
-   collection of typeset paragraphs and preformatted text.  Except for
-   preformatted elements (<PRE>, <XMP>, <LISTING>, <TEXTAREA>), each
-   block structuring element is regarded as a paragraph by taking the
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 35]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   data characters in its content and the content of its descendant
-   elements, concatenating them, and splitting the result into words,
-   separated by space, tab, or record end characters (and perhaps hyphen
-   characters). The sequence of words is typeset as a paragraph by
-   breaking it into lines.
-
-6.1. The HTML Document Character Set
-
-   The document character set specified in 9.5, "SGML Declaration for
-   HTML" must be supported by HTML user agents. It includes the graphic
-   characters of Latin Alphabet No. 1, or simply Latin-1.  Latin-1
-   comprises 191 graphic characters, including the alphabets of most
-   Western European languages.
-
-      NOTE - Use of the non-breaking space and soft hyphen indicator
-      characters is discouraged because support for them is not widely
-      deployed.
-
-      NOTE - To support non-western writing systems, a larger character
-      repertoire will be specified in a future version of HTML. The
-      document character set will be [ISO-10646], or some subset that
-      agrees with [ISO-10646]; in particular, all numeric character
-      references must use code positions assigned by [ISO-10646].
-
-   In SGML applications, the use of control characters is limited in
-   order to maximize the chance of successful interchange over
-   heterogeneous networks and operating systems. In the HTML document
-   character set only three control characters are allowed: Horizontal
-   Tab, Carriage Return, and Line Feed (code positions 9, 13, and 10).
-
-   The HTML DTD references the Added Latin 1 entity set, to allow
-   mnemonic representation of selected Latin 1 characters using only the
-   widely supported ASCII character repertoire. For example:
-
-   Kurt G&ouml;del was a famous logician and mathematician.
-
-   See 9.7.2, "ISO Latin 1 Character Entity Set" for a table of the
-   "Added Latin 1" entities, and 13, "The HTML Coded Character Set" for
-   a table of the code positions of [ISO 8859-1] and the control
-   characters in the HTML document character set.
-
-7. Hyperlinks
-
-   In addition to general purpose elements such as paragraphs and lists,
-   HTML documents can express hyperlinks. An HTML user agent allows the
-   user to navigate these hyperlinks.
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 36]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   A hyperlink is a relationship between two anchors, called the head
-   and the tail of the hyperlink[DEXTER]. Anchors are identified by an
-   anchor address: an absolute Uniform Resource Identifier (URI),
-   optionally followed by a '#' and a sequence of characters called a
-   fragment identifier. For example:
-
-   http://www.w3.org/hypertext/WWW/TheProject.html
-   http://www.w3.org/hypertext/WWW/TheProject.html#z31
-
-   In an anchor address, the URI refers to a resource; it may be used in
-   a variety of information retrieval protocols to obtain an entity that
-   represents the resource, such as an HTML document. The fragment
-   identifier, if present, refers to some view on, or portion of the
-   resource.
-
-   Each of the following markup constructs indicates the tail anchor of
-   a hyperlink or set of hyperlinks:
-
-        * <A> elements with HREF present.
-
-        * <LINK> elements.
-
-        * <IMG> elements.
-
-        * <INPUT> elements with the SRC attribute present.
-
-        * <ISINDEX> elements.
-
-        * <FORM> elements with `METHOD=GET'.
-
-   These markup constructs refer to head anchors by a URI, either
-   absolute or relative, or a fragment identifier, or both.
-
-   In the case of a relative URI, the absolute URI in the address of the
-   head anchor is the result of combining the relative URI with a base
-   absolute URI as in [RELURL]. The base document is taken from the
-   document's <BASE> element, if present; else, it is determined as in
-   [RELURL].
-
-7.1. Accessing Resources
-
-   Once the address of the head anchor is determined, the user agent may
-   obtain a representation of the resource.
-
-   For example, if the base URI is `http://host/x/y.html' and the
-   document contains:
-
-   <img src="../icons/abc.gif">
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 37]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   then the user agent uses the URI `http://host/icons/abc.gif' to
-   access the resource, as in [URL]..
-
-7.2. Activation of Hyperlinks
-
-   An HTML user agent allows the user to navigate the content of the
-   document and request activation of hyperlinks denoted by <A>
-   elements. HTML user agents should also allow activation of <LINK>
-   element hyperlinks.
-
-   To activate a link, the user agent obtains a representation of the
-   resource identified in the address of the head anchor. If the
-   representation is another HTML document, navigation may begin again
-   with this new document.
-
-7.3. Simultaneous Presentation of Image Resources
-
-   An HTML user agent may activate hyperlinks indicated by <IMG> and
-   <INPUT> elements concurrently with processing the document; that is,
-   image hyperlinks may be processed without explicit request by the
-   user. Image resources should be embedded in the presentation at the
-   point of the tail anchor, that is the <IMG> or <INPUT> element.
-
-   <LINK> hyperlinks may also be processed without explicit user
-   request; for example, style sheet resources may be processed before
-   or during the processing of the document.
-
-7.4. Fragment Identifiers
-
-   Any characters following a `#' character in a hypertext address
-   constitute a fragment identifier. In particular, an address of the
-   form `#fragment' refers to an anchor in the same document.
-
-   The meaning of fragment identifiers depends on the media type of the
-   representation of the anchor's resource. For `text/html'
-   representations, it refers to the <A> element with a NAME attribute
-   whose value is the same as the fragment identifier.  The matching is
-   case sensitive. The document should have exactly one such element.
-   The user agent should indicate the anchor element, for example by
-   scrolling to and/or highlighting the phrase.
-
-   For example, if the base URI is `http://host/x/y.html' and the user
-   activated the link denoted by the following markup:
-
-   <p> See: <a href="app1.html#bananas">appendix 1</a>
-   for more detail on bananas.
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 38]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   Then the user agent accesses the resource identified by
-   `http://host/x/app1.html'. Assuming the resource is represented using
-   the `text/html' media type, the user agent must locate the <A>
-   element whose NAME attribute is `bananas' and begin navigation there.
-
-7.5. Queries and Indexes
-
-   The <ISINDEX> element represents a set of hyperlinks. The user can
-   choose from the set by providing keywords to the user agent.  The
-   user agent computes the head URI by appending `?' and the keywords to
-   the base URI. The keywords are escaped according to [URL] and joined
-   by `+'. For example, if a document contains:
-
-    <BASE HREF="http://host/index">
-    <ISINDEX>
-
-    and the user provides the keywords `apple' and `berry', then the
-    user agent must access the resource
-    `http://host/index?apple+berry'.
-
-    <FORM> elements with `METHOD=GET' also represent sets of
-    hyperlinks. See 8.2.2, "Query Forms: METHOD=GET" for details.
-
-7.6. Image Maps
-
-   If the ISMAP attribute is present on an <IMG> element, the <IMG>
-   element must be contained in an <A> element with an HREF present.
-   This construct represents a set of hyperlinks. The user can choose
-   from the set by choosing a pixel of the image. The user agent
-   computes the head URI by appending `?' and the x and y coordinates of
-   the pixel to the URI given in the <A> element.  For example, if a
-   document contains:
-
-   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-   <head><title>ImageMap Example</title>
-   <BASE HREF="http://host/index"></head>
-   <body>
-   <p> Choose any of these icons:<br>
-   <a href="/cgi-bin/imagemap"><img ismap src="icons.gif"></a>
-
-   and the user chooses the upper-leftmost pixel, the chosen
-   hyperlink is the one with the URI
-   `http://host/cgi-bin/imagemap?0,0'.
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 39]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-8. Forms
-
-   A form is a template for a form data set and an associated
-   method and action URI. A form data set is a sequence of
-   name/value pair fields. The names are specified on the NAME
-   attributes of form input elements, and the values are given
-   initial values by various forms of markup and edited by the
-   user. The resulting form data set is used to access an
-   information service as a function of the action and method.
-
-   Forms elements can be mixed in with document structuring
-   elements. For example, a <PRE> element may contain a <FORM>
-   element, or a <FORM> element may contain lists which contain
-   <INPUT> elements. This gives considerable flexibility in
-   designing the layout of forms.
-
-   Form processing is a level 2 feature.
-
-8.1. Form Elements
-
-8.1.1. Form: FORM
-
-   The <FORM> element contains a sequence of input elements, along
-   with document structuring elements. The attributes are:
-
-    ACTION
-            specifies the action URI for the form. The action URI of
-            a form defaults to the base URI of the document (see 7,
-            "Hyperlinks").
-
-    METHOD
-            selects a method of accessing the action URI. The set of
-            applicable methods is a function of the scheme of the
-            action URI of the form. See 8.2.2, "Query Forms:
-            METHOD=GET" and 8.2.3, "Forms with Side-Effects:
-            METHOD=POST".
-
-    ENCTYPE
-            specifies the media type used to encode the name/value
-            pairs for transport, in case the protocol does not
-            itself impose a format. See 8.2.1, "The form-urlencoded
-            Media Type".
-
-8.1.2. Input Field: INPUT
-
-   The <INPUT> element represents a field for user input. The TYPE
-   attribute discriminates between several variations of fields.
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 40]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   The <INPUT> element has a number of attributes. The set of applicable
-   attributes depends on the value of the TYPE attribute.
-
-8.1.2.1. Text Field: INPUT TYPE=TEXT
-
-   The default value of the TYPE attribute is `TEXT', indicating a
-   single line text entry field. (Use the <TEXTAREA> element for multi-
-   line text fields.)
-
-   Required attributes are:
-
-    NAME
-            name for the form field corresponding to this element.
-
-    The optional attributes are:
-
-    MAXLENGTH
-            constrains the number of characters that can be entered
-            into a text input field. If the value of MAXLENGTH is
-            greater the the value of the SIZE attribute, the field
-            should scroll appropriately. The default number of
-            characters is unlimited.
-
-    SIZE
-            specifies the amount of display space allocated to this
-            input field according to its type. The default depends
-            on the user agent.
-
-    VALUE
-            The initial value of the field.
-
-    For example:
-
-<p>Street Address: <input name=street><br>
-Postal City code: <input name=city size=16 maxlength=16><br>
-Zip Code: <input name=zip size=10 maxlength=10 value="99999-9999"><br>
-
-8.1.2.2. Password Field: INPUT TYPE=PASSWORD
-
-   An <INPUT> element with `TYPE=PASSWORD' is a text field as above,
-   except that the value is obscured as it is entered. (see also: 10,
-   "Security Considerations").
-
-   For example:
-
-<p>Name: <input name=login> Password: <input type=password name=passwd>
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 41]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-8.1.2.3. Check Box: INPUT TYPE=CHECKBOX
-
-   An <INPUT> element with `TYPE=CHECKBOX' represents a boolean choice.
-   A set of such elements with the same name represents an n-of-many
-   choice field. Required attributes are:
-
-    NAME
-            symbolic name for the form field corresponding to this
-            element or group of elements.
-
-    VALUE
-            The portion of the value of the field contributed by
-            this element.
-
-    Optional attributes are:
-
-    CHECKED
-            indicates that the initial state is on.
-
-    For example:
-
-  <p>What flavors do you like?
-  <input type=checkbox name=flavor value=vanilla>Vanilla<br>
-  <input type=checkbox name=flavor value=strawberry>Strawberry<br>
-  <input type=checkbox name=flavor value=chocolate checked>Chocolate<br>
-
-8.1.2.4. Radio Button: INPUT TYPE=RADIO
-
-   An <INPUT> element with `TYPE=RADIO' represents a boolean choice. A
-   set of such elements with the same name represents a 1-of-many choice
-   field. The NAME and VALUE attributes are required as for check boxes.
-   Optional attributes are:
-
-    CHECKED
-            indicates that the initial state is on.
-   At all times, exactly one of the radio buttons in a set is checked.
-   If none of the <INPUT> elements of a set of radio buttons specifies
-   `CHECKED', then the user agent must check the first radio button of
-   the set initially.
-
-   For example:
-
-    <p>Which is your favorite?
-    <input type=radio name=flavor value=vanilla>Vanilla<br>
-    <input type=radio name=flavor value=strawberry>Strawberry<br>
-    <input type=radio name=flavor value=chocolate>Chocolate<br>
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 42]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-8.1.2.5. Image Pixel: INPUT TYPE=IMAGE
-
-   An <INPUT> element with `TYPE=IMAGE' specifies an image resource to
-   display, and allows input of two form fields: the x and y coordinate
-   of a pixel chosen from the image. The names of the fields are the
-   name of the field with `.x' and `.y' appended.  `TYPE=IMAGE' implies
-   `TYPE=SUBMIT' processing; that is, when a pixel is chosen, the form
-   as a whole is submitted.
-
-   The NAME attribute is required as for other input fields. The SRC
-   attribute is required and the ALIGN is optional as for the <IMG>
-   element (see 5.10, "Image: IMG").
-
-   For example:
-
-    <p>Choose a point on the map:
-    <input type=image name=point src="map.gif">
-
-8.1.2.6. Hidden Field: INPUT TYPE=HIDDEN
-
-   An <INPUT> element with `TYPE=HIDDEN' represents a hidden field.The
-   user does not interact with this field; instead, the VALUE attribute
-   specifies the value of the field. The NAME and VALUE attributes are
-   required.
-
-   For example:
-
-   <input type=hidden name=context value="l2k3j4l2k3j4l2k3j4lk23">
-
-8.1.2.7. Submit Button: INPUT TYPE=SUBMIT
-
-   An <INPUT> element with `TYPE=SUBMIT' represents an input option,
-   typically a button, that instructs the user agent to submit the form.
-   Optional attributes are:
-
-    NAME
-            indicates that this element contributes a form field
-            whose value is given by the VALUE attribute. If the NAME
-            attribute is not present, this element does not
-            contribute a form field.
-
-    VALUE
-            indicates a label for the input (button).
-
-    You may submit this request internally:
-    <input type=submit name=recipient value=internal><br>
-    or to the external world:
-    <input type=submit name=recipient value=world>
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 43]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-8.1.2.8. Reset Button: INPUT TYPE=RESET
-
-   An <INPUT> element with `TYPE=RESET' represents an input option,
-   typically a button, that instructs the user agent to reset the form's
-   fields to their initial states. The VALUE attribute, if present,
-   indicates a label for the input (button).
-
-   When you are finished, you may submit this request:
-   <input type=submit><br>
-   You may clear the form and start over at any time: <input type=reset>
-
-8.1.3. Selection: SELECT
-
-   The <SELECT> element constrains the form field to an enumerated list
-   of values. The values are given in <OPTION> elements.  Attributes
-   are:
-
-    MULTIPLE
-            indicates that more than one option may be included in
-            the value.
-
-    NAME
-            specifies the name of the form field.
-
-    SIZE
-            specifies the number of visible items. Select fields of
-            size one are typically pop-down menus, whereas select
-            fields with size greater than one are typically lists.
-
-    For example:
-
-    <SELECT NAME="flavor">
-    <OPTION>Vanilla
-    <OPTION>Strawberry
-    <OPTION value="RumRasin">Rum and Raisin
-    <OPTION selected>Peach and Orange
-    </SELECT>
-
-   The initial state has the first option selected, unless a SELECTED
-   attribute is present on any of the <OPTION> elements.
-
-8.1.3.1. Option: OPTION
-
-   The Option element can only occur within a Select element. It
-   represents one choice, and has the following attributes:
-
-    SELECTED
-            Indicates that this option is initially selected.
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 44]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    VALUE
-            indicates the value to be returned if this option is
-            chosen. The field value defaults to the content of the
-            <OPTION> element.
-
-   The content of the <OPTION> element is presented to the user to
-   represent the option. It is used as a returned value if the VALUE
-   attribute is not present.
-
-8.1.4. Text Area: TEXTAREA
-
-   The <TEXTAREA> element represents a multi-line text field.
-   Attributes are:
-
-    COLS
-            the number of visible columns to display for the text
-            area, in characters.
-
-    NAME
-            Specifies the name of the form field.
-
-    ROWS
-            The number of visible rows to display for the text area,
-            in characters.
-
-    For example:
-
-    <TEXTAREA NAME="address" ROWS=6 COLS=64>
-    HaL Computer Systems
-    1315 Dell Avenue
-    Campbell, California 95008
-    </TEXTAREA>
-
-   The content of the <TEXTAREA> element is the field's initial value.
-
-   Typically, the ROWS and COLS attributes determine the visible
-   dimension of the field in characters. The field is typically rendered
-   in a fixed-width font. HTML user agents should allow text to extend
-   beyond these limits by scrolling as needed.
-
-8.2. Form Submission
-
-   An HTML user agent begins processing a form by presenting the
-   document with the fields in their initial state. The user is allowed
-   to modify the fields, constrained by the field type etc.  When the
-   user indicates that the form should be submitted (using a submit
-   button or image input), the form data set is processed according to
-   its method, action URI and enctype.
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 45]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   When there is only one single-line text input field in a form, the
-   user agent should accept Enter in that field as a request to submit
-   the form.
-
-8.2.1. The form-urlencoded Media Type
-
-   The default encoding for all forms is `application/x-www-form-
-   urlencoded'. A form data set is represented in this media type as
-   follows:
-
-        1. The form field names and values are escaped: space
-        characters are replaced by `+', and then reserved characters
-        are escaped as per [URL]; that is, non-alphanumeric
-        characters are replaced by `%HH', a percent sign and two
-        hexadecimal digits representing the ASCII code of the
-        character. Line breaks, as in multi-line text field values,
-        are represented as CR LF pairs, i.e. `%0D%0A'.
-
-        2. The fields are listed in the order they appear in the
-        document with the name separated from the value by `=' and
-        the pairs separated from each other by `&'. Fields with null
-        values may be omitted. In particular, unselected radio
-        buttons and checkboxes should not appear in the encoded
-        data, but hidden fields with VALUE attributes present
-        should.
-
-            NOTE - The URI from a query form submission can be
-            used in a normal anchor style hyperlink.
-            Unfortunately, the use of the `&' character to
-            separate form fields interacts with its use in SGML
-            attribute values as an entity reference delimiter.
-            For example, the URI `http://host/?x=1&y=2' must be
-            written `<a href="http://host/?x=1&#38;y=2"' or `<a
-            href="http://host/?x=1&amp;y=2">'.
-
-            HTTP server implementors, and in particular, CGI
-            implementors are encouraged to support the use of
-            `;' in place of `&' to save users the trouble of
-            escaping `&' characters this way.
-
-8.2.2. Query Forms: METHOD=GET
-
-   If the processing of a form is idempotent (i.e. it has no lasting
-   observable effect on the state of the world), then the form method
-   should be `GET'. Many database searches have no visible side-effects
-   and make ideal applications of query forms.
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 46]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   To process a form whose action URL is an HTTP URL and whose method is
-   `GET', the user agent starts with the action URI and appends a `?'
-   and the form data set, in `application/x-www-form-urlencoded' format
-   as above. The user agent then traverses the link to this URI just as
-   if it were an anchor (see 7.2, "Activation of Hyperlinks").
-
-      NOTE - The URL encoding may result in very long URIs, which cause
-      some historical HTTP server implementations to exhibit defective
-      behavior. As a result, some HTML forms are written using
-      `METHOD=POST' even though the form submission has no side-effects.
-
-8.2.3. Forms with Side-Effects: METHOD=POST
-
-   If the service associated with the processing of a form has side
-   effects (for example, modification of a database or subscription to a
-   service), the method should be `POST'.
-
-   To process a form whose action URL is an HTTP URL and whose method is
-   `POST', the user agent conducts an HTTP POST transaction using the
-   action URI, and a message body of type `application/x-www-form-
-   urlencoded' format as above. The user agent should display the
-   response from the HTTP POST interaction just as it would display the
-   response from an HTTP GET above.
-
-8.2.4. Example Form Submission: Questionnaire Form
-
-   Consider the following document:
-
-    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-    <title>Sample of HTML Form Submission</title>
-    <H1>Sample Questionnaire</H1>
-    <P>Please fill out this questionnaire:
-    <FORM METHOD="POST" ACTION="http://www.w3.org/sample">
-    <P>Your name: <INPUT NAME="name" size="48">
-    <P>Male <INPUT NAME="gender" TYPE=RADIO VALUE="male">
-    <P>Female <INPUT NAME="gender" TYPE=RADIO VALUE="female">
-    <P>Number in family: <INPUT NAME="family" TYPE=text>
-    <P>Cities in which you maintain a residence:
-    <UL>
-    <LI>Kent <INPUT NAME="city" TYPE=checkbox VALUE="kent">
-    <LI>Miami <INPUT NAME="city" TYPE=checkbox VALUE="miami">
-    <LI>Other <TEXTAREA NAME="other" cols=48 rows=4></textarea>
-    </UL>
-    Nickname: <INPUT NAME="nickname" SIZE="42">
-    <P>Thank you for responding to this questionnaire.
-    <P><INPUT TYPE=SUBMIT> <INPUT TYPE=RESET>
-    </FORM>
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 47]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    The initial state of the form data set is:
-
-    name
-            ""
-
-    gender
-            "male"
-
-    family
-            ""
-
-    other
-            ""
-
-    nickname
-            ""
-
-    Note that the radio input has an initial value, while the
-    checkbox has none.
-
-    The user might edit the fields and request that the form be
-    submitted. At that point, suppose the values are:
-
-    name
-            "John Doe"
-
-    gender
-            "male"
-
-    family
-            "5"
-
-    city
-            "kent"
-
-    city
-            "miami"
-
-    other
-            "abc\ndefk"
-
-    nickname
-            "J&D"
-
-   The user agent then conducts an HTTP POST transaction using the URI
-   `http://www.w3.org/sample'. The message body would be (ignore the
-   line break):
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 48]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   name=John+Doe&gender=male&family=5&city=kent&city=miami&
-   other=abc%0D%0Adef&nickname=J%26D
-
-9. HTML Public Text
-
-9.1. HTML DTD
-
-   This is the Document Type Definition for the HyperText Markup
-   Language, level 2.
-
-<!--    html.dtd
-
-        Document Type Definition for the HyperText Markup Language
-                 (HTML DTD)
-
-        $Id: html.dtd,v 1.30 1995/09/21 23:30:19 connolly Exp $
-
-        Author: Daniel W. Connolly <connolly@w3.org>
-        See Also: html.decl, html-1.dtd
-          http://www.w3.org/hypertext/WWW/MarkUp/MarkUp.html
--->
-
-<!ENTITY % HTML.Version
-        "-//IETF//DTD HTML 2.0//EN"
-
-        -- Typical usage:
-
-            <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-            <html>
-            ...
-            </html>
-        --
-        >
-
-
-<!--============ Feature Test Entities ========================-->
-
-<!ENTITY % HTML.Recommended "IGNORE"
-        -- Certain features of the language are necessary for
-           compatibility with widespread usage, but they may
-           compromise the structural integrity of a document.
-           This feature test entity enables a more prescriptive
-           document type definition that eliminates
-           those features.
-        -->
-
-<![ %HTML.Recommended [
-        <!ENTITY % HTML.Deprecated "IGNORE">
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 49]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-]]>
-
-<!ENTITY % HTML.Deprecated "INCLUDE"
-        -- Certain features of the language are necessary for
-           compatibility with earlier versions of the specification,
-           but they tend to be used and implemented inconsistently,
-           and their use is deprecated. This feature test entity
-           enables a document type definition that eliminates
-           these features.
-        -->
-
-<!ENTITY % HTML.Highlighting "INCLUDE"
-        -- Use this feature test entity to validate that a
-           document uses no highlighting tags, which may be
-           ignored on minimal implementations.
-        -->
-
-<!ENTITY % HTML.Forms "INCLUDE"
-        -- Use this feature test entity to validate that a document
-           contains no forms, which may not be supported in minimal
-           implementations
-        -->
-
-<!--============== Imported Names ==============================-->
-
-<!ENTITY % Content-Type "CDATA"
-        -- meaning an internet media type
-           (aka MIME content type, as per RFC1521)
-        -->
-
-<!ENTITY % HTTP-Method "GET | POST"
-        -- as per HTTP specification, in progress
-        -->
-
-<!--========= DTD "Macros" =====================-->
-
-<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
-
-<!ENTITY % list " UL | OL | DIR | MENU " >
-
-
-<!--======= Character mnemonic entities =================-->
-
-<!ENTITY % ISOlat1 PUBLIC
-  "ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML">
-%ISOlat1;
-
-<!ENTITY amp CDATA "&#38;"     -- ampersand          -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 50]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ENTITY gt CDATA "&#62;"      -- greater than       -->
-<!ENTITY lt CDATA "&#60;"      -- less than          -->
-<!ENTITY quot CDATA "&#34;"    -- double quote       -->
-
-
-<!--========= SGML Document Access (SDA) Parameter Entities =====-->
-
-<!-- HTML 2.0 contains SGML Document Access (SDA) fixed attributes
-in support of easy transformation to the International Committee
-for Accessible Document Design (ICADD) DTD
-         "-//EC-USA-CDA/ICADD//DTD ICADD22//EN".
-ICADD applications are designed to support usable access to
-structured information by print-impaired individuals through
-Braille, large print and voice synthesis.  For more information on
-SDA & ICADD:
-        - ISO 12083:1993, Annex A.8, Facilities for Braille,
-          large print and computer voice
-        - ICADD ListServ
-          <ICADD%ASUACAD.BITNET@ARIZVM1.ccit.arizona.edu>
-        - Usenet news group bit.listserv.easi
-        - Recording for the Blind, +1 800 221 4792
--->
-
-<!ENTITY % SDAFORM  "SDAFORM  CDATA  #FIXED"
-          -- one to one mapping        -->
-<!ENTITY % SDARULE  "SDARULE  CDATA  #FIXED"
-          -- context-sensitive mapping -->
-<!ENTITY % SDAPREF  "SDAPREF  CDATA  #FIXED"
-          -- generated text prefix     -->
-<!ENTITY % SDASUFF  "SDASUFF  CDATA  #FIXED"
-          -- generated text suffix     -->
-<!ENTITY % SDASUSP  "SDASUSP  NAME   #FIXED"
-          -- suspend transform process -->
-
-
-<!--========== Text Markup =====================-->
-
-<![ %HTML.Highlighting [
-
-<!ENTITY % font " TT | B | I ">
-
-<!ENTITY % phrase "EM | STRONG | CODE | SAMP | KBD | VAR | CITE ">
-
-<!ENTITY % text "#PCDATA | A | IMG | BR | %phrase | %font">
-
-<!ELEMENT (%font;|%phrase) - - (%text)*>
-<!ATTLIST ( TT | CODE | SAMP | KBD | VAR )
-        %SDAFORM; "Lit"
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 51]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        >
-<!ATTLIST ( B | STRONG )
-        %SDAFORM; "B"
-        >
-<!ATTLIST ( I | EM | CITE )
-        %SDAFORM; "It"
-        >
-
-<!-- <TT>       Typewriter text                         -->
-<!-- <B>        Bold text                               -->
-<!-- <I>        Italic text                             -->
-
-<!-- <EM>       Emphasized phrase                       -->
-<!-- <STRONG>   Strong emphasis                         -->
-<!-- <CODE>     Source code phrase                      -->
-<!-- <SAMP>     Sample text or characters               -->
-<!-- <KBD>      Keyboard phrase, e.g. user input        -->
-<!-- <VAR>      Variable phrase or substitutable        -->
-<!-- <CITE>     Name or title of cited work             -->
-
-<!ENTITY % pre.content "#PCDATA | A | HR | BR | %font | %phrase">
-
-]]>
-
-<!ENTITY % text "#PCDATA | A | IMG | BR">
-
-<!ELEMENT BR    - O EMPTY>
-<!ATTLIST BR
-        %SDAPREF; "&#RE;"
-        >
-
-<!-- <BR>       Line break      -->
-
-
-<!--========= Link Markup ======================-->
-
-<!ENTITY % linkType "NAMES">
-
-<!ENTITY % linkExtraAttributes
-        "REL %linkType #IMPLIED
-        REV %linkType #IMPLIED
-        URN CDATA #IMPLIED
-        TITLE CDATA #IMPLIED
-        METHODS NAMES #IMPLIED
-        ">
-
-<![ %HTML.Recommended [
-        <!ENTITY % A.content   "(%text)*"
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 52]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        -- <H1><a name="xxx">Heading</a></H1>
-                is preferred to
-           <a name="xxx"><H1>Heading</H1></a>
-        -->
-]]>
-
-<!ENTITY % A.content   "(%heading|%text)*">
-
-<!ELEMENT A     - - %A.content -(A)>
-<!ATTLIST A
-        HREF CDATA #IMPLIED
-        NAME CDATA #IMPLIED
-        %linkExtraAttributes;
-        %SDAPREF; "<Anchor: #AttList>"
-        >
-<!-- <A>                Anchor; source/destination of link      -->
-<!-- <A NAME="...">     Name of this anchor                     -->
-<!-- <A HREF="...">     Address of link destination             -->
-<!-- <A URN="...">      Permanent address of destination        -->
-<!-- <A REL=...>        Relationship to destination             -->
-<!-- <A REV=...>        Relationship of destination to this     -->
-<!-- <A TITLE="...">    Title of destination (advisory)         -->
-<!-- <A METHODS="...">  Operations on destination (advisory)    -->
-
-
-<!--========== Images ==========================-->
-
-<!ELEMENT IMG    - O EMPTY>
-<!ATTLIST IMG
-        SRC CDATA  #REQUIRED
-        ALT CDATA #IMPLIED
-        ALIGN (top|middle|bottom) #IMPLIED
-        ISMAP (ISMAP) #IMPLIED
-        %SDAPREF; "<Fig><?SDATrans Img: #AttList>#AttVal(Alt)</Fig>"
-        >
-
-<!-- <IMG>              Image; icon, glyph or illustration      -->
-<!-- <IMG SRC="...">    Address of image object                 -->
-<!-- <IMG ALT="...">    Textual alternative                     -->
-<!-- <IMG ALIGN=...>    Position relative to text               -->
-<!-- <IMG ISMAP>        Each pixel can be a link                -->
-
-<!--========== Paragraphs=======================-->
-
-<!ELEMENT P     - O (%text)*>
-<!ATTLIST P
-        %SDAFORM; "Para"
-        >
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 53]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!-- <P>        Paragraph       -->
-
-
-<!--========== Headings, Titles, Sections ===============-->
-
-<!ELEMENT HR    - O EMPTY>
-<!ATTLIST HR
-        %SDAPREF; "&#RE;&#RE;"
-        >
-
-<!-- <HR>       Horizontal rule -->
-
-<!ELEMENT ( %heading )  - -  (%text;)*>
-<!ATTLIST H1
-        %SDAFORM; "H1"
-        >
-<!ATTLIST H2
-        %SDAFORM; "H2"
-        >
-<!ATTLIST H3
-        %SDAFORM; "H3"
-        >
-<!ATTLIST H4
-        %SDAFORM; "H4"
-        >
-<!ATTLIST H5
-        %SDAFORM; "H5"
-        >
-<!ATTLIST H6
-        %SDAFORM; "H6"
-        >
-
-<!-- <H1>       Heading, level 1 -->
-<!-- <H2>       Heading, level 2 -->
-<!-- <H3>       Heading, level 3 -->
-<!-- <H4>       Heading, level 4 -->
-<!-- <H5>       Heading, level 5 -->
-<!-- <H6>       Heading, level 6 -->
-
-
-<!--========== Text Flows ======================-->
-
-<![ %HTML.Forms [
-        <!ENTITY % block.forms "BLOCKQUOTE | FORM | ISINDEX">
-]]>
-
-<!ENTITY % block.forms "BLOCKQUOTE">
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 54]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<![ %HTML.Deprecated [
-        <!ENTITY % preformatted "PRE | XMP | LISTING">
-]]>
-
-<!ENTITY % preformatted "PRE">
-
-<!ENTITY % block "P | %list | DL
-        | %preformatted
-        | %block.forms">
-
-<!ENTITY % flow "(%text|%block)*">
-
-<!ENTITY % pre.content "#PCDATA | A | HR | BR">
-<!ELEMENT PRE - - (%pre.content)*>
-<!ATTLIST PRE
-        WIDTH NUMBER #implied
-        %SDAFORM; "Lit"
-        >
-
-<!-- <PRE>              Preformatted text               -->
-<!-- <PRE WIDTH=...>    Maximum characters per line     -->
-
-<![ %HTML.Deprecated [
-
-<!ENTITY % literal "CDATA"
-        -- historical, non-conforming parsing mode where
-           the only markup signal is the end tag
-           in full
-        -->
-
-<!ELEMENT (XMP|LISTING) - -  %literal>
-<!ATTLIST XMP
-        %SDAFORM; "Lit"
-        %SDAPREF; "Example:&#RE;"
-        >
-<!ATTLIST LISTING
-        %SDAFORM; "Lit"
-        %SDAPREF; "Listing:&#RE;"
-        >
-
-<!-- <XMP>              Example section         -->
-<!-- <LISTING>          Computer listing        -->
-
-<!ELEMENT PLAINTEXT - O %literal>
-<!-- <PLAINTEXT>        Plain text passage      -->
-
-<!ATTLIST PLAINTEXT
-        %SDAFORM; "Lit"
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 55]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        >
-]]>
-
-<!--========== Lists ==================-->
-
-<!ELEMENT DL    - -  (DT | DD)+>
-<!ATTLIST DL
-        COMPACT (COMPACT) #IMPLIED
-        %SDAFORM; "List"
-        %SDAPREF; "Definition List:"
-        >
-
-<!ELEMENT DT    - O (%text)*>
-<!ATTLIST DT
-        %SDAFORM; "Term"
-        >
-
-<!ELEMENT DD    - O %flow>
-<!ATTLIST DD
-        %SDAFORM; "LItem"
-        >
-
-<!-- <DL>               Definition list, or glossary    -->
-<!-- <DL COMPACT>       Compact style list              -->
-<!-- <DT>               Term in definition list         -->
-<!-- <DD>               Definition of term              -->
-
-<!ELEMENT (OL|UL) - -  (LI)+>
-<!ATTLIST OL
-        COMPACT (COMPACT) #IMPLIED
-        %SDAFORM; "List"
-        >
-<!ATTLIST UL
-        COMPACT (COMPACT) #IMPLIED
-        %SDAFORM; "List"
-        >
-<!-- <UL>               Unordered list                  -->
-<!-- <UL COMPACT>       Compact list style              -->
-<!-- <OL>               Ordered, or numbered list       -->
-<!-- <OL COMPACT>       Compact list style              -->
-
-
-<!ELEMENT (DIR|MENU) - -  (LI)+ -(%block)>
-<!ATTLIST DIR
-        COMPACT (COMPACT) #IMPLIED
-        %SDAFORM; "List"
-        %SDAPREF; "<LHead>Directory</LHead>"
-        >
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 56]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ATTLIST MENU
-        COMPACT (COMPACT) #IMPLIED
-        %SDAFORM; "List"
-        %SDAPREF; "<LHead>Menu</LHead>"
-        >
-
-<!-- <DIR>              Directory list                  -->
-<!-- <DIR COMPACT>      Compact list style              -->
-<!-- <MENU>             Menu list                       -->
-<!-- <MENU COMPACT>     Compact list style              -->
-
-<!ELEMENT LI    - O %flow>
-<!ATTLIST LI
-        %SDAFORM; "LItem"
-        >
-
-<!-- <LI>               List item                       -->
-
-<!--========== Document Body ===================-->
-
-<![ %HTML.Recommended [
-        <!ENTITY % body.content "(%heading|%block|HR|ADDRESS|IMG)*"
-        -- <h1>Heading</h1>
-           <p>Text ...
-                is preferred to
-           <h1>Heading</h1>
-           Text ...
-        -->
-]]>
-
-<!ENTITY % body.content "(%heading | %text | %block |
-                                 HR | ADDRESS)*">
-
-<!ELEMENT BODY O O  %body.content>
-
-<!-- <BODY>     Document body   -->
-
-<!ELEMENT BLOCKQUOTE - - %body.content>
-<!ATTLIST BLOCKQUOTE
-        %SDAFORM; "BQ"
-        >
-
-<!-- <BLOCKQUOTE>       Quoted passage  -->
-
-<!ELEMENT ADDRESS - - (%text|P)*>
-<!ATTLIST  ADDRESS
-        %SDAFORM; "Lit"
-        %SDAPREF; "Address:&#RE;"
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 57]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        >
-
-<!-- <ADDRESS>  Address, signature, or byline   -->
-
-
-<!--======= Forms ====================-->
-
-<![ %HTML.Forms [
-
-<!ELEMENT FORM - - %body.content -(FORM) +(INPUT|SELECT|TEXTAREA)>
-<!ATTLIST FORM
-        ACTION CDATA #IMPLIED
-        METHOD (%HTTP-Method) GET
-        ENCTYPE %Content-Type; "application/x-www-form-urlencoded"
-        %SDAPREF; "<Para>Form:</Para>"
-        %SDASUFF; "<Para>Form End.</Para>"
-        >
-
-<!-- <FORM>                     Fill-out or data-entry form     -->
-<!-- <FORM ACTION="...">        Address for completed form      -->
-<!-- <FORM METHOD=...>          Method of submitting form       -->
-<!-- <FORM ENCTYPE="...">       Representation of form data     -->
-
-<!ENTITY % InputType "(TEXT | PASSWORD | CHECKBOX |
-                        RADIO | SUBMIT | RESET |
-                        IMAGE | HIDDEN )">
-<!ELEMENT INPUT - O EMPTY>
-<!ATTLIST INPUT
-        TYPE %InputType TEXT
-        NAME CDATA #IMPLIED
-        VALUE CDATA #IMPLIED
-        SRC CDATA #IMPLIED
-        CHECKED (CHECKED) #IMPLIED
-        SIZE CDATA #IMPLIED
-        MAXLENGTH NUMBER #IMPLIED
-        ALIGN (top|middle|bottom) #IMPLIED
-        %SDAPREF; "Input: "
-        >
-
-<!-- <INPUT>                    Form input datum                -->
-<!-- <INPUT TYPE=...>           Type of input interaction       -->
-<!-- <INPUT NAME=...>           Name of form datum              -->
-<!-- <INPUT VALUE="...">        Default/initial/selected value  -->
-<!-- <INPUT SRC="...">          Address of image                -->
-<!-- <INPUT CHECKED>            Initial state is "on"           -->
-<!-- <INPUT SIZE=...>           Field size hint                 -->
-<!-- <INPUT MAXLENGTH=...>      Data length maximum             -->
-<!-- <INPUT ALIGN=...>          Image alignment                 -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 58]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ELEMENT SELECT - - (OPTION+) -(INPUT|SELECT|TEXTAREA)>
-<!ATTLIST SELECT
-        NAME CDATA #REQUIRED
-        SIZE NUMBER #IMPLIED
-        MULTIPLE (MULTIPLE) #IMPLIED
-        %SDAFORM; "List"
-        %SDAPREF;
-        "<LHead>Select #AttVal(Multiple)</LHead>"
-        >
-
-<!-- <SELECT>                   Selection of option(s)          -->
-<!-- <SELECT NAME=...>          Name of form datum              -->
-<!-- <SELECT SIZE=...>          Options displayed at a time     -->
-<!-- <SELECT MULTIPLE>          Multiple selections allowed     -->
-
-<!ELEMENT OPTION - O (#PCDATA)*>
-<!ATTLIST OPTION
-        SELECTED (SELECTED) #IMPLIED
-        VALUE CDATA #IMPLIED
-        %SDAFORM; "LItem"
-        %SDAPREF;
-        "Option: #AttVal(Value) #AttVal(Selected)"
-        >
-
-<!-- <OPTION>                   A selection option              -->
-<!-- <OPTION SELECTED>          Initial state                   -->
-<!-- <OPTION VALUE="...">       Form datum value for this option-->
-
-<!ELEMENT TEXTAREA - - (#PCDATA)* -(INPUT|SELECT|TEXTAREA)>
-<!ATTLIST TEXTAREA
-        NAME CDATA #REQUIRED
-        ROWS NUMBER #REQUIRED
-        COLS NUMBER #REQUIRED
-        %SDAFORM; "Para"
-        %SDAPREF; "Input Text -- #AttVal(Name): "
-        >
-
-<!-- <TEXTAREA>                 An area for text input          -->
-<!-- <TEXTAREA NAME=...>        Name of form datum              -->
-<!-- <TEXTAREA ROWS=...>        Height of area                  -->
-<!-- <TEXTAREA COLS=...>        Width of area                   -->
-
-]]>
-
-
-<!--======= Document Head ======================-->
-
-<![ %HTML.Recommended [
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 59]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        <!ENTITY % head.extra "">
-]]>
-<!ENTITY % head.extra "& NEXTID?">
-
-<!ENTITY % head.content "TITLE & ISINDEX? & BASE? %head.extra">
-
-<!ELEMENT HEAD O O  (%head.content) +(META|LINK)>
-
-<!-- <HEAD>     Document head   -->
-
-<!ELEMENT TITLE - -  (#PCDATA)*  -(META|LINK)>
-<!ATTLIST TITLE
-        %SDAFORM; "Ti"    >
-
-<!-- <TITLE>    Title of document -->
-
-<!ELEMENT LINK - O EMPTY>
-<!ATTLIST LINK
-        HREF CDATA #REQUIRED
-        %linkExtraAttributes;
-        %SDAPREF; "Linked to : #AttVal (TITLE) (URN) (HREF)>"    >
-
-<!-- <LINK>             Link from this document                 -->
-<!-- <LINK HREF="...">  Address of link destination             -->
-<!-- <LINK URN="...">   Lasting name of destination             -->
-<!-- <LINK REL=...>     Relationship to destination             -->
-<!-- <LINK REV=...>     Relationship of destination to this     -->
-<!-- <LINK TITLE="..."> Title of destination (advisory)         -->
-<!-- <LINK METHODS="..."> Operations allowed (advisory)         -->
-
-<!ELEMENT ISINDEX - O EMPTY>
-<!ATTLIST ISINDEX
-        %SDAPREF;
-   "<Para>[Document is indexed/searchable.]</Para>">
-
-<!-- <ISINDEX>          Document is a searchable index          -->
-
-<!ELEMENT BASE - O EMPTY>
-<!ATTLIST BASE
-        HREF CDATA #REQUIRED     >
-
-<!-- <BASE>             Base context document                   -->
-<!-- <BASE HREF="...">  Address for this document               -->
-
-<!ELEMENT NEXTID - O EMPTY>
-<!ATTLIST NEXTID
-        N CDATA #REQUIRED     >
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 60]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!-- <NEXTID>           Next ID to use for link name            -->
-<!-- <NEXTID N=...>     Next ID to use for link name            -->
-
-<!ELEMENT META - O EMPTY>
-<!ATTLIST META
-        HTTP-EQUIV  NAME    #IMPLIED
-        NAME        NAME    #IMPLIED
-        CONTENT     CDATA   #REQUIRED    >
-
-<!-- <META>                     Generic Meta-information        -->
-<!-- <META HTTP-EQUIV=...>      HTTP response header name       -->
-<!-- <META NAME=...>            Meta-information name           -->
-<!-- <META CONTENT="...">       Associated information          -->
-
-<!--======= Document Structure =================-->
-
-<![ %HTML.Deprecated [
-        <!ENTITY % html.content "HEAD, BODY, PLAINTEXT?">
-]]>
-<!ENTITY % html.content "HEAD, BODY">
-
-<!ELEMENT HTML O O  (%html.content)>
-<!ENTITY % version.attr "VERSION CDATA #FIXED '%HTML.Version;'">
-
-<!ATTLIST HTML
-        %version.attr;
-        %SDAFORM; "Book"
-        >
-
-<!-- <HTML>                     HTML Document   -->
-
-9.2. Strict HTML DTD
-
-   This document type declaration refers to the HTML DTD with the
-   `HTML.Recommended' entity defined as `INCLUDE' rather than IGNORE;
-   that is, it refers to the more structurally rigid definition of HTML.
-
-<!--    html-s.dtd
-
-        Document Type Definition for the HyperText Markup Language
-        with strict validation (HTML Strict DTD).
-
-        $Id: html-s.dtd,v 1.3 1995/06/02 18:55:46 connolly Exp $
-
-        Author: Daniel W. Connolly <connolly@w3.org>
-        See Also: http://www.w3.org/hypertext/WWW/MarkUp/MarkUp.html
--->
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 61]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ENTITY % HTML.Version
-        "-//IETF//DTD HTML 2.0 Strict//EN"
-
-        -- Typical usage:
-
-            <!DOCTYPE HTML PUBLIC
-                "-//IETF//DTD HTML Strict//EN">
-            <html>
-            ...
-            </html>
-        --
-        >
-
-<!-- Feature Test Entities -->
-<!ENTITY % HTML.Recommended "INCLUDE">
-
-<!ENTITY % html PUBLIC "-//IETF//DTD HTML 2.0//EN">
-%html;
-
-9.3. Level 1 HTML DTD
-
-   This document type declaration refers to the HTML DTD with the
-   `HTML.Forms' entity defined as `IGNORE' rather than `INCLUDE'.
-   Documents which contain <FORM> elements do not conform to this DTD,
-   and must use the level 2 DTD.
-
-<!--    html-1.dtd
-
-        Document Type Definition for the HyperText Markup Language
-        with Level 1 Extensions (HTML Level 1 DTD).
-
-        $Id: html-1.dtd,v 1.2 1995/03/29 18:53:10 connolly Exp $
-
-        Author: Daniel W. Connolly <connolly@w3.org>
-        See Also: http://info.cern.ch/hypertext/WWW/MarkUp/MarkUp.html
-
--->
-
-<!ENTITY % HTML.Version
-        "-//IETF//DTD HTML 2.0 Level 1//EN"
-
-        -- Typical usage:
-
-            <!DOCTYPE HTML PUBLIC
-                "-//IETF//DTD HTML Level 1//EN">
-            <html>
-            ...
-            </html>
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 62]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-        --
-        >
-
-<!-- Feature Test Entities -->
-<!ENTITY % HTML.Forms "IGNORE">
-
-<!ENTITY % html PUBLIC "-//IETF//DTD HTML 2.0//EN">
-%html;
-
-9.4. Strict Level 1 HTML DTD
-
-   This document type declaration refers to the level 1 HTML DTD with
-   the `HTML.Recommended' entity defined as `INCLUDE' rather than
-   IGNORE; that is, it refers to the more structurally rigid definition
-   of HTML.
-
-<!--    html-1s.dtd
-
-        Document Type Definition for the HyperText Markup Language
-        Struct Level 1
-
-        $Id: html-1s.dtd,v 1.3 1995/06/02 18:55:43 connolly Exp $
-
-        Author: Daniel W. Connolly <connolly@w3.org>
-        See Also: http://www.w3.org/hypertext/WWW/MarkUp/MarkUp.html
--->
-
-<!ENTITY % HTML.Version
-        "-//IETF//DTD HTML 2.0 Strict Level 1//EN"
-
-        -- Typical usage:
-
-            <!DOCTYPE HTML PUBLIC
-                "-//IETF//DTD HTML Strict Level 1//EN">
-            <html>
-            ...
-            </html>
-        --
-        >
-
-<!-- Feature Test Entities -->
-
-
-<!ENTITY % HTML.Recommended "INCLUDE">
-
-<!ENTITY % html-1 PUBLIC "-//IETF//DTD HTML 2.0 Level 1//EN">
-%html-1;
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 63]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-9.5. SGML Declaration for HTML
-
-   This is the SGML Declaration for HyperText Markup Language.
-
-<!SGML  "ISO 8879:1986"
---
-        SGML Declaration for HyperText Markup Language (HTML).
-
---
-
-CHARSET
-         BASESET  "ISO 646:1983//CHARSET
-                   International Reference Version
-                   (IRV)//ESC 2/5 4/0"
-         DESCSET  0   9   UNUSED
-                  9   2   9
-                  11  2   UNUSED
-                  13  1   13
-                  14  18  UNUSED
-                  32  95  32
-                  127 1   UNUSED
-     BASESET   "ISO Registration Number 100//CHARSET
-                ECMA-94 Right Part of
-                Latin Alphabet Nr. 1//ESC 2/13 4/1"
-
-         DESCSET  128  32   UNUSED
-                  160  96    32
-
-CAPACITY        SGMLREF
-                TOTALCAP        150000
-                GRPCAP          150000
-                ENTCAP          150000
-
-SCOPE    DOCUMENT
-SYNTAX
-         SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
-                 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127
-         BASESET  "ISO 646:1983//CHARSET
-                   International Reference Version
-                   (IRV)//ESC 2/5 4/0"
-         DESCSET  0 128 0
-         FUNCTION
-                  RE          13
-                  RS          10
-                  SPACE       32
-                  TAB SEPCHAR  9
-         NAMING   LCNMSTRT ""
-                  UCNMSTRT ""
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 64]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-                  LCNMCHAR ".-"
-                  UCNMCHAR ".-"
-                  NAMECASE GENERAL YES
-                           ENTITY  NO
-         DELIM    GENERAL  SGMLREF
-                  SHORTREF SGMLREF
-         NAMES    SGMLREF
-         QUANTITY SGMLREF
-                  ATTSPLEN 2100
-                  LITLEN   1024
-                  NAMELEN  72    -- somewhat arbitrary; taken from
-                                internet line length conventions --
-                  PILEN    1024
-                  TAGLVL   100
-                  TAGLEN   2100
-                  GRPGTCNT 150
-                  GRPCNT   64
-
-FEATURES
-  MINIMIZE
-    DATATAG  NO
-    OMITTAG  YES
-    RANK     NO
-    SHORTTAG YES
-  LINK
-    SIMPLE   NO
-    IMPLICIT NO
-    EXPLICIT NO
-  OTHER
-    CONCUR   NO
-    SUBDOC   NO
-    FORMAL   YES
-  APPINFO    "SDA"  -- conforming SGML Document Access application
-                    --
->
-<!--
-        $Id: html.decl,v 1.17 1995/06/08 14:59:32 connolly Exp $
-
-        Author: Daniel W. Connolly <connolly@w3.org>
-
-        See also: http://www.w3.org/hypertext/WWW/MarkUp/MarkUp.html
- -->
-
-9.6. Sample SGML Open Entity Catalog for HTML
-
-   The SGML standard describes an "entity manager" as the portion or
-   component of an SGML system that maps SGML entities into the actual
-   storage model (e.g., the file system). The standard itself does not
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 65]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   define a particular mapping methodology or notation.
-
-   To assist the interoperability among various SGML tools and systems,
-   the SGML Open consortium has passed a technical resolution that
-   defines a format for an application-independent entity catalog that
-   maps external identifiers and/or entity names to file names.
-
-   Each entry in the catalog associates a storage object identifier
-   (such as a file name) with information about the external entity that
-   appears in the SGML document. In addition to entries that associate
-   public identifiers, a catalog entry can associate an entity name with
-   a storage object identifier. For example, the following are possible
-   catalog entries:
-
-        -- catalog: SGML Open style entity catalog for HTML --
-        -- $Id: catalog,v 1.3 1995/09/21 23:30:23 connolly Exp $ --
-
-        -- Ways to refer to Level 2: most general to most specific --
-PUBLIC  "-//IETF//DTD HTML//EN"                 html.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0//EN"             html.dtd
-PUBLIC  "-//IETF//DTD HTML Level 2//EN"         html.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0 Level 2//EN"     html.dtd
-
-        -- Ways to refer to Level 1: most general to most specific --
-PUBLIC  "-//IETF//DTD HTML Level 1//EN"         html-1.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0 Level 1//EN"     html-1.dtd
-
-        -- Ways to refer to
-                 Strict Level 2: most general to most specific --
-PUBLIC  "-//IETF//DTD HTML Strict//EN"                  html-s.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0 Strict//EN"              html-s.dtd
-PUBLIC  "-//IETF//DTD HTML Strict Level 2//EN"          html-s.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0 Strict Level 2//EN"      html-s.dtd
-
-        -- Ways to refer to
-                 Strict Level 1: most general to most specific --
-PUBLIC  "-//IETF//DTD HTML Strict Level 1//EN"          html-1s.dtd
-PUBLIC  "-//IETF//DTD HTML 2.0 Strict Level 1//EN"      html-1s.dtd
-
-        -- ISO latin 1 entity set for HTML --
-PUBLIC  "ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML" ISOlat1\
-sgml
-
-9.7. Character Entity Sets
-
-   The HTML DTD defines the following entities. They represent
-   particular graphic characters which have special meanings in places
-   in the markup, or may not be part of the character set available to
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 66]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-   the writer.
-
-9.7.1. Numeric and Special Graphic Entity Set
-
-   The following table lists each of the characters included from the
-   Numeric and Special Graphic entity set, along with its name, syntax
-   for use, and description. This list is derived from `ISO Standard
-   8879:1986//ENTITIES Numeric and Special Graphic//EN'.  However, HTML
-   does not include for the entire entity set -- only the entities
-   listed below are included.
-
-    GLYPH   NAME    SYNTAX  DESCRIPTION
-    <       lt      &lt;    Less than sign
-    >       gt      &gt;    Greater than signn
-    &       amp     &amp;   Ampersand
-    "       quot    &quot;  Double quote sign
-
-9.7.2. ISO Latin 1 Character Entity Set
-
-   The following public text lists each of the characters specified in
-   the Added Latin 1 entity set, along with its name, syntax for use,
-   and description. This list is derived from ISO Standard
-   8879:1986//ENTITIES Added Latin 1//EN. HTML includes the entire
-   entity set.
-
-<!-- (C) International Organization for Standardization 1986
-     Permission to copy in any form is granted for use with
-     conforming SGML systems and applications as defined in
-     ISO 8879, provided this notice is included in all copies.
--->
-<!-- Character entity set. Typical invocation:
-     <!ENTITY % ISOlat1 PUBLIC
-       "ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML">
-     %ISOlat1;
--->
-<!--    Modified for use in HTML
-        $Id: ISOlat1.sgml,v 1.2 1994/11/30 23:45:12 connolly Exp $ -->
-<!ENTITY AElig  CDATA "&#198;" -- capital AE diphthong (ligature) -->
-<!ENTITY Aacute CDATA "&#193;" -- capital A, acute accent -->
-<!ENTITY Acirc  CDATA "&#194;" -- capital A, circumflex accent -->
-<!ENTITY Agrave CDATA "&#192;" -- capital A, grave accent -->
-<!ENTITY Aring  CDATA "&#197;" -- capital A, ring -->
-<!ENTITY Atilde CDATA "&#195;" -- capital A, tilde -->
-<!ENTITY Auml   CDATA "&#196;" -- capital A, dieresis or umlaut mark -->
-<!ENTITY Ccedil CDATA "&#199;" -- capital C, cedilla -->
-<!ENTITY ETH    CDATA "&#208;" -- capital Eth, Icelandic -->
-<!ENTITY Eacute CDATA "&#201;" -- capital E, acute accent -->
-<!ENTITY Ecirc  CDATA "&#202;" -- capital E, circumflex accent -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 67]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ENTITY Egrave CDATA "&#200;" -- capital E, grave accent -->
-<!ENTITY Euml   CDATA "&#203;" -- capital E, dieresis or umlaut mark -->
-<!ENTITY Iacute CDATA "&#205;" -- capital I, acute accent -->
-<!ENTITY Icirc  CDATA "&#206;" -- capital I, circumflex accent -->
-<!ENTITY Igrave CDATA "&#204;" -- capital I, grave accent -->
-<!ENTITY Iuml   CDATA "&#207;" -- capital I, dieresis or umlaut mark -->
-<!ENTITY Ntilde CDATA "&#209;" -- capital N, tilde -->
-<!ENTITY Oacute CDATA "&#211;" -- capital O, acute accent -->
-<!ENTITY Ocirc  CDATA "&#212;" -- capital O, circumflex accent -->
-<!ENTITY Ograve CDATA "&#210;" -- capital O, grave accent -->
-<!ENTITY Oslash CDATA "&#216;" -- capital O, slash -->
-<!ENTITY Otilde CDATA "&#213;" -- capital O, tilde -->
-<!ENTITY Ouml   CDATA "&#214;" -- capital O, dieresis or umlaut mark -->
-<!ENTITY THORN  CDATA "&#222;" -- capital THORN, Icelandic -->
-<!ENTITY Uacute CDATA "&#218;" -- capital U, acute accent -->
-<!ENTITY Ucirc  CDATA "&#219;" -- capital U, circumflex accent -->
-<!ENTITY Ugrave CDATA "&#217;" -- capital U, grave accent -->
-<!ENTITY Uuml   CDATA "&#220;" -- capital U, dieresis or umlaut mark -->
-<!ENTITY Yacute CDATA "&#221;" -- capital Y, acute accent -->
-<!ENTITY aacute CDATA "&#225;" -- small a, acute accent -->
-<!ENTITY acirc  CDATA "&#226;" -- small a, circumflex accent -->
-<!ENTITY aelig  CDATA "&#230;" -- small ae diphthong (ligature) -->
-<!ENTITY agrave CDATA "&#224;" -- small a, grave accent -->
-<!ENTITY aring  CDATA "&#229;" -- small a, ring -->
-<!ENTITY atilde CDATA "&#227;" -- small a, tilde -->
-<!ENTITY auml   CDATA "&#228;" -- small a, dieresis or umlaut mark -->
-<!ENTITY ccedil CDATA "&#231;" -- small c, cedilla -->
-<!ENTITY eacute CDATA "&#233;" -- small e, acute accent -->
-<!ENTITY ecirc  CDATA "&#234;" -- small e, circumflex accent -->
-<!ENTITY egrave CDATA "&#232;" -- small e, grave accent -->
-<!ENTITY eth    CDATA "&#240;" -- small eth, Icelandic -->
-<!ENTITY euml   CDATA "&#235;" -- small e, dieresis or umlaut mark -->
-<!ENTITY iacute CDATA "&#237;" -- small i, acute accent -->
-<!ENTITY icirc  CDATA "&#238;" -- small i, circumflex accent -->
-<!ENTITY igrave CDATA "&#236;" -- small i, grave accent -->
-<!ENTITY iuml   CDATA "&#239;" -- small i, dieresis or umlaut mark -->
-<!ENTITY ntilde CDATA "&#241;" -- small n, tilde -->
-<!ENTITY oacute CDATA "&#243;" -- small o, acute accent -->
-<!ENTITY ocirc  CDATA "&#244;" -- small o, circumflex accent -->
-<!ENTITY ograve CDATA "&#242;" -- small o, grave accent -->
-<!ENTITY oslash CDATA "&#248;" -- small o, slash -->
-<!ENTITY otilde CDATA "&#245;" -- small o, tilde -->
-<!ENTITY ouml   CDATA "&#246;" -- small o, dieresis or umlaut mark -->
-<!ENTITY szlig  CDATA "&#223;" -- small sharp s, German (sz ligature)->
-<!ENTITY thorn  CDATA "&#254;" -- small thorn, Icelandic -->
-<!ENTITY uacute CDATA "&#250;" -- small u, acute accent -->
-<!ENTITY ucirc  CDATA "&#251;" -- small u, circumflex accent -->
-<!ENTITY ugrave CDATA "&#249;" -- small u, grave accent -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 68]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-<!ENTITY uuml   CDATA "&#252;" -- small u, dieresis or umlaut mark -->
-<!ENTITY yacute CDATA "&#253;" -- small y, acute accent -->
-<!ENTITY yuml   CDATA "&#255;" -- small y, dieresis or umlaut mark -->
-
-10. Security Considerations
-
-   Anchors, embedded images, and all other elements which contain URIs
-   as parameters may cause the URI to be dereferenced in response to
-   user input. In this case, the security considerations of [URL] apply.
-
-   The widely deployed methods for submitting forms requests -- HTTP and
-   SMTP -- provide little assurance of confidentiality.  Information
-   providers who request sensitive information via forms -- especially
-   by way of the `PASSWORD' type input field (see 8.1.2, "Input Field:
-   INPUT") -- should be aware and make their users aware of the lack of
-   confidentiality.
-
-11. References
-
-    [URI]
-            Berners-Lee, T., "Universal Resource Identifiers in WWW:
-            A Unifying Syntax for the Expression of Names and
-            Addresses of Objects on the Network as used in the
-            World- Wide Web",  RFC 1630, CERN, June 1994.
-            <URL:ftp://ds.internic.net/rfc/rfc1630.txt>
-
-    [URL]
-            Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform
-            Resource Locators (URL)", RFC 1738, CERN, Xerox PARC,
-            University of Minnesota, December 1994.
-            <URL:ftp://ds.internic.net/rfc/rfc1738.txt>
-
-    [HTTP]
-            Berners-Lee, T., Fielding, R., and H. Frystyk Nielsen,
-            "Hypertext Transfer Protocol - HTTP/1.0", Work in
-            Progress, MIT, UC Irvine, CERN, March 1995.
-
-    [MIME]
-            Borenstein, N., and N. Freed. "MIME (Multipurpose
-            Internet Mail Extensions) Part One: Mechanisms for
-            Specifying and Describing the Format of Internet Message
-            Bodies", RFC 1521, Bellcore, Innosoft, September 1993.
-            <URL:ftp://ds.internic.net/rfc/rfc1521.txt>
-
-    [RELURL]
-            Fielding, R., "Relative Uniform Resource Locators", RFC
-            1808, June 1995
-            <URL:ftp://ds.internic.net/rfc/rfc1808.txt>
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 69]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    [GOLD90]
-            Goldfarb, C., "The SGML Handbook", Y. Rubinsky, Ed.,
-            Oxford University Press, 1990.
-
-    [DEXTER]
-            Frank Halasz and Mayer Schwartz, "The Dexter Hypertext
-            Reference Model", Communications of the ACM, pp.
-            30-39, vol. 37 no. 2, Feb 1994.
-
-    [IMEDIA]
-            Postel, J., "Media Type Registration Procedure",
-            RFC 1590, USC/Information Sciences Institute, March 1994.
-            <URL:ftp://ds.internic.net/rfc/rfc1590.txt>
-
-    [IANA]
-            Reynolds, J., and J. Postel, "Assigned Numbers", STD 2,
-            RFC 1700, USC/Information Sciecnes Institute, October
-            1994.  <URL:ftp://ds.internic.net/rfc/rfc1700.txt>
-
-    [SQ91]
-            SoftQuad. "The SGML Primer", 3rd ed., SoftQuad Inc.,
-            1991. <URL:http://www.sq.com/>
-
-    [ISO-646]
-            ISO/IEC 646:1991 Information technology -- ISO 7-bit
-            coded character set for information interchange
-            <URL:http://www.iso.ch/cate/d4777.html>
-
-    [ISO-10646]
-            ISO/IEC 10646-1:1993 Information technology -- Universal
-            Multiple-Octet Coded Character Set (UCS) -- Part 1:
-            Architecture and Basic Multilingual Plane
-            <URL:http://www.iso.ch/cate/d18741.html>
-
-    [ISO-8859-1]
-            ISO 8859. International Standard -- Information
-            Processing -- 8-bit Single-Byte Coded Graphic Character
-            Sets -- Part 1: Latin Alphabet No. 1, ISO 8859-1:1987.
-            <URL:http://www.iso.ch/cate/d16338.html>
-
-    [SGML]
-            ISO 8879. Information Processing -- Text and Office
-            Systems - Standard Generalized Markup Language (SGML),
-            1986. <URL:http://www.iso.ch/cate/d16387.html>
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 70]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-12. Acknowledgments
-
-   The HTML document type was designed by Tim Berners-Lee at CERN as
-   part of the 1990 World Wide Web project. In 1992, Dan Connolly wrote
-   the HTML Document Type Definition (DTD) and a brief HTML
-   specification.
-
-   Since 1993, a wide variety of Internet participants have contributed
-   to the evolution of HTML, which has included the addition of in-line
-   images introduced by the NCSA Mosaic software for WWW. Dave Raggett
-   played an important role in deriving the forms material from the
-   HTML+ specification.
-
-   Dan Connolly and Karen Olson Muldrow rewrote the HTML Specification
-   in 1994. The document was then edited by the HTML working group as a
-   whole, with updates being made by Eric Schieler, Mike Knezovich, and
-   Eric W. Sink at Spyglass, Inc.  Finally, Roy Fielding restructured
-   the entire draft into its current form.
-
-   Special thanks to the many active participants in the HTML working
-   group, too numerous to list individually, without whom there would be
-   no standards process and no standard. That this document approaches
-   its objective of carefully converging a description of current
-   practice and formalization of HTML's relationship to SGML is a
-   tribute to their effort.
-
-12.1. Authors' Addresses
-
-   Tim Berners-Lee
-   Director, W3 Consortium
-   MIT Laboratory for Computer Science
-   545 Technology Square
-   Cambridge, MA 02139, U.S.A.
-
-   Phone: +1 (617) 253 9670
-   Fax: +1 (617) 258 8682
-   EMail: timbl@w3.org
-
-
-   Daniel W. Connolly
-   Research Technical Staff, W3 Consortium
-   MIT Laboratory for Computer Science
-   545 Technology Square
-   Cambridge, MA 02139, U.S.A.
-
-   Phone: +1 (617) 258 8682
-   EMail: connolly@w3.org
-   URI: http://www.w3.org/hypertext/WWW/People/Connolly/
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 71]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-13. The HTML Coded Character Set
-
-   This list details the code positions and characters of the HTML
-   document character set, specified in 9.5, "SGML Declaration for
-   HTML". This coded character set is based on [ISO-8859-1].
-
-    REFERENCE       DESCRIPTION
-    --------------  -----------
-    &#00; - &#08;   Unused
-    &#09;           Horizontal tab
-    &#10;           Line feed
-    &#11; - &#12;   Unused
-    &#13;           Carriage Return
-    &#14; - &#31;   Unused
-    &#32;           Space
-    &#33;           Exclamation mark
-    &#34;           Quotation mark
-    &#35;           Number sign
-    &#36;           Dollar sign
-    &#37;           Percent sign
-    &#38;           Ampersand
-    &#39;           Apostrophe
-    &#40;           Left parenthesis
-    &#41;           Right parenthesis
-    &#42;           Asterisk
-    &#43;           Plus sign
-    &#44;           Comma
-    &#45;           Hyphen
-    &#46;           Period (fullstop)
-    &#47;           Solidus (slash)
-    &#48; - &#57;   Digits 0-9
-    &#58;           Colon
-    &#59;           Semi-colon
-    &#60;           Less than
-    &#61;           Equals sign
-    &#62;           Greater than
-    &#63;           Question mark
-    &#64;           Commercial at
-    &#65; - &#90;   Letters A-Z
-    &#91;           Left square bracket
-    &#92;           Reverse solidus (backslash)
-    &#93;           Right square bracket
-    &#94;           Caret
-    &#95;           Horizontal bar (underscore)
-    &#96;           Acute accent
-    &#97; - &#122;  Letters a-z
-    &#123;          Left curly brace
-    &#124;          Vertical bar
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 72]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    &#125;          Right curly brace
-    &#126;          Tilde
-    &#127; - &#159; Unused
-    &#160;          Non-breaking Space
-    &#161;          Inverted exclamation
-    &#162;          Cent sign
-    &#163;          Pound sterling
-    &#164;          General currency sign
-    &#165;          Yen sign
-    &#166;          Broken vertical bar
-    &#167;          Section sign
-    &#168;          Umlaut (dieresis)
-    &#169;          Copyright
-    &#170;          Feminine ordinal
-    &#171;          Left angle quote, guillemotleft
-    &#172;          Not sign
-    &#173;          Soft hyphen
-    &#174;          Registered trademark
-    &#175;          Macron accent
-    &#176;          Degree sign
-    &#177;          Plus or minus
-    &#178;          Superscript two
-    &#179;          Superscript three
-    &#180;          Acute accent
-    &#181;          Micro sign
-    &#182;          Paragraph sign
-    &#183;          Middle dot
-    &#184;          Cedilla
-    &#185;          Superscript one
-    &#186;          Masculine ordinal
-    &#187;          Right angle quote, guillemotright
-    &#188;          Fraction one-fourth
-    &#189;          Fraction one-half
-    &#190;          Fraction three-fourths
-    &#191;          Inverted question mark
-    &#192;          Capital A, grave accent
-    &#193;          Capital A, acute accent
-    &#194;          Capital A, circumflex accent
-    &#195;          Capital A, tilde
-    &#196;          Capital A, dieresis or umlaut mark
-    &#197;          Capital A, ring
-    &#198;          Capital AE dipthong (ligature)
-    &#199;          Capital C, cedilla
-    &#200;          Capital E, grave accent
-    &#201;          Capital E, acute accent
-    &#202;          Capital E, circumflex accent
-    &#203;          Capital E, dieresis or umlaut mark
-    &#204;          Capital I, grave accent
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 73]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    &#205;          Capital I, acute accent
-    &#206;          Capital I, circumflex accent
-    &#207;          Capital I, dieresis or umlaut mark
-    &#208;          Capital Eth, Icelandic
-    &#209;          Capital N, tilde
-    &#210;          Capital O, grave accent
-    &#211;          Capital O, acute accent
-    &#212;          Capital O, circumflex accent
-    &#213;          Capital O, tilde
-    &#214;          Capital O, dieresis or umlaut mark
-    &#215;          Multiply sign
-    &#216;          Capital O, slash
-    &#217;          Capital U, grave accent
-    &#218;          Capital U, acute accent
-    &#219;          Capital U, circumflex accent
-    &#220;          Capital U, dieresis or umlaut mark
-    &#221;          Capital Y, acute accent
-    &#222;          Capital THORN, Icelandic
-    &#223;          Small sharp s, German (sz ligature)
-    &#224;          Small a, grave accent
-    &#225;          Small a, acute accent
-    &#226;          Small a, circumflex accent
-    &#227;          Small a, tilde
-    &#228;          Small a, dieresis or umlaut mark
-    &#229;          Small a, ring
-    &#230;          Small ae dipthong (ligature)
-    &#231;          Small c, cedilla
-    &#232;          Small e, grave accent
-    &#233;          Small e, acute accent
-    &#234;          Small e, circumflex accent
-    &#235;          Small e, dieresis or umlaut mark
-    &#236;          Small i, grave accent
-    &#237;          Small i, acute accent
-    &#238;          Small i, circumflex accent
-    &#239;          Small i, dieresis or umlaut mark
-    &#240;          Small eth, Icelandic
-    &#241;          Small n, tilde
-    &#242;          Small o, grave accent
-    &#243;          Small o, acute accent
-    &#244;          Small o, circumflex accent
-    &#245;          Small o, tilde
-    &#246;          Small o, dieresis or umlaut mark
-    &#247;          Division sign
-    &#248;          Small o, slash
-    &#249;          Small u, grave accent
-    &#250;          Small u, acute accent
-    &#251;          Small u, circumflex accent
-    &#252;          Small u, dieresis or umlaut mark
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 74]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    &#253;          Small y, acute accent
-    &#254;          Small thorn, Icelandic
-    &#255;          Small y, dieresis or umlaut mark
-
-14. Proposed Entities
-
-   The HTML DTD references the "Added Latin 1" entity set, which only
-   supplies named entities for a subset of the non-ASCII characters in
-   [ISO-8859-1], namely the accented characters. The following entities
-   should be supported so that all ISO 8859-1 characters may only be
-   referenced symbolically. The names for these entities are taken from
-   the appendixes of [SGML].
-
-    <!ENTITY nbsp   CDATA "&#160;" -- no-break space -->
-    <!ENTITY iexcl  CDATA "&#161;" -- inverted exclamation mark -->
-    <!ENTITY cent   CDATA "&#162;" -- cent sign -->
-    <!ENTITY pound  CDATA "&#163;" -- pound sterling sign -->
-    <!ENTITY curren CDATA "&#164;" -- general currency sign -->
-    <!ENTITY yen    CDATA "&#165;" -- yen sign -->
-    <!ENTITY brvbar CDATA "&#166;" -- broken (vertical) bar -->
-    <!ENTITY sect   CDATA "&#167;" -- section sign -->
-    <!ENTITY uml    CDATA "&#168;" -- umlaut (dieresis) -->
-    <!ENTITY copy   CDATA "&#169;" -- copyright sign -->
-    <!ENTITY ordf   CDATA "&#170;" -- ordinal indicator, feminine -->
-    <!ENTITY laquo  CDATA "&#171;" -- angle quotation mark, left -->
-    <!ENTITY not    CDATA "&#172;" -- not sign -->
-    <!ENTITY shy    CDATA "&#173;" -- soft hyphen -->
-    <!ENTITY reg    CDATA "&#174;" -- registered sign -->
-    <!ENTITY macr   CDATA "&#175;" -- macron -->
-    <!ENTITY deg    CDATA "&#176;" -- degree sign -->
-    <!ENTITY plusmn CDATA "&#177;" -- plus-or-minus sign -->
-    <!ENTITY sup2   CDATA "&#178;" -- superscript two -->
-    <!ENTITY sup3   CDATA "&#179;" -- superscript three -->
-    <!ENTITY acute  CDATA "&#180;" -- acute accent -->
-    <!ENTITY micro  CDATA "&#181;" -- micro sign -->
-    <!ENTITY para   CDATA "&#182;" -- pilcrow (paragraph sign) -->
-    <!ENTITY middot CDATA "&#183;" -- middle dot -->
-    <!ENTITY cedil  CDATA "&#184;" -- cedilla -->
-    <!ENTITY sup1   CDATA "&#185;" -- superscript one -->
-    <!ENTITY ordm   CDATA "&#186;" -- ordinal indicator, masculine -->
-    <!ENTITY raquo  CDATA "&#187;" -- angle quotation mark, right -->
-    <!ENTITY frac14 CDATA "&#188;" -- fraction one-quarter -->
-    <!ENTITY frac12 CDATA "&#189;" -- fraction one-half -->
-    <!ENTITY frac34 CDATA "&#190;" -- fraction three-quarters -->
-    <!ENTITY iquest CDATA "&#191;" -- inverted question mark -->
-    <!ENTITY Agrave CDATA "&#192;" -- capital A, grave accent -->
-    <!ENTITY Aacute CDATA "&#193;" -- capital A, acute accent -->
-    <!ENTITY Acirc  CDATA "&#194;" -- capital A, circumflex accent -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 75]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    <!ENTITY Atilde CDATA "&#195;" -- capital A, tilde -->
-    <!ENTITY Auml   CDATA "&#196;" -- capital A, dieresis or umlaut mark -->
-    <!ENTITY Aring  CDATA "&#197;" -- capital A, ring -->
-    <!ENTITY AElig  CDATA "&#198;" -- capital AE diphthong (ligature) -->
-    <!ENTITY Ccedil CDATA "&#199;" -- capital C, cedilla -->
-    <!ENTITY Egrave CDATA "&#200;" -- capital E, grave accent -->
-    <!ENTITY Eacute CDATA "&#201;" -- capital E, acute accent -->
-    <!ENTITY Ecirc  CDATA "&#202;" -- capital E, circumflex accent -->
-    <!ENTITY Euml   CDATA "&#203;" -- capital E, dieresis or umlaut mark -->
-    <!ENTITY Igrave CDATA "&#204;" -- capital I, grave accent -->
-    <!ENTITY Iacute CDATA "&#205;" -- capital I, acute accent -->
-    <!ENTITY Icirc  CDATA "&#206;" -- capital I, circumflex accent -->
-    <!ENTITY Iuml   CDATA "&#207;" -- capital I, dieresis or umlaut mark -->
-    <!ENTITY ETH    CDATA "&#208;" -- capital Eth, Icelandic -->
-    <!ENTITY Ntilde CDATA "&#209;" -- capital N, tilde -->
-    <!ENTITY Ograve CDATA "&#210;" -- capital O, grave accent -->
-    <!ENTITY Oacute CDATA "&#211;" -- capital O, acute accent -->
-    <!ENTITY Ocirc  CDATA "&#212;" -- capital O, circumflex accent -->
-    <!ENTITY Otilde CDATA "&#213;" -- capital O, tilde -->
-    <!ENTITY Ouml   CDATA "&#214;" -- capital O, dieresis or umlaut mark -->
-    <!ENTITY times  CDATA "&#215;" -- multiply sign -->
-    <!ENTITY Oslash CDATA "&#216;" -- capital O, slash -->
-    <!ENTITY Ugrave CDATA "&#217;" -- capital U, grave accent -->
-    <!ENTITY Uacute CDATA "&#218;" -- capital U, acute accent -->
-    <!ENTITY Ucirc  CDATA "&#219;" -- capital U, circumflex accent -->
-    <!ENTITY Uuml   CDATA "&#220;" -- capital U, dieresis or umlaut mark -->
-    <!ENTITY Yacute CDATA "&#221;" -- capital Y, acute accent -->
-    <!ENTITY THORN  CDATA "&#222;" -- capital THORN, Icelandic -->
-    <!ENTITY szlig  CDATA "&#223;" -- small sharp s, German (sz ligature) -->
-    <!ENTITY agrave CDATA "&#224;" -- small a, grave accent -->
-    <!ENTITY aacute CDATA "&#225;" -- small a, acute accent -->
-    <!ENTITY acirc  CDATA "&#226;" -- small a, circumflex accent -->
-    <!ENTITY atilde CDATA "&#227;" -- small a, tilde -->
-    <!ENTITY auml   CDATA "&#228;" -- small a, dieresis or umlaut mark -->
-    <!ENTITY aring  CDATA "&#229;" -- small a, ring -->
-    <!ENTITY aelig  CDATA "&#230;" -- small ae diphthong (ligature) -->
-    <!ENTITY ccedil CDATA "&#231;" -- small c, cedilla -->
-    <!ENTITY egrave CDATA "&#232;" -- small e, grave accent -->
-    <!ENTITY eacute CDATA "&#233;" -- small e, acute accent -->
-    <!ENTITY ecirc  CDATA "&#234;" -- small e, circumflex accent -->
-    <!ENTITY euml   CDATA "&#235;" -- small e, dieresis or umlaut mark -->
-    <!ENTITY igrave CDATA "&#236;" -- small i, grave accent -->
-    <!ENTITY iacute CDATA "&#237;" -- small i, acute accent -->
-    <!ENTITY icirc  CDATA "&#238;" -- small i, circumflex accent -->
-    <!ENTITY iuml   CDATA "&#239;" -- small i, dieresis or umlaut mark -->
-    <!ENTITY eth    CDATA "&#240;" -- small eth, Icelandic -->
-    <!ENTITY ntilde CDATA "&#241;" -- small n, tilde -->
-    <!ENTITY ograve CDATA "&#242;" -- small o, grave accent -->
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 76]
-
-RFC 1866            Hypertext Markup Language - 2.0        November 1995
-
-
-    <!ENTITY oacute CDATA "&#243;" -- small o, acute accent -->
-    <!ENTITY ocirc  CDATA "&#244;" -- small o, circumflex accent -->
-    <!ENTITY otilde CDATA "&#245;" -- small o, tilde -->
-    <!ENTITY ouml   CDATA "&#246;" -- small o, dieresis or umlaut mark -->
-    <!ENTITY divide CDATA "&#247;" -- divide sign -->
-    <!ENTITY oslash CDATA "&#248;" -- small o, slash -->
-    <!ENTITY ugrave CDATA "&#249;" -- small u, grave accent -->
-    <!ENTITY uacute CDATA "&#250;" -- small u, acute accent -->
-    <!ENTITY ucirc  CDATA "&#251;" -- small u, circumflex accent -->
-    <!ENTITY uuml   CDATA "&#252;" -- small u, dieresis or umlaut mark -->
-    <!ENTITY yacute CDATA "&#253;" -- small y, acute accent -->
-    <!ENTITY thorn  CDATA "&#254;" -- small thorn, Icelandic -->
-    <!ENTITY yuml   CDATA "&#255;" -- small y, dieresis or umlaut mark -->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Berners-Lee & Connolly      Standards Track                    [Page 77]
- 
-
-

-Html markup produced by rfcmarkup 1.60, available from -http://tools.ietf.org/tools/rfcmarkup/ - - diff --git a/external/uriparser/doc/rfc3513.htm b/external/uriparser/doc/rfc3513.htm deleted file mode 100644 index 0b8bfb6..0000000 --- a/external/uriparser/doc/rfc3513.htm +++ /dev/null @@ -1,1579 +0,0 @@ - - - - - - - - - RFC 3513 Internet Protocol Version 6 (IPv6) Addressing Architecture - - - - - -
- - -
-[RFCs/IDs] [Plain Text] [From draft-ietf-ipngwg-addr-arch-v3]
-
-Obsoleted by: 4291 PROPOSED STANDARD
-
-
Network Working Group                                          R. Hinden
-Request for Comments: 3513                                         Nokia
-Obsoletes: 2373                                               S. Deering
-Category: Standards Track                                  Cisco Systems
-                                                              April 2003
-
-
-       

Internet Protocol Version 6 (IPv6) Addressing Architecture

- -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (2003). All Rights Reserved. - -Abstract - - This specification defines the addressing architecture of the IP - Version 6 (IPv6) protocol. The document includes the IPv6 addressing - model, text representations of IPv6 addresses, definition of IPv6 - unicast addresses, anycast addresses, and multicast addresses, and an - IPv6 node's required addresses. - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 1] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -Table of Contents - - 1. Introduction.................................................3 - 2. IPv6 Addressing..............................................3 - 2.1 Addressing Model.........................................4 - 2.2 Text Representation of Addresses.........................4 - 2.3 Text Representation of Address Prefixes..................5 - 2.4 Address Type Identification..............................6 - 2.5 Unicast Addresses........................................7 - 2.5.1 Interface Identifiers..............................8 - 2.5.2 The Unspecified Address............................9 - 2.5.3 The Loopback Address...............................9 - 2.5.4 Global Unicast Addresses..........................10 - 2.5.5 IPv6 Addresses with Embedded IPv4 Addresses.......10 - 2.5.6 Local-use IPv6 Unicast Addresses..................11 - 2.6 Anycast Addresses.......................................12 - 2.6.1 Required Anycast Address..........................13 - 2.7 Multicast Addresses.....................................13 - 2.7.1 Pre-Defined Multicast Addresses...................15 - 2.8 A Node's Required Addresses.............................17 - 3. Security Considerations.....................................17 - 4. IANA Considerations.........................................18 - 5. References..................................................19 - 5.1 Normative References....................................19 - 5.2 Informative References..................................19 - APPENDIX A: Creating Modified EUI-64 format Interface IDs......21 - APPENDIX B: Changes from RFC-2373..............................24 - Authors' Addresses.............................................25 - Full Copyright Statement.......................................26 - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 2] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

1. Introduction

- - This specification defines the addressing architecture of the IP - Version 6 (IPv6) protocol. It includes the basic formats for the - various types of IPv6 addresses (unicast, anycast, and multicast). - - The authors would like to acknowledge the contributions of Paul - Francis, Scott Bradner, Jim Bound, Brian Carpenter, Matt Crawford, - Deborah Estrin, Roger Fajman, Bob Fink, Peter Ford, Bob Gilligan, - Dimitry Haskin, Tom Harsch, Christian Huitema, Tony Li, Greg - Minshall, Thomas Narten, Erik Nordmark, Yakov Rekhter, Bill Simpson, - Sue Thomson, Markku Savela, and Larry Masinter. - -

2. IPv6 Addressing

- - IPv6 addresses are 128-bit identifiers for interfaces and sets of - interfaces (where "interface" is as defined in section 2 of [IPV6]). - There are three types of addresses: - - Unicast: An identifier for a single interface. A packet sent to a - unicast address is delivered to the interface identified - by that address. - - Anycast: An identifier for a set of interfaces (typically belonging - to different nodes). A packet sent to an anycast address - is delivered to one of the interfaces identified by that - address (the "nearest" one, according to the routing - protocols' measure of distance). - - Multicast: An identifier for a set of interfaces (typically belonging - to different nodes). A packet sent to a multicast address - is delivered to all interfaces identified by that address. - - There are no broadcast addresses in IPv6, their function being - superseded by multicast addresses. - - In this document, fields in addresses are given a specific name, for - example "subnet". When this name is used with the term "ID" for - identifier after the name (e.g., "subnet ID"), it refers to the - contents of the named field. When it is used with the term "prefix" - (e.g., "subnet prefix") it refers to all of the address from the left - up to and including this field. - - In IPv6, all zeros and all ones are legal values for any field, - unless specifically excluded. Specifically, prefixes may contain, or - end with, zero-valued fields. - - - - - -Hinden & Deering Standards Track [Page 3] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

2.1 Addressing Model

- - IPv6 addresses of all types are assigned to interfaces, not nodes. - An IPv6 unicast address refers to a single interface. Since each - interface belongs to a single node, any of that node's interfaces' - unicast addresses may be used as an identifier for the node. - - All interfaces are required to have at least one link-local unicast - address (see section 2.8 for additional required addresses). A - single interface may also have multiple IPv6 addresses of any type - (unicast, anycast, and multicast) or scope. Unicast addresses with - scope greater than link-scope are not needed for interfaces that are - not used as the origin or destination of any IPv6 packets to or from - non-neighbors. This is sometimes convenient for point-to-point - interfaces. There is one exception to this addressing model: - - A unicast address or a set of unicast addresses may be assigned to - multiple physical interfaces if the implementation treats the - multiple physical interfaces as one interface when presenting it - to the internet layer. This is useful for load-sharing over - multiple physical interfaces. - - Currently IPv6 continues the IPv4 model that a subnet prefix is - associated with one link. Multiple subnet prefixes may be assigned - to the same link. - -

2.2 Text Representation of Addresses

- - There are three conventional forms for representing IPv6 addresses as - text strings: - - 1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the - hexadecimal values of the eight 16-bit pieces of the address. - - Examples: - - FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 - - 1080:0:0:0:8:800:200C:417A - - Note that it is not necessary to write the leading zeros in an - individual field, but there must be at least one numeral in every - field (except for the case described in 2.). - - 2. Due to some methods of allocating certain styles of IPv6 - addresses, it will be common for addresses to contain long strings - of zero bits. In order to make writing addresses containing zero - bits easier a special syntax is available to compress the zeros. - - - -Hinden & Deering Standards Track [Page 4] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - The use of "::" indicates one or more groups of 16 bits of zeros. - The "::" can only appear once in an address. The "::" can also be - used to compress leading or trailing zeros in an address. - - For example, the following addresses: - - 1080:0:0:0:8:800:200C:417A a unicast address - FF01:0:0:0:0:0:0:101 a multicast address - 0:0:0:0:0:0:0:1 the loopback address - 0:0:0:0:0:0:0:0 the unspecified addresses - - may be represented as: - - 1080::8:800:200C:417A a unicast address - FF01::101 a multicast address - ::1 the loopback address - :: the unspecified addresses - - 3. An alternative form that is sometimes more convenient when dealing - with a mixed environment of IPv4 and IPv6 nodes is - x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of - the six high-order 16-bit pieces of the address, and the 'd's are - the decimal values of the four low-order 8-bit pieces of the - address (standard IPv4 representation). Examples: - - 0:0:0:0:0:0:13.1.68.3 - - 0:0:0:0:0:FFFF:129.144.52.38 - - or in compressed form: - - ::13.1.68.3 - - ::FFFF:129.144.52.38 - -

2.3 Text Representation of Address Prefixes

- - The text representation of IPv6 address prefixes is similar to the - way IPv4 addresses prefixes are written in CIDR notation [CIDR]. An - IPv6 address prefix is represented by the notation: - - ipv6-address/prefix-length - - where - - ipv6-address is an IPv6 address in any of the notations listed - in section 2.2. - - - - -Hinden & Deering Standards Track [Page 5] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - prefix-length is a decimal value specifying how many of the - leftmost contiguous bits of the address comprise - the prefix. - - For example, the following are legal representations of the 60-bit - prefix 12AB00000000CD3 (hexadecimal): - - 12AB:0000:0000:CD30:0000:0000:0000:0000/60 - 12AB::CD30:0:0:0:0/60 - 12AB:0:0:CD30::/60 - - The following are NOT legal representations of the above prefix: - - 12AB:0:0:CD3/60 may drop leading zeros, but not trailing zeros, - within any 16-bit chunk of the address - - 12AB::CD30/60 address to left of "/" expands to - 12AB:0000:0000:0000:0000:000:0000:CD30 - - 12AB::CD3/60 address to left of "/" expands to - 12AB:0000:0000:0000:0000:000:0000:0CD3 - - When writing both a node address and a prefix of that node address - (e.g., the node's subnet prefix), the two can combined as follows: - - the node address 12AB:0:0:CD30:123:4567:89AB:CDEF - and its subnet number 12AB:0:0:CD30::/60 - - can be abbreviated as 12AB:0:0:CD30:123:4567:89AB:CDEF/60 - -2.4 Address Type Identification - - The type of an IPv6 address is identified by the high-order bits of - the address, as follows: - - Address type Binary prefix IPv6 notation Section - ------------ ------------- ------------- ------- - Unspecified 00...0 (128 bits) ::/128 2.5.2 - Loopback 00...1 (128 bits) ::1/128 2.5.3 - Multicast 11111111 FF00::/8 2.7 - Link-local unicast 1111111010 FE80::/10 2.5.6 - Site-local unicast 1111111011 FEC0::/10 2.5.6 - Global unicast (everything else) - - Anycast addresses are taken from the unicast address spaces (of any - scope) and are not syntactically distinguishable from unicast - addresses. - - - - -Hinden & Deering Standards Track [Page 6] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - The general format of global unicast addresses is described in - section 2.5.4. Some special-purpose subtypes of global unicast - addresses which contain embedded IPv4 addresses (for the purposes of - IPv4-IPv6 interoperation) are described in section 2.5.5. - - Future specifications may redefine one or more sub-ranges of the - global unicast space for other purposes, but unless and until that - happens, implementations must treat all addresses that do not start - with any of the above-listed prefixes as global unicast addresses. - -

2.5 Unicast Addresses

- - IPv6 unicast addresses are aggregable with prefixes of arbitrary - bit-length similar to IPv4 addresses under Classless Interdomain - Routing. - - There are several types of unicast addresses in IPv6, in particular - global unicast, site-local unicast, and link-local unicast. There - are also some special-purpose subtypes of global unicast, such as - IPv6 addresses with embedded IPv4 addresses or encoded NSAP - addresses. Additional address types or subtypes can be defined in - the future. - - IPv6 nodes may have considerable or little knowledge of the internal - structure of the IPv6 address, depending on the role the node plays - (for instance, host versus router). At a minimum, a node may - consider that unicast addresses (including its own) have no internal - structure: - - | 128 bits | - +-----------------------------------------------------------------+ - | node address | - +-----------------------------------------------------------------+ - - A slightly sophisticated host (but still rather simple) may - additionally be aware of subnet prefix(es) for the link(s) it is - attached to, where different addresses may have different values for - n: - - | n bits | 128-n bits | - +------------------------------------------------+----------------+ - | subnet prefix | interface ID | - +------------------------------------------------+----------------+ - - Though a very simple router may have no knowledge of the internal - structure of IPv6 unicast addresses, routers will more generally have - knowledge of one or more of the hierarchical boundaries for the - operation of routing protocols. The known boundaries will differ - - - -Hinden & Deering Standards Track [Page 7] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - from router to router, depending on what positions the router holds - in the routing hierarchy. - -

2.5.1 Interface Identifiers

- - Interface identifiers in IPv6 unicast addresses are used to identify - interfaces on a link. They are required to be unique within a subnet - prefix. It is recommended that the same interface identifier not be - assigned to different nodes on a link. They may also be unique over - a broader scope. In some cases an interface's identifier will be - derived directly from that interface's link-layer address. The same - interface identifier may be used on multiple interfaces on a single - node, as long as they are attached to different subnets. - - Note that the uniqueness of interface identifiers is independent of - the uniqueness of IPv6 addresses. For example, a global unicast - address may be created with a non-global scope interface identifier - and a site-local address may be created with a global scope interface - identifier. - - For all unicast addresses, except those that start with binary value - 000, Interface IDs are required to be 64 bits long and to be - constructed in Modified EUI-64 format. - - Modified EUI-64 format based Interface identifiers may have global - scope when derived from a global token (e.g., IEEE 802 48-bit MAC or - IEEE EUI-64 identifiers [EUI64]) or may have local scope where a - global token is not available (e.g., serial links, tunnel end-points, - etc.) or where global tokens are undesirable (e.g., temporary tokens - for privacy [PRIV]). - - Modified EUI-64 format interface identifiers are formed by inverting - the "u" bit (universal/local bit in IEEE EUI-64 terminology) when - forming the interface identifier from IEEE EUI-64 identifiers. In - the resulting Modified EUI-64 format the "u" bit is set to one (1) to - indicate global scope, and it is set to zero (0) to indicate local - scope. The first three octets in binary of an IEEE EUI-64 identifier - are as follows: - - 0 0 0 1 1 2 - |0 7 8 5 6 3| - +----+----+----+----+----+----+ - |cccc|ccug|cccc|cccc|cccc|cccc| - +----+----+----+----+----+----+ - - written in Internet standard bit-order , where "u" is the - universal/local bit, "g" is the individual/group bit, and "c" are the - bits of the company_id. Appendix A: "Creating Modified EUI-64 format - - - -Hinden & Deering Standards Track [Page 8] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - Interface Identifiers" provides examples on the creation of Modified - EUI-64 format based interface identifiers. - - The motivation for inverting the "u" bit when forming an interface - identifier is to make it easy for system administrators to hand - configure non-global identifiers when hardware tokens are not - available. This is expected to be case for serial links, tunnel end- - points, etc. The alternative would have been for these to be of the - form 0200:0:0:1, 0200:0:0:2, etc., instead of the much simpler 1, 2, - etc. - - The use of the universal/local bit in the Modified EUI-64 format - identifier is to allow development of future technology that can take - advantage of interface identifiers with global scope. - - The details of forming interface identifiers are defined in the - appropriate "IPv6 over <link>" specification such as "IPv6 over - Ethernet" [ETHER], "IPv6 over FDDI" [FDDI], etc. - -

2.5.2 The Unspecified Address

- - The address 0:0:0:0:0:0:0:0 is called the unspecified address. It - must never be assigned to any node. It indicates the absence of an - address. One example of its use is in the Source Address field of - any IPv6 packets sent by an initializing host before it has learned - its own address. - - The unspecified address must not be used as the destination address - of IPv6 packets or in IPv6 Routing Headers. An IPv6 packet with a - source address of unspecified must never be forwarded by an IPv6 - router. - -

2.5.3 The Loopback Address

- - The unicast address 0:0:0:0:0:0:0:1 is called the loopback address. - It may be used by a node to send an IPv6 packet to itself. It may - never be assigned to any physical interface. It is treated as - having link-local scope, and may be thought of as the link-local - unicast address of a virtual interface (typically called "the - loopback interface") to an imaginary link that goes nowhere. - - The loopback address must not be used as the source address in IPv6 - packets that are sent outside of a single node. An IPv6 packet with - a destination address of loopback must never be sent outside of a - single node and must never be forwarded by an IPv6 router. A packet - received on an interface with destination address of loopback must be - dropped. - - - - -Hinden & Deering Standards Track [Page 9] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

2.5.4 Global Unicast Addresses

- - The general format for IPv6 global unicast addresses is as follows: - - | n bits | m bits | 128-n-m bits | - +------------------------+-----------+----------------------------+ - | global routing prefix | subnet ID | interface ID | - +------------------------+-----------+----------------------------+ - - where the global routing prefix is a (typically hierarchically- - structured) value assigned to a site (a cluster of subnets/links), - the subnet ID is an identifier of a link within the site, and the - interface ID is as defined in section 2.5.1. - - All global unicast addresses other than those that start with binary - 000 have a 64-bit interface ID field (i.e., n + m = 64), formatted as - described in section 2.5.1. Global unicast addresses that start with - binary 000 have no such constraint on the size or structure of the - interface ID field. - - Examples of global unicast addresses that start with binary 000 are - the IPv6 address with embedded IPv4 addresses described in section - 2.5.5 and the IPv6 address containing encoded NSAP addresses - specified in [NSAP]. An example of global addresses starting with a - binary value other than 000 (and therefore having a 64-bit interface - ID field) can be found in [AGGR]. - -

2.5.5 IPv6 Addresses with Embedded IPv4 Addresses

- - The IPv6 transition mechanisms [TRAN] include a technique for hosts - and routers to dynamically tunnel IPv6 packets over IPv4 routing - infrastructure. IPv6 nodes that use this technique are assigned - special IPv6 unicast addresses that carry a global IPv4 address in - the low-order 32 bits. This type of address is termed an "IPv4- - compatible IPv6 address" and has the format: - - | 80 bits | 16 | 32 bits | - +--------------------------------------+--------------------------+ - |0000..............................0000|0000| IPv4 address | - +--------------------------------------+----+---------------------+ - - Note: The IPv4 address used in the "IPv4-compatible IPv6 address" - must be a globally-unique IPv4 unicast address. - - A second type of IPv6 address which holds an embedded IPv4 address is - also defined. This address type is used to represent the addresses - of IPv4 nodes as IPv6 addresses. This type of address is termed an - "IPv4-mapped IPv6 address" and has the format: - - - -Hinden & Deering Standards Track [Page 10] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - | 80 bits | 16 | 32 bits | - +--------------------------------------+--------------------------+ - |0000..............................0000|FFFF| IPv4 address | - +--------------------------------------+----+---------------------+ - -

2.5.6 Local-Use IPv6 Unicast Addresses

- - There are two types of local-use unicast addresses defined. These - are Link-Local and Site-Local. The Link-Local is for use on a single - link and the Site-Local is for use in a single site. Link-Local - addresses have the following format: - - | 10 | - | bits | 54 bits | 64 bits | - +----------+-------------------------+----------------------------+ - |1111111010| 0 | interface ID | - +----------+-------------------------+----------------------------+ - - Link-Local addresses are designed to be used for addressing on a - single link for purposes such as automatic address configuration, - neighbor discovery, or when no routers are present. - - Routers must not forward any packets with link-local source or - destination addresses to other links. - - Site-Local addresses have the following format: - - | 10 | - | bits | 54 bits | 64 bits | - +----------+-------------------------+----------------------------+ - |1111111011| subnet ID | interface ID | - +----------+-------------------------+----------------------------+ - - Site-local addresses are designed to be used for addressing inside of - a site without the need for a global prefix. Although a subnet ID - may be up to 54-bits long, it is expected that globally-connected - sites will use the same subnet IDs for site-local and global - prefixes. - - Routers must not forward any packets with site-local source or - destination addresses outside of the site. - - - - - - - - - - -Hinden & Deering Standards Track [Page 11] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

2.6 Anycast Addresses

- - An IPv6 anycast address is an address that is assigned to more than - one interface (typically belonging to different nodes), with the - property that a packet sent to an anycast address is routed to the - "nearest" interface having that address, according to the routing - protocols' measure of distance. - - Anycast addresses are allocated from the unicast address space, using - any of the defined unicast address formats. Thus, anycast addresses - are syntactically indistinguishable from unicast addresses. When a - unicast address is assigned to more than one interface, thus turning - it into an anycast address, the nodes to which the address is - assigned must be explicitly configured to know that it is an anycast - address. - - For any assigned anycast address, there is a longest prefix P of that - address that identifies the topological region in which all - interfaces belonging to that anycast address reside. Within the - region identified by P, the anycast address must be maintained as a - separate entry in the routing system (commonly referred to as a "host - route"); outside the region identified by P, the anycast address may - be aggregated into the routing entry for prefix P. - - Note that in the worst case, the prefix P of an anycast set may be - the null prefix, i.e., the members of the set may have no topological - locality. In that case, the anycast address must be maintained as a - separate routing entry throughout the entire internet, which presents - a severe scaling limit on how many such "global" anycast sets may be - supported. Therefore, it is expected that support for global anycast - sets may be unavailable or very restricted. - - One expected use of anycast addresses is to identify the set of - routers belonging to an organization providing internet service. - Such addresses could be used as intermediate addresses in an IPv6 - Routing header, to cause a packet to be delivered via a particular - service provider or sequence of service providers. - - Some other possible uses are to identify the set of routers attached - to a particular subnet, or the set of routers providing entry into a - particular routing domain. - - There is little experience with widespread, arbitrary use of internet - anycast addresses, and some known complications and hazards when - using them in their full generality [ANYCST]. Until more experience - has been gained and solutions are specified, the following - restrictions are imposed on IPv6 anycast addresses: - - - - -Hinden & Deering Standards Track [Page 12] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - o An anycast address must not be used as the source address of an - IPv6 packet. - - o An anycast address must not be assigned to an IPv6 host, that is, - it may be assigned to an IPv6 router only. - -

2.6.1 Required Anycast Address

- - The Subnet-Router anycast address is predefined. Its format is as - follows: - - | n bits | 128-n bits | - +------------------------------------------------+----------------+ - | subnet prefix | 00000000000000 | - +------------------------------------------------+----------------+ - - The "subnet prefix" in an anycast address is the prefix which - identifies a specific link. This anycast address is syntactically - the same as a unicast address for an interface on the link with the - interface identifier set to zero. - - Packets sent to the Subnet-Router anycast address will be delivered - to one router on the subnet. All routers are required to support the - Subnet-Router anycast addresses for the subnets to which they have - interfaces. - - The subnet-router anycast address is intended to be used for - applications where a node needs to communicate with any one of the - set of routers. - -

2.7 Multicast Addresses

- - An IPv6 multicast address is an identifier for a group of interfaces - (typically on different nodes). An interface may belong to any - number of multicast groups. Multicast addresses have the following - format: - - | 8 | 4 | 4 | 112 bits | - +------ -+----+----+---------------------------------------------+ - |11111111|flgs|scop| group ID | - +--------+----+----+---------------------------------------------+ - - binary 11111111 at the start of the address identifies the - address as being a multicast address. - - +-+-+-+-+ - flgs is a set of 4 flags: |0|0|0|T| - +-+-+-+-+ - - - -Hinden & Deering Standards Track [Page 13] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - The high-order 3 flags are reserved, and must be initialized - to 0. - - T = 0 indicates a permanently-assigned ("well-known") - multicast address, assigned by the Internet Assigned Number - Authority (IANA). - - T = 1 indicates a non-permanently-assigned ("transient") - multicast address. - - scop is a 4-bit multicast scope value used to limit the scope - of the multicast group. The values are: - - 0 reserved - 1 interface-local scope - 2 link-local scope - 3 reserved - 4 admin-local scope - 5 site-local scope - 6 (unassigned) - 7 (unassigned) - 8 organization-local scope - 9 (unassigned) - A (unassigned) - B (unassigned) - C (unassigned) - D (unassigned) - E global scope - F reserved - - interface-local scope spans only a single interface on a - node, and is useful only for loopback transmission of - multicast. - - link-local and site-local multicast scopes span the same - topological regions as the corresponding unicast scopes. - - admin-local scope is the smallest scope that must be - administratively configured, i.e., not automatically derived - from physical connectivity or other, non- multicast-related - configuration. - - organization-local scope is intended to span multiple sites - belonging to a single organization. - - scopes labeled "(unassigned)" are available for - administrators to define additional multicast regions. - - - - -Hinden & Deering Standards Track [Page 14] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - group ID identifies the multicast group, either permanent or - transient, within the given scope. - - The "meaning" of a permanently-assigned multicast address is - independent of the scope value. For example, if the "NTP servers - group" is assigned a permanent multicast address with a group ID of - 101 (hex), then: - - FF01:0:0:0:0:0:0:101 means all NTP servers on the same interface - (i.e., the same node) as the sender. - - FF02:0:0:0:0:0:0:101 means all NTP servers on the same link as the - sender. - - FF05:0:0:0:0:0:0:101 means all NTP servers in the same site as the - sender. - - FF0E:0:0:0:0:0:0:101 means all NTP servers in the internet. - - Non-permanently-assigned multicast addresses are meaningful only - within a given scope. For example, a group identified by the non- - permanent, site-local multicast address FF15:0:0:0:0:0:0:101 at one - site bears no relationship to a group using the same address at a - different site, nor to a non-permanent group using the same group ID - with different scope, nor to a permanent group with the same group - ID. - - Multicast addresses must not be used as source addresses in IPv6 - packets or appear in any Routing header. - - Routers must not forward any multicast packets beyond of the scope - indicated by the scop field in the destination multicast address. - - Nodes must not originate a packet to a multicast address whose scop - field contains the reserved value 0; if such a packet is received, it - must be silently dropped. Nodes should not originate a packet to a - multicast address whose scop field contains the reserved value F; if - such a packet is sent or received, it must be treated the same as - packets destined to a global (scop E) multicast address. - -

2.7.1 Pre-Defined Multicast Addresses

- - The following well-known multicast addresses are pre-defined. The - group ID's defined in this section are defined for explicit scope - values. - - Use of these group IDs for any other scope values, with the T flag - equal to 0, is not allowed. - - - -Hinden & Deering Standards Track [Page 15] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - Reserved Multicast Addresses: FF00:0:0:0:0:0:0:0 - FF01:0:0:0:0:0:0:0 - FF02:0:0:0:0:0:0:0 - FF03:0:0:0:0:0:0:0 - FF04:0:0:0:0:0:0:0 - FF05:0:0:0:0:0:0:0 - FF06:0:0:0:0:0:0:0 - FF07:0:0:0:0:0:0:0 - FF08:0:0:0:0:0:0:0 - FF09:0:0:0:0:0:0:0 - FF0A:0:0:0:0:0:0:0 - FF0B:0:0:0:0:0:0:0 - FF0C:0:0:0:0:0:0:0 - FF0D:0:0:0:0:0:0:0 - FF0E:0:0:0:0:0:0:0 - FF0F:0:0:0:0:0:0:0 - - The above multicast addresses are reserved and shall never be - assigned to any multicast group. - - All Nodes Addresses: FF01:0:0:0:0:0:0:1 - FF02:0:0:0:0:0:0:1 - - The above multicast addresses identify the group of all IPv6 nodes, - within scope 1 (interface-local) or 2 (link-local). - - All Routers Addresses: FF01:0:0:0:0:0:0:2 - FF02:0:0:0:0:0:0:2 - FF05:0:0:0:0:0:0:2 - - The above multicast addresses identify the group of all IPv6 routers, - within scope 1 (interface-local), 2 (link-local), or 5 (site-local). - - Solicited-Node Address: FF02:0:0:0:0:1:FFXX:XXXX - - Solicited-node multicast address are computed as a function of a - node's unicast and anycast addresses. A solicited-node multicast - address is formed by taking the low-order 24 bits of an address - (unicast or anycast) and appending those bits to the prefix - FF02:0:0:0:0:1:FF00::/104 resulting in a multicast address in the - range - - FF02:0:0:0:0:1:FF00:0000 - - to - - FF02:0:0:0:0:1:FFFF:FFFF - - - - -Hinden & Deering Standards Track [Page 16] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - For example, the solicited node multicast address corresponding to - the IPv6 address 4037::01:800:200E:8C6C is FF02::1:FF0E:8C6C. IPv6 - addresses that differ only in the high-order bits, e.g., due to - multiple high-order prefixes associated with different aggregations, - will map to the same solicited-node address thereby, reducing the - number of multicast addresses a node must join. - - A node is required to compute and join (on the appropriate interface) - the associated Solicited-Node multicast addresses for every unicast - and anycast address it is assigned. - -

2.8 A Node's Required Addresses

- - A host is required to recognize the following addresses as - identifying itself: - - o Its required Link-Local Address for each interface. - o Any additional Unicast and Anycast Addresses that have been - configured for the node's interfaces (manually or - automatically). - o The loopback address. - o The All-Nodes Multicast Addresses defined in section 2.7.1. - o The Solicited-Node Multicast Address for each of its unicast - and anycast addresses. - o Multicast Addresses of all other groups to which the node - belongs. - - A router is required to recognize all addresses that a host is - required to recognize, plus the following addresses as identifying - itself: - - o The Subnet-Router Anycast Addresses for all interfaces for - which it is configured to act as a router. - o All other Anycast Addresses with which the router has been - configured. - o The All-Routers Multicast Addresses defined in section 2.7.1. - -

3. Security Considerations

- - IPv6 addressing documents do not have any direct impact on Internet - infrastructure security. Authentication of IPv6 packets is defined - in [AUTH]. - - - - - - - - - -Hinden & Deering Standards Track [Page 17] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

4. IANA Considerations

- - The table and notes at http://www.isi.edu/in- - notes/iana/assignments/ipv6-address-space.txt should be replaced with - the following: - - INTERNET PROTOCOL VERSION 6 ADDRESS SPACE - - The initial assignment of IPv6 address space is as follows: - - Allocation Prefix Fraction of - (binary) Address Space - ----------------------------------- -------- ------------- - Unassigned (see Note 1 below) 0000 0000 1/256 - Unassigned 0000 0001 1/256 - Reserved for NSAP Allocation 0000 001 1/128 [RFC1888] - Unassigned 0000 01 1/64 - Unassigned 0000 1 1/32 - Unassigned 0001 1/16 - Global Unicast 001 1/8 [RFC2374] - Unassigned 010 1/8 - Unassigned 011 1/8 - Unassigned 100 1/8 - Unassigned 101 1/8 - Unassigned 110 1/8 - Unassigned 1110 1/16 - Unassigned 1111 0 1/32 - Unassigned 1111 10 1/64 - Unassigned 1111 110 1/128 - Unassigned 1111 1110 0 1/512 - Link-Local Unicast Addresses 1111 1110 10 1/1024 - Site-Local Unicast Addresses 1111 1110 11 1/1024 - Multicast Addresses 1111 1111 1/256 - - Notes: - - 1. The "unspecified address", the "loopback address", and the IPv6 - Addresses with Embedded IPv4 Addresses are assigned out of the - 0000 0000 binary prefix space. - - 2. For now, IANA should limit its allocation of IPv6 unicast address - space to the range of addresses that start with binary value 001. - The rest of the global unicast address space (approximately 85% of - the IPv6 address space) is reserved for future definition and use, - and is not to be assigned by IANA at this time. - - - - - - -Hinden & Deering Standards Track [Page 18] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -

5. References

- -

5.1 Normative References

- - [IPV6] Deering, S. and R. Hinden, "Internet Protocol, Version 6 - (IPv6) Specification", RFC 2460, December 1998. - - [RFC2026] Bradner, S., "The Internet Standards Process -- Revision - 3", BCP 9 , RFC 2026, October 1996. - -

5.2 Informative References

- - [ANYCST] Partridge, C., Mendez, T. and W. Milliken, "Host Anycasting - Service", RFC 1546, November 1993. - - [AUTH] Kent, S. and R. Atkinson, "IP Authentication Header", RFC - 2402, November 1998. - - [AGGR] Hinden, R., O'Dell, M. and S. Deering, "An Aggregatable - Global Unicast Address Format", RFC 2374, July 1998. - - [CIDR] Fuller, V., Li, T., Yu, J. and K. Varadhan, "Classless - Inter-Domain Routing (CIDR): An Address Assignment and - Aggregation Strategy", RFC 1519, September 1993. - - [ETHER] Crawford, M., "Transmission of IPv6 Packets over Ethernet - Networks", RFC 2464, December 1998. - - [EUI64] IEEE, "Guidelines for 64-bit Global Identifier (EUI-64) - Registration Authority", - http://standards.ieee.org/regauth/oui/tutorials/EUI64.html, - March 1997. - - [FDDI] Crawford, M., "Transmission of IPv6 Packets over FDDI - Networks", RFC 2467, December 1998. - - [MASGN] Hinden, R. and S. Deering, "IPv6 Multicast Address - Assignments", RFC 2375, July 1998. - - [NSAP] Bound, J., Carpenter, B., Harrington, D., Houldsworth, J. - and A. Lloyd, "OSI NSAPs and IPv6", RFC 1888, August 1996. - - [PRIV] Narten, T. and R. Draves, "Privacy Extensions for Stateless - Address Autoconfiguration in IPv6", RFC 3041, January 2001. - - [TOKEN] Crawford, M., Narten, T. and S. Thomas, "Transmission of - IPv6 Packets over Token Ring Networks", RFC 2470, December - 1998. - - - -Hinden & Deering Standards Track [Page 19] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - [TRAN] Gilligan, R. and E. Nordmark, "Transition Mechanisms for - IPv6 Hosts and Routers", RFC 2893, August 2000. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 20] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -APPENDIX A: Creating Modified EUI-64 format Interface Identifiers - - Depending on the characteristics of a specific link or node there are - a number of approaches for creating Modified EUI-64 format interface - identifiers. This appendix describes some of these approaches. - -Links or Nodes with IEEE EUI-64 Identifiers - - The only change needed to transform an IEEE EUI-64 identifier to an - interface identifier is to invert the "u" (universal/local) bit. For - example, a globally unique IEEE EUI-64 identifier of the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc0gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - where "c" are the bits of the assigned company_id, "0" is the value - of the universal/local bit to indicate global scope, "g" is - individual/group bit, and "m" are the bits of the manufacturer- - selected extension identifier. The IPv6 interface identifier would - be of the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc1gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - The only change is inverting the value of the universal/local bit. - -Links or Nodes with IEEE 802 48 bit MAC's - - [EUI64] defines a method to create a IEEE EUI-64 identifier from an - IEEE 48bit MAC identifier. This is to insert two octets, with - hexadecimal values of 0xFF and 0xFE, in the middle of the 48 bit MAC - (between the company_id and vendor supplied id). For example, the 48 - bit IEEE MAC with global scope: - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 21] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - |0 1|1 3|3 4| - |0 5|6 1|2 7| - +----------------+----------------+----------------+ - |cccccc0gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+ - - where "c" are the bits of the assigned company_id, "0" is the value - of the universal/local bit to indicate global scope, "g" is - individual/group bit, and "m" are the bits of the manufacturer- - selected extension identifier. The interface identifier would be of - the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc1gcccccccc|cccccccc11111111|11111110mmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - When IEEE 802 48bit MAC addresses are available (on an interface or a - node), an implementation may use them to create interface identifiers - due to their availability and uniqueness properties. - -Links with Other Kinds of Identifiers - - There are a number of types of links that have link-layer interface - identifiers other than IEEE EIU-64 or IEEE 802 48-bit MACs. Examples - include LocalTalk and Arcnet. The method to create an Modified EUI- - 64 format identifier is to take the link identifier (e.g., the - LocalTalk 8 bit node identifier) and zero fill it to the left. For - example, a LocalTalk 8 bit node identifier of hexadecimal value 0x4F - results in the following interface identifier: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |0000000000000000|0000000000000000|0000000000000000|0000000001001111| - +----------------+----------------+----------------+----------------+ - - Note that this results in the universal/local bit set to "0" to - indicate local scope. - -Links without Identifiers - - There are a number of links that do not have any type of built-in - identifier. The most common of these are serial links and configured - tunnels. Interface identifiers must be chosen that are unique within - a subnet-prefix. - - - - -Hinden & Deering Standards Track [Page 22] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - When no built-in identifier is available on a link the preferred - approach is to use a global interface identifier from another - interface or one which is assigned to the node itself. When using - this approach no other interface connecting the same node to the same - subnet-prefix may use the same identifier. - - If there is no global interface identifier available for use on the - link the implementation needs to create a local-scope interface - identifier. The only requirement is that it be unique within a - subnet prefix. There are many possible approaches to select a - subnet-prefix-unique interface identifier. These include: - - Manual Configuration - Node Serial Number - Other node-specific token - - The subnet-prefix-unique interface identifier should be generated in - a manner that it does not change after a reboot of a node or if - interfaces are added or deleted from the node. - - The selection of the appropriate algorithm is link and implementation - dependent. The details on forming interface identifiers are defined - in the appropriate "IPv6 over <link>" specification. It is strongly - recommended that a collision detection algorithm be implemented as - part of any automatic algorithm. - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 23] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -APPENDIX B: Changes from RFC-2373 - - The following changes were made from RFC-2373 "IP Version 6 - Addressing Architecture": - - - Clarified text in section 2.2 to allow "::" to represent one or - more groups of 16 bits of zeros. - - Changed uniqueness requirement of Interface Identifiers from - unique on a link to unique within a subnet prefix. Also added a - recommendation that the same interface identifier not be assigned - to different machines on a link. - - Change site-local format to make the subnet ID field 54-bit long - and remove the 38-bit zero's field. - - Added description of multicast scop values and rules to handle the - reserved scop value 0. - - Revised sections 2.4 and 2.5.6 to simplify and clarify how - different address types are identified. This was done to insure - that implementations do not build in any knowledge about global - unicast format prefixes. Changes include: - o Removed Format Prefix (FP) terminology - o Revised list of address types to only include exceptions to - global unicast and a singe entry that identifies everything - else as Global Unicast. - o Removed list of defined prefix exceptions from section 2.5.6 - as it is now the main part of section 2.4. - - Clarified text relating to EUI-64 identifiers to distinguish - between IPv6's "Modified EUI-64 format" identifiers and IEEE EUI- - 64 identifiers. - - Combined the sections on the Global Unicast Addresses and NSAP - Addresses into a single section on Global Unicast Addresses, - generalized the Global Unicast format, and cited [AGGR] and [NSAP] - as examples. - - Reordered sections 2.5.4 and 2.5.5. - - Removed section 2.7.2 Assignment of New IPv6 Multicast Addresses - because this is being redefined elsewhere. - - Added an IANA considerations section that updates the IANA IPv6 - address allocations and documents the NSAP and AGGR allocations. - - Added clarification that the "IPv4-compatible IPv6 address" must - use global IPv4 unicast addresses. - - Divided references in to normative and non-normative sections. - - Added reference to [PRIV] in section 2.5.1 - - Added clarification that routers must not forward multicast - packets outside of the scope indicated in the multicast address. - - Added clarification that routers must not forward packets with - source address of the unspecified address. - - Added clarification that routers must drop packets received on an - interface with destination address of loopback. - - Clarified the definition of IPv4-mapped addresses. - - - -Hinden & Deering Standards Track [Page 24] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - - - Removed the ABNF Description of Text Representations Appendix. - - Removed the address block reserved for IPX addresses. - - Multicast scope changes: - o Changed name of scope value 1 from "node-local" to - "interface-local" - o Defined scope value 4 as "admin-local" - - Corrected reference to RFC1933 and updated references. - - Many small changes to clarify and make the text more consistent. - -Authors' Addresses - - Robert M. Hinden - Nokia - 313 Fairchild Drive - Mountain View, CA 94043 - USA - - Phone: +1 650 625-2004 - EMail: hinden@iprg.nokia.com - - - Stephen E. Deering - Cisco Systems, Inc. - 170 West Tasman Drive - San Jose, CA 95134-1706 - USA - - Phone: +1 408 527-8213 - EMail: deering@cisco.com - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 25] - -RFC 3513 IPv6 Addressing Architecture April 2003 - - -Full Copyright Statement - - Copyright (C) The Internet Society (2003). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Acknowledgement - - Funding for the RFC Editor function is currently provided by the - Internet Society. - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 26] - - -

-Html markup produced by rfcmarkup 1.46, available from -http://tools.ietf.org/tools/rfcmarkup/ - - - \ No newline at end of file diff --git a/external/uriparser/doc/rfc3986.htm b/external/uriparser/doc/rfc3986.htm deleted file mode 100644 index b392007..0000000 --- a/external/uriparser/doc/rfc3986.htm +++ /dev/null @@ -1,3539 +0,0 @@ - - - - - - - - - RFC 3986 Uniform Resource Identifier (URI): Generic Syntax - - - - - -
- - -
-[RFCs/IDs] [Plain Text] [From draft-fielding-uri-rfc2396bis]
-
- STANDARD
-
-
Network Working Group                                     T. Berners-Lee
-Request for Comments: 3986                                       W3C/MIT
-STD: 66                                                      R. Fielding
-Updates: 1738                                               Day Software
-Obsoletes: 2732, 2396, 1808                                  L. Masinter
-Category: Standards Track                                  Adobe Systems
-                                                            January 2005
-
-
-           

Uniform Resource Identifier (URI): Generic Syntax

- -Status of This Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (2005). - -Abstract - - A Uniform Resource Identifier (URI) is a compact sequence of - characters that identifies an abstract or physical resource. This - specification defines the generic URI syntax and a process for - resolving URI references that might be in relative form, along with - guidelines and security considerations for the use of URIs on the - Internet. The URI syntax defines a grammar that is a superset of all - valid URIs, allowing an implementation to parse the common components - of a URI reference without knowing the scheme-specific requirements - of every possible identifier. This specification does not define a - generative grammar for URIs; that task is performed by the individual - specifications of each URI scheme. - - - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 1] - -RFC 3986 URI Generic Syntax January 2005 - - -Table of Contents - - 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 - 1.1. Overview of URIs . . . . . . . . . . . . . . . . . . . . 4 - 1.1.1. Generic Syntax . . . . . . . . . . . . . . . . . 6 - 1.1.2. Examples . . . . . . . . . . . . . . . . . . . . 7 - 1.1.3. URI, URL, and URN . . . . . . . . . . . . . . . 7 - 1.2. Design Considerations . . . . . . . . . . . . . . . . . 8 - 1.2.1. Transcription . . . . . . . . . . . . . . . . . 8 - 1.2.2. Separating Identification from Interaction . . . 9 - 1.2.3. Hierarchical Identifiers . . . . . . . . . . . . 10 - 1.3. Syntax Notation . . . . . . . . . . . . . . . . . . . . 11 - 2. Characters . . . . . . . . . . . . . . . . . . . . . . . . . . 11 - 2.1. Percent-Encoding . . . . . . . . . . . . . . . . . . . . 12 - 2.2. Reserved Characters . . . . . . . . . . . . . . . . . . 12 - 2.3. Unreserved Characters . . . . . . . . . . . . . . . . . 13 - 2.4. When to Encode or Decode . . . . . . . . . . . . . . . . 14 - 2.5. Identifying Data . . . . . . . . . . . . . . . . . . . . 14 - 3. Syntax Components . . . . . . . . . . . . . . . . . . . . . . 16 - 3.1. Scheme . . . . . . . . . . . . . . . . . . . . . . . . . 17 - 3.2. Authority . . . . . . . . . . . . . . . . . . . . . . . 17 - 3.2.1. User Information . . . . . . . . . . . . . . . . 18 - 3.2.2. Host . . . . . . . . . . . . . . . . . . . . . . 18 - 3.2.3. Port . . . . . . . . . . . . . . . . . . . . . . 22 - 3.3. Path . . . . . . . . . . . . . . . . . . . . . . . . . . 22 - 3.4. Query . . . . . . . . . . . . . . . . . . . . . . . . . 23 - 3.5. Fragment . . . . . . . . . . . . . . . . . . . . . . . . 24 - 4. Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 - 4.1. URI Reference . . . . . . . . . . . . . . . . . . . . . 25 - 4.2. Relative Reference . . . . . . . . . . . . . . . . . . . 26 - 4.3. Absolute URI . . . . . . . . . . . . . . . . . . . . . . 27 - 4.4. Same-Document Reference . . . . . . . . . . . . . . . . 27 - 4.5. Suffix Reference . . . . . . . . . . . . . . . . . . . . 27 - 5. Reference Resolution . . . . . . . . . . . . . . . . . . . . . 28 - 5.1. Establishing a Base URI . . . . . . . . . . . . . . . . 28 - 5.1.1. Base URI Embedded in Content . . . . . . . . . . 29 - 5.1.2. Base URI from the Encapsulating Entity . . . . . 29 - 5.1.3. Base URI from the Retrieval URI . . . . . . . . 30 - 5.1.4. Default Base URI . . . . . . . . . . . . . . . . 30 - 5.2. Relative Resolution . . . . . . . . . . . . . . . . . . 30 - 5.2.1. Pre-parse the Base URI . . . . . . . . . . . . . 31 - 5.2.2. Transform References . . . . . . . . . . . . . . 31 - 5.2.3. Merge Paths . . . . . . . . . . . . . . . . . . 32 - 5.2.4. Remove Dot Segments . . . . . . . . . . . . . . 33 - 5.3. Component Recomposition . . . . . . . . . . . . . . . . 35 - 5.4. Reference Resolution Examples . . . . . . . . . . . . . 35 - 5.4.1. Normal Examples . . . . . . . . . . . . . . . . 36 - 5.4.2. Abnormal Examples . . . . . . . . . . . . . . . 36 - - - -Berners-Lee, et al. Standards Track [Page 2] - -RFC 3986 URI Generic Syntax January 2005 - - - 6. Normalization and Comparison . . . . . . . . . . . . . . . . . 38 - 6.1. Equivalence . . . . . . . . . . . . . . . . . . . . . . 38 - 6.2. Comparison Ladder . . . . . . . . . . . . . . . . . . . 39 - 6.2.1. Simple String Comparison . . . . . . . . . . . . 39 - 6.2.2. Syntax-Based Normalization . . . . . . . . . . . 40 - 6.2.3. Scheme-Based Normalization . . . . . . . . . . . 41 - 6.2.4. Protocol-Based Normalization . . . . . . . . . . 42 - 7. Security Considerations . . . . . . . . . . . . . . . . . . . 43 - 7.1. Reliability and Consistency . . . . . . . . . . . . . . 43 - 7.2. Malicious Construction . . . . . . . . . . . . . . . . . 43 - 7.3. Back-End Transcoding . . . . . . . . . . . . . . . . . . 44 - 7.4. Rare IP Address Formats . . . . . . . . . . . . . . . . 45 - 7.5. Sensitive Information . . . . . . . . . . . . . . . . . 45 - 7.6. Semantic Attacks . . . . . . . . . . . . . . . . . . . . 45 - 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 46 - 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 46 - 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 46 - 10.1. Normative References . . . . . . . . . . . . . . . . . . 46 - 10.2. Informative References . . . . . . . . . . . . . . . . . 47 - A. Collected ABNF for URI . . . . . . . . . . . . . . . . . . . . 49 - B. Parsing a URI Reference with a Regular Expression . . . . . . 50 - C. Delimiting a URI in Context . . . . . . . . . . . . . . . . . 51 - D. Changes from RFC 2396 . . . . . . . . . . . . . . . . . . . . 53 - D.1. Additions . . . . . . . . . . . . . . . . . . . . . . . 53 - D.2. Modifications . . . . . . . . . . . . . . . . . . . . . 53 - Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 60 - Full Copyright Statement . . . . . . . . . . . . . . . . . . . . . 61 - - - - - - - - - - - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 3] - -RFC 3986 URI Generic Syntax January 2005 - - -

1. Introduction

- - A Uniform Resource Identifier (URI) provides a simple and extensible - means for identifying a resource. This specification of URI syntax - and semantics is derived from concepts introduced by the World Wide - Web global information initiative, whose use of these identifiers - dates from 1990 and is described in "Universal Resource Identifiers - in WWW" [RFC1630]. The syntax is designed to meet the - recommendations laid out in "Functional Recommendations for Internet - Resource Locators" [RFC1736] and "Functional Requirements for Uniform - Resource Names" [RFC1737]. - - This document obsoletes [RFC2396], which merged "Uniform Resource - Locators" [RFC1738] and "Relative Uniform Resource Locators" - [RFC1808] in order to define a single, generic syntax for all URIs. - It obsoletes [RFC2732], which introduced syntax for an IPv6 address. - It excludes portions of RFC 1738 that defined the specific syntax of - individual URI schemes; those portions will be updated as separate - documents. The process for registration of new URI schemes is - defined separately by [BCP35]. Advice for designers of new URI - schemes can be found in [RFC2718]. All significant changes from RFC - 2396 are noted in Appendix D. - - This specification uses the terms "character" and "coded character - set" in accordance with the definitions provided in [BCP19], and - "character encoding" in place of what [BCP19] refers to as a - "charset". - -

1.1. Overview of URIs

- - URIs are characterized as follows: - - Uniform - - Uniformity provides several benefits. It allows different types - of resource identifiers to be used in the same context, even when - the mechanisms used to access those resources may differ. It - allows uniform semantic interpretation of common syntactic - conventions across different types of resource identifiers. It - allows introduction of new types of resource identifiers without - interfering with the way that existing identifiers are used. It - allows the identifiers to be reused in many different contexts, - thus permitting new applications or protocols to leverage a pre- - existing, large, and widely used set of resource identifiers. - - - - - - - -Berners-Lee, et al. Standards Track [Page 4] - -RFC 3986 URI Generic Syntax January 2005 - - - Resource - - This specification does not limit the scope of what might be a - resource; rather, the term "resource" is used in a general sense - for whatever might be identified by a URI. Familiar examples - include an electronic document, an image, a source of information - with a consistent purpose (e.g., "today's weather report for Los - Angeles"), a service (e.g., an HTTP-to-SMS gateway), and a - collection of other resources. A resource is not necessarily - accessible via the Internet; e.g., human beings, corporations, and - bound books in a library can also be resources. Likewise, - abstract concepts can be resources, such as the operators and - operands of a mathematical equation, the types of a relationship - (e.g., "parent" or "employee"), or numeric values (e.g., zero, - one, and infinity). - - Identifier - - An identifier embodies the information required to distinguish - what is being identified from all other things within its scope of - identification. Our use of the terms "identify" and "identifying" - refer to this purpose of distinguishing one resource from all - other resources, regardless of how that purpose is accomplished - (e.g., by name, address, or context). These terms should not be - mistaken as an assumption that an identifier defines or embodies - the identity of what is referenced, though that may be the case - for some identifiers. Nor should it be assumed that a system - using URIs will access the resource identified: in many cases, - URIs are used to denote resources without any intention that they - be accessed. Likewise, the "one" resource identified might not be - singular in nature (e.g., a resource might be a named set or a - mapping that varies over time). - - A URI is an identifier consisting of a sequence of characters - matching the syntax rule named <URI> in Section 3. It enables - uniform identification of resources via a separately defined - extensible set of naming schemes (Section 3.1). How that - identification is accomplished, assigned, or enabled is delegated to - each scheme specification. - - This specification does not place any limits on the nature of a - resource, the reasons why an application might seek to refer to a - resource, or the kinds of systems that might use URIs for the sake of - identifying resources. This specification does not require that a - URI persists in identifying the same resource over time, though that - is a common goal of all URI schemes. Nevertheless, nothing in this - - - - - -Berners-Lee, et al. Standards Track [Page 5] - -RFC 3986 URI Generic Syntax January 2005 - - - specification prevents an application from limiting itself to - particular types of resources, or to a subset of URIs that maintains - characteristics desired by that application. - - URIs have a global scope and are interpreted consistently regardless - of context, though the result of that interpretation may be in - relation to the end-user's context. For example, "http://localhost/" - has the same interpretation for every user of that reference, even - though the network interface corresponding to "localhost" may be - different for each end-user: interpretation is independent of access. - However, an action made on the basis of that reference will take - place in relation to the end-user's context, which implies that an - action intended to refer to a globally unique thing must use a URI - that distinguishes that resource from all other things. URIs that - identify in relation to the end-user's local context should only be - used when the context itself is a defining aspect of the resource, - such as when an on-line help manual refers to a file on the end- - user's file system (e.g., "file:///etc/hosts"). - -

1.1.1. Generic Syntax

- - Each URI begins with a scheme name, as defined in Section 3.1, that - refers to a specification for assigning identifiers within that - scheme. As such, the URI syntax is a federated and extensible naming - system wherein each scheme's specification may further restrict the - syntax and semantics of identifiers using that scheme. - - This specification defines those elements of the URI syntax that are - required of all URI schemes or are common to many URI schemes. It - thus defines the syntax and semantics needed to implement a scheme- - independent parsing mechanism for URI references, by which the - scheme-dependent handling of a URI can be postponed until the - scheme-dependent semantics are needed. Likewise, protocols and data - formats that make use of URI references can refer to this - specification as a definition for the range of syntax allowed for all - URIs, including those schemes that have yet to be defined. This - decouples the evolution of identification schemes from the evolution - of protocols, data formats, and implementations that make use of - URIs. - - A parser of the generic URI syntax can parse any URI reference into - its major components. Once the scheme is determined, further - scheme-specific parsing can be performed on the components. In other - words, the URI generic syntax is a superset of the syntax of all URI - schemes. - - - - - - -Berners-Lee, et al. Standards Track [Page 6] - -RFC 3986 URI Generic Syntax January 2005 - - -

1.1.2. Examples

- - The following example URIs illustrate several URI schemes and - variations in their common syntax components: - - ftp://ftp.is.co.za/rfc/rfc1808.txt - - http://www.ietf.org/rfc/rfc2396.txt - - ldap://[2001:db8::7]/c=GB?objectClass?one - - mailto:John.Doe@example.com - - news:comp.infosystems.www.servers.unix - - tel:+1-816-555-1212 - - telnet://192.0.2.16:80/ - - urn:oasis:names:specification:docbook:dtd:xml:4.1.2 - - -

1.1.3. URI, URL, and URN

- - A URI can be further classified as a locator, a name, or both. The - term "Uniform Resource Locator" (URL) refers to the subset of URIs - that, in addition to identifying a resource, provide a means of - locating the resource by describing its primary access mechanism - (e.g., its network "location"). The term "Uniform Resource Name" - (URN) has been used historically to refer to both URIs under the - "urn" scheme [RFC2141], which are required to remain globally unique - and persistent even when the resource ceases to exist or becomes - unavailable, and to any other URI with the properties of a name. - - An individual scheme does not have to be classified as being just one - of "name" or "locator". Instances of URIs from any given scheme may - have the characteristics of names or locators or both, often - depending on the persistence and care in the assignment of - identifiers by the naming authority, rather than on any quality of - the scheme. Future specifications and related documentation should - use the general term "URI" rather than the more restrictive terms - "URL" and "URN" [RFC3305]. - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 7] - -RFC 3986 URI Generic Syntax January 2005 - - -

1.2. Design Considerations

- -

1.2.1. Transcription

- - The URI syntax has been designed with global transcription as one of - its main considerations. A URI is a sequence of characters from a - very limited set: the letters of the basic Latin alphabet, digits, - and a few special characters. A URI may be represented in a variety - of ways; e.g., ink on paper, pixels on a screen, or a sequence of - character encoding octets. The interpretation of a URI depends only - on the characters used and not on how those characters are - represented in a network protocol. - - The goal of transcription can be described by a simple scenario. - Imagine two colleagues, Sam and Kim, sitting in a pub at an - international conference and exchanging research ideas. Sam asks Kim - for a location to get more information, so Kim writes the URI for the - research site on a napkin. Upon returning home, Sam takes out the - napkin and types the URI into a computer, which then retrieves the - information to which Kim referred. - - There are several design considerations revealed by the scenario: - - o A URI is a sequence of characters that is not always represented - as a sequence of octets. - - o A URI might be transcribed from a non-network source and thus - should consist of characters that are most likely able to be - entered into a computer, within the constraints imposed by - keyboards (and related input devices) across languages and - locales. - - o A URI often has to be remembered by people, and it is easier for - people to remember a URI when it consists of meaningful or - familiar components. - - These design considerations are not always in alignment. For - example, it is often the case that the most meaningful name for a URI - component would require characters that cannot be typed into some - systems. The ability to transcribe a resource identifier from one - medium to another has been considered more important than having a - URI consist of the most meaningful of components. - - In local or regional contexts and with improving technology, users - might benefit from being able to use a wider range of characters; - such use is not defined by this specification. Percent-encoded - octets (Section 2.1) may be used within a URI to represent characters - outside the range of the US-ASCII coded character set if this - - - -Berners-Lee, et al. Standards Track [Page 8] - -RFC 3986 URI Generic Syntax January 2005 - - - representation is allowed by the scheme or by the protocol element in - which the URI is referenced. Such a definition should specify the - character encoding used to map those characters to octets prior to - being percent-encoded for the URI. - -

1.2.2. Separating Identification from Interaction

- - A common misunderstanding of URIs is that they are only used to refer - to accessible resources. The URI itself only provides - identification; access to the resource is neither guaranteed nor - implied by the presence of a URI. Instead, any operation associated - with a URI reference is defined by the protocol element, data format - attribute, or natural language text in which it appears. - - Given a URI, a system may attempt to perform a variety of operations - on the resource, as might be characterized by words such as "access", - "update", "replace", or "find attributes". Such operations are - defined by the protocols that make use of URIs, not by this - specification. However, we do use a few general terms for describing - common operations on URIs. URI "resolution" is the process of - determining an access mechanism and the appropriate parameters - necessary to dereference a URI; this resolution may require several - iterations. To use that access mechanism to perform an action on the - URI's resource is to "dereference" the URI. - - When URIs are used within information retrieval systems to identify - sources of information, the most common form of URI dereference is - "retrieval": making use of a URI in order to retrieve a - representation of its associated resource. A "representation" is a - sequence of octets, along with representation metadata describing - those octets, that constitutes a record of the state of the resource - at the time when the representation is generated. Retrieval is - achieved by a process that might include using the URI as a cache key - to check for a locally cached representation, resolution of the URI - to determine an appropriate access mechanism (if any), and - dereference of the URI for the sake of applying a retrieval - operation. Depending on the protocols used to perform the retrieval, - additional information might be supplied about the resource (resource - metadata) and its relation to other resources. - - URI references in information retrieval systems are designed to be - late-binding: the result of an access is generally determined when it - is accessed and may vary over time or due to other aspects of the - interaction. These references are created in order to be used in the - future: what is being identified is not some specific result that was - obtained in the past, but rather some characteristic that is expected - to be true for future results. In such cases, the resource referred - to by the URI is actually a sameness of characteristics as observed - - - -Berners-Lee, et al. Standards Track [Page 9] - -RFC 3986 URI Generic Syntax January 2005 - - - over time, perhaps elucidated by additional comments or assertions - made by the resource provider. - - Although many URI schemes are named after protocols, this does not - imply that use of these URIs will result in access to the resource - via the named protocol. URIs are often used simply for the sake of - identification. Even when a URI is used to retrieve a representation - of a resource, that access might be through gateways, proxies, - caches, and name resolution services that are independent of the - protocol associated with the scheme name. The resolution of some - URIs may require the use of more than one protocol (e.g., both DNS - and HTTP are typically used to access an "http" URI's origin server - when a representation isn't found in a local cache). - -

1.2.3. Hierarchical Identifiers

- - The URI syntax is organized hierarchically, with components listed in - order of decreasing significance from left to right. For some URI - schemes, the visible hierarchy is limited to the scheme itself: - everything after the scheme component delimiter (":") is considered - opaque to URI processing. Other URI schemes make the hierarchy - explicit and visible to generic parsing algorithms. - - The generic syntax uses the slash ("/"), question mark ("?"), and - number sign ("#") characters to delimit components that are - significant to the generic parser's hierarchical interpretation of an - identifier. In addition to aiding the readability of such - identifiers through the consistent use of familiar syntax, this - uniform representation of hierarchy across naming schemes allows - scheme-independent references to be made relative to that hierarchy. - - It is often the case that a group or "tree" of documents has been - constructed to serve a common purpose, wherein the vast majority of - URI references in these documents point to resources within the tree - rather than outside it. Similarly, documents located at a particular - site are much more likely to refer to other resources at that site - than to resources at remote sites. Relative referencing of URIs - allows document trees to be partially independent of their location - and access scheme. For instance, it is possible for a single set of - hypertext documents to be simultaneously accessible and traversable - via each of the "file", "http", and "ftp" schemes if the documents - refer to each other with relative references. Furthermore, such - document trees can be moved, as a whole, without changing any of the - relative references. - - A relative reference (Section 4.2) refers to a resource by describing - the difference within a hierarchical name space between the reference - context and the target URI. The reference resolution algorithm, - - - -Berners-Lee, et al. Standards Track [Page 10] - -RFC 3986 URI Generic Syntax January 2005 - - - presented in Section 5, defines how such a reference is transformed - to the target URI. As relative references can only be used within - the context of a hierarchical URI, designers of new URI schemes - should use a syntax consistent with the generic syntax's hierarchical - components unless there are compelling reasons to forbid relative - referencing within that scheme. - - NOTE: Previous specifications used the terms "partial URI" and - "relative URI" to denote a relative reference to a URI. As some - readers misunderstood those terms to mean that relative URIs are a - subset of URIs rather than a method of referencing URIs, this - specification simply refers to them as relative references. - - All URI references are parsed by generic syntax parsers when used. - However, because hierarchical processing has no effect on an absolute - URI used in a reference unless it contains one or more dot-segments - (complete path segments of "." or "..", as described in Section 3.3), - URI scheme specifications can define opaque identifiers by - disallowing use of slash characters, question mark characters, and - the URIs "scheme:." and "scheme:..". - -

1.3. Syntax Notation

- - This specification uses the Augmented Backus-Naur Form (ABNF) - notation of [RFC2234], including the following core ABNF syntax rules - defined by that specification: ALPHA (letters), CR (carriage return), - DIGIT (decimal digits), DQUOTE (double quote), HEXDIG (hexadecimal - digits), LF (line feed), and SP (space). The complete URI syntax is - collected in Appendix A. - -

2. Characters

- - The URI syntax provides a method of encoding data, presumably for the - sake of identifying a resource, as a sequence of characters. The URI - characters are, in turn, frequently encoded as octets for transport - or presentation. This specification does not mandate any particular - character encoding for mapping between URI characters and the octets - used to store or transmit those characters. When a URI appears in a - protocol element, the character encoding is defined by that protocol; - without such a definition, a URI is assumed to be in the same - character encoding as the surrounding text. - - The ABNF notation defines its terminal values to be non-negative - integers (codepoints) based on the US-ASCII coded character set - [ASCII]. Because a URI is a sequence of characters, we must invert - that relation in order to understand the URI syntax. Therefore, the - - - - - -Berners-Lee, et al. Standards Track [Page 11] - -RFC 3986 URI Generic Syntax January 2005 - - - integer values used by the ABNF must be mapped back to their - corresponding characters via US-ASCII in order to complete the syntax - rules. - - A URI is composed from a limited set of characters consisting of - digits, letters, and a few graphic symbols. A reserved subset of - those characters may be used to delimit syntax components within a - URI while the remaining characters, including both the unreserved set - and those reserved characters not acting as delimiters, define each - component's identifying data. - -

2.1. Percent-Encoding

- - A percent-encoding mechanism is used to represent a data octet in a - component when that octet's corresponding character is outside the - allowed set or is being used as a delimiter of, or within, the - component. A percent-encoded octet is encoded as a character - triplet, consisting of the percent character "%" followed by the two - hexadecimal digits representing that octet's numeric value. For - example, "%20" is the percent-encoding for the binary octet - "00100000" (ABNF: %x20), which in US-ASCII corresponds to the space - character (SP). Section 2.4 describes when percent-encoding and - decoding is applied. - - pct-encoded = "%" HEXDIG HEXDIG - - The uppercase hexadecimal digits 'A' through 'F' are equivalent to - the lowercase digits 'a' through 'f', respectively. If two URIs - differ only in the case of hexadecimal digits used in percent-encoded - octets, they are equivalent. For consistency, URI producers and - normalizers should use uppercase hexadecimal digits for all percent- - encodings. - -

2.2. Reserved Characters

- - URIs include components and subcomponents that are delimited by - characters in the "reserved" set. These characters are called - "reserved" because they may (or may not) be defined as delimiters by - the generic syntax, by each scheme-specific syntax, or by the - implementation-specific syntax of a URI's dereferencing algorithm. - If data for a URI component would conflict with a reserved - character's purpose as a delimiter, then the conflicting data must be - percent-encoded before the URI is formed. - - - - - - - - -Berners-Lee, et al. Standards Track [Page 12] - -RFC 3986 URI Generic Syntax January 2005 - - - reserved = gen-delims / sub-delims - - gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" - - sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - / "*" / "+" / "," / ";" / "=" - - The purpose of reserved characters is to provide a set of delimiting - characters that are distinguishable from other data within a URI. - URIs that differ in the replacement of a reserved character with its - corresponding percent-encoded octet are not equivalent. Percent- - encoding a reserved character, or decoding a percent-encoded octet - that corresponds to a reserved character, will change how the URI is - interpreted by most applications. Thus, characters in the reserved - set are protected from normalization and are therefore safe to be - used by scheme-specific and producer-specific algorithms for - delimiting data subcomponents within a URI. - - A subset of the reserved characters (gen-delims) is used as - delimiters of the generic URI components described in Section 3. A - component's ABNF syntax rule will not use the reserved or gen-delims - rule names directly; instead, each syntax rule lists the characters - allowed within that component (i.e., not delimiting it), and any of - those characters that are also in the reserved set are "reserved" for - use as subcomponent delimiters within the component. Only the most - common subcomponents are defined by this specification; other - subcomponents may be defined by a URI scheme's specification, or by - the implementation-specific syntax of a URI's dereferencing - algorithm, provided that such subcomponents are delimited by - characters in the reserved set allowed within that component. - - URI producing applications should percent-encode data octets that - correspond to characters in the reserved set unless these characters - are specifically allowed by the URI scheme to represent data in that - component. If a reserved character is found in a URI component and - no delimiting role is known for that character, then it must be - interpreted as representing the data octet corresponding to that - character's encoding in US-ASCII. - -

2.3. Unreserved Characters

- - Characters that are allowed in a URI but do not have a reserved - purpose are called unreserved. These include uppercase and lowercase - letters, decimal digits, hyphen, period, underscore, and tilde. - - unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - - - - - -Berners-Lee, et al. Standards Track [Page 13] - -RFC 3986 URI Generic Syntax January 2005 - - - URIs that differ in the replacement of an unreserved character with - its corresponding percent-encoded US-ASCII octet are equivalent: they - identify the same resource. However, URI comparison implementations - do not always perform normalization prior to comparison (see Section - 6). For consistency, percent-encoded octets in the ranges of ALPHA - (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), - underscore (%5F), or tilde (%7E) should not be created by URI - producers and, when found in a URI, should be decoded to their - corresponding unreserved characters by URI normalizers. - -

2.4. When to Encode or Decode

- - Under normal circumstances, the only time when octets within a URI - are percent-encoded is during the process of producing the URI from - its component parts. This is when an implementation determines which - of the reserved characters are to be used as subcomponent delimiters - and which can be safely used as data. Once produced, a URI is always - in its percent-encoded form. - - When a URI is dereferenced, the components and subcomponents - significant to the scheme-specific dereferencing process (if any) - must be parsed and separated before the percent-encoded octets within - those components can be safely decoded, as otherwise the data may be - mistaken for component delimiters. The only exception is for - percent-encoded octets corresponding to characters in the unreserved - set, which can be decoded at any time. For example, the octet - corresponding to the tilde ("~") character is often encoded as "%7E" - by older URI processing implementations; the "%7E" can be replaced by - "~" without changing its interpretation. - - Because the percent ("%") character serves as the indicator for - percent-encoded octets, it must be percent-encoded as "%25" for that - octet to be used as data within a URI. Implementations must not - percent-encode or decode the same string more than once, as decoding - an already decoded string might lead to misinterpreting a percent - data octet as the beginning of a percent-encoding, or vice versa in - the case of percent-encoding an already percent-encoded string. - -

2.5. Identifying Data

- - URI characters provide identifying data for each of the URI - components, serving as an external interface for identification - between systems. Although the presence and nature of the URI - production interface is hidden from clients that use its URIs (and is - thus beyond the scope of the interoperability requirements defined by - this specification), it is a frequent source of confusion and errors - in the interpretation of URI character issues. Implementers have to - be aware that there are multiple character encodings involved in the - - - -Berners-Lee, et al. Standards Track [Page 14] - -RFC 3986 URI Generic Syntax January 2005 - - - production and transmission of URIs: local name and data encoding, - public interface encoding, URI character encoding, data format - encoding, and protocol encoding. - - Local names, such as file system names, are stored with a local - character encoding. URI producing applications (e.g., origin - servers) will typically use the local encoding as the basis for - producing meaningful names. The URI producer will transform the - local encoding to one that is suitable for a public interface and - then transform the public interface encoding into the restricted set - of URI characters (reserved, unreserved, and percent-encodings). - Those characters are, in turn, encoded as octets to be used as a - reference within a data format (e.g., a document charset), and such - data formats are often subsequently encoded for transmission over - Internet protocols. - - For most systems, an unreserved character appearing within a URI - component is interpreted as representing the data octet corresponding - to that character's encoding in US-ASCII. Consumers of URIs assume - that the letter "X" corresponds to the octet "01011000", and even - when that assumption is incorrect, there is no harm in making it. A - system that internally provides identifiers in the form of a - different character encoding, such as EBCDIC, will generally perform - character translation of textual identifiers to UTF-8 [STD63] (or - some other superset of the US-ASCII character encoding) at an - internal interface, thereby providing more meaningful identifiers - than those resulting from simply percent-encoding the original - octets. - - For example, consider an information service that provides data, - stored locally using an EBCDIC-based file system, to clients on the - Internet through an HTTP server. When an author creates a file with - the name "Laguna Beach" on that file system, the "http" URI - corresponding to that resource is expected to contain the meaningful - string "Laguna%20Beach". If, however, that server produces URIs by - using an overly simplistic raw octet mapping, then the result would - be a URI containing "%D3%81%87%A4%95%81@%C2%85%81%83%88". An - internal transcoding interface fixes this problem by transcoding the - local name to a superset of US-ASCII prior to producing the URI. - Naturally, proper interpretation of an incoming URI on such an - interface requires that percent-encoded octets be decoded (e.g., - "%20" to SP) before the reverse transcoding is applied to obtain the - local name. - - In some cases, the internal interface between a URI component and the - identifying data that it has been crafted to represent is much less - direct than a character encoding translation. For example, portions - of a URI might reflect a query on non-ASCII data, or numeric - - - -Berners-Lee, et al. Standards Track [Page 15] - -RFC 3986 URI Generic Syntax January 2005 - - - coordinates on a map. Likewise, a URI scheme may define components - with additional encoding requirements that are applied prior to - forming the component and producing the URI. - - When a new URI scheme defines a component that represents textual - data consisting of characters from the Universal Character Set [UCS], - the data should first be encoded as octets according to the UTF-8 - character encoding [STD63]; then only those octets that do not - correspond to characters in the unreserved set should be percent- - encoded. For example, the character A would be represented as "A", - the character LATIN CAPITAL LETTER A WITH GRAVE would be represented - as "%C3%80", and the character KATAKANA LETTER A would be represented - as "%E3%82%A2". - -

3. Syntax Components

- - The generic URI syntax consists of a hierarchical sequence of - components referred to as the scheme, authority, path, query, and - fragment. - - URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] - - hier-part = "//" authority path-abempty - / path-absolute - / path-rootless - / path-empty - - The scheme and path components are required, though the path may be - empty (no characters). When authority is present, the path must - either be empty or begin with a slash ("/") character. When - authority is not present, the path cannot begin with two slash - characters ("//"). These restrictions result in five different ABNF - rules for a path (Section 3.3), only one of which will match any - given URI reference. - - The following are two example URIs and their component parts: - - foo://example.com:8042/over/there?name=ferret#nose - \_/ \______________/\_________/ \_________/ \__/ - | | | | | - scheme authority path query fragment - | _____________________|__ - / \ / \ - urn:example:animal:ferret:nose - - - - - - - -Berners-Lee, et al. Standards Track [Page 16] - -RFC 3986 URI Generic Syntax January 2005 - - -

3.1. Scheme

- - Each URI begins with a scheme name that refers to a specification for - assigning identifiers within that scheme. As such, the URI syntax is - a federated and extensible naming system wherein each scheme's - specification may further restrict the syntax and semantics of - identifiers using that scheme. - - Scheme names consist of a sequence of characters beginning with a - letter and followed by any combination of letters, digits, plus - ("+"), period ("."), or hyphen ("-"). Although schemes are case- - insensitive, the canonical form is lowercase and documents that - specify schemes must do so with lowercase letters. An implementation - should accept uppercase letters as equivalent to lowercase in scheme - names (e.g., allow "HTTP" as well as "http") for the sake of - robustness but should only produce lowercase scheme names for - consistency. - - scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) - - Individual schemes are not specified by this document. The process - for registration of new URI schemes is defined separately by [BCP35]. - The scheme registry maintains the mapping between scheme names and - their specifications. Advice for designers of new URI schemes can be - found in [RFC2718]. URI scheme specifications must define their own - syntax so that all strings matching their scheme-specific syntax will - also match the <absolute-URI> grammar, as described in Section 4.3. - - When presented with a URI that violates one or more scheme-specific - restrictions, the scheme-specific resolution process should flag the - reference as an error rather than ignore the unused parts; doing so - reduces the number of equivalent URIs and helps detect abuses of the - generic syntax, which might indicate that the URI has been - constructed to mislead the user (Section 7.6). - -

3.2. Authority

- - Many URI schemes include a hierarchical element for a naming - authority so that governance of the name space defined by the - remainder of the URI is delegated to that authority (which may, in - turn, delegate it further). The generic syntax provides a common - means for distinguishing an authority based on a registered name or - server address, along with optional port and user information. - - The authority component is preceded by a double slash ("//") and is - terminated by the next slash ("/"), question mark ("?"), or number - sign ("#") character, or by the end of the URI. - - - - -Berners-Lee, et al. Standards Track [Page 17] - -RFC 3986 URI Generic Syntax January 2005 - - - authority = [ userinfo "@" ] host [ ":" port ] - - URI producers and normalizers should omit the ":" delimiter that - separates host from port if the port component is empty. Some - schemes do not allow the userinfo and/or port subcomponents. - - If a URI contains an authority component, then the path component - must either be empty or begin with a slash ("/") character. Non- - validating parsers (those that merely separate a URI reference into - its major components) will often ignore the subcomponent structure of - authority, treating it as an opaque string from the double-slash to - the first terminating delimiter, until such time as the URI is - dereferenced. - -

3.2.1. User Information

- - The userinfo subcomponent may consist of a user name and, optionally, - scheme-specific information about how to gain authorization to access - the resource. The user information, if present, is followed by a - commercial at-sign ("@") that delimits it from the host. - - userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) - - Use of the format "user:password" in the userinfo field is - deprecated. Applications should not render as clear text any data - after the first colon (":") character found within a userinfo - subcomponent unless the data after the colon is the empty string - (indicating no password). Applications may choose to ignore or - reject such data when it is received as part of a reference and - should reject the storage of such data in unencrypted form. The - passing of authentication information in clear text has proven to be - a security risk in almost every case where it has been used. - - Applications that render a URI for the sake of user feedback, such as - in graphical hypertext browsing, should render userinfo in a way that - is distinguished from the rest of a URI, when feasible. Such - rendering will assist the user in cases where the userinfo has been - misleadingly crafted to look like a trusted domain name - (Section 7.6). - -

3.2.2. Host

- - The host subcomponent of authority is identified by an IP literal - encapsulated within square brackets, an IPv4 address in dotted- - decimal form, or a registered name. The host subcomponent is case- - insensitive. The presence of a host subcomponent within a URI does - not imply that the scheme requires access to the given host on the - Internet. In many cases, the host syntax is used only for the sake - - - -Berners-Lee, et al. Standards Track [Page 18] - -RFC 3986 URI Generic Syntax January 2005 - - - of reusing the existing registration process created and deployed for - DNS, thus obtaining a globally unique name without the cost of - deploying another registry. However, such use comes with its own - costs: domain name ownership may change over time for reasons not - anticipated by the URI producer. In other cases, the data within the - host component identifies a registered name that has nothing to do - with an Internet host. We use the name "host" for the ABNF rule - because that is its most common purpose, not its only purpose. - - host = IP-literal / IPv4address / reg-name - - The syntax rule for host is ambiguous because it does not completely - distinguish between an IPv4address and a reg-name. In order to - disambiguate the syntax, we apply the "first-match-wins" algorithm: - If host matches the rule for IPv4address, then it should be - considered an IPv4 address literal and not a reg-name. Although host - is case-insensitive, producers and normalizers should use lowercase - for registered names and hexadecimal addresses for the sake of - uniformity, while only using uppercase letters for percent-encodings. - - A host identified by an Internet Protocol literal address, version 6 - [RFC3513] or later, is distinguished by enclosing the IP literal - within square brackets ("[" and "]"). This is the only place where - square bracket characters are allowed in the URI syntax. In - anticipation of future, as-yet-undefined IP literal address formats, - an implementation may use an optional version flag to indicate such a - format explicitly rather than rely on heuristic determination. - - IP-literal = "[" ( IPv6address / IPvFuture ) "]" - - IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) - - The version flag does not indicate the IP version; rather, it - indicates future versions of the literal format. As such, - implementations must not provide the version flag for the existing - IPv4 and IPv6 literal address forms described below. If a URI - containing an IP-literal that starts with "v" (case-insensitive), - indicating that the version flag is present, is dereferenced by an - application that does not know the meaning of that version flag, then - the application should return an appropriate error for "address - mechanism not supported". - - A host identified by an IPv6 literal address is represented inside - the square brackets without a preceding version flag. The ABNF - provided here is a translation of the text definition of an IPv6 - literal address provided in [RFC3513]. This syntax does not support - IPv6 scoped addressing zone identifiers. - - - - -Berners-Lee, et al. Standards Track [Page 19] - -RFC 3986 URI Generic Syntax January 2005 - - - A 128-bit IPv6 address is divided into eight 16-bit pieces. Each - piece is represented numerically in case-insensitive hexadecimal, - using one to four hexadecimal digits (leading zeroes are permitted). - The eight encoded pieces are given most-significant first, separated - by colon characters. Optionally, the least-significant two pieces - may instead be represented in IPv4 address textual format. A - sequence of one or more consecutive zero-valued 16-bit pieces within - the address may be elided, omitting all their digits and leaving - exactly two consecutive colons in their place to mark the elision. - - IPv6address = 6( h16 ":" ) ls32 - / "::" 5( h16 ":" ) ls32 - / [ h16 ] "::" 4( h16 ":" ) ls32 - / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 - / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 - / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 - / [ *4( h16 ":" ) h16 ] "::" ls32 - / [ *5( h16 ":" ) h16 ] "::" h16 - / [ *6( h16 ":" ) h16 ] "::" - - ls32 = ( h16 ":" h16 ) / IPv4address - ; least-significant 32 bits of address - - h16 = 1*4HEXDIG - ; 16 bits of address represented in hexadecimal - - A host identified by an IPv4 literal address is represented in - dotted-decimal notation (a sequence of four decimal numbers in the - range 0 to 255, separated by "."), as described in [RFC1123] by - reference to [RFC0952]. Note that other forms of dotted notation may - be interpreted on some platforms, as described in Section 7.4, but - only the dotted-decimal form of four octets is allowed by this - grammar. - - IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet - - dec-octet = DIGIT ; 0-9 - / %x31-39 DIGIT ; 10-99 - / "1" 2DIGIT ; 100-199 - / "2" %x30-34 DIGIT ; 200-249 - / "25" %x30-35 ; 250-255 - - A host identified by a registered name is a sequence of characters - usually intended for lookup within a locally defined host or service - name registry, though the URI's scheme-specific semantics may require - that a specific registry (or fixed name table) be used instead. The - most common name registry mechanism is the Domain Name System (DNS). - A registered name intended for lookup in the DNS uses the syntax - - - -Berners-Lee, et al. Standards Track [Page 20] - -RFC 3986 URI Generic Syntax January 2005 - - - defined in Section 3.5 of [RFC1034] and Section 2.1 of [RFC1123]. - Such a name consists of a sequence of domain labels separated by ".", - each domain label starting and ending with an alphanumeric character - and possibly also containing "-" characters. The rightmost domain - label of a fully qualified domain name in DNS may be followed by a - single "." and should be if it is necessary to distinguish between - the complete domain name and some local domain. - - reg-name = *( unreserved / pct-encoded / sub-delims ) - - If the URI scheme defines a default for host, then that default - applies when the host subcomponent is undefined or when the - registered name is empty (zero length). For example, the "file" URI - scheme is defined so that no authority, an empty host, and - "localhost" all mean the end-user's machine, whereas the "http" - scheme considers a missing authority or empty host invalid. - - This specification does not mandate a particular registered name - lookup technology and therefore does not restrict the syntax of reg- - name beyond what is necessary for interoperability. Instead, it - delegates the issue of registered name syntax conformance to the - operating system of each application performing URI resolution, and - that operating system decides what it will allow for the purpose of - host identification. A URI resolution implementation might use DNS, - host tables, yellow pages, NetInfo, WINS, or any other system for - lookup of registered names. However, a globally scoped naming - system, such as DNS fully qualified domain names, is necessary for - URIs intended to have global scope. URI producers should use names - that conform to the DNS syntax, even when use of DNS is not - immediately apparent, and should limit these names to no more than - 255 characters in length. - - The reg-name syntax allows percent-encoded octets in order to - represent non-ASCII registered names in a uniform way that is - independent of the underlying name resolution technology. Non-ASCII - characters must first be encoded according to UTF-8 [STD63], and then - each octet of the corresponding UTF-8 sequence must be percent- - encoded to be represented as URI characters. URI producing - applications must not use percent-encoding in host unless it is used - to represent a UTF-8 character sequence. When a non-ASCII registered - name represents an internationalized domain name intended for - resolution via the DNS, the name must be transformed to the IDNA - encoding [RFC3490] prior to name lookup. URI producers should - provide these registered names in the IDNA encoding, rather than a - percent-encoding, if they wish to maximize interoperability with - legacy URI resolvers. - - - - - -Berners-Lee, et al. Standards Track [Page 21] - -RFC 3986 URI Generic Syntax January 2005 - - -

3.2.3. Port

- - The port subcomponent of authority is designated by an optional port - number in decimal following the host and delimited from it by a - single colon (":") character. - - port = *DIGIT - - A scheme may define a default port. For example, the "http" scheme - defines a default port of "80", corresponding to its reserved TCP - port number. The type of port designated by the port number (e.g., - TCP, UDP, SCTP) is defined by the URI scheme. URI producers and - normalizers should omit the port component and its ":" delimiter if - port is empty or if its value would be the same as that of the - scheme's default. - -

3.3. Path

- - The path component contains data, usually organized in hierarchical - form, that, along with data in the non-hierarchical query component - (Section 3.4), serves to identify a resource within the scope of the - URI's scheme and naming authority (if any). The path is terminated - by the first question mark ("?") or number sign ("#") character, or - by the end of the URI. - - If a URI contains an authority component, then the path component - must either be empty or begin with a slash ("/") character. If a URI - does not contain an authority component, then the path cannot begin - with two slash characters ("//"). In addition, a URI reference - (Section 4.1) may be a relative-path reference, in which case the - first path segment cannot contain a colon (":") character. The ABNF - requires five separate rules to disambiguate these cases, only one of - which will match the path substring within a given URI reference. We - use the generic term "path component" to describe the URI substring - matched by the parser to one of these rules. - - path = path-abempty ; begins with "/" or is empty - / path-absolute ; begins with "/" but not "//" - / path-noscheme ; begins with a non-colon segment - / path-rootless ; begins with a segment - / path-empty ; zero characters - - path-abempty = *( "/" segment ) - path-absolute = "/" [ segment-nz *( "/" segment ) ] - path-noscheme = segment-nz-nc *( "/" segment ) - path-rootless = segment-nz *( "/" segment ) - path-empty = 0<pchar> - - - - -Berners-Lee, et al. Standards Track [Page 22] - -RFC 3986 URI Generic Syntax January 2005 - - - segment = *pchar - segment-nz = 1*pchar - segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) - ; non-zero-length segment without any colon ":" - - pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - - A path consists of a sequence of path segments separated by a slash - ("/") character. A path is always defined for a URI, though the - defined path may be empty (zero length). Use of the slash character - to indicate hierarchy is only required when a URI will be used as the - context for relative references. For example, the URI - <mailto:fred@example.com> has a path of "fred@example.com", whereas - the URI <foo://info.example.com?fred> has an empty path. - - The path segments "." and "..", also known as dot-segments, are - defined for relative reference within the path name hierarchy. They - are intended for use at the beginning of a relative-path reference - (Section 4.2) to indicate relative position within the hierarchical - tree of names. This is similar to their role within some operating - systems' file directory structures to indicate the current directory - and parent directory, respectively. However, unlike in a file - system, these dot-segments are only interpreted within the URI path - hierarchy and are removed as part of the resolution process (Section - 5.2). - - Aside from dot-segments in hierarchical paths, a path segment is - considered opaque by the generic syntax. URI producing applications - often use the reserved characters allowed in a segment to delimit - scheme-specific or dereference-handler-specific subcomponents. For - example, the semicolon (";") and equals ("=") reserved characters are - often used to delimit parameters and parameter values applicable to - that segment. The comma (",") reserved character is often used for - similar purposes. For example, one URI producer might use a segment - such as "name;v=1.1" to indicate a reference to version 1.1 of - "name", whereas another might use a segment such as "name,1.1" to - indicate the same. Parameter types may be defined by scheme-specific - semantics, but in most cases the syntax of a parameter is specific to - the implementation of the URI's dereferencing algorithm. - -

3.4. Query

- - The query component contains non-hierarchical data that, along with - data in the path component (Section 3.3), serves to identify a - resource within the scope of the URI's scheme and naming authority - (if any). The query component is indicated by the first question - mark ("?") character and terminated by a number sign ("#") character - or by the end of the URI. - - - -Berners-Lee, et al. Standards Track [Page 23] - -RFC 3986 URI Generic Syntax January 2005 - - - query = *( pchar / "/" / "?" ) - - The characters slash ("/") and question mark ("?") may represent data - within the query component. Beware that some older, erroneous - implementations may not handle such data correctly when it is used as - the base URI for relative references (Section 5.1), apparently - because they fail to distinguish query data from path data when - looking for hierarchical separators. However, as query components - are often used to carry identifying information in the form of - "key=value" pairs and one frequently used value is a reference to - another URI, it is sometimes better for usability to avoid percent- - encoding those characters. - -

3.5. Fragment

- - The fragment identifier component of a URI allows indirect - identification of a secondary resource by reference to a primary - resource and additional identifying information. The identified - secondary resource may be some portion or subset of the primary - resource, some view on representations of the primary resource, or - some other resource defined or described by those representations. A - fragment identifier component is indicated by the presence of a - number sign ("#") character and terminated by the end of the URI. - - fragment = *( pchar / "/" / "?" ) - - The semantics of a fragment identifier are defined by the set of - representations that might result from a retrieval action on the - primary resource. The fragment's format and resolution is therefore - dependent on the media type [RFC2046] of a potentially retrieved - representation, even though such a retrieval is only performed if the - URI is dereferenced. If no such representation exists, then the - semantics of the fragment are considered unknown and are effectively - unconstrained. Fragment identifier semantics are independent of the - URI scheme and thus cannot be redefined by scheme specifications. - - Individual media types may define their own restrictions on or - structures within the fragment identifier syntax for specifying - different types of subsets, views, or external references that are - identifiable as secondary resources by that media type. If the - primary resource has multiple representations, as is often the case - for resources whose representation is selected based on attributes of - the retrieval request (a.k.a., content negotiation), then whatever is - identified by the fragment should be consistent across all of those - representations. Each representation should either define the - fragment so that it corresponds to the same secondary resource, - regardless of how it is represented, or should leave the fragment - undefined (i.e., not found). - - - -Berners-Lee, et al. Standards Track [Page 24] - -RFC 3986 URI Generic Syntax January 2005 - - - As with any URI, use of a fragment identifier component does not - imply that a retrieval action will take place. A URI with a fragment - identifier may be used to refer to the secondary resource without any - implication that the primary resource is accessible or will ever be - accessed. - - Fragment identifiers have a special role in information retrieval - systems as the primary form of client-side indirect referencing, - allowing an author to specifically identify aspects of an existing - resource that are only indirectly provided by the resource owner. As - such, the fragment identifier is not used in the scheme-specific - processing of a URI; instead, the fragment identifier is separated - from the rest of the URI prior to a dereference, and thus the - identifying information within the fragment itself is dereferenced - solely by the user agent, regardless of the URI scheme. Although - this separate handling is often perceived to be a loss of - information, particularly for accurate redirection of references as - resources move over time, it also serves to prevent information - providers from denying reference authors the right to refer to - information within a resource selectively. Indirect referencing also - provides additional flexibility and extensibility to systems that use - URIs, as new media types are easier to define and deploy than new - schemes of identification. - - The characters slash ("/") and question mark ("?") are allowed to - represent data within the fragment identifier. Beware that some - older, erroneous implementations may not handle this data correctly - when it is used as the base URI for relative references (Section - 5.1). - -

4. Usage

- - When applications make reference to a URI, they do not always use the - full form of reference defined by the "URI" syntax rule. To save - space and take advantage of hierarchical locality, many Internet - protocol elements and media type formats allow an abbreviation of a - URI, whereas others restrict the syntax to a particular form of URI. - We define the most common forms of reference syntax in this - specification because they impact and depend upon the design of the - generic syntax, requiring a uniform parsing algorithm in order to be - interpreted consistently. - -

4.1. URI Reference

- - URI-reference is used to denote the most common usage of a resource - identifier. - - URI-reference = URI / relative-ref - - - -Berners-Lee, et al. Standards Track [Page 25] - -RFC 3986 URI Generic Syntax January 2005 - - - A URI-reference is either a URI or a relative reference. If the - URI-reference's prefix does not match the syntax of a scheme followed - by its colon separator, then the URI-reference is a relative - reference. - - A URI-reference is typically parsed first into the five URI - components, in order to determine what components are present and - whether the reference is relative. Then, each component is parsed - for its subparts and their validation. The ABNF of URI-reference, - along with the "first-match-wins" disambiguation rule, is sufficient - to define a validating parser for the generic syntax. Readers - familiar with regular expressions should see Appendix B for an - example of a non-validating URI-reference parser that will take any - given string and extract the URI components. - -

4.2. Relative Reference

- - A relative reference takes advantage of the hierarchical syntax - (Section 1.2.3) to express a URI reference relative to the name space - of another hierarchical URI. - - relative-ref = relative-part [ "?" query ] [ "#" fragment ] - - relative-part = "//" authority path-abempty - / path-absolute - / path-noscheme - / path-empty - - The URI referred to by a relative reference, also known as the target - URI, is obtained by applying the reference resolution algorithm of - Section 5. - - A relative reference that begins with two slash characters is termed - a network-path reference; such references are rarely used. A - relative reference that begins with a single slash character is - termed an absolute-path reference. A relative reference that does - not begin with a slash character is termed a relative-path reference. - - A path segment that contains a colon character (e.g., "this:that") - cannot be used as the first segment of a relative-path reference, as - it would be mistaken for a scheme name. Such a segment must be - preceded by a dot-segment (e.g., "./this:that") to make a relative- - path reference. - - - - - - - - -Berners-Lee, et al. Standards Track [Page 26] - -RFC 3986 URI Generic Syntax January 2005 - - -

4.3. Absolute URI

- - Some protocol elements allow only the absolute form of a URI without - a fragment identifier. For example, defining a base URI for later - use by relative references calls for an absolute-URI syntax rule that - does not allow a fragment. - - absolute-URI = scheme ":" hier-part [ "?" query ] - - URI scheme specifications must define their own syntax so that all - strings matching their scheme-specific syntax will also match the - <absolute-URI> grammar. Scheme specifications will not define - fragment identifier syntax or usage, regardless of its applicability - to resources identifiable via that scheme, as fragment identification - is orthogonal to scheme definition. However, scheme specifications - are encouraged to include a wide range of examples, including - examples that show use of the scheme's URIs with fragment identifiers - when such usage is appropriate. - -

4.4. Same-Document Reference

- - When a URI reference refers to a URI that is, aside from its fragment - component (if any), identical to the base URI (Section 5.1), that - reference is called a "same-document" reference. The most frequent - examples of same-document references are relative references that are - empty or include only the number sign ("#") separator followed by a - fragment identifier. - - When a same-document reference is dereferenced for a retrieval - action, the target of that reference is defined to be within the same - entity (representation, document, or message) as the reference; - therefore, a dereference should not result in a new retrieval action. - - Normalization of the base and target URIs prior to their comparison, - as described in Sections 6.2.2 and 6.2.3, is allowed but rarely - performed in practice. Normalization may increase the set of same- - document references, which may be of benefit to some caching - applications. As such, reference authors should not assume that a - slightly different, though equivalent, reference URI will (or will - not) be interpreted as a same-document reference by any given - application. - -

4.5. Suffix Reference

- - The URI syntax is designed for unambiguous reference to resources and - extensibility via the URI scheme. However, as URI identification and - usage have become commonplace, traditional media (television, radio, - newspapers, billboards, etc.) have increasingly used a suffix of the - - - -Berners-Lee, et al. Standards Track [Page 27] - -RFC 3986 URI Generic Syntax January 2005 - - - URI as a reference, consisting of only the authority and path - portions of the URI, such as - - www.w3.org/Addressing/ - - or simply a DNS registered name on its own. Such references are - primarily intended for human interpretation rather than for machines, - with the assumption that context-based heuristics are sufficient to - complete the URI (e.g., most registered names beginning with "www" - are likely to have a URI prefix of "http://"). Although there is no - standard set of heuristics for disambiguating a URI suffix, many - client implementations allow them to be entered by the user and - heuristically resolved. - - Although this practice of using suffix references is common, it - should be avoided whenever possible and should never be used in - situations where long-term references are expected. The heuristics - noted above will change over time, particularly when a new URI scheme - becomes popular, and are often incorrect when used out of context. - Furthermore, they can lead to security issues along the lines of - those described in [RFC1535]. - - As a URI suffix has the same syntax as a relative-path reference, a - suffix reference cannot be used in contexts where a relative - reference is expected. As a result, suffix references are limited to - places where there is no defined base URI, such as dialog boxes and - off-line advertisements. - -

5. Reference Resolution

- - This section defines the process of resolving a URI reference within - a context that allows relative references so that the result is a - string matching the <URI> syntax rule of Section 3. - -

5.1. Establishing a Base URI

- - The term "relative" implies that a "base URI" exists against which - the relative reference is applied. Aside from fragment-only - references (Section 4.4), relative references are only usable when a - base URI is known. A base URI must be established by the parser - prior to parsing URI references that might be relative. A base URI - must conform to the <absolute-URI> syntax rule (Section 4.3). If the - base URI is obtained from a URI reference, then that reference must - be converted to absolute form and stripped of any fragment component - prior to its use as a base URI. - - - - - - -Berners-Lee, et al. Standards Track [Page 28] - -RFC 3986 URI Generic Syntax January 2005 - - - The base URI of a reference can be established in one of four ways, - discussed below in order of precedence. The order of precedence can - be thought of in terms of layers, where the innermost defined base - URI has the highest precedence. This can be visualized graphically - as follows: - - .----------------------------------------------------------. - | .----------------------------------------------------. | - | | .----------------------------------------------. | | - | | | .----------------------------------------. | | | - | | | | .----------------------------------. | | | | - | | | | | <relative-reference> | | | | | - | | | | `----------------------------------' | | | | - | | | | (5.1.1) Base URI embedded in content | | | | - | | | `----------------------------------------' | | | - | | | (5.1.2) Base URI of the encapsulating entity | | | - | | | (message, representation, or none) | | | - | | `----------------------------------------------' | | - | | (5.1.3) URI used to retrieve the entity | | - | `----------------------------------------------------' | - | (5.1.4) Default Base URI (application-dependent) | - `----------------------------------------------------------' - -

5.1.1. Base URI Embedded in Content

- - Within certain media types, a base URI for relative references can be - embedded within the content itself so that it can be readily obtained - by a parser. This can be useful for descriptive documents, such as - tables of contents, which may be transmitted to others through - protocols other than their usual retrieval context (e.g., email or - USENET news). - - It is beyond the scope of this specification to specify how, for each - media type, a base URI can be embedded. The appropriate syntax, when - available, is described by the data format specification associated - with each media type. - -

5.1.2. Base URI from the Encapsulating Entity

- - If no base URI is embedded, the base URI is defined by the - representation's retrieval context. For a document that is enclosed - within another entity, such as a message or archive, the retrieval - context is that entity. Thus, the default base URI of a - representation is the base URI of the entity in which the - representation is encapsulated. - - - - - - -Berners-Lee, et al. Standards Track [Page 29] - -RFC 3986 URI Generic Syntax January 2005 - - - A mechanism for embedding a base URI within MIME container types - (e.g., the message and multipart types) is defined by MHTML - [RFC2557]. Protocols that do not use the MIME message header syntax, - but that do allow some form of tagged metadata to be included within - messages, may define their own syntax for defining a base URI as part - of a message. - -

5.1.3. Base URI from the Retrieval URI

- - If no base URI is embedded and the representation is not encapsulated - within some other entity, then, if a URI was used to retrieve the - representation, that URI shall be considered the base URI. Note that - if the retrieval was the result of a redirected request, the last URI - used (i.e., the URI that resulted in the actual retrieval of the - representation) is the base URI. - -

5.1.4. Default Base URI

- - If none of the conditions described above apply, then the base URI is - defined by the context of the application. As this definition is - necessarily application-dependent, failing to define a base URI by - using one of the other methods may result in the same content being - interpreted differently by different types of applications. - - A sender of a representation containing relative references is - responsible for ensuring that a base URI for those references can be - established. Aside from fragment-only references, relative - references can only be used reliably in situations where the base URI - is well defined. - -

5.2. Relative Resolution

- - This section describes an algorithm for converting a URI reference - that might be relative to a given base URI into the parsed components - of the reference's target. The components can then be recomposed, as - described in Section 5.3, to form the target URI. This algorithm - provides definitive results that can be used to test the output of - other implementations. Applications may implement relative reference - resolution by using some other algorithm, provided that the results - match what would be given by this one. - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 30] - -RFC 3986 URI Generic Syntax January 2005 - - -

5.2.1. Pre-parse the Base URI

- - The base URI (Base) is established according to the procedure of - Section 5.1 and parsed into the five main components described in - Section 3. Note that only the scheme component is required to be - present in a base URI; the other components may be empty or - undefined. A component is undefined if its associated delimiter does - not appear in the URI reference; the path component is never - undefined, though it may be empty. - - Normalization of the base URI, as described in Sections 6.2.2 and - 6.2.3, is optional. A URI reference must be transformed to its - target URI before it can be normalized. - -

5.2.2. Transform References

- - For each URI reference (R), the following pseudocode describes an - algorithm for transforming R into its target URI (T): - - -- The URI reference is parsed into the five URI components - -- - (R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R); - - -- A non-strict parser may ignore a scheme in the reference - -- if it is identical to the base URI's scheme. - -- - if ((not strict) and (R.scheme == Base.scheme)) then - undefine(R.scheme); - endif; - - - - - - - - - - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 31] - -RFC 3986 URI Generic Syntax January 2005 - - - if defined(R.scheme) then - T.scheme = R.scheme; - T.authority = R.authority; - T.path = remove_dot_segments(R.path); - T.query = R.query; - else - if defined(R.authority) then - T.authority = R.authority; - T.path = remove_dot_segments(R.path); - T.query = R.query; - else - if (R.path == "") then - T.path = Base.path; - if defined(R.query) then - T.query = R.query; - else - T.query = Base.query; - endif; - else - if (R.path starts-with "/") then - T.path = remove_dot_segments(R.path); - else - T.path = merge(Base.path, R.path); - T.path = remove_dot_segments(T.path); - endif; - T.query = R.query; - endif; - T.authority = Base.authority; - endif; - T.scheme = Base.scheme; - endif; - - T.fragment = R.fragment; - -

5.2.3. Merge Paths

- - The pseudocode above refers to a "merge" routine for merging a - relative-path reference with the path of the base URI. This is - accomplished as follows: - - o If the base URI has a defined authority component and an empty - path, then return a string consisting of "/" concatenated with the - reference's path; otherwise, - - - - - - - - -Berners-Lee, et al. Standards Track [Page 32] - -RFC 3986 URI Generic Syntax January 2005 - - - o return a string consisting of the reference's path component - appended to all but the last segment of the base URI's path (i.e., - excluding any characters after the right-most "/" in the base URI - path, or excluding the entire base URI path if it does not contain - any "/" characters). - -

5.2.4. Remove Dot Segments

- - The pseudocode also refers to a "remove_dot_segments" routine for - interpreting and removing the special "." and ".." complete path - segments from a referenced path. This is done after the path is - extracted from a reference, whether or not the path was relative, in - order to remove any invalid or extraneous dot-segments prior to - forming the target URI. Although there are many ways to accomplish - this removal process, we describe a simple method using two string - buffers. - - 1. The input buffer is initialized with the now-appended path - components and the output buffer is initialized to the empty - string. - - 2. While the input buffer is not empty, loop as follows: - - A. If the input buffer begins with a prefix of "../" or "./", - then remove that prefix from the input buffer; otherwise, - - B. if the input buffer begins with a prefix of "/./" or "/.", - where "." is a complete path segment, then replace that - prefix with "/" in the input buffer; otherwise, - - C. if the input buffer begins with a prefix of "/../" or "/..", - where ".." is a complete path segment, then replace that - prefix with "/" in the input buffer and remove the last - segment and its preceding "/" (if any) from the output - buffer; otherwise, - - D. if the input buffer consists only of "." or "..", then remove - that from the input buffer; otherwise, - - E. move the first path segment in the input buffer to the end of - the output buffer, including the initial "/" character (if - any) and any subsequent characters up to, but not including, - the next "/" character or the end of the input buffer. - - 3. Finally, the output buffer is returned as the result of - remove_dot_segments. - - - - - -Berners-Lee, et al. Standards Track [Page 33] - -RFC 3986 URI Generic Syntax January 2005 - - - Note that dot-segments are intended for use in URI references to - express an identifier relative to the hierarchy of names in the base - URI. The remove_dot_segments algorithm respects that hierarchy by - removing extra dot-segments rather than treat them as an error or - leaving them to be misinterpreted by dereference implementations. - - The following illustrates how the above steps are applied for two - examples of merged paths, showing the state of the two buffers after - each step. - - STEP OUTPUT BUFFER INPUT BUFFER - - 1 : /a/b/c/./../../g - 2E: /a /b/c/./../../g - 2E: /a/b /c/./../../g - 2E: /a/b/c /./../../g - 2B: /a/b/c /../../g - 2C: /a/b /../g - 2C: /a /g - 2E: /a/g - - STEP OUTPUT BUFFER INPUT BUFFER - - 1 : mid/content=5/../6 - 2E: mid /content=5/../6 - 2E: mid/content=5 /../6 - 2C: mid /6 - 2E: mid/6 - - Some applications may find it more efficient to implement the - remove_dot_segments algorithm by using two segment stacks rather than - strings. - - Note: Beware that some older, erroneous implementations will fail - to separate a reference's query component from its path component - prior to merging the base and reference paths, resulting in an - interoperability failure if the query component contains the - strings "/../" or "/./". - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 34] - -RFC 3986 URI Generic Syntax January 2005 - - -

5.3. Component Recomposition

- - Parsed URI components can be recomposed to obtain the corresponding - URI reference string. Using pseudocode, this would be: - - result = "" - - if defined(scheme) then - append scheme to result; - append ":" to result; - endif; - - if defined(authority) then - append "//" to result; - append authority to result; - endif; - - append path to result; - - if defined(query) then - append "?" to result; - append query to result; - endif; - - if defined(fragment) then - append "#" to result; - append fragment to result; - endif; - - return result; - - Note that we are careful to preserve the distinction between a - component that is undefined, meaning that its separator was not - present in the reference, and a component that is empty, meaning that - the separator was present and was immediately followed by the next - component separator or the end of the reference. - -

5.4. Reference Resolution Examples

- - Within a representation with a well defined base URI of - - http://a/b/c/d;p?q - - a relative reference is transformed to its target URI as follows. - - - - - - - -Berners-Lee, et al. Standards Track [Page 35] - -RFC 3986 URI Generic Syntax January 2005 - - -

5.4.1. Normal Examples

- - "g:h" = "g:h" - "g" = "http://a/b/c/g" - "./g" = "http://a/b/c/g" - "g/" = "http://a/b/c/g/" - "/g" = "http://a/g" - "//g" = "http://g" - "?y" = "http://a/b/c/d;p?y" - "g?y" = "http://a/b/c/g?y" - "#s" = "http://a/b/c/d;p?q#s" - "g#s" = "http://a/b/c/g#s" - "g?y#s" = "http://a/b/c/g?y#s" - ";x" = "http://a/b/c/;x" - "g;x" = "http://a/b/c/g;x" - "g;x?y#s" = "http://a/b/c/g;x?y#s" - "" = "http://a/b/c/d;p?q" - "." = "http://a/b/c/" - "./" = "http://a/b/c/" - ".." = "http://a/b/" - "../" = "http://a/b/" - "../g" = "http://a/b/g" - "../.." = "http://a/" - "../../" = "http://a/" - "../../g" = "http://a/g" - -

5.4.2. Abnormal Examples

- - Although the following abnormal examples are unlikely to occur in - normal practice, all URI parsers should be capable of resolving them - consistently. Each example uses the same base as that above. - - Parsers must be careful in handling cases where there are more ".." - segments in a relative-path reference than there are hierarchical - levels in the base URI's path. Note that the ".." syntax cannot be - used to change the authority component of a URI. - - "../../../g" = "http://a/g" - "../../../../g" = "http://a/g" - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 36] - -RFC 3986 URI Generic Syntax January 2005 - - - Similarly, parsers must remove the dot-segments "." and ".." when - they are complete components of a path, but not when they are only - part of a segment. - - "/./g" = "http://a/g" - "/../g" = "http://a/g" - "g." = "http://a/b/c/g." - ".g" = "http://a/b/c/.g" - "g.." = "http://a/b/c/g.." - "..g" = "http://a/b/c/..g" - - Less likely are cases where the relative reference uses unnecessary - or nonsensical forms of the "." and ".." complete path segments. - - "./../g" = "http://a/b/g" - "./g/." = "http://a/b/c/g/" - "g/./h" = "http://a/b/c/g/h" - "g/../h" = "http://a/b/c/h" - "g;x=1/./y" = "http://a/b/c/g;x=1/y" - "g;x=1/../y" = "http://a/b/c/y" - - Some applications fail to separate the reference's query and/or - fragment components from the path component before merging it with - the base path and removing dot-segments. This error is rarely - noticed, as typical usage of a fragment never includes the hierarchy - ("/") character and the query component is not normally used within - relative references. - - "g?y/./x" = "http://a/b/c/g?y/./x" - "g?y/../x" = "http://a/b/c/g?y/../x" - "g#s/./x" = "http://a/b/c/g#s/./x" - "g#s/../x" = "http://a/b/c/g#s/../x" - - Some parsers allow the scheme name to be present in a relative - reference if it is the same as the base URI scheme. This is - considered to be a loophole in prior specifications of partial URI - [RFC1630]. Its use should be avoided but is allowed for backward - compatibility. - - "http:g" = "http:g" ; for strict parsers - / "http://a/b/c/g" ; for backward compatibility - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 37] - -RFC 3986 URI Generic Syntax January 2005 - - -

6. Normalization and Comparison

- - One of the most common operations on URIs is simple comparison: - determining whether two URIs are equivalent without using the URIs to - access their respective resource(s). A comparison is performed every - time a response cache is accessed, a browser checks its history to - color a link, or an XML parser processes tags within a namespace. - Extensive normalization prior to comparison of URIs is often used by - spiders and indexing engines to prune a search space or to reduce - duplication of request actions and response storage. - - URI comparison is performed for some particular purpose. Protocols - or implementations that compare URIs for different purposes will - often be subject to differing design trade-offs in regards to how - much effort should be spent in reducing aliased identifiers. This - section describes various methods that may be used to compare URIs, - the trade-offs between them, and the types of applications that might - use them. - -

6.1. Equivalence

- - Because URIs exist to identify resources, presumably they should be - considered equivalent when they identify the same resource. However, - this definition of equivalence is not of much practical use, as there - is no way for an implementation to compare two resources unless it - has full knowledge or control of them. For this reason, - determination of equivalence or difference of URIs is based on string - comparison, perhaps augmented by reference to additional rules - provided by URI scheme definitions. We use the terms "different" and - "equivalent" to describe the possible outcomes of such comparisons, - but there are many application-dependent versions of equivalence. - - Even though it is possible to determine that two URIs are equivalent, - URI comparison is not sufficient to determine whether two URIs - identify different resources. For example, an owner of two different - domain names could decide to serve the same resource from both, - resulting in two different URIs. Therefore, comparison methods are - designed to minimize false negatives while strictly avoiding false - positives. - - In testing for equivalence, applications should not directly compare - relative references; the references should be converted to their - respective target URIs before comparison. When URIs are compared to - select (or avoid) a network action, such as retrieval of a - representation, fragment components (if any) should be excluded from - the comparison. - - - - - -Berners-Lee, et al. Standards Track [Page 38] - -RFC 3986 URI Generic Syntax January 2005 - - -

6.2. Comparison Ladder

- - A variety of methods are used in practice to test URI equivalence. - These methods fall into a range, distinguished by the amount of - processing required and the degree to which the probability of false - negatives is reduced. As noted above, false negatives cannot be - eliminated. In practice, their probability can be reduced, but this - reduction requires more processing and is not cost-effective for all - applications. - - If this range of comparison practices is considered as a ladder, the - following discussion will climb the ladder, starting with practices - that are cheap but have a relatively higher chance of producing false - negatives, and proceeding to those that have higher computational - cost and lower risk of false negatives. - -

6.2.1. Simple String Comparison

- - If two URIs, when considered as character strings, are identical, - then it is safe to conclude that they are equivalent. This type of - equivalence test has very low computational cost and is in wide use - in a variety of applications, particularly in the domain of parsing. - - Testing strings for equivalence requires some basic precautions. - This procedure is often referred to as "bit-for-bit" or - "byte-for-byte" comparison, which is potentially misleading. Testing - strings for equality is normally based on pair comparison of the - characters that make up the strings, starting from the first and - proceeding until both strings are exhausted and all characters are - found to be equal, until a pair of characters compares unequal, or - until one of the strings is exhausted before the other. - - This character comparison requires that each pair of characters be - put in comparable form. For example, should one URI be stored in a - byte array in EBCDIC encoding and the second in a Java String object - (UTF-16), bit-for-bit comparisons applied naively will produce - errors. It is better to speak of equality on a character-for- - character basis rather than on a byte-for-byte or bit-for-bit basis. - In practical terms, character-by-character comparisons should be done - codepoint-by-codepoint after conversion to a common character - encoding. - - False negatives are caused by the production and use of URI aliases. - Unnecessary aliases can be reduced, regardless of the comparison - method, by consistently providing URI references in an already- - normalized form (i.e., a form identical to what would be produced - after normalization is applied, as described below). - - - - -Berners-Lee, et al. Standards Track [Page 39] - -RFC 3986 URI Generic Syntax January 2005 - - - Protocols and data formats often limit some URI comparisons to simple - string comparison, based on the theory that people and - implementations will, in their own best interest, be consistent in - providing URI references, or at least consistent enough to negate any - efficiency that might be obtained from further normalization. - -

6.2.2. Syntax-Based Normalization

- - Implementations may use logic based on the definitions provided by - this specification to reduce the probability of false negatives. - This processing is moderately higher in cost than character-for- - character string comparison. For example, an application using this - approach could reasonably consider the following two URIs equivalent: - - example://a/b/c/%7Bfoo%7D - eXAMPLE://a/./b/../b/%63/%7bfoo%7d - - Web user agents, such as browsers, typically apply this type of URI - normalization when determining whether a cached response is - available. Syntax-based normalization includes such techniques as - case normalization, percent-encoding normalization, and removal of - dot-segments. - -
6.2.2.1. Case Normalization
- - For all URIs, the hexadecimal digits within a percent-encoding - triplet (e.g., "%3a" versus "%3A") are case-insensitive and therefore - should be normalized to use uppercase letters for the digits A-F. - - When a URI uses components of the generic syntax, the component - syntax equivalence rules always apply; namely, that the scheme and - host are case-insensitive and therefore should be normalized to - lowercase. For example, the URI <HTTP://www.EXAMPLE.com/> is - equivalent to <http://www.example.com/>. The other generic syntax - components are assumed to be case-sensitive unless specifically - defined otherwise by the scheme (see Section 6.2.3). - -
6.2.2.2. Percent-Encoding Normalization
- - The percent-encoding mechanism (Section 2.1) is a frequent source of - variance among otherwise identical URIs. In addition to the case - normalization issue noted above, some URI producers percent-encode - octets that do not require percent-encoding, resulting in URIs that - are equivalent to their non-encoded counterparts. These URIs should - be normalized by decoding any percent-encoded octet that corresponds - to an unreserved character, as described in Section 2.3. - - - - - -Berners-Lee, et al. Standards Track [Page 40] - -RFC 3986 URI Generic Syntax January 2005 - - -
6.2.2.3. Path Segment Normalization
- - The complete path segments "." and ".." are intended only for use - within relative references (Section 4.1) and are removed as part of - the reference resolution process (Section 5.2). However, some - deployed implementations incorrectly assume that reference resolution - is not necessary when the reference is already a URI and thus fail to - remove dot-segments when they occur in non-relative paths. URI - normalizers should remove dot-segments by applying the - remove_dot_segments algorithm to the path, as described in - Section 5.2.4. - -

6.2.3. Scheme-Based Normalization

- - The syntax and semantics of URIs vary from scheme to scheme, as - described by the defining specification for each scheme. - Implementations may use scheme-specific rules, at further processing - cost, to reduce the probability of false negatives. For example, - because the "http" scheme makes use of an authority component, has a - default port of "80", and defines an empty path to be equivalent to - "/", the following four URIs are equivalent: - - http://example.com - http://example.com/ - http://example.com:/ - http://example.com:80/ - - In general, a URI that uses the generic syntax for authority with an - empty path should be normalized to a path of "/". Likewise, an - explicit ":port", for which the port is empty or the default for the - scheme, is equivalent to one where the port and its ":" delimiter are - elided and thus should be removed by scheme-based normalization. For - example, the second URI above is the normal form for the "http" - scheme. - - Another case where normalization varies by scheme is in the handling - of an empty authority component or empty host subcomponent. For many - scheme specifications, an empty authority or host is considered an - error; for others, it is considered equivalent to "localhost" or the - end-user's host. When a scheme defines a default for authority and a - URI reference to that default is desired, the reference should be - normalized to an empty authority for the sake of uniformity, brevity, - and internationalization. If, however, either the userinfo or port - subcomponents are non-empty, then the host should be given explicitly - even if it matches the default. - - Normalization should not remove delimiters when their associated - component is empty unless licensed to do so by the scheme - - - -Berners-Lee, et al. Standards Track [Page 41] - -RFC 3986 URI Generic Syntax January 2005 - - - specification. For example, the URI "http://example.com/?" cannot be - assumed to be equivalent to any of the examples above. Likewise, the - presence or absence of delimiters within a userinfo subcomponent is - usually significant to its interpretation. The fragment component is - not subject to any scheme-based normalization; thus, two URIs that - differ only by the suffix "#" are considered different regardless of - the scheme. - - Some schemes define additional subcomponents that consist of case- - insensitive data, giving an implicit license to normalizers to - convert this data to a common case (e.g., all lowercase). For - example, URI schemes that define a subcomponent of path to contain an - Internet hostname, such as the "mailto" URI scheme, cause that - subcomponent to be case-insensitive and thus subject to case - normalization (e.g., "mailto:Joe@Example.COM" is equivalent to - "mailto:Joe@example.com", even though the generic syntax considers - the path component to be case-sensitive). - - Other scheme-specific normalizations are possible. - -

6.2.4. Protocol-Based Normalization

- - Substantial effort to reduce the incidence of false negatives is - often cost-effective for web spiders. Therefore, they implement even - more aggressive techniques in URI comparison. For example, if they - observe that a URI such as - - http://example.com/data - - redirects to a URI differing only in the trailing slash - - http://example.com/data/ - - they will likely regard the two as equivalent in the future. This - kind of technique is only appropriate when equivalence is clearly - indicated by both the result of accessing the resources and the - common conventions of their scheme's dereference algorithm (in this - case, use of redirection by HTTP origin servers to avoid problems - with relative references). - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 42] - -RFC 3986 URI Generic Syntax January 2005 - - -

7. Security Considerations

- - A URI does not in itself pose a security threat. However, as URIs - are often used to provide a compact set of instructions for access to - network resources, care must be taken to properly interpret the data - within a URI, to prevent that data from causing unintended access, - and to avoid including data that should not be revealed in plain - text. - -

7.1. Reliability and Consistency

- - There is no guarantee that once a URI has been used to retrieve - information, the same information will be retrievable by that URI in - the future. Nor is there any guarantee that the information - retrievable via that URI in the future will be observably similar to - that retrieved in the past. The URI syntax does not constrain how a - given scheme or authority apportions its namespace or maintains it - over time. Such guarantees can only be obtained from the person(s) - controlling that namespace and the resource in question. A specific - URI scheme may define additional semantics, such as name persistence, - if those semantics are required of all naming authorities for that - scheme. - -

7.2. Malicious Construction

- - It is sometimes possible to construct a URI so that an attempt to - perform a seemingly harmless, idempotent operation, such as the - retrieval of a representation, will in fact cause a possibly damaging - remote operation. The unsafe URI is typically constructed by - specifying a port number other than that reserved for the network - protocol in question. The client unwittingly contacts a site running - a different protocol service, and data within the URI contains - instructions that, when interpreted according to this other protocol, - cause an unexpected operation. A frequent example of such abuse has - been the use of a protocol-based scheme with a port component of - "25", thereby fooling user agent software into sending an unintended - or impersonating message via an SMTP server. - - Applications should prevent dereference of a URI that specifies a TCP - port number within the "well-known port" range (0 - 1023) unless the - protocol being used to dereference that URI is compatible with the - protocol expected on that well-known port. Although IANA maintains a - registry of well-known ports, applications should make such - restrictions user-configurable to avoid preventing the deployment of - new services. - - - - - - -Berners-Lee, et al. Standards Track [Page 43] - -RFC 3986 URI Generic Syntax January 2005 - - - When a URI contains percent-encoded octets that match the delimiters - for a given resolution or dereference protocol (for example, CR and - LF characters for the TELNET protocol), these percent-encodings must - not be decoded before transmission across that protocol. Transfer of - the percent-encoding, which might violate the protocol, is less - harmful than allowing decoded octets to be interpreted as additional - operations or parameters, perhaps triggering an unexpected and - possibly harmful remote operation. - -

7.3. Back-End Transcoding

- - When a URI is dereferenced, the data within it is often parsed by - both the user agent and one or more servers. In HTTP, for example, a - typical user agent will parse a URI into its five major components, - access the authority's server, and send it the data within the - authority, path, and query components. A typical server will take - that information, parse the path into segments and the query into - key/value pairs, and then invoke implementation-specific handlers to - respond to the request. As a result, a common security concern for - server implementations that handle a URI, either as a whole or split - into separate components, is proper interpretation of the octet data - represented by the characters and percent-encodings within that URI. - - Percent-encoded octets must be decoded at some point during the - dereference process. Applications must split the URI into its - components and subcomponents prior to decoding the octets, as - otherwise the decoded octets might be mistaken for delimiters. - Security checks of the data within a URI should be applied after - decoding the octets. Note, however, that the "%00" percent-encoding - (NUL) may require special handling and should be rejected if the - application is not expecting to receive raw data within a component. - - Special care should be taken when the URI path interpretation process - involves the use of a back-end file system or related system - functions. File systems typically assign an operational meaning to - special characters, such as the "/", "\", ":", "[", and "]" - characters, and to special device names like ".", "..", "...", "aux", - "lpt", etc. In some cases, merely testing for the existence of such - a name will cause the operating system to pause or invoke unrelated - system calls, leading to significant security concerns regarding - denial of service and unintended data transfer. It would be - impossible for this specification to list all such significant - characters and device names. Implementers should research the - reserved names and characters for the types of storage device that - may be attached to their applications and restrict the use of data - obtained from URI components accordingly. - - - - - -Berners-Lee, et al. Standards Track [Page 44] - -RFC 3986 URI Generic Syntax January 2005 - - -

7.4. Rare IP Address Formats

- - Although the URI syntax for IPv4address only allows the common - dotted-decimal form of IPv4 address literal, many implementations - that process URIs make use of platform-dependent system routines, - such as gethostbyname() and inet_aton(), to translate the string - literal to an actual IP address. Unfortunately, such system routines - often allow and process a much larger set of formats than those - described in Section 3.2.2. - - For example, many implementations allow dotted forms of three - numbers, wherein the last part is interpreted as a 16-bit quantity - and placed in the right-most two bytes of the network address (e.g., - a Class B network). Likewise, a dotted form of two numbers means - that the last part is interpreted as a 24-bit quantity and placed in - the right-most three bytes of the network address (Class A), and a - single number (without dots) is interpreted as a 32-bit quantity and - stored directly in the network address. Adding further to the - confusion, some implementations allow each dotted part to be - interpreted as decimal, octal, or hexadecimal, as specified in the C - language (i.e., a leading 0x or 0X implies hexadecimal; a leading 0 - implies octal; otherwise, the number is interpreted as decimal). - - These additional IP address formats are not allowed in the URI syntax - due to differences between platform implementations. However, they - can become a security concern if an application attempts to filter - access to resources based on the IP address in string literal format. - If this filtering is performed, literals should be converted to - numeric form and filtered based on the numeric value, and not on a - prefix or suffix of the string form. - -

7.5. Sensitive Information

- - URI producers should not provide a URI that contains a username or - password that is intended to be secret. URIs are frequently - displayed by browsers, stored in clear text bookmarks, and logged by - user agent history and intermediary applications (proxies). A - password appearing within the userinfo component is deprecated and - should be considered an error (or simply ignored) except in those - rare cases where the 'password' parameter is intended to be public. - -

7.6. Semantic Attacks

- - Because the userinfo subcomponent is rarely used and appears before - the host in the authority component, it can be used to construct a - URI intended to mislead a human user by appearing to identify one - (trusted) naming authority while actually identifying a different - authority hidden behind the noise. For example - - - -Berners-Lee, et al. Standards Track [Page 45] - -RFC 3986 URI Generic Syntax January 2005 - - - ftp://cnn.example.com&story=breaking_news@10.0.0.1/top_story.htm - - might lead a human user to assume that the host is 'cnn.example.com', - whereas it is actually '10.0.0.1'. Note that a misleading userinfo - subcomponent could be much longer than the example above. - - A misleading URI, such as that above, is an attack on the user's - preconceived notions about the meaning of a URI rather than an attack - on the software itself. User agents may be able to reduce the impact - of such attacks by distinguishing the various components of the URI - when they are rendered, such as by using a different color or tone to - render userinfo if any is present, though there is no panacea. More - information on URI-based semantic attacks can be found in [Siedzik]. - -

8. IANA Considerations

- - URI scheme names, as defined by <scheme> in Section 3.1, form a - registered namespace that is managed by IANA according to the - procedures defined in [BCP35]. No IANA actions are required by this - document. - -

9. Acknowledgements

- - This specification is derived from RFC 2396 [RFC2396], RFC 1808 - [RFC1808], and RFC 1738 [RFC1738]; the acknowledgements in those - documents still apply. It also incorporates the update (with - corrections) for IPv6 literals in the host syntax, as defined by - Robert M. Hinden, Brian E. Carpenter, and Larry Masinter in - [RFC2732]. In addition, contributions by Gisle Aas, Reese Anschultz, - Daniel Barclay, Tim Bray, Mike Brown, Rob Cameron, Jeremy Carroll, - Dan Connolly, Adam M. Costello, John Cowan, Jason Diamond, Martin - Duerst, Stefan Eissing, Clive D.W. Feather, Al Gilman, Tony Hammond, - Elliotte Harold, Pat Hayes, Henry Holtzman, Ian B. Jacobs, Michael - Kay, John C. Klensin, Graham Klyne, Dan Kohn, Bruce Lilly, Andrew - Main, Dave McAlpin, Ira McDonald, Michael Mealling, Ray Merkert, - Stephen Pollei, Julian Reschke, Tomas Rokicki, Miles Sabin, Kai - Schaetzl, Mark Thomson, Ronald Tschalaer, Norm Walsh, Marc Warne, - Stuart Williams, and Henry Zongaro are gratefully acknowledged. - -

10. References

- -

10.1. Normative References

- - [ASCII] American National Standards Institute, "Coded Character - Set -- 7-bit American Standard Code for Information - Interchange", ANSI X3.4, 1986. - - - - - -Berners-Lee, et al. Standards Track [Page 46] - -RFC 3986 URI Generic Syntax January 2005 - - - [RFC2234] Crocker, D. and P. Overell, "Augmented BNF for Syntax - Specifications: ABNF", RFC 2234, November 1997. - - [STD63] Yergeau, F., "UTF-8, a transformation format of - ISO 10646", STD 63, RFC 3629, November 2003. - - [UCS] International Organization for Standardization, - "Information Technology - Universal Multiple-Octet Coded - Character Set (UCS)", ISO/IEC 10646:2003, December 2003. - -

10.2. Informative References

- - [BCP19] Freed, N. and J. Postel, "IANA Charset Registration - Procedures", BCP 19, RFC 2978, October 2000. - - [BCP35] Petke, R. and I. King, "Registration Procedures for URL - Scheme Names", BCP 35, RFC 2717, November 1999. - - [RFC0952] Harrenstien, K., Stahl, M., and E. Feinler, "DoD Internet - host table specification", RFC 952, October 1985. - - [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", - STD 13, RFC 1034, November 1987. - - [RFC1123] Braden, R., "Requirements for Internet Hosts - Application - and Support", STD 3, RFC 1123, October 1989. - - [RFC1535] Gavron, E., "A Security Problem and Proposed Correction - With Widely Deployed DNS Software", RFC 1535, - October 1993. - - [RFC1630] Berners-Lee, T., "Universal Resource Identifiers in WWW: A - Unifying Syntax for the Expression of Names and Addresses - of Objects on the Network as used in the World-Wide Web", - RFC 1630, June 1994. - - [RFC1736] Kunze, J., "Functional Recommendations for Internet - Resource Locators", RFC 1736, February 1995. - - [RFC1737] Sollins, K. and L. Masinter, "Functional Requirements for - Uniform Resource Names", RFC 1737, December 1994. - - [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform - Resource Locators (URL)", RFC 1738, December 1994. - - [RFC1808] Fielding, R., "Relative Uniform Resource Locators", - RFC 1808, June 1995. - - - - -Berners-Lee, et al. Standards Track [Page 47] - -RFC 3986 URI Generic Syntax January 2005 - - - [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail - Extensions (MIME) Part Two: Media Types", RFC 2046, - November 1996. - - [RFC2141] Moats, R., "URN Syntax", RFC 2141, May 1997. - - [RFC2396] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform - Resource Identifiers (URI): Generic Syntax", RFC 2396, - August 1998. - - [RFC2518] Goland, Y., Whitehead, E., Faizi, A., Carter, S., and D. - Jensen, "HTTP Extensions for Distributed Authoring -- - WEBDAV", RFC 2518, February 1999. - - [RFC2557] Palme, J., Hopmann, A., and N. Shelness, "MIME - Encapsulation of Aggregate Documents, such as HTML - (MHTML)", RFC 2557, March 1999. - - [RFC2718] Masinter, L., Alvestrand, H., Zigmond, D., and R. Petke, - "Guidelines for new URL Schemes", RFC 2718, November 1999. - - [RFC2732] Hinden, R., Carpenter, B., and L. Masinter, "Format for - Literal IPv6 Addresses in URL's", RFC 2732, December 1999. - - [RFC3305] Mealling, M. and R. Denenberg, "Report from the Joint - W3C/IETF URI Planning Interest Group: Uniform Resource - Identifiers (URIs), URLs, and Uniform Resource Names - (URNs): Clarifications and Recommendations", RFC 3305, - August 2002. - - [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, - "Internationalizing Domain Names in Applications (IDNA)", - RFC 3490, March 2003. - - [RFC3513] Hinden, R. and S. Deering, "Internet Protocol Version 6 - (IPv6) Addressing Architecture", RFC 3513, April 2003. - - [Siedzik] Siedzik, R., "Semantic Attacks: What's in a URL?", - April 2001, <http://www.giac.org/practical/gsec/ - Richard_Siedzik_GSEC.pdf>. - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 48] - -RFC 3986 URI Generic Syntax January 2005 - - -Appendix A. Collected ABNF for URI - - URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] - - hier-part = "//" authority path-abempty - / path-absolute - / path-rootless - / path-empty - - URI-reference = URI / relative-ref - - absolute-URI = scheme ":" hier-part [ "?" query ] - - relative-ref = relative-part [ "?" query ] [ "#" fragment ] - - relative-part = "//" authority path-abempty - / path-absolute - / path-noscheme - / path-empty - - scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) - - authority = [ userinfo "@" ] host [ ":" port ] - userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) - host = IP-literal / IPv4address / reg-name - port = *DIGIT - - IP-literal = "[" ( IPv6address / IPvFuture ) "]" - - IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) - - IPv6address = 6( h16 ":" ) ls32 - / "::" 5( h16 ":" ) ls32 - / [ h16 ] "::" 4( h16 ":" ) ls32 - / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 - / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 - / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 - / [ *4( h16 ":" ) h16 ] "::" ls32 - / [ *5( h16 ":" ) h16 ] "::" h16 - / [ *6( h16 ":" ) h16 ] "::" - - h16 = 1*4HEXDIG - ls32 = ( h16 ":" h16 ) / IPv4address - IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet - - - - - - - -Berners-Lee, et al. Standards Track [Page 49] - -RFC 3986 URI Generic Syntax January 2005 - - - dec-octet = DIGIT ; 0-9 - / %x31-39 DIGIT ; 10-99 - / "1" 2DIGIT ; 100-199 - / "2" %x30-34 DIGIT ; 200-249 - / "25" %x30-35 ; 250-255 - - reg-name = *( unreserved / pct-encoded / sub-delims ) - - path = path-abempty ; begins with "/" or is empty - / path-absolute ; begins with "/" but not "//" - / path-noscheme ; begins with a non-colon segment - / path-rootless ; begins with a segment - / path-empty ; zero characters - - path-abempty = *( "/" segment ) - path-absolute = "/" [ segment-nz *( "/" segment ) ] - path-noscheme = segment-nz-nc *( "/" segment ) - path-rootless = segment-nz *( "/" segment ) - path-empty = 0<pchar> - - segment = *pchar - segment-nz = 1*pchar - segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) - ; non-zero-length segment without any colon ":" - - pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - - query = *( pchar / "/" / "?" ) - - fragment = *( pchar / "/" / "?" ) - - pct-encoded = "%" HEXDIG HEXDIG - - unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - reserved = gen-delims / sub-delims - gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" - sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - / "*" / "+" / "," / ";" / "=" - -Appendix B. Parsing a URI Reference with a Regular Expression - - As the "first-match-wins" algorithm is identical to the "greedy" - disambiguation method used by POSIX regular expressions, it is - natural and commonplace to use a regular expression for parsing the - potential five components of a URI reference. - - The following line is the regular expression for breaking-down a - well-formed URI reference into its components. - - - -Berners-Lee, et al. Standards Track [Page 50] - -RFC 3986 URI Generic Syntax January 2005 - - - ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? - 12 3 4 5 6 7 8 9 - - The numbers in the second line above are only to assist readability; - they indicate the reference points for each subexpression (i.e., each - paired parenthesis). We refer to the value matched for subexpression - <n> as $<n>. For example, matching the above expression to - - http://www.ics.uci.edu/pub/ietf/uri/#Related - - results in the following subexpression matches: - - $1 = http: - $2 = http - $3 = //www.ics.uci.edu - $4 = www.ics.uci.edu - $5 = /pub/ietf/uri/ - $6 = <undefined> - $7 = <undefined> - $8 = #Related - $9 = Related - - where <undefined> indicates that the component is not present, as is - the case for the query component in the above example. Therefore, we - can determine the value of the five components as - - scheme = $2 - authority = $4 - path = $5 - query = $7 - fragment = $9 - - Going in the opposite direction, we can recreate a URI reference from - its components by using the algorithm of Section 5.3. - -Appendix C. Delimiting a URI in Context - - URIs are often transmitted through formats that do not provide a - clear context for their interpretation. For example, there are many - occasions when a URI is included in plain text; examples include text - sent in email, USENET news, and on printed paper. In such cases, it - is important to be able to delimit the URI from the rest of the text, - and in particular from punctuation marks that might be mistaken for - part of the URI. - - In practice, URIs are delimited in a variety of ways, but usually - within double-quotes "http://example.com/", angle brackets - <http://example.com/>, or just by using whitespace: - - - -Berners-Lee, et al. Standards Track [Page 51] - -RFC 3986 URI Generic Syntax January 2005 - - - http://example.com/ - - These wrappers do not form part of the URI. - - In some cases, extra whitespace (spaces, line-breaks, tabs, etc.) may - have to be added to break a long URI across lines. The whitespace - should be ignored when the URI is extracted. - - No whitespace should be introduced after a hyphen ("-") character. - Because some typesetters and printers may (erroneously) introduce a - hyphen at the end of line when breaking it, the interpreter of a URI - containing a line break immediately after a hyphen should ignore all - whitespace around the line break and should be aware that the hyphen - may or may not actually be part of the URI. - - Using <> angle brackets around each URI is especially recommended as - a delimiting style for a reference that contains embedded whitespace. - - The prefix "URL:" (with or without a trailing space) was formerly - recommended as a way to help distinguish a URI from other bracketed - designators, though it is not commonly used in practice and is no - longer recommended. - - For robustness, software that accepts user-typed URI should attempt - to recognize and strip both delimiters and embedded whitespace. - - For example, the text - - Yes, Jim, I found it under "http://www.w3.org/Addressing/", - but you can probably pick it up from <ftp://foo.example. - http://www.ics.uci.edu/pub/ - ietf/uri/historical.html#WARNING>. - - contains the URI references - - http://www.w3.org/Addressing/ - ftp://foo.example.com/rfc/ - http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 52] - -RFC 3986 URI Generic Syntax January 2005 - - -Appendix D. Changes from RFC 2396 - -D.1. Additions - - An ABNF rule for URI has been introduced to correspond to one common - usage of the term: an absolute URI with optional fragment. - - IPv6 (and later) literals have been added to the list of possible - identifiers for the host portion of an authority component, as - described by [RFC2732], with the addition of "[" and "]" to the - reserved set and a version flag to anticipate future versions of IP - literals. Square brackets are now specified as reserved within the - authority component and are not allowed outside their use as - delimiters for an IP literal within host. In order to make this - change without changing the technical definition of the path, query, - and fragment components, those rules were redefined to directly - specify the characters allowed. - - As [RFC2732] defers to [RFC3513] for definition of an IPv6 literal - address, which, unfortunately, lacks an ABNF description of - IPv6address, we created a new ABNF rule for IPv6address that matches - the text representations defined by Section 2.2 of [RFC3513]. - Likewise, the definition of IPv4address has been improved in order to - limit each decimal octet to the range 0-255. - - Section 6, on URI normalization and comparison, has been completely - rewritten and extended by using input from Tim Bray and discussion - within the W3C Technical Architecture Group. - -D.2. Modifications - - The ad-hoc BNF syntax of RFC 2396 has been replaced with the ABNF of - [RFC2234]. This change required all rule names that formerly - included underscore characters to be renamed with a dash instead. In - addition, a number of syntax rules have been eliminated or simplified - to make the overall grammar more comprehensible. Specifications that - refer to the obsolete grammar rules may be understood by replacing - those rules according to the following table: - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 53] - -RFC 3986 URI Generic Syntax January 2005 - - - +----------------+--------------------------------------------------+ - | obsolete rule | translation | - +----------------+--------------------------------------------------+ - | absoluteURI | absolute-URI | - | relativeURI | relative-part [ "?" query ] | - | hier_part | ( "//" authority path-abempty / | - | | path-absolute ) [ "?" query ] | - | | | - | opaque_part | path-rootless [ "?" query ] | - | net_path | "//" authority path-abempty | - | abs_path | path-absolute | - | rel_path | path-rootless | - | rel_segment | segment-nz-nc | - | reg_name | reg-name | - | server | authority | - | hostport | host [ ":" port ] | - | hostname | reg-name | - | path_segments | path-abempty | - | param | *<pchar excluding ";"> | - | | | - | uric | unreserved / pct-encoded / ";" / "?" / ":" | - | | / "@" / "&" / "=" / "+" / "$" / "," / "/" | - | | | - | uric_no_slash | unreserved / pct-encoded / ";" / "?" / ":" | - | | / "@" / "&" / "=" / "+" / "$" / "," | - | | | - | mark | "-" / "_" / "." / "!" / "~" / "*" / "'" | - | | / "(" / ")" | - | | | - | escaped | pct-encoded | - | hex | HEXDIG | - | alphanum | ALPHA / DIGIT | - +----------------+--------------------------------------------------+ - - Use of the above obsolete rules for the definition of scheme-specific - syntax is deprecated. - - Section 2, on characters, has been rewritten to explain what - characters are reserved, when they are reserved, and why they are - reserved, even when they are not used as delimiters by the generic - syntax. The mark characters that are typically unsafe to decode, - including the exclamation mark ("!"), asterisk ("*"), single-quote - ("'"), and open and close parentheses ("(" and ")"), have been moved - to the reserved set in order to clarify the distinction between - reserved and unreserved and, hopefully, to answer the most common - question of scheme designers. Likewise, the section on - percent-encoded characters has been rewritten, and URI normalizers - are now given license to decode any percent-encoded octets - - - -Berners-Lee, et al. Standards Track [Page 54] - -RFC 3986 URI Generic Syntax January 2005 - - - corresponding to unreserved characters. In general, the terms - "escaped" and "unescaped" have been replaced with "percent-encoded" - and "decoded", respectively, to reduce confusion with other forms of - escape mechanisms. - - The ABNF for URI and URI-reference has been redesigned to make them - more friendly to LALR parsers and to reduce complexity. As a result, - the layout form of syntax description has been removed, along with - the uric, uric_no_slash, opaque_part, net_path, abs_path, rel_path, - path_segments, rel_segment, and mark rules. All references to - "opaque" URIs have been replaced with a better description of how the - path component may be opaque to hierarchy. The relativeURI rule has - been replaced with relative-ref to avoid unnecessary confusion over - whether they are a subset of URI. The ambiguity regarding the - parsing of URI-reference as a URI or a relative-ref with a colon in - the first segment has been eliminated through the use of five - separate path matching rules. - - The fragment identifier has been moved back into the section on - generic syntax components and within the URI and relative-ref rules, - though it remains excluded from absolute-URI. The number sign ("#") - character has been moved back to the reserved set as a result of - reintegrating the fragment syntax. - - The ABNF has been corrected to allow the path component to be empty. - This also allows an absolute-URI to consist of nothing after the - "scheme:", as is present in practice with the "dav:" namespace - [RFC2518] and with the "about:" scheme used internally by many WWW - browser implementations. The ambiguity regarding the boundary - between authority and path has been eliminated through the use of - five separate path matching rules. - - Registry-based naming authorities that use the generic syntax are now - defined within the host rule. This change allows current - implementations, where whatever name provided is simply fed to the - local name resolution mechanism, to be consistent with the - specification. It also removes the need to re-specify DNS name - formats here. Furthermore, it allows the host component to contain - percent-encoded octets, which is necessary to enable - internationalized domain names to be provided in URIs, processed in - their native character encodings at the application layers above URI - processing, and passed to an IDNA library as a registered name in the - UTF-8 character encoding. The server, hostport, hostname, - domainlabel, toplabel, and alphanum rules have been removed. - - The resolving relative references algorithm of [RFC2396] has been - rewritten with pseudocode for this revision to improve clarity and - fix the following issues: - - - -Berners-Lee, et al. Standards Track [Page 55] - -RFC 3986 URI Generic Syntax January 2005 - - - o [RFC2396] section 5.2, step 6a, failed to account for a base URI - with no path. - - o Restored the behavior of [RFC1808] where, if the reference - contains an empty path and a defined query component, the target - URI inherits the base URI's path component. - - o The determination of whether a URI reference is a same-document - reference has been decoupled from the URI parser, simplifying the - URI processing interface within applications in a way consistent - with the internal architecture of deployed URI processing - implementations. The determination is now based on comparison to - the base URI after transforming a reference to absolute form, - rather than on the format of the reference itself. This change - may result in more references being considered "same-document" - under this specification than there would be under the rules given - in RFC 2396, especially when normalization is used to reduce - aliases. However, it does not change the status of existing - same-document references. - - o Separated the path merge routine into two routines: merge, for - describing combination of the base URI path with a relative-path - reference, and remove_dot_segments, for describing how to remove - the special "." and ".." segments from a composed path. The - remove_dot_segments algorithm is now applied to all URI reference - paths in order to match common implementations and to improve the - normalization of URIs in practice. This change only impacts the - parsing of abnormal references and same-scheme references wherein - the base URI has a non-hierarchical path. - -Index - - A - ABNF 11 - absolute 27 - absolute-path 26 - absolute-URI 27 - access 9 - authority 17, 18 - - B - base URI 28 - - C - character encoding 4 - character 4 - characters 8, 11 - coded character set 4 - - - -Berners-Lee, et al. Standards Track [Page 56] - -RFC 3986 URI Generic Syntax January 2005 - - - D - dec-octet 20 - dereference 9 - dot-segments 23 - - F - fragment 16, 24 - - G - gen-delims 13 - generic syntax 6 - - H - h16 20 - hier-part 16 - hierarchical 10 - host 18 - - I - identifier 5 - IP-literal 19 - IPv4 20 - IPv4address 19, 20 - IPv6 19 - IPv6address 19, 20 - IPvFuture 19 - - L - locator 7 - ls32 20 - - M - merge 32 - - N - name 7 - network-path 26 - - P - path 16, 22, 26 - path-abempty 22 - path-absolute 22 - path-empty 22 - path-noscheme 22 - path-rootless 22 - path-abempty 16, 22, 26 - path-absolute 16, 22, 26 - path-empty 16, 22, 26 - - - -Berners-Lee, et al. Standards Track [Page 57] - -RFC 3986 URI Generic Syntax January 2005 - - - path-rootless 16, 22 - pchar 23 - pct-encoded 12 - percent-encoding 12 - port 22 - - Q - query 16, 23 - - R - reg-name 21 - registered name 20 - relative 10, 28 - relative-path 26 - relative-ref 26 - remove_dot_segments 33 - representation 9 - reserved 12 - resolution 9, 28 - resource 5 - retrieval 9 - - S - same-document 27 - sameness 9 - scheme 16, 17 - segment 22, 23 - segment-nz 23 - segment-nz-nc 23 - sub-delims 13 - suffix 27 - - T - transcription 8 - - U - uniform 4 - unreserved 13 - URI grammar - absolute-URI 27 - ALPHA 11 - authority 18 - CR 11 - dec-octet 20 - DIGIT 11 - DQUOTE 11 - fragment 24 - gen-delims 13 - - - -Berners-Lee, et al. Standards Track [Page 58] - -RFC 3986 URI Generic Syntax January 2005 - - - h16 20 - HEXDIG 11 - hier-part 16 - host 19 - IP-literal 19 - IPv4address 20 - IPv6address 20 - IPvFuture 19 - LF 11 - ls32 20 - OCTET 11 - path 22 - path-abempty 22 - path-absolute 22 - path-empty 22 - path-noscheme 22 - path-rootless 22 - pchar 23 - pct-encoded 12 - port 22 - query 24 - reg-name 21 - relative-ref 26 - reserved 13 - scheme 17 - segment 23 - segment-nz 23 - segment-nz-nc 23 - SP 11 - sub-delims 13 - unreserved 13 - URI 16 - URI-reference 25 - userinfo 18 - URI 16 - URI-reference 25 - URL 7 - URN 7 - userinfo 18 - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 59] - -RFC 3986 URI Generic Syntax January 2005 - - -Authors' Addresses - - Tim Berners-Lee - World Wide Web Consortium - Massachusetts Institute of Technology - 77 Massachusetts Avenue - Cambridge, MA 02139 - USA - - Phone: +1-617-253-5702 - Fax: +1-617-258-5999 - EMail: timbl@w3.org - URI: http://www.w3.org/People/Berners-Lee/ - - - Roy T. Fielding - Day Software - 5251 California Ave., Suite 110 - Irvine, CA 92617 - USA - - Phone: +1-949-679-2960 - Fax: +1-949-679-2972 - EMail: fielding@gbiv.com - URI: http://roy.gbiv.com/ - - - Larry Masinter - Adobe Systems Incorporated - 345 Park Ave - San Jose, CA 95110 - USA - - Phone: +1-408-536-3024 - EMail: LMM@acm.org - URI: http://larry.masinter.net/ - - - - - - - - - - - - - - - -Berners-Lee, et al. Standards Track [Page 60] - -RFC 3986 URI Generic Syntax January 2005 - - -Full Copyright Statement - - Copyright (C) The Internet Society (2005). - - This document is subject to the rights, licenses and restrictions - contained in BCP 78, and except as set forth therein, the authors - retain all their rights. - - This document and the information contained herein are provided on an - "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS - OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET - ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE - INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED - WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Intellectual Property - - The IETF takes no position regarding the validity or scope of any - Intellectual Property Rights or other rights that might be claimed to - pertain to the implementation or use of the technology described in - this document or the extent to which any license under such rights - might or might not be available; nor does it represent that it has - made any independent effort to identify any such rights. Information - on the IETF's procedures with respect to rights in IETF Documents can - be found in BCP 78 and BCP 79. - - Copies of IPR disclosures made to the IETF Secretariat and any - assurances of licenses to be made available, or the result of an - attempt made to obtain a general license or permission for the use of - such proprietary rights by implementers or users of this - specification can be obtained from the IETF on-line IPR repository at - http://www.ietf.org/ipr. - - The IETF invites any interested party to bring to its attention any - copyrights, patents or patent applications, or other proprietary - rights that may cover technology that may be required to implement - this standard. Please address the information to the IETF at ietf- - ipr@ietf.org. - - -Acknowledgement - - Funding for the RFC Editor function is currently provided by the - Internet Society. - - - - - - -Berners-Lee, et al. Standards Track [Page 61] - - -

-Html markup produced by rfcmarkup 1.46, available from -http://tools.ietf.org/tools/rfcmarkup/ - - - \ No newline at end of file diff --git a/external/uriparser/doc/rfc3986_grammar_only.txt b/external/uriparser/doc/rfc3986_grammar_only.txt deleted file mode 100644 index e8b8d08..0000000 --- a/external/uriparser/doc/rfc3986_grammar_only.txt +++ /dev/null @@ -1,80 +0,0 @@ -URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] - -hier-part = "//" authority path-abempty - / path-absolute - / path-rootless - / path-empty - -URI-reference = URI / relative-ref - -absolute-URI = scheme ":" hier-part [ "?" query ] - -relative-ref = relative-part [ "?" query ] [ "#" fragment ] - -relative-part = "//" authority path-abempty - / path-absolute - / path-noscheme - / path-empty - -scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) - -authority = [ userinfo "@" ] host [ ":" port ] -userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) -host = IP-literal / IPv4address / reg-name -port = *DIGIT - -IP-literal = "[" ( IPv6address / IPvFuture ) "]" - -IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) - -IPv6address = 6( h16 ":" ) ls32 - / "::" 5( h16 ":" ) ls32 - / [ h16 ] "::" 4( h16 ":" ) ls32 - / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 - / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 - / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 - / [ *4( h16 ":" ) h16 ] "::" ls32 - / [ *5( h16 ":" ) h16 ] "::" h16 - / [ *6( h16 ":" ) h16 ] "::" - -h16 = 1*4HEXDIG -ls32 = ( h16 ":" h16 ) / IPv4address -IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet -dec-octet = DIGIT ; 0-9 - / %x31-39 DIGIT ; 10-99 - / "1" 2DIGIT ; 100-199 - / "2" %x30-34 DIGIT ; 200-249 - / "25" %x30-35 ; 250-255 - -reg-name = *( unreserved / pct-encoded / sub-delims ) - -path = path-abempty ; begins with "/" or is empty - / path-absolute ; begins with "/" but not "//" - / path-noscheme ; begins with a non-colon segment - / path-rootless ; begins with a segment - / path-empty ; zero characters - -path-abempty = *( "/" segment ) -path-absolute = "/" [ segment-nz *( "/" segment ) ] -path-noscheme = segment-nz-nc *( "/" segment ) -path-rootless = segment-nz *( "/" segment ) -path-empty = 0 - -segment = *pchar -segment-nz = 1*pchar -segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) - ; non-zero-length segment without any colon ":" - -pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - -query = *( pchar / "/" / "?" ) - -fragment = *( pchar / "/" / "?" ) - -pct-encoded = "%" HEXDIG HEXDIG - -unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" -reserved = gen-delims / sub-delims -gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" -sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - / "*" / "+" / "," / ";" / "=" diff --git a/external/uriparser/doc/rule_dependencies.dot b/external/uriparser/doc/rule_dependencies.dot deleted file mode 100644 index cf2576c..0000000 --- a/external/uriparser/doc/rule_dependencies.dot +++ /dev/null @@ -1,64 +0,0 @@ -digraph whoCallsWhom { - size="20,20"; - fontsize=12 - node [style=bold]; - "authority" -> "authorityTwo"; - "authority" -> "ipLiteral"; - "authority" -> "ownHostUserInfoNz"; - "authorityTwo" -> "port"; - "hexZero" -> "hexZero"; - "hierPart" -> "partHelperTwo"; - "hierPart" -> "pathRootless"; - "ipFutLoop" -> "ipFutStopGo"; - "ipFutStopGo" -> "ipFutLoop"; - "ipFuture" -> "hexZero"; - "ipFuture" -> "ipFutLoop"; - "ipLit2" -> "ipFuture"; - "ipLit2" -> "IPv6address2"; - "ipLiteral" -> "ipLit2"; - "mustBeSegmentNzNc" -> "mustBeSegmentNzNc"; - "mustBeSegmentNzNc" -> "segment"; - "mustBeSegmentNzNc" -> "uriTail"; - "mustBeSegmentNzNc" -> "zeroMoreSlashSegs"; - "ownHost" -> "authorityTwo"; - "ownHost" -> "ipLiteral"; - "ownHost" -> "ownHost2"; - "ownHost2" -> "authorityTwo"; - "ownHost2" -> "ownHost2"; - "ownHostUserInfo" -> "ownHostUserInfoNz"; - "ownHostUserInfoNz" -> "ownHost"; - "ownHostUserInfoNz" -> "ownHostUserInfo"; - "ownHostUserInfoNz" -> "ownPortUserInfo"; - "ownPortUserInfo" -> "ownPortUserInfo"; - "ownPortUserInfo" -> "ownUserInfo"; - "ownUserInfo" -> "ownHost"; - "ownUserInfo" -> "ownUserInfo"; - "partHelperTwo" -> "authority"; - "partHelperTwo" -> "pathAbsEmpty"; - "partHelperTwo" -> "pathAbsNoLeadSlash"; - "pathAbsEmpty" -> "pathAbsEmpty"; - "pathAbsEmpty" -> "segment"; - "pathAbsNoLeadSlash" -> "segmentNz"; - "pathAbsNoLeadSlash" -> "zeroMoreSlashSegs"; - "pathRootless" -> "segmentNz"; - "pathRootless" -> "zeroMoreSlashSegs"; - "port" -> "port"; - "queryFrag" -> "queryFrag"; - "segment" -> "segment"; - "segmentNz" -> "segment"; - "segmentNzNcOrScheme2" -> "hierPart"; - "segmentNzNcOrScheme2" -> "mustBeSegmentNzNc"; - "segmentNzNcOrScheme2" -> "segment"; - "segmentNzNcOrScheme2" -> "segmentNzNcOrScheme2"; - "segmentNzNcOrScheme2" -> "uriTail"; - "segmentNzNcOrScheme2" -> "zeroMoreSlashSegs"; - "uriReference" -> "mustBeSegmentNzNc"; - "uriReference" -> "partHelperTwo"; - "uriReference" -> "segmentNzNcOrScheme2"; - "uriReference" -> "uriTail"; - "uriTail" -> "queryFrag"; - "uriTail" -> "uriTailTwo"; - "uriTailTwo" -> "queryFrag"; - "zeroMoreSlashSegs" -> "segment"; - "zeroMoreSlashSegs" -> "zeroMoreSlashSegs"; -} diff --git a/external/uriparser/doc/rule_dependencies.sh b/external/uriparser/doc/rule_dependencies.sh deleted file mode 100755 index 3d3c54c..0000000 --- a/external/uriparser/doc/rule_dependencies.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -dot -Tsvg -orule_dependencies.svg rule_dependencies.dot -dot -Tpng -orule_dependencies.png rule_dependencies.dot diff --git a/external/uriparser/include/uriparser/Uri.h b/external/uriparser/include/uriparser/Uri.h deleted file mode 100644 index 44d8760..0000000 --- a/external/uriparser/include/uriparser/Uri.h +++ /dev/null @@ -1,1124 +0,0 @@ -/* 6db8b5726a796167bb96b3d83ff9ac6792a01474dbe3778deb3c2a25d60b3693 (0.9.5+) - * - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file Uri.h - * Holds the RFC 3986 %URI parser interface. - * NOTE: This header includes itself twice. - */ - -#if (defined(URI_PASS_ANSI) && !defined(URI_H_ANSI)) \ - || (defined(URI_PASS_UNICODE) && !defined(URI_H_UNICODE)) \ - || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* What encodings are enabled? */ -#include "UriDefsConfig.h" -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "Uri.h" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "Uri.h" -# undef URI_PASS_UNICODE -# endif -/* Only one pass for each encoding */ -#elif (defined(URI_PASS_ANSI) && !defined(URI_H_ANSI) \ - && defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \ - && !defined(URI_H_UNICODE) && defined(URI_ENABLE_UNICODE)) -# ifdef URI_PASS_ANSI -# define URI_H_ANSI 1 -# include "UriDefsAnsi.h" -# else -# define URI_H_UNICODE 1 -# include "UriDefsUnicode.h" -# endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifndef URI_DOXYGEN -# include "UriBase.h" -#endif - - - -/** - * Specifies a range of characters within a string. - * The range includes all characters from first - * to one before afterLast. So if both are - * non-NULL the difference is the length of the text range. - * - * @see UriUriA - * @see UriPathSegmentA - * @see UriHostDataA - * @since 0.3.0 - */ -typedef struct URI_TYPE(TextRangeStruct) { - const URI_CHAR * first; /**< Pointer to first character */ - const URI_CHAR * afterLast; /**< Pointer to character after the last one still in */ -} URI_TYPE(TextRange); /**< @copydoc UriTextRangeStructA */ - - - -/** - * Represents a path segment within a %URI path. - * More precisely it is a node in a linked - * list of path segments. - * - * @see UriUriA - * @since 0.3.0 - */ -typedef struct URI_TYPE(PathSegmentStruct) { - URI_TYPE(TextRange) text; /**< Path segment name */ - struct URI_TYPE(PathSegmentStruct) * next; /**< Pointer to the next path segment in the list, can be NULL if last already */ - - void * reserved; /**< Reserved to the parser */ -} URI_TYPE(PathSegment); /**< @copydoc UriPathSegmentStructA */ - - - -/** - * Holds structured host information. - * This is either a IPv4, IPv6, plain - * text for IPvFuture or all zero for - * a registered name. - * - * @see UriUriA - * @since 0.3.0 - */ -typedef struct URI_TYPE(HostDataStruct) { - UriIp4 * ip4; /**< IPv4 address */ - UriIp6 * ip6; /**< IPv6 address */ - URI_TYPE(TextRange) ipFuture; /**< IPvFuture address */ -} URI_TYPE(HostData); /**< @copydoc UriHostDataStructA */ - - - -/** - * Represents an RFC 3986 %URI. - * Missing components can be {NULL, NULL} ranges. - * - * @see uriFreeUriMembersA - * @see uriFreeUriMembersMmA - * @see UriParserStateA - * @since 0.3.0 - */ -typedef struct URI_TYPE(UriStruct) { - URI_TYPE(TextRange) scheme; /**< Scheme (e.g. "http") */ - URI_TYPE(TextRange) userInfo; /**< User info (e.g. "user:pass") */ - URI_TYPE(TextRange) hostText; /**< Host text (set for all hosts, excluding square brackets) */ - URI_TYPE(HostData) hostData; /**< Structured host type specific data */ - URI_TYPE(TextRange) portText; /**< Port (e.g. "80") */ - URI_TYPE(PathSegment) * pathHead; /**< Head of a linked list of path segments */ - URI_TYPE(PathSegment) * pathTail; /**< Tail of the list behind pathHead */ - URI_TYPE(TextRange) query; /**< Query without leading "?" */ - URI_TYPE(TextRange) fragment; /**< Query without leading "#" */ - UriBool absolutePath; /**< Absolute path flag, distincting "a" and "/a"; - always URI_FALSE for URIs with host */ - UriBool owner; /**< Memory owner flag */ - - void * reserved; /**< Reserved to the parser */ -} URI_TYPE(Uri); /**< @copydoc UriUriStructA */ - - - -/** - * Represents a state of the %URI parser. - * Missing components can be NULL to reflect - * a components absence. - * - * @see uriFreeUriMembersA - * @see uriFreeUriMembersMmA - * @since 0.3.0 - */ -typedef struct URI_TYPE(ParserStateStruct) { - URI_TYPE(Uri) * uri; /**< Plug in the %URI structure to be filled while parsing here */ - int errorCode; /**< Code identifying the error which occurred */ - const URI_CHAR * errorPos; /**< Pointer to position in case of a syntax error */ - - void * reserved; /**< Reserved to the parser */ -} URI_TYPE(ParserState); /**< @copydoc UriParserStateStructA */ - - - -/** - * Represents a query element. - * More precisely it is a node in a linked - * list of query elements. - * - * @since 0.7.0 - */ -typedef struct URI_TYPE(QueryListStruct) { - const URI_CHAR * key; /**< Key of the query element */ - const URI_CHAR * value; /**< Value of the query element, can be NULL */ - - struct URI_TYPE(QueryListStruct) * next; /**< Pointer to the next key/value pair in the list, can be NULL if last already */ -} URI_TYPE(QueryList); /**< @copydoc UriQueryListStructA */ - - - -/** - * Parses a RFC 3986 %URI. - * Uses default libc-based memory manager. - * - * @param state INOUT: Parser state with set output %URI, must not be NULL - * @param first IN: Pointer to the first character to parse, must not be NULL - * @param afterLast IN: Pointer to the character after the last to parse, must not be NULL - * @return 0 on success, error code otherwise - * - * @see uriParseUriA - * @see uriParseSingleUriA - * @see uriParseSingleUriExA - * @see uriToStringA - * @since 0.3.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriExA (with "Single"). - */ -URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast); - - - -/** - * Parses a RFC 3986 %URI. - * Uses default libc-based memory manager. - * - * @param state INOUT: Parser state with set output %URI, must not be NULL - * @param text IN: Text to parse, must not be NULL - * @return 0 on success, error code otherwise - * - * @see uriParseUriExA - * @see uriParseSingleUriA - * @see uriParseSingleUriExA - * @see uriToStringA - * @since 0.3.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriA (with "Single"). - */ -URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, - const URI_CHAR * text); - - - -/** - * Parses a single RFC 3986 %URI. - * Uses default libc-based memory manager. - * - * @param uri OUT: Output %URI, must not be NULL - * @param text IN: Pointer to the first character to parse, - * must not be NULL - * @param errorPos OUT: Pointer to a pointer to the first character - * causing a syntax error, can be NULL; - * only set when URI_ERROR_SYNTAX was returned - * @return 0 on success, error code otherwise - * - * @see uriParseSingleUriExA - * @see uriParseSingleUriExMmA - * @see uriToStringA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, - const URI_CHAR * text, const URI_CHAR ** errorPos); - - - -/** - * Parses a single RFC 3986 %URI. - * Uses default libc-based memory manager. - * - * @param uri OUT: Output %URI, must not be NULL - * @param first IN: Pointer to the first character to parse, - * must not be NULL - * @param afterLast IN: Pointer to the character after the last to - * parse, can be NULL - * (to use first + strlen(first)) - * @param errorPos OUT: Pointer to a pointer to the first character - * causing a syntax error, can be NULL; - * only set when URI_ERROR_SYNTAX was returned - * @return 0 on success, error code otherwise - * - * @see uriParseSingleUriA - * @see uriParseSingleUriExMmA - * @see uriToStringA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos); - - - -/** - * Parses a single RFC 3986 %URI. - * - * @param uri OUT: Output %URI, must not be NULL - * @param first IN: Pointer to the first character to parse, - * must not be NULL - * @param afterLast IN: Pointer to the character after the last to - * parse, can be NULL - * (to use first + strlen(first)) - * @param errorPos OUT: Pointer to a pointer to the first character - * causing a syntax error, can be NULL; - * only set when URI_ERROR_SYNTAX was returned - * @param memory IN: Memory manager to use, NULL for default libc - * @return 0 on success, error code otherwise - * - * @see uriParseSingleUriA - * @see uriParseSingleUriExA - * @see uriToStringA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos, UriMemoryManager * memory); - - - -/** - * Frees all memory associated with the members - * of the %URI structure. Note that the structure - * itself is not freed, only its members. - * Uses default libc-based memory manager. - * - * @param uri INOUT: %URI structure whose members should be freed - * - * @see uriFreeUriMembersMmA - * @since 0.3.0 - */ -URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); - - - -/** - * Frees all memory associated with the members - * of the %URI structure. Note that the structure - * itself is not freed, only its members. - * - * @param uri INOUT: %URI structure whose members should be freed - * @param memory IN: Memory manager to use, NULL for default libc - * @return 0 on success, error code otherwise - * - * @see uriFreeUriMembersA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); - - - -/** - * Percent-encodes all unreserved characters from the input string and - * writes the encoded version to the output string. - * Be sure to allocate 3 times the space of the input buffer for - * the output buffer for normalizeBreaks == URI_FALSE and 6 times - * the space for normalizeBreaks == URI_TRUE - * (since e.g. "\x0d" becomes "%0D%0A" in that case) - * - * @param inFirst IN: Pointer to first character of the input text - * @param inAfterLast IN: Pointer after the last character of the input text - * @param out OUT: Encoded text destination - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @return Position of terminator in output string - * - * @see uriEscapeA - * @see uriUnescapeInPlaceExA - * @since 0.5.2 - */ -URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, - const URI_CHAR * inAfterLast, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks); - - - -/** - * Percent-encodes all unreserved characters from the input string and - * writes the encoded version to the output string. - * Be sure to allocate 3 times the space of the input buffer for - * the output buffer for normalizeBreaks == URI_FALSE and 6 times - * the space for normalizeBreaks == URI_TRUE - * (since e.g. "\x0d" becomes "%0D%0A" in that case) - * - * @param in IN: Text source - * @param out OUT: Encoded text destination - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @return Position of terminator in output string - * - * @see uriEscapeExA - * @see uriUnescapeInPlaceA - * @since 0.5.0 - */ -URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks); - - - -/** - * Unescapes percent-encoded groups in a given string. - * E.g. "%20" will become " ". Unescaping is done in place. - * The return value will be point to the new position - * of the terminating zero. Use this value to get the new - * length of the string. NULL is only returned if inout - * is NULL. - * - * @param inout INOUT: Text to unescape/decode - * @param plusToSpace IN: Whether to convert '+' to ' ' or not - * @param breakConversion IN: Line break conversion mode - * @return Pointer to new position of the terminating zero - * - * @see uriUnescapeInPlaceA - * @see uriEscapeExA - * @since 0.5.0 - */ -URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, - UriBool plusToSpace, UriBreakConversion breakConversion); - - - -/** - * Unescapes percent-encoded groups in a given string. - * E.g. "%20" will become " ". Unescaping is done in place. - * The return value will be point to the new position - * of the terminating zero. Use this value to get the new - * length of the string. NULL is only returned if inout - * is NULL. - * - * NOTE: '+' is not decoded to ' ' and line breaks are not converted. - * Use the more advanced UnescapeInPlaceEx for that features instead. - * - * @param inout INOUT: Text to unescape/decode - * @return Pointer to new position of the terminating zero - * - * @see uriUnescapeInPlaceExA - * @see uriEscapeA - * @since 0.3.0 - */ -URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); - - - -/** - * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * Uses default libc-based memory manager. - * NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later. - * - * @param absoluteDest OUT: Result %URI - * @param relativeSource IN: Reference to resolve - * @param absoluteBase IN: Base %URI to apply - * @return Error code or 0 on success - * - * @see uriRemoveBaseUriA - * @see uriRemoveBaseUriMmA - * @see uriAddBaseUriExA - * @see uriAddBaseUriExMmA - * @since 0.4.0 - */ -URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase); - - - -/** - * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * Uses default libc-based memory manager. - * NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later. - * - * @param absoluteDest OUT: Result %URI - * @param relativeSource IN: Reference to resolve - * @param absoluteBase IN: Base %URI to apply - * @param options IN: Configuration to apply - * @return Error code or 0 on success - * - * @see uriRemoveBaseUriA - * @see uriAddBaseUriA - * @see uriAddBaseUriExMmA - * @since 0.8.1 - */ -URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase, - UriResolutionOptions options); - - - -/** - * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * NOTE: On success you have to call uriFreeUriMembersMmA on \p absoluteDest manually later. - * - * @param absoluteDest OUT: Result %URI - * @param relativeSource IN: Reference to resolve - * @param absoluteBase IN: Base %URI to apply - * @param options IN: Configuration to apply - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriRemoveBaseUriA - * @see uriRemoveBaseUriMmA - * @see uriAddBaseUriA - * @see uriAddBaseUriExA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase, - UriResolutionOptions options, UriMemoryManager * memory); - - - -/** - * Tries to make a relative %URI (a reference) from an - * absolute %URI and a given base %URI. The resulting %URI is going to be - * relative if the absolute %URI and base %UI share both scheme and authority. - * If that is not the case, the result will still be - * an absolute URI (with scheme part if necessary). - * Uses default libc-based memory manager. - * NOTE: On success you have to call uriFreeUriMembersA on - * \p dest manually later. - * - * @param dest OUT: Result %URI - * @param absoluteSource IN: Absolute %URI to make relative - * @param absoluteBase IN: Base %URI - * @param domainRootMode IN: Create %URI with path relative to domain root - * @return Error code or 0 on success - * - * @see uriRemoveBaseUriMmA - * @see uriAddBaseUriA - * @see uriAddBaseUriExA - * @see uriAddBaseUriExMmA - * @since 0.5.2 - */ -URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absoluteSource, - const URI_TYPE(Uri) * absoluteBase, - UriBool domainRootMode); - - - -/** - * Tries to make a relative %URI (a reference) from an - * absolute %URI and a given base %URI. The resulting %URI is going to be - * relative if the absolute %URI and base %UI share both scheme and authority. - * If that is not the case, the result will still be - * an absolute URI (with scheme part if necessary). - * NOTE: On success you have to call uriFreeUriMembersMmA on - * \p dest manually later. - * - * @param dest OUT: Result %URI - * @param absoluteSource IN: Absolute %URI to make relative - * @param absoluteBase IN: Base %URI - * @param domainRootMode IN: Create %URI with path relative to domain root - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriRemoveBaseUriA - * @see uriAddBaseUriA - * @see uriAddBaseUriExA - * @see uriAddBaseUriExMmA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absoluteSource, - const URI_TYPE(Uri) * absoluteBase, - UriBool domainRootMode, UriMemoryManager * memory); - - - -/** - * Checks two URIs for equivalence. Comparison is done - * the naive way, without prior normalization. - * NOTE: Two NULL URIs are equal as well. - * - * @param a IN: First %URI - * @param b IN: Second %URI - * @return URI_TRUE when equal, URI_FAlSE else - * - * @since 0.4.0 - */ -URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, - const URI_TYPE(Uri) * b); - - - -/** - * Calculates the number of characters needed to store the - * string representation of the given %URI excluding the - * terminator. - * - * @param uri IN: %URI to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator - * @return Error code or 0 on success - * - * @see uriToStringA - * @since 0.5.0 - */ -URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, - int * charsRequired); - - - -/** - * Converts a %URI structure back to text as described in - * section 5.3 of RFC 3986. - * - * @param dest OUT: Output destination - * @param uri IN: %URI to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the %URI is too long! - * @return Error code or 0 on success - * - * @see uriToStringCharsRequiredA - * @since 0.4.0 - */ -URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, - int maxChars, int * charsWritten); - - - -/** - * Determines the components of a %URI that are not normalized. - * - * @param uri IN: %URI to check - * @return Normalization job mask - * - * @see uriNormalizeSyntaxA - * @see uriNormalizeSyntaxExA - * @see uriNormalizeSyntaxExMmA - * @see uriNormalizeSyntaxMaskRequiredExA - * @since 0.5.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriNormalizeSyntaxMaskRequiredExA (with "Ex"). - */ -URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( - const URI_TYPE(Uri) * uri); - - - -/** - * Determines the components of a %URI that are not normalized. - * - * @param uri IN: %URI to check - * @param outMask OUT: Normalization job mask - * @return Error code or 0 on success - * - * @see uriNormalizeSyntaxA - * @see uriNormalizeSyntaxExA - * @see uriNormalizeSyntaxExMmA - * @see uriNormalizeSyntaxMaskRequiredA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( - const URI_TYPE(Uri) * uri, unsigned int * outMask); - - - -/** - * Normalizes a %URI using a normalization mask. - * The normalization mask decides what components are normalized. - * - * NOTE: If necessary the %URI becomes owner of all memory - * behind the text pointed to. Text is duplicated in that case. - * Uses default libc-based memory manager. - * - * @param uri INOUT: %URI to normalize - * @param mask IN: Normalization mask - * @return Error code or 0 on success - * - * @see uriNormalizeSyntaxA - * @see uriNormalizeSyntaxExMmA - * @see uriNormalizeSyntaxMaskRequiredA - * @since 0.5.0 - */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, - unsigned int mask); - - - -/** - * Normalizes a %URI using a normalization mask. - * The normalization mask decides what components are normalized. - * - * NOTE: If necessary the %URI becomes owner of all memory - * behind the text pointed to. Text is duplicated in that case. - * - * @param uri INOUT: %URI to normalize - * @param mask IN: Normalization mask - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriNormalizeSyntaxA - * @see uriNormalizeSyntaxExA - * @see uriNormalizeSyntaxMaskRequiredA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, - unsigned int mask, UriMemoryManager * memory); - - - -/** - * Normalizes all components of a %URI. - * - * NOTE: If necessary the %URI becomes owner of all memory - * behind the text pointed to. Text is duplicated in that case. - * Uses default libc-based memory manager. - * - * @param uri INOUT: %URI to normalize - * @return Error code or 0 on success - * - * @see uriNormalizeSyntaxExA - * @see uriNormalizeSyntaxExMmA - * @see uriNormalizeSyntaxMaskRequiredA - * @since 0.5.0 - */ -URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); - - - -/** - * Converts a Unix filename to a %URI string. - * The destination buffer must be large enough to hold 7 + 3 * len(filename) + 1 - * characters in case of an absolute filename or 3 * len(filename) + 1 in case - * of a relative filename. - * - * EXAMPLE - * Input: "/bin/bash" - * Output: "file:///bin/bash" - * - * @param filename IN: Unix filename to convert - * @param uriString OUT: Destination to write %URI string to - * @return Error code or 0 on success - * - * @see uriUriStringToUnixFilenameA - * @see uriWindowsFilenameToUriStringA - * @since 0.5.2 - */ -URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, - URI_CHAR * uriString); - - - -/** - * Converts a Windows filename to a %URI string. - * The destination buffer must be large enough to hold 8 + 3 * len(filename) + 1 - * characters in case of an absolute filename or 3 * len(filename) + 1 in case - * of a relative filename. - * - * EXAMPLE - * Input: "E:\\Documents and Settings" - * Output: "file:///E:/Documents%20and%20Settings" - * - * @param filename IN: Windows filename to convert - * @param uriString OUT: Destination to write %URI string to - * @return Error code or 0 on success - * - * @see uriUriStringToWindowsFilenameA - * @see uriUnixFilenameToUriStringA - * @since 0.5.2 - */ -URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, - URI_CHAR * uriString); - - - -/** - * Extracts a Unix filename from a %URI string. - * The destination buffer must be large enough to hold len(uriString) + 1 - 7 - * characters in case of an absolute %URI or len(uriString) + 1 in case - * of a relative %URI. - * - * @param uriString IN: %URI string to convert - * @param filename OUT: Destination to write filename to - * @return Error code or 0 on success - * - * @see uriUnixFilenameToUriStringA - * @see uriUriStringToWindowsFilenameA - * @since 0.5.2 - */ -URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, - URI_CHAR * filename); - - - -/** - * Extracts a Windows filename from a %URI string. - * The destination buffer must be large enough to hold len(uriString) + 1 - 5 - * characters in case of an absolute %URI or len(uriString) + 1 in case - * of a relative %URI. - * - * @param uriString IN: %URI string to convert - * @param filename OUT: Destination to write filename to - * @return Error code or 0 on success - * - * @see uriWindowsFilenameToUriStringA - * @see uriUriStringToUnixFilenameA - * @since 0.5.2 - */ -URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, - URI_CHAR * filename); - - - -/** - * Calculates the number of characters needed to store the - * string representation of the given query list excluding the - * terminator. It is assumed that line breaks are will be - * normalized to "%0D%0A". - * - * @param queryList IN: Query list to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator - * @return Error code or 0 on success - * - * @see uriComposeQueryCharsRequiredExA - * @see uriComposeQueryA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( - const URI_TYPE(QueryList) * queryList, int * charsRequired); - - - -/** - * Calculates the number of characters needed to store the - * string representation of the given query list excluding the - * terminator. - * - * @param queryList IN: Query list to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @return Error code or 0 on success - * - * @see uriComposeQueryCharsRequiredA - * @see uriComposeQueryExA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( - const URI_TYPE(QueryList) * queryList, - int * charsRequired, UriBool spaceToPlus, UriBool normalizeBreaks); - - - -/** - * Converts a query list structure back to a query string. - * The composed string does not start with '?', - * on the way ' ' is converted to '+' and line breaks are - * normalized to "%0D%0A". - * - * @param dest OUT: Output destination - * @param queryList IN: Query list to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the query list is too long! - * @return Error code or 0 on success - * - * @see uriComposeQueryExA - * @see uriComposeQueryMallocA - * @see uriComposeQueryMallocExA - * @see uriComposeQueryMallocExMmA - * @see uriComposeQueryCharsRequiredA - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten); - - - -/** - * Converts a query list structure back to a query string. - * The composed string does not start with '?'. - * - * @param dest OUT: Output destination - * @param queryList IN: Query list to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the query list is too long! - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @return Error code or 0 on success - * - * @see uriComposeQueryA - * @see uriComposeQueryMallocA - * @see uriComposeQueryMallocExA - * @see uriComposeQueryMallocExMmA - * @see uriComposeQueryCharsRequiredExA - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten, - UriBool spaceToPlus, UriBool normalizeBreaks); - - - -/** - * Converts a query list structure back to a query string. - * Memory for this string is allocated internally. - * The composed string does not start with '?', - * on the way ' ' is converted to '+' and line breaks are - * normalized to "%0D%0A". - * Uses default libc-based memory manager. - * - * @param dest OUT: Output destination - * @param queryList IN: Query list to convert - * @return Error code or 0 on success - * - * @see uriComposeQueryMallocExA - * @see uriComposeQueryMallocExMmA - * @see uriComposeQueryA - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList); - - - -/** - * Converts a query list structure back to a query string. - * Memory for this string is allocated internally. - * The composed string does not start with '?'. - * Uses default libc-based memory manager. - * - * @param dest OUT: Output destination - * @param queryList IN: Query list to convert - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @return Error code or 0 on success - * - * @see uriComposeQueryMallocA - * @see uriComposeQueryMallocExMmA - * @see uriComposeQueryExA - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks); - - - -/** - * Converts a query list structure back to a query string. - * Memory for this string is allocated internally. - * The composed string does not start with '?'. - * - * @param dest OUT: Output destination - * @param queryList IN: Query list to convert - * @param spaceToPlus IN: Whether to convert ' ' to '+' or not - * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriComposeQueryMallocA - * @see uriComposeQueryMallocExA - * @see uriComposeQueryExA - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks, - UriMemoryManager * memory); - - - -/** - * Constructs a query list from the raw query string of a given URI. - * On the way '+' is converted back to ' ', line breaks are not modified. - * Uses default libc-based memory manager. - * - * @param dest OUT: Output destination - * @param itemCount OUT: Number of items found, can be NULL - * @param first IN: Pointer to first character after '?' - * @param afterLast IN: Pointer to character after the last one still in - * @return Error code or 0 on success - * - * @see uriDissectQueryMallocExA - * @see uriDissectQueryMallocExMmA - * @see uriComposeQueryA - * @see uriFreeQueryListA - * @see uriFreeQueryListMmA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast); - - - -/** - * Constructs a query list from the raw query string of a given URI. - * Uses default libc-based memory manager. - * - * @param dest OUT: Output destination - * @param itemCount OUT: Number of items found, can be NULL - * @param first IN: Pointer to first character after '?' - * @param afterLast IN: Pointer to character after the last one still in - * @param plusToSpace IN: Whether to convert '+' to ' ' or not - * @param breakConversion IN: Line break conversion mode - * @return Error code or 0 on success - * - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExMmA - * @see uriComposeQueryExA - * @see uriFreeQueryListA - * @since 0.7.0 - */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion); - - - -/** - * Constructs a query list from the raw query string of a given URI. - * - * @param dest OUT: Output destination - * @param itemCount OUT: Number of items found, can be NULL - * @param first IN: Pointer to first character after '?' - * @param afterLast IN: Pointer to character after the last one still in - * @param plusToSpace IN: Whether to convert '+' to ' ' or not - * @param breakConversion IN: Line break conversion mode - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriDissectQueryMallocA - * @see uriDissectQueryMallocExA - * @see uriComposeQueryExA - * @see uriFreeQueryListA - * @see uriFreeQueryListMmA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion, - UriMemoryManager * memory); - - - -/** - * Frees all memory associated with the given query list. - * The structure itself is freed as well. - * - * @param queryList INOUT: Query list to free - * - * @see uriFreeQueryListMmA - * @since 0.7.0 - */ -URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); - - - -/** - * Frees all memory associated with the given query list. - * The structure itself is freed as well. - * - * @param queryList INOUT: Query list to free - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriFreeQueryListA - * @since 0.9.0 - */ -URI_PUBLIC int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, - UriMemoryManager * memory); - - - -/** - * Makes the %URI hold copies of strings so that it no longer depends - * on the original %URI string. If the %URI is already owner of copies, - * this function returns URI_TRUE and does not modify the %URI further. - * - * Uses default libc-based memory manager. - * - * @param uri INOUT: %URI to make independent - * @return Error code or 0 on success - * - * @see uriMakeOwnerMmA - * @since 0.9.4 - */ -URI_PUBLIC int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri); - - - -/** - * Makes the %URI hold copies of strings so that it no longer depends - * on the original %URI string. If the %URI is already owner of copies, - * this function returns URI_TRUE and does not modify the %URI further. - * - * @param uri INOUT: %URI to make independent - * @param memory IN: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriMakeOwnerA - * @since 0.9.4 - */ -URI_PUBLIC int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); - - - -#ifdef __cplusplus -} -#endif - - - -#endif -#endif diff --git a/external/uriparser/include/uriparser/UriBase.h b/external/uriparser/include/uriparser/UriBase.h deleted file mode 100644 index 565abcf..0000000 --- a/external/uriparser/include/uriparser/UriBase.h +++ /dev/null @@ -1,377 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriBase.h - * Holds definitions independent of the encoding pass. - */ - -#ifndef URI_BASE_H -#define URI_BASE_H 1 - - - -/* Version helper macro */ -#define URI_ANSI_TO_UNICODE(x) L##x - - - -/* Version */ -#define URI_VER_MAJOR 0 -#define URI_VER_MINOR 9 -#define URI_VER_RELEASE 5 -#define URI_VER_SUFFIX_ANSI "" -#define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) - - - -/* More version helper macros */ -#define URI_INT_TO_ANSI_HELPER(x) #x -#define URI_INT_TO_ANSI(x) URI_INT_TO_ANSI_HELPER(x) - -#define URI_INT_TO_UNICODE_HELPER(x) URI_ANSI_TO_UNICODE(#x) -#define URI_INT_TO_UNICODE(x) URI_INT_TO_UNICODE_HELPER(x) - -#define URI_VER_ANSI_HELPER(ma, mi, r, s) \ - URI_INT_TO_ANSI(ma) "." \ - URI_INT_TO_ANSI(mi) "." \ - URI_INT_TO_ANSI(r) \ - s - -#define URI_VER_UNICODE_HELPER(ma, mi, r, s) \ - URI_INT_TO_UNICODE(ma) L"." \ - URI_INT_TO_UNICODE(mi) L"." \ - URI_INT_TO_UNICODE(r) \ - s - - - -/* Full version strings */ -#define URI_VER_ANSI URI_VER_ANSI_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_ANSI) -#define URI_VER_UNICODE URI_VER_UNICODE_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_UNICODE) - - - -/* Unused parameter macro */ -#ifdef __GNUC__ -# define URI_UNUSED(x) unused_##x __attribute__((unused)) -#else -# define URI_UNUSED(x) x -#endif - - - -/* Import/export decorator */ -#if defined(URI_STATIC_BUILD) -# define URI_PUBLIC -#else -# if defined(URI_LIBRARY_BUILD) -# if defined(_MSC_VER) -# define URI_PUBLIC __declspec(dllexport) -# elif defined(URI_VISIBILITY) -# define URI_PUBLIC __attribute__ ((visibility("default"))) -# else -# define URI_PUBLIC -# endif -# else -# if defined(_MSC_VER) -# define URI_PUBLIC __declspec(dllimport) -# else -# define URI_PUBLIC -# endif -# endif -#endif - - - -typedef int UriBool; /**< Boolean type */ - -#define URI_TRUE 1 -#define URI_FALSE 0 - - - -/* Shared errors */ -#define URI_SUCCESS 0 -#define URI_ERROR_SYNTAX 1 /* Parsed text violates expected format */ -#define URI_ERROR_NULL 2 /* One of the params passed was NULL - although it mustn't be */ -#define URI_ERROR_MALLOC 3 /* Requested memory could not be allocated */ -#define URI_ERROR_OUTPUT_TOO_LARGE 4 /* Some output is to large for the receiving buffer */ -#define URI_ERROR_NOT_IMPLEMENTED 8 /* The called function is not implemented yet */ -#define URI_ERROR_RANGE_INVALID 9 /* The parameters passed contained invalid ranges */ -#define URI_ERROR_MEMORY_MANAGER_INCOMPLETE 10 /* [>=0.9.0] The UriMemoryManager passed does not implement all needed functions */ - - -/* Errors specific to ToString */ -#define URI_ERROR_TOSTRING_TOO_LONG URI_ERROR_OUTPUT_TOO_LARGE /* Deprecated, test for URI_ERROR_OUTPUT_TOO_LARGE instead */ - -/* Errors specific to AddBaseUri */ -#define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */ - -/* Errors specific to RemoveBaseUri */ -#define URI_ERROR_REMOVEBASE_REL_BASE 6 /* Given base is not absolute */ -#define URI_ERROR_REMOVEBASE_REL_SOURCE 7 /* Given base is not absolute */ - -/* Error specific to uriTestMemoryManager */ -#define URI_ERROR_MEMORY_MANAGER_FAULTY 11 /* [>=0.9.0] The UriMemoryManager given did not pass the test suite */ - - -#ifndef URI_DOXYGEN -# include /* For NULL, snprintf */ -# include /* For wchar_t */ -# include /* For strlen, memset, memcpy */ -# include /* For malloc */ -#endif /* URI_DOXYGEN */ - - - -/** - * Holds an IPv4 address. - */ -typedef struct UriIp4Struct { - unsigned char data[4]; /**< Each octet in one byte */ -} UriIp4; /**< @copydoc UriIp4Struct */ - - - -/** - * Holds an IPv6 address. - */ -typedef struct UriIp6Struct { - unsigned char data[16]; /**< Each quad in two bytes */ -} UriIp6; /**< @copydoc UriIp6Struct */ - - -struct UriMemoryManagerStruct; /* foward declaration to break loop */ - - -/** - * Function signature that custom malloc(3) functions must conform to - * - * @since 0.9.0 - */ -typedef void * (*UriFuncMalloc)(struct UriMemoryManagerStruct *, size_t); - -/** - * Function signature that custom calloc(3) functions must conform to - * - * @since 0.9.0 - */ -typedef void * (*UriFuncCalloc)(struct UriMemoryManagerStruct *, size_t, size_t); - -/** - * Function signature that custom realloc(3) functions must conform to - * - * @since 0.9.0 - */ -typedef void * (*UriFuncRealloc)(struct UriMemoryManagerStruct *, void *, size_t); - -/** - * Function signature that custom reallocarray(3) functions must conform to - * - * @since 0.9.0 - */ -typedef void * (*UriFuncReallocarray)(struct UriMemoryManagerStruct *, void *, size_t, size_t); - -/** - * Function signature that custom free(3) functions must conform to - * - * @since 0.9.0 - */ -typedef void (*UriFuncFree)(struct UriMemoryManagerStruct *, void *); - - -/** - * Class-like interface of custom memory managers - * - * @see uriCompleteMemoryManager - * @see uriEmulateCalloc - * @see uriEmulateReallocarray - * @see uriTestMemoryManager - * @since 0.9.0 - */ -typedef struct UriMemoryManagerStruct { - UriFuncMalloc malloc; /**< Pointer to custom malloc(3) */ - UriFuncCalloc calloc; /**< Pointer to custom calloc(3); to emulate using malloc and memset see uriEmulateCalloc */ - UriFuncRealloc realloc; /**< Pointer to custom realloc(3) */ - UriFuncReallocarray reallocarray; /**< Pointer to custom reallocarray(3); to emulate using realloc see uriEmulateReallocarray */ - UriFuncFree free; /**< Pointer to custom free(3) */ - void * userData; /**< Pointer to data that the other function members need access to */ -} UriMemoryManager; /**< @copydoc UriMemoryManagerStruct */ - - -/** - * Specifies a line break conversion mode. - */ -typedef enum UriBreakConversionEnum { - URI_BR_TO_LF, /**< Convert to Unix line breaks ("\\x0a") */ - URI_BR_TO_CRLF, /**< Convert to Windows line breaks ("\\x0d\\x0a") */ - URI_BR_TO_CR, /**< Convert to Macintosh line breaks ("\\x0d") */ - URI_BR_TO_UNIX = URI_BR_TO_LF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_LF */ - URI_BR_TO_WINDOWS = URI_BR_TO_CRLF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CRLF */ - URI_BR_TO_MAC = URI_BR_TO_CR, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CR */ - URI_BR_DONT_TOUCH /**< Copy line breaks unmodified */ -} UriBreakConversion; /**< @copydoc UriBreakConversionEnum */ - - - -/** - * Specifies which component of a %URI has to be normalized. - */ -typedef enum UriNormalizationMaskEnum { - URI_NORMALIZED = 0, /**< Do not normalize anything */ - URI_NORMALIZE_SCHEME = 1 << 0, /**< Normalize scheme (fix uppercase letters) */ - URI_NORMALIZE_USER_INFO = 1 << 1, /**< Normalize user info (fix uppercase percent-encodings) */ - URI_NORMALIZE_HOST = 1 << 2, /**< Normalize host (fix uppercase letters) */ - URI_NORMALIZE_PATH = 1 << 3, /**< Normalize path (fix uppercase percent-encodings and redundant dot segments) */ - URI_NORMALIZE_QUERY = 1 << 4, /**< Normalize query (fix uppercase percent-encodings) */ - URI_NORMALIZE_FRAGMENT = 1 << 5 /**< Normalize fragment (fix uppercase percent-encodings) */ -} UriNormalizationMask; /**< @copydoc UriNormalizationMaskEnum */ - - - -/** - * Specifies how to resolve %URI references. - */ -typedef enum UriResolutionOptionsEnum { - URI_RESOLVE_STRICTLY = 0, /**< Full RFC conformance */ - URI_RESOLVE_IDENTICAL_SCHEME_COMPAT = 1 << 0 /**< Treat %URI to resolve with identical scheme as having no scheme */ -} UriResolutionOptions; /**< @copydoc UriResolutionOptionsEnum */ - - - -/** - * Wraps a memory manager backend that only provides malloc and free - * to make a complete memory manager ready to be used. - * - * The core feature of this wrapper is that you don't need to implement - * realloc if you don't want to. The wrapped memory manager uses - * backend->malloc, memcpy, and backend->free and soieof(size_t) extra - * bytes per allocation to emulate fallback realloc for you. - * - * memory->calloc is uriEmulateCalloc. - * memory->free uses backend->free and handles the size header. - * memory->malloc uses backend->malloc and adds a size header. - * memory->realloc uses memory->malloc, memcpy, and memory->free and reads - * the size header. - * memory->reallocarray is uriEmulateReallocarray. - * - * The internal workings behind memory->free, memory->malloc, and - * memory->realloc may change so the functions exposed by these function - * pointer sshould be consided internal and not public API. - * - * @param memory OUT: Where to write the wrapped memory manager to - * @param backend IN: Memory manager to use as a backend - * @return Error code or 0 on success - * - * @see uriEmulateCalloc - * @see uriEmulateReallocarray - * @see UriMemoryManager - * @since 0.9.0 - */ -URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, - UriMemoryManager * backend); - - - -/** - * Offers emulation of calloc(3) based on memory->malloc and memset. - * See "man 3 calloc" as well. - * - * @param memory IN: Memory manager to use, should not be NULL - * @param nmemb IN: Number of elements to allocate - * @param size IN: Size in bytes per element - * @return Pointer to allocated memory or NULL - * - * @see uriCompleteMemoryManager - * @see uriEmulateReallocarray - * @see UriMemoryManager - * @since 0.9.0 - */ -URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, - size_t nmemb, size_t size); - - - -/** - * Offers emulation of reallocarray(3) based on memory->realloc. - * See "man 3 reallocarray" as well. - * - * @param memory IN: Memory manager to use, should not be NULL - * @param ptr IN: Pointer allocated using memory->malloc/... or NULL - * @param nmemb IN: Number of elements to allocate - * @param size IN: Size in bytes per element - * @return Pointer to allocated memory or NULL - * - * @see uriCompleteMemoryManager - * @see uriEmulateCalloc - * @see UriMemoryManager - * @since 0.9.0 - */ -URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, - void * ptr, size_t nmemb, size_t size); - - - -/** - * Run multiple tests against a given memory manager. - * For example, one test - * 1. allocates a small amount of memory, - * 2. writes some magic bytes to it, - * 3. reallocates it, - * 4. checks that previous values are still present, - * 5. and frees that memory. - * - * It is recommended to compile with AddressSanitizer enabled - * to take full advantage of uriTestMemoryManager. - * - * @param memory IN: Memory manager to use, should not be NULL - * @return Error code or 0 on success - * - * @see uriEmulateCalloc - * @see uriEmulateReallocarray - * @see UriMemoryManager - * @since 0.9.0 - */ -URI_PUBLIC int uriTestMemoryManager(UriMemoryManager * memory); - - - -#endif /* URI_BASE_H */ diff --git a/external/uriparser/include/uriparser/UriDefsAnsi.h b/external/uriparser/include/uriparser/UriDefsAnsi.h deleted file mode 100644 index af581b9..0000000 --- a/external/uriparser/include/uriparser/UriDefsAnsi.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriDefsAnsi.h - * Holds definitions for the ANSI pass. - * NOTE: This header is included N times, not once. - */ - -/* Allow multi inclusion */ -#include "UriDefsConfig.h" - - - -#undef URI_CHAR -#define URI_CHAR char - -#undef _UT -#define _UT(x) x - - - -#undef URI_FUNC -#define URI_FUNC(x) uri##x##A - -#undef URI_TYPE -#define URI_TYPE(x) Uri##x##A - - - -#undef URI_STRLEN -#define URI_STRLEN strlen -#undef URI_STRCPY -#define URI_STRCPY strcpy -#undef URI_STRCMP -#define URI_STRCMP strcmp -#undef URI_STRNCMP -#define URI_STRNCMP strncmp - -/* TODO Remove on next source-compatibility break */ -#undef URI_SNPRINTF -#if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) -# define URI_SNPRINTF _snprintf -#else -# define URI_SNPRINTF snprintf -#endif diff --git a/external/uriparser/include/uriparser/UriDefsConfig.h b/external/uriparser/include/uriparser/UriDefsConfig.h deleted file mode 100644 index 51bc93e..0000000 --- a/external/uriparser/include/uriparser/UriDefsConfig.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriDefsConfig.h - * Adjusts the internal configuration after processing external definitions. - */ - -#ifndef URI_DEFS_CONFIG_H -#define URI_DEFS_CONFIG_H 1 - - - -/* Deny external overriding */ -#undef URI_ENABLE_ANSI /* Internal for !URI_NO_ANSI */ -#undef URI_ENABLE_UNICODE /* Internal for !URI_NO_UNICODE */ - - - -/* Encoding */ -#ifdef URI_NO_ANSI -# ifdef URI_NO_UNICODE -/* No encoding at all */ -# error URI_NO_ANSI and URI_NO_UNICODE cannot go together. -# else -/* Wide strings only */ -# define URI_ENABLE_UNICODE 1 -# endif -#else -# ifdef URI_NO_UNICODE -/* Narrow strings only */ -# define URI_ENABLE_ANSI 1 -# else -/* Both narrow and wide strings */ -# define URI_ENABLE_ANSI 1 -# define URI_ENABLE_UNICODE 1 -# endif -#endif - - - -/* Function inlining, not ANSI/ISO C! */ -#if defined(URI_DOXYGEN) -# define URI_INLINE -#elif defined(__INTEL_COMPILER) -/* Intel C/C++ */ -/* http://predef.sourceforge.net/precomp.html#sec20 */ -/* http://www.intel.com/support/performancetools/c/windows/sb/CS-007751.htm#2 */ -# define URI_INLINE __forceinline -#elif defined(_MSC_VER) -/* Microsoft Visual C++ */ -/* http://predef.sourceforge.net/precomp.html#sec32 */ -/* http://msdn2.microsoft.com/en-us/library/ms882281.aspx */ -# define URI_INLINE __forceinline -#elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) -/* C99, "inline" is a keyword */ -# define URI_INLINE inline -#else -/* No inlining */ -# define URI_INLINE -#endif - - - -#endif /* URI_DEFS_CONFIG_H */ diff --git a/external/uriparser/include/uriparser/UriDefsUnicode.h b/external/uriparser/include/uriparser/UriDefsUnicode.h deleted file mode 100644 index 01421f5..0000000 --- a/external/uriparser/include/uriparser/UriDefsUnicode.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriDefsUnicode.h - * Holds definitions for the wide string pass. - * NOTE: This header is included N times, not once. - */ - -/* Allow multi inclusion */ -#include "UriDefsConfig.h" - - - -#undef URI_CHAR -#define URI_CHAR wchar_t - -#undef _UT -#define _UT(x) L##x - - - -#undef URI_FUNC -#define URI_FUNC(x) uri##x##W - -#undef URI_TYPE -#define URI_TYPE(x) Uri##x##W - - - -#undef URI_STRLEN -#define URI_STRLEN wcslen -#undef URI_STRCPY -#define URI_STRCPY wcscpy -#undef URI_STRCMP -#define URI_STRCMP wcscmp -#undef URI_STRNCMP -#define URI_STRNCMP wcsncmp - -/* TODO Remove on next source-compatibility break */ -#undef URI_SNPRINTF -#if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) -# define URI_SNPRINTF _snwprintf -#else -# define URI_SNPRINTF swprintf -#endif diff --git a/external/uriparser/include/uriparser/UriIp4.h b/external/uriparser/include/uriparser/UriIp4.h deleted file mode 100644 index c2e59a6..0000000 --- a/external/uriparser/include/uriparser/UriIp4.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriIp4.h - * Holds the IPv4 parser interface. - * NOTE: This header includes itself twice. - */ - -#if (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI)) \ - || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE)) \ - || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* What encodings are enabled? */ -#include "UriDefsConfig.h" -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriIp4.h" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriIp4.h" -# undef URI_PASS_UNICODE -# endif -/* Only one pass for each encoding */ -#elif (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI) \ - && defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \ - && !defined(URI_IP4_TWICE_H_UNICODE) && defined(URI_ENABLE_UNICODE)) -# ifdef URI_PASS_ANSI -# define URI_IP4_TWICE_H_ANSI 1 -# include "UriDefsAnsi.h" -# else -# define URI_IP4_TWICE_H_UNICODE 1 -# include "UriDefsUnicode.h" -# include -# endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifndef URI_DOXYGEN -# include "UriBase.h" -#endif - - - -/** - * Converts a IPv4 text representation into four bytes. - * - * @param octetOutput Output destination - * @param first First character of IPv4 text to parse - * @param afterLast Position to stop parsing at - * @return Error code or 0 on success - */ -URI_PUBLIC int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, - const URI_CHAR * first, const URI_CHAR * afterLast); - - - -#ifdef __cplusplus -} -#endif - - - -#endif -#endif diff --git a/external/uriparser/liburiparser.pc.in b/external/uriparser/liburiparser.pc.in deleted file mode 100644 index 9547860..0000000 --- a/external/uriparser/liburiparser.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ - -Name: liburiparser -Description: URI parsing and handling library - -Version: @PROJECT_VERSION@ -URL: https://uriparser.github.io/ -Libs: -L${libdir} -luriparser -Cflags: -I${includedir} diff --git a/external/uriparser/make-distcheck.sh b/external/uriparser/make-distcheck.sh deleted file mode 100755 index 0918a08..0000000 --- a/external/uriparser/make-distcheck.sh +++ /dev/null @@ -1,115 +0,0 @@ -#! /usr/bin/env bash -# uriparser - RFC 3986 URI parsing library -# -# Copyright (C) 2018, Sebastian Pipping -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of -# its contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -set -e -set -u -PS4='# ' - -create_git_archive() ( - local tarname="$1" - local format="$2" - local git_archive_args=( - --format="${format}" - --prefix="${tarname}"/ - --output="${tarname}.${format}" - "${@:3}" - ) - set -x - git archive "${git_archive_args[@]}" HEAD -) - -compress_tarball() ( - local tarname="$1" - local command="$2" - local format="$3" - echo "${PS4}${command} -c ${*:4} < ${tarname}.tar > ${tarname}.tar.${format}" >&2 - "${command}" -c "${@:4}" < "${tarname}".tar > "${tarname}.tar.${format}" -) - -check_tarball() ( - local tarname="$1" - set -x - tar xf "${tarname}".tar - ( - cd "${tarname}" - - mkdir build - cd build - - cmake "${@:2}" .. - make - make test - make DESTDIR="${PWD}"/ROOT/ install - ) - rm -Rf "${tarname}" -) - -report() { - local tarname="$1" - echo ================================================= - echo "${tarname} archives ready for distribution:" - ls -1 "${tarname}".* - echo ================================================= -} - -cleanup() ( - local tarname="$1" - set -x - rm "${tarname}".tar -) - -main() { - local PACKAGE=uriparser - local PACKAGE_VERSION="$(git describe | sed 's,^uriparser-,,')" - local PACKAGE_TARNAME="${PACKAGE}-${PACKAGE_VERSION}" - - create_git_archive ${PACKAGE_TARNAME} tar - check_tarball ${PACKAGE_TARNAME} "$@" - - create_git_archive ${PACKAGE_TARNAME} zip -9 - - compress_tarball ${PACKAGE_TARNAME} bzip2 bz2 -9 - compress_tarball ${PACKAGE_TARNAME} gzip gz --best - compress_tarball ${PACKAGE_TARNAME} lzip lz -9 - compress_tarball ${PACKAGE_TARNAME} xz xz -e - - cleanup ${PACKAGE_TARNAME} - - report ${PACKAGE_TARNAME} -} - -main "$@" diff --git a/external/uriparser/scripts/edit_version.sh b/external/uriparser/scripts/edit_version.sh deleted file mode 100755 index 372b29b..0000000 --- a/external/uriparser/scripts/edit_version.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env bash -kwrite \ - include/uriparser/Uri.h \ - include/uriparser/UriBase.h \ - configure.ac \ - ChangeLog \ - & diff --git a/external/uriparser/scripts/release.sh b/external/uriparser/scripts/release.sh deleted file mode 100755 index ffca2fd..0000000 --- a/external/uriparser/scripts/release.sh +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/bin/env bash -( -cd $(dirname $(which "$0"))/.. || exit 1 -#################################################################### - - -echo ========== cleanup ========== -rm -vf uriparser-*.tar.* uriparser-*.zip 2> /dev/null -rm -vRf uriparser-* 2> /dev/null - -echo -echo ========== configure ========== -cmake . || exit 1 - -echo -echo ========== make distcheck ========== -./make-distcheck.sh || exit 1 - -echo -echo ========== package docs ========== -./doc/release.sh || exit 1 - - -#################################################################### -) -res=$? -[ $res = 0 ] || exit $res - -cat <<'CHECKLIST' - -Fine. - - -Have you -* run ./edit_version.sh -* updated the soname -* updated file lists - - Makefile.am - - Code::Blocks - - Visual Studio 2005 -* searched for TODO inside code using - grep -R 'TODO' include/* lib/* test/* -? - -If so .. -* upload release with ReleaseForge -* announce through .. - - Blog - - Mailing lists - - Freshmeat - - SourceForge news -* upload doc -* update doc to website -* tag svn trunk - -CHECKLIST -exit $res diff --git a/external/uriparser/src/UriCommon.c b/external/uriparser/src/UriCommon.c deleted file mode 100644 index 7ba92f2..0000000 --- a/external/uriparser/src/UriCommon.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriCommon.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriCommon.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -#endif - - - -/*extern*/ const URI_CHAR * const URI_FUNC(SafeToPointTo) = _UT("X"); -/*extern*/ const URI_CHAR * const URI_FUNC(ConstPwd) = _UT("."); -/*extern*/ const URI_CHAR * const URI_FUNC(ConstParent) = _UT(".."); - - - -void URI_FUNC(ResetUri)(URI_TYPE(Uri) * uri) { - if (uri == NULL) { - return; - } - memset(uri, 0, sizeof(URI_TYPE(Uri))); -} - - - -/* Compares two text ranges for equal text content */ -int URI_FUNC(CompareRange)( - const URI_TYPE(TextRange) * a, - const URI_TYPE(TextRange) * b) { - int diff; - - /* NOTE: Both NULL means equal! */ - if ((a == NULL) || (b == NULL)) { - return ((a == NULL) ? 0 : 1) - ((b == NULL) ? 0 : 1); - } - - /* NOTE: Both NULL means equal! */ - if ((a->first == NULL) || (b->first == NULL)) { - return ((a->first == NULL) ? 0 : 1) - ((b->first == NULL) ? 0 : 1); - } - - diff = ((int)(a->afterLast - a->first) - (int)(b->afterLast - b->first)); - if (diff > 0) { - return 1; - } else if (diff < 0) { - return -1; - } - - diff = URI_STRNCMP(a->first, b->first, (a->afterLast - a->first)); - - if (diff > 0) { - return 1; - } else if (diff < 0) { - return -1; - } - - return diff; -} - - - -UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri, - UriBool relative, UriBool pathOwned, UriMemoryManager * memory) { - URI_TYPE(PathSegment) * walker; - if ((uri == NULL) || (uri->pathHead == NULL)) { - return URI_TRUE; - } - - walker = uri->pathHead; - walker->reserved = NULL; /* Prev pointer */ - do { - UriBool removeSegment = URI_FALSE; - int len = (int)(walker->text.afterLast - walker->text.first); - switch (len) { - case 1: - if ((walker->text.first)[0] == _UT('.')) { - /* "." segment -> remove if not essential */ - URI_TYPE(PathSegment) * const prev = walker->reserved; - URI_TYPE(PathSegment) * const nextBackup = walker->next; - - /* - * Is this dot segment essential, - * i.e. is there a chance of changing semantics by dropping this dot segment? - * - * For example, changing "./http://foo" into "http://foo" would change semantics - * and hence the dot segment is essential to that case and cannot be removed. - */ - removeSegment = URI_TRUE; - if (relative && (walker == uri->pathHead) && (walker->next != NULL)) { - const URI_CHAR * ch = walker->next->text.first; - for (; ch < walker->next->text.afterLast; ch++) { - if (*ch == _UT(':')) { - removeSegment = URI_FALSE; - break; - } - } - } - - if (removeSegment) { - /* .. then let's go remove that segment. */ - /* Last segment? */ - if (walker->next != NULL) { - /* Not last segment, i.e. first or middle segment - * OLD: (prev|NULL) <- walker <- next - * NEW: (prev|NULL) <----------- next */ - walker->next->reserved = prev; - - if (prev == NULL) { - /* First but not last segment - * OLD: head -> walker -> next - * NEW: head -----------> next */ - uri->pathHead = walker->next; - } else { - /* Middle segment - * OLD: prev -> walker -> next - * NEW: prev -----------> next */ - prev->next = walker->next; - } - - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - } else { - /* Last segment */ - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - - if (prev == NULL) { - /* Last and first */ - if (URI_FUNC(IsHostSet)(uri)) { - /* Replace "." with empty segment to represent trailing slash */ - walker->text.first = URI_FUNC(SafeToPointTo); - walker->text.afterLast = URI_FUNC(SafeToPointTo); - } else { - memory->free(memory, walker); - - uri->pathHead = NULL; - uri->pathTail = NULL; - } - } else { - /* Last but not first, replace "." with empty segment to represent trailing slash */ - walker->text.first = URI_FUNC(SafeToPointTo); - walker->text.afterLast = URI_FUNC(SafeToPointTo); - } - } - - walker = nextBackup; - } - } - break; - - case 2: - if (((walker->text.first)[0] == _UT('.')) - && ((walker->text.first)[1] == _UT('.'))) { - /* Path ".." -> remove this and the previous segment */ - URI_TYPE(PathSegment) * const prev = walker->reserved; - URI_TYPE(PathSegment) * prevPrev; - URI_TYPE(PathSegment) * const nextBackup = walker->next; - - removeSegment = URI_TRUE; - if (relative) { - if (prev == NULL) { - /* We cannot remove traversal beyond because the - * URI is relative and may be resolved later. - * So we can simplify "a/../b/d" to "b/d" but - * we cannot simplify "../b/d" (outside of reference resolution). */ - removeSegment = URI_FALSE; - } else if ((prev != NULL) - && ((prev->text.afterLast - prev->text.first) == 2) - && ((prev->text.first)[0] == _UT('.')) - && ((prev->text.first)[1] == _UT('.'))) { - /* We need to protect against mis-simplifying "a/../../b" to "a/b". */ - removeSegment = URI_FALSE; - } - } - - if (removeSegment) { - if (prev != NULL) { - /* Not first segment */ - prevPrev = prev->reserved; - if (prevPrev != NULL) { - /* Not even prev is the first one - * OLD: prevPrev -> prev -> walker -> (next|NULL) - * NEW: prevPrev -------------------> (next|NULL) */ - prevPrev->next = walker->next; - if (walker->next != NULL) { - /* Update parent relationship as well - * OLD: prevPrev <- prev <- walker <- next - * NEW: prevPrev <------------------- next */ - walker->next->reserved = prevPrev; - } else { - /* Last segment -> insert "" segment to represent trailing slash, update tail */ - URI_TYPE(PathSegment) * const segment = memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment))); - if (segment == NULL) { - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - - if (pathOwned && (prev->text.first != prev->text.afterLast)) { - memory->free(memory, (URI_CHAR *)prev->text.first); - } - memory->free(memory, prev); - - return URI_FALSE; /* Raises malloc error */ - } - segment->text.first = URI_FUNC(SafeToPointTo); - segment->text.afterLast = URI_FUNC(SafeToPointTo); - prevPrev->next = segment; - uri->pathTail = segment; - } - - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - - if (pathOwned && (prev->text.first != prev->text.afterLast)) { - memory->free(memory, (URI_CHAR *)prev->text.first); - } - memory->free(memory, prev); - - walker = nextBackup; - } else { - /* Prev is the first segment */ - if (walker->next != NULL) { - uri->pathHead = walker->next; - walker->next->reserved = NULL; - - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - } else { - /* Re-use segment for "" path segment to represent trailing slash, update tail */ - URI_TYPE(PathSegment) * const segment = walker; - if (pathOwned && (segment->text.first != segment->text.afterLast)) { - memory->free(memory, (URI_CHAR *)segment->text.first); - } - segment->text.first = URI_FUNC(SafeToPointTo); - segment->text.afterLast = URI_FUNC(SafeToPointTo); - uri->pathHead = segment; - uri->pathTail = segment; - } - - if (pathOwned && (prev->text.first != prev->text.afterLast)) { - memory->free(memory, (URI_CHAR *)prev->text.first); - } - memory->free(memory, prev); - - walker = nextBackup; - } - } else { - URI_TYPE(PathSegment) * const anotherNextBackup = walker->next; - int freeWalker = URI_TRUE; - - /* First segment */ - if (walker->next != NULL) { - /* First segment of multiple -> update head - * OLD: head -> walker -> next - * NEW: head -----------> next */ - uri->pathHead = walker->next; - - /* Update parent link as well - * OLD: head <- walker <- next - * NEW: head <----------- next */ - walker->next->reserved = NULL; - } else { - if (uri->absolutePath) { - /* First and only segment -> update head - * OLD: head -> walker -> NULL - * NEW: head -----------> NULL */ - uri->pathHead = NULL; - - /* Last segment -> update tail - * OLD: tail -> walker - * NEW: tail -> NULL */ - uri->pathTail = NULL; - } else { - /* Re-use segment for "" path segment to represent trailing slash, - * then update head and tail */ - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - walker->text.first = URI_FUNC(SafeToPointTo); - walker->text.afterLast = URI_FUNC(SafeToPointTo); - freeWalker = URI_FALSE; - } - } - - if (freeWalker) { - if (pathOwned && (walker->text.first != walker->text.afterLast)) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - } - - walker = anotherNextBackup; - } - } - } - break; - } /* end of switch */ - - if (!removeSegment) { - /* .. then let's move to the next element, and start again. */ - if (walker->next != NULL) { - walker->next->reserved = walker; - } else { - /* Last segment -> update tail */ - uri->pathTail = walker; - } - walker = walker->next; - } - } while (walker != NULL); - - return URI_TRUE; -} - - - -/* Properly removes "." and ".." path segments */ -UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory) { - const UriBool ABSOLUTE = URI_FALSE; - if (uri == NULL) { - return URI_TRUE; - } - return URI_FUNC(RemoveDotSegmentsEx)(uri, ABSOLUTE, uri->owner, memory); -} - - - -unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) { - switch (hexdig) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - return (unsigned char)(9 + hexdig - _UT('9')); - - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): - return (unsigned char)(15 + hexdig - _UT('f')); - - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): - return (unsigned char)(15 + hexdig - _UT('F')); - - default: - return 0; - } -} - - - -URI_CHAR URI_FUNC(HexToLetter)(unsigned int value) { - /* Uppercase recommended in section 2.1. of RFC 3986 * - * http://tools.ietf.org/html/rfc3986#section-2.1 */ - return URI_FUNC(HexToLetterEx)(value, URI_TRUE); -} - - - -URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase) { - switch (value) { - case 0: return _UT('0'); - case 1: return _UT('1'); - case 2: return _UT('2'); - case 3: return _UT('3'); - case 4: return _UT('4'); - case 5: return _UT('5'); - case 6: return _UT('6'); - case 7: return _UT('7'); - case 8: return _UT('8'); - case 9: return _UT('9'); - - case 10: return (uppercase == URI_TRUE) ? _UT('A') : _UT('a'); - case 11: return (uppercase == URI_TRUE) ? _UT('B') : _UT('b'); - case 12: return (uppercase == URI_TRUE) ? _UT('C') : _UT('c'); - case 13: return (uppercase == URI_TRUE) ? _UT('D') : _UT('d'); - case 14: return (uppercase == URI_TRUE) ? _UT('E') : _UT('e'); - default: return (uppercase == URI_TRUE) ? _UT('F') : _UT('f'); - } -} - - - -/* Checks if a URI has the host component set. */ -UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri) { - return (uri != NULL) - && ((uri->hostText.first != NULL) - || (uri->hostData.ip4 != NULL) - || (uri->hostData.ip6 != NULL) - || (uri->hostData.ipFuture.first != NULL) - ); -} - - - -/* Copies the path segment list from one URI to another. */ -UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * source, UriMemoryManager * memory) { - if (source->pathHead == NULL) { - /* No path component */ - dest->pathHead = NULL; - dest->pathTail = NULL; - } else { - /* Copy list but not the text contained */ - URI_TYPE(PathSegment) * sourceWalker = source->pathHead; - URI_TYPE(PathSegment) * destPrev = NULL; - do { - URI_TYPE(PathSegment) * cur = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); - if (cur == NULL) { - /* Fix broken list */ - if (destPrev != NULL) { - destPrev->next = NULL; - } - return URI_FALSE; /* Raises malloc error */ - } - - /* From this functions usage we know that * - * the dest URI cannot be uri->owner */ - cur->text = sourceWalker->text; - if (destPrev == NULL) { - /* First segment ever */ - dest->pathHead = cur; - } else { - destPrev->next = cur; - } - destPrev = cur; - sourceWalker = sourceWalker->next; - } while (sourceWalker != NULL); - dest->pathTail = destPrev; - dest->pathTail->next = NULL; - } - - dest->absolutePath = source->absolutePath; - return URI_TRUE; -} - - - -/* Copies the authority part of an URI over to another. */ -UriBool URI_FUNC(CopyAuthority)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * source, UriMemoryManager * memory) { - /* From this functions usage we know that * - * the dest URI cannot be uri->owner */ - - /* Copy userInfo */ - dest->userInfo = source->userInfo; - - /* Copy hostText */ - dest->hostText = source->hostText; - - /* Copy hostData */ - if (source->hostData.ip4 != NULL) { - dest->hostData.ip4 = memory->malloc(memory, sizeof(UriIp4)); - if (dest->hostData.ip4 == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - *(dest->hostData.ip4) = *(source->hostData.ip4); - dest->hostData.ip6 = NULL; - dest->hostData.ipFuture.first = NULL; - dest->hostData.ipFuture.afterLast = NULL; - } else if (source->hostData.ip6 != NULL) { - dest->hostData.ip4 = NULL; - dest->hostData.ip6 = memory->malloc(memory, sizeof(UriIp6)); - if (dest->hostData.ip6 == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - *(dest->hostData.ip6) = *(source->hostData.ip6); - dest->hostData.ipFuture.first = NULL; - dest->hostData.ipFuture.afterLast = NULL; - } else { - dest->hostData.ip4 = NULL; - dest->hostData.ip6 = NULL; - dest->hostData.ipFuture = source->hostData.ipFuture; - } - - /* Copy portText */ - dest->portText = source->portText; - - return URI_TRUE; -} - - - -UriBool URI_FUNC(FixAmbiguity)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory) { - URI_TYPE(PathSegment) * segment; - - if ( /* Case 1: absolute path, empty first segment */ - (uri->absolutePath - && (uri->pathHead != NULL) - && (uri->pathHead->text.afterLast == uri->pathHead->text.first)) - - /* Case 2: relative path, empty first and second segment */ - || (!uri->absolutePath - && (uri->pathHead != NULL) - && (uri->pathHead->next != NULL) - && (uri->pathHead->text.afterLast == uri->pathHead->text.first) - && (uri->pathHead->next->text.afterLast == uri->pathHead->next->text.first))) { - /* NOOP */ - } else { - return URI_TRUE; - } - - segment = memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment))); - if (segment == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - - /* Insert "." segment in front */ - segment->next = uri->pathHead; - segment->text.first = URI_FUNC(ConstPwd); - segment->text.afterLast = URI_FUNC(ConstPwd) + 1; - uri->pathHead = segment; - return URI_TRUE; -} - - - -void URI_FUNC(FixEmptyTrailSegment)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory) { - /* Fix path if only one empty segment */ - if (!uri->absolutePath - && !URI_FUNC(IsHostSet)(uri) - && (uri->pathHead != NULL) - && (uri->pathHead->next == NULL) - && (uri->pathHead->text.first == uri->pathHead->text.afterLast)) { - memory->free(memory, uri->pathHead); - uri->pathHead = NULL; - uri->pathTail = NULL; - } -} - - - -#endif diff --git a/external/uriparser/src/UriCommon.h b/external/uriparser/src/UriCommon.h deleted file mode 100644 index 42311dd..0000000 --- a/external/uriparser/src/UriCommon.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if (defined(URI_PASS_ANSI) && !defined(URI_COMMON_H_ANSI)) \ - || (defined(URI_PASS_UNICODE) && !defined(URI_COMMON_H_UNICODE)) \ - || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriCommon.h" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriCommon.h" -# undef URI_PASS_UNICODE -# endif -/* Only one pass for each encoding */ -#elif (defined(URI_PASS_ANSI) && !defined(URI_COMMON_H_ANSI) \ - && defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \ - && !defined(URI_COMMON_H_UNICODE) && defined(URI_ENABLE_UNICODE)) -# ifdef URI_PASS_ANSI -# define URI_COMMON_H_ANSI 1 -# include -# else -# define URI_COMMON_H_UNICODE 1 -# include -# endif - - - -/* Used to point to from empty path segments. - * X.first and X.afterLast must be the same non-NULL value then. */ -extern const URI_CHAR * const URI_FUNC(SafeToPointTo); -extern const URI_CHAR * const URI_FUNC(ConstPwd); -extern const URI_CHAR * const URI_FUNC(ConstParent); - - - -void URI_FUNC(ResetUri)(URI_TYPE(Uri) * uri); - -int URI_FUNC(CompareRange)( - const URI_TYPE(TextRange) * a, - const URI_TYPE(TextRange) * b); - -UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); -UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri, - UriBool relative, UriBool pathOwned, UriMemoryManager * memory); - -unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig); -URI_CHAR URI_FUNC(HexToLetter)(unsigned int value); -URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase); - -UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri); - -UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * source, - UriMemoryManager * memory); -UriBool URI_FUNC(CopyAuthority)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * source, UriMemoryManager * memory); - -UriBool URI_FUNC(FixAmbiguity)(URI_TYPE(Uri) * uri, UriMemoryManager * memory); -void URI_FUNC(FixEmptyTrailSegment)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); - - -#endif -#endif diff --git a/external/uriparser/src/UriCompare.c b/external/uriparser/src/UriCompare.c deleted file mode 100644 index bca3db9..0000000 --- a/external/uriparser/src/UriCompare.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriCompare.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriCompare.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include -# include "UriCommon.h" -#endif - - - -UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, - const URI_TYPE(Uri) * b) { - /* NOTE: Both NULL means equal! */ - if ((a == NULL) || (b == NULL)) { - return ((a == NULL) && (b == NULL)) ? URI_TRUE : URI_FALSE; - } - - /* scheme */ - if (URI_FUNC(CompareRange)(&(a->scheme), &(b->scheme))) { - return URI_FALSE; - } - - /* absolutePath */ - if ((a->scheme.first == NULL)&& (a->absolutePath != b->absolutePath)) { - return URI_FALSE; - } - - /* userInfo */ - if (URI_FUNC(CompareRange)(&(a->userInfo), &(b->userInfo))) { - return URI_FALSE; - } - - /* Host */ - if (((a->hostData.ip4 == NULL) != (b->hostData.ip4 == NULL)) - || ((a->hostData.ip6 == NULL) != (b->hostData.ip6 == NULL)) - || ((a->hostData.ipFuture.first == NULL) - != (b->hostData.ipFuture.first == NULL))) { - return URI_FALSE; - } - - if (a->hostData.ip4 != NULL) { - if (memcmp(a->hostData.ip4->data, b->hostData.ip4->data, 4)) { - return URI_FALSE; - } - } - - if (a->hostData.ip6 != NULL) { - if (memcmp(a->hostData.ip6->data, b->hostData.ip6->data, 16)) { - return URI_FALSE; - } - } - - if (a->hostData.ipFuture.first != NULL) { - if (URI_FUNC(CompareRange)(&(a->hostData.ipFuture), &(b->hostData.ipFuture))) { - return URI_FALSE; - } - } - - if ((a->hostData.ip4 == NULL) - && (a->hostData.ip6 == NULL) - && (a->hostData.ipFuture.first == NULL)) { - if (URI_FUNC(CompareRange)(&(a->hostText), &(b->hostText))) { - return URI_FALSE; - } - } - - /* portText */ - if (URI_FUNC(CompareRange)(&(a->portText), &(b->portText))) { - return URI_FALSE; - } - - /* Path */ - if ((a->pathHead == NULL) != (b->pathHead == NULL)) { - return URI_FALSE; - } - - if (a->pathHead != NULL) { - URI_TYPE(PathSegment) * walkA = a->pathHead; - URI_TYPE(PathSegment) * walkB = b->pathHead; - do { - if (URI_FUNC(CompareRange)(&(walkA->text), &(walkB->text))) { - return URI_FALSE; - } - if ((walkA->next == NULL) != (walkB->next == NULL)) { - return URI_FALSE; - } - walkA = walkA->next; - walkB = walkB->next; - } while (walkA != NULL); - } - - /* query */ - if (URI_FUNC(CompareRange)(&(a->query), &(b->query))) { - return URI_FALSE; - } - - /* fragment */ - if (URI_FUNC(CompareRange)(&(a->fragment), &(b->fragment))) { - return URI_FALSE; - } - - return URI_TRUE; /* Equal*/ -} - - - -#endif diff --git a/external/uriparser/src/UriConfig.h.in b/external/uriparser/src/UriConfig.h.in deleted file mode 100644 index a16a933..0000000 --- a/external/uriparser/src/UriConfig.h.in +++ /dev/null @@ -1,51 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(URI_CONFIG_H) -# define URI_CONFIG_H 1 - - - -#define PACKAGE_VERSION "@PROJECT_VERSION@" - -#cmakedefine HAVE_WPRINTF -#cmakedefine HAVE_REALLOCARRAY - - - -#endif /* !defined(URI_CONFIG_H) */ diff --git a/external/uriparser/src/UriEscape.c b/external/uriparser/src/UriEscape.c deleted file mode 100644 index ab8305f..0000000 --- a/external/uriparser/src/UriEscape.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriEscape.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriEscape.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -#endif - - - -URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks) { - return URI_FUNC(EscapeEx)(in, NULL, out, spaceToPlus, normalizeBreaks); -} - - - -URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, - const URI_CHAR * inAfterLast, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks) { - const URI_CHAR * read = inFirst; - URI_CHAR * write = out; - UriBool prevWasCr = URI_FALSE; - if ((out == NULL) || (inFirst == out)) { - return NULL; - } else if (inFirst == NULL) { - if (out != NULL) { - out[0] = _UT('\0'); - } - return out; - } - - for (;;) { - if ((inAfterLast != NULL) && (read >= inAfterLast)) { - write[0] = _UT('\0'); - return write; - } - - switch (read[0]) { - case _UT('\0'): - write[0] = _UT('\0'); - return write; - - case _UT(' '): - if (spaceToPlus) { - write[0] = _UT('+'); - write++; - } else { - write[0] = _UT('%'); - write[1] = _UT('2'); - write[2] = _UT('0'); - write += 3; - } - prevWasCr = URI_FALSE; - break; - - case _UT('a'): /* ALPHA */ - case _UT('A'): - case _UT('b'): - case _UT('B'): - case _UT('c'): - case _UT('C'): - case _UT('d'): - case _UT('D'): - case _UT('e'): - case _UT('E'): - case _UT('f'): - case _UT('F'): - case _UT('g'): - case _UT('G'): - case _UT('h'): - case _UT('H'): - case _UT('i'): - case _UT('I'): - case _UT('j'): - case _UT('J'): - case _UT('k'): - case _UT('K'): - case _UT('l'): - case _UT('L'): - case _UT('m'): - case _UT('M'): - case _UT('n'): - case _UT('N'): - case _UT('o'): - case _UT('O'): - case _UT('p'): - case _UT('P'): - case _UT('q'): - case _UT('Q'): - case _UT('r'): - case _UT('R'): - case _UT('s'): - case _UT('S'): - case _UT('t'): - case _UT('T'): - case _UT('u'): - case _UT('U'): - case _UT('v'): - case _UT('V'): - case _UT('w'): - case _UT('W'): - case _UT('x'): - case _UT('X'): - case _UT('y'): - case _UT('Y'): - case _UT('z'): - case _UT('Z'): - case _UT('0'): /* DIGIT */ - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('-'): /* "-" / "." / "_" / "~" */ - case _UT('.'): - case _UT('_'): - case _UT('~'): - /* Copy unmodified */ - write[0] = read[0]; - write++; - - prevWasCr = URI_FALSE; - break; - - case _UT('\x0a'): - if (normalizeBreaks) { - if (!prevWasCr) { - write[0] = _UT('%'); - write[1] = _UT('0'); - write[2] = _UT('D'); - write[3] = _UT('%'); - write[4] = _UT('0'); - write[5] = _UT('A'); - write += 6; - } - } else { - write[0] = _UT('%'); - write[1] = _UT('0'); - write[2] = _UT('A'); - write += 3; - } - prevWasCr = URI_FALSE; - break; - - case _UT('\x0d'): - if (normalizeBreaks) { - write[0] = _UT('%'); - write[1] = _UT('0'); - write[2] = _UT('D'); - write[3] = _UT('%'); - write[4] = _UT('0'); - write[5] = _UT('A'); - write += 6; - } else { - write[0] = _UT('%'); - write[1] = _UT('0'); - write[2] = _UT('D'); - write += 3; - } - prevWasCr = URI_TRUE; - break; - - default: - /* Percent encode */ - { - const unsigned char code = (unsigned char)read[0]; - write[0] = _UT('%'); - write[1] = URI_FUNC(HexToLetter)(code >> 4); - write[2] = URI_FUNC(HexToLetter)(code & 0x0f); - write += 3; - } - prevWasCr = URI_FALSE; - break; - } - - read++; - } -} - - - -const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout) { - return URI_FUNC(UnescapeInPlaceEx)(inout, URI_FALSE, URI_BR_DONT_TOUCH); -} - - - -const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, - UriBool plusToSpace, UriBreakConversion breakConversion) { - URI_CHAR * read = inout; - URI_CHAR * write = inout; - UriBool prevWasCr = URI_FALSE; - - if (inout == NULL) { - return NULL; - } - - for (;;) { - switch (read[0]) { - case _UT('\0'): - if (read > write) { - write[0] = _UT('\0'); - } - return write; - - case _UT('%'): - switch (read[1]) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): - switch (read[2]) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): - { - /* Percent group found */ - const unsigned char left = URI_FUNC(HexdigToInt)(read[1]); - const unsigned char right = URI_FUNC(HexdigToInt)(read[2]); - const int code = 16 * left + right; - switch (code) { - case 10: - switch (breakConversion) { - case URI_BR_TO_LF: - if (!prevWasCr) { - write[0] = (URI_CHAR)10; - write++; - } - break; - - case URI_BR_TO_CRLF: - if (!prevWasCr) { - write[0] = (URI_CHAR)13; - write[1] = (URI_CHAR)10; - write += 2; - } - break; - - case URI_BR_TO_CR: - if (!prevWasCr) { - write[0] = (URI_CHAR)13; - write++; - } - break; - - case URI_BR_DONT_TOUCH: - default: - write[0] = (URI_CHAR)10; - write++; - - } - prevWasCr = URI_FALSE; - break; - - case 13: - switch (breakConversion) { - case URI_BR_TO_LF: - write[0] = (URI_CHAR)10; - write++; - break; - - case URI_BR_TO_CRLF: - write[0] = (URI_CHAR)13; - write[1] = (URI_CHAR)10; - write += 2; - break; - - case URI_BR_TO_CR: - write[0] = (URI_CHAR)13; - write++; - break; - - case URI_BR_DONT_TOUCH: - default: - write[0] = (URI_CHAR)13; - write++; - - } - prevWasCr = URI_TRUE; - break; - - default: - write[0] = (URI_CHAR)(code); - write++; - - prevWasCr = URI_FALSE; - - } - read += 3; - } - break; - - default: - /* Copy two chars unmodified and */ - /* look at this char again */ - if (read > write) { - write[0] = read[0]; - write[1] = read[1]; - } - read += 2; - write += 2; - - prevWasCr = URI_FALSE; - } - break; - - default: - /* Copy one char unmodified and */ - /* look at this char again */ - if (read > write) { - write[0] = read[0]; - } - read++; - write++; - - prevWasCr = URI_FALSE; - } - break; - - case _UT('+'): - if (plusToSpace) { - /* Convert '+' to ' ' */ - write[0] = _UT(' '); - } else { - /* Copy one char unmodified */ - if (read > write) { - write[0] = read[0]; - } - } - read++; - write++; - - prevWasCr = URI_FALSE; - break; - - default: - /* Copy one char unmodified */ - if (read > write) { - write[0] = read[0]; - } - read++; - write++; - - prevWasCr = URI_FALSE; - } - } -} - - - -#endif diff --git a/external/uriparser/src/UriFile.c b/external/uriparser/src/UriFile.c deleted file mode 100644 index 232957d..0000000 --- a/external/uriparser/src/UriFile.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriFile.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriFile.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -#endif - - - -#include /* for size_t, avoiding stddef.h for older MSVCs */ - - - -static URI_INLINE int URI_FUNC(FilenameToUriString)(const URI_CHAR * filename, - URI_CHAR * uriString, UriBool fromUnix) { - const URI_CHAR * input = filename; - const URI_CHAR * lastSep = input - 1; - UriBool firstSegment = URI_TRUE; - URI_CHAR * output = uriString; - UriBool absolute; - UriBool is_windows_network; - - if ((filename == NULL) || (uriString == NULL)) { - return URI_ERROR_NULL; - } - - is_windows_network = (filename[0] == _UT('\\')) && (filename[1] == _UT('\\')); - absolute = fromUnix - ? (filename[0] == _UT('/')) - : (((filename[0] != _UT('\0')) && (filename[1] == _UT(':'))) - || is_windows_network); - - if (absolute) { - const URI_CHAR * const prefix = fromUnix - ? _UT("file://") - : is_windows_network - ? _UT("file:") - : _UT("file:///"); - const size_t prefixLen = URI_STRLEN(prefix); - - /* Copy prefix */ - memcpy(uriString, prefix, prefixLen * sizeof(URI_CHAR)); - output += prefixLen; - } - - /* Copy and escape on the fly */ - for (;;) { - if ((input[0] == _UT('\0')) - || (fromUnix && input[0] == _UT('/')) - || (!fromUnix && input[0] == _UT('\\'))) { - /* Copy text after last separator */ - if (lastSep + 1 < input) { - if (!fromUnix && absolute && (firstSegment == URI_TRUE)) { - /* Quick hack to not convert "C:" to "C%3A" */ - const int charsToCopy = (int)(input - (lastSep + 1)); - memcpy(output, lastSep + 1, charsToCopy * sizeof(URI_CHAR)); - output += charsToCopy; - } else { - output = URI_FUNC(EscapeEx)(lastSep + 1, input, output, - URI_FALSE, URI_FALSE); - } - } - firstSegment = URI_FALSE; - } - - if (input[0] == _UT('\0')) { - output[0] = _UT('\0'); - break; - } else if (fromUnix && (input[0] == _UT('/'))) { - /* Copy separators unmodified */ - output[0] = _UT('/'); - output++; - lastSep = input; - } else if (!fromUnix && (input[0] == _UT('\\'))) { - /* Convert backslashes to forward slashes */ - output[0] = _UT('/'); - output++; - lastSep = input; - } - input++; - } - - return URI_SUCCESS; -} - - - -static URI_INLINE int URI_FUNC(UriStringToFilename)(const URI_CHAR * uriString, - URI_CHAR * filename, UriBool toUnix) { - if ((uriString == NULL) || (filename == NULL)) { - return URI_ERROR_NULL; - } - - { - const UriBool file_unknown_slashes = - URI_STRNCMP(uriString, _UT("file:"), URI_STRLEN(_UT("file:"))) == 0; - const UriBool file_one_or_more_slashes = file_unknown_slashes - && (URI_STRNCMP(uriString, _UT("file:/"), URI_STRLEN(_UT("file:/"))) == 0); - const UriBool file_two_or_more_slashes = file_one_or_more_slashes - && (URI_STRNCMP(uriString, _UT("file://"), URI_STRLEN(_UT("file://"))) == 0); - const UriBool file_three_or_more_slashes = file_two_or_more_slashes - && (URI_STRNCMP(uriString, _UT("file:///"), URI_STRLEN(_UT("file:///"))) == 0); - - const size_t charsToSkip = file_two_or_more_slashes - ? file_three_or_more_slashes - ? toUnix - /* file:///bin/bash */ - ? URI_STRLEN(_UT("file://")) - /* file:///E:/Documents%20and%20Settings */ - : URI_STRLEN(_UT("file:///")) - /* file://Server01/Letter.txt */ - : URI_STRLEN(_UT("file://")) - : ((file_one_or_more_slashes && toUnix) - /* file:/bin/bash */ - /* https://tools.ietf.org/html/rfc8089#appendix-B */ - ? URI_STRLEN(_UT("file:")) - : ((! toUnix && file_unknown_slashes && ! file_one_or_more_slashes) - /* file:c:/path/to/file */ - /* https://tools.ietf.org/html/rfc8089#appendix-E.2 */ - ? URI_STRLEN(_UT("file:")) - : 0)); - const size_t charsToCopy = URI_STRLEN(uriString + charsToSkip) + 1; - - const UriBool is_windows_network_with_authority = - (toUnix == URI_FALSE) - && file_two_or_more_slashes - && ! file_three_or_more_slashes; - - URI_CHAR * const unescape_target = is_windows_network_with_authority - ? (filename + 2) - : filename; - - if (is_windows_network_with_authority) { - filename[0] = '\\'; - filename[1] = '\\'; - } - - memcpy(unescape_target, uriString + charsToSkip, charsToCopy * sizeof(URI_CHAR)); - URI_FUNC(UnescapeInPlaceEx)(filename, URI_FALSE, URI_BR_DONT_TOUCH); - } - - /* Convert forward slashes to backslashes */ - if (!toUnix) { - URI_CHAR * walker = filename; - while (walker[0] != _UT('\0')) { - if (walker[0] == _UT('/')) { - walker[0] = _UT('\\'); - } - walker++; - } - } - - return URI_SUCCESS; -} - - - -int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, URI_CHAR * uriString) { - return URI_FUNC(FilenameToUriString)(filename, uriString, URI_TRUE); -} - - - -int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, URI_CHAR * uriString) { - return URI_FUNC(FilenameToUriString)(filename, uriString, URI_FALSE); -} - - - -int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, URI_CHAR * filename) { - return URI_FUNC(UriStringToFilename)(uriString, filename, URI_TRUE); -} - - - -int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, URI_CHAR * filename) { - return URI_FUNC(UriStringToFilename)(uriString, filename, URI_FALSE); -} - - - -#endif diff --git a/external/uriparser/src/UriIp4.c b/external/uriparser/src/UriIp4.c deleted file mode 100644 index a794265..0000000 --- a/external/uriparser/src/UriIp4.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriIp4.c - * Holds the IPv4 parser implementation. - * NOTE: This source file includes itself twice. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriIp4.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriIp4.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriIp4Base.h" -# include -#endif - - - -/* Prototypes */ -static const URI_CHAR * URI_FUNC(ParseDecOctet)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseDecOctetOne)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseDecOctetTwo)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseDecOctetThree)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseDecOctetFour)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast); - - - -/* - * [ipFourAddress]->[decOctet]<.>[decOctet]<.>[decOctet]<.>[decOctet] - */ -int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, - const URI_CHAR * first, const URI_CHAR * afterLast) { - const URI_CHAR * after; - UriIp4Parser parser; - - /* Essential checks */ - if ((octetOutput == NULL) || (first == NULL) - || (afterLast <= first)) { - return URI_ERROR_SYNTAX; - } - - /* Reset parser */ - parser.stackCount = 0; - - /* Octet #1 */ - after = URI_FUNC(ParseDecOctet)(&parser, first, afterLast); - if ((after == NULL) || (after >= afterLast) || (*after != _UT('.'))) { - return URI_ERROR_SYNTAX; - } - uriStackToOctet(&parser, octetOutput); - - /* Octet #2 */ - after = URI_FUNC(ParseDecOctet)(&parser, after + 1, afterLast); - if ((after == NULL) || (after >= afterLast) || (*after != _UT('.'))) { - return URI_ERROR_SYNTAX; - } - uriStackToOctet(&parser, octetOutput + 1); - - /* Octet #3 */ - after = URI_FUNC(ParseDecOctet)(&parser, after + 1, afterLast); - if ((after == NULL) || (after >= afterLast) || (*after != _UT('.'))) { - return URI_ERROR_SYNTAX; - } - uriStackToOctet(&parser, octetOutput + 2); - - /* Octet #4 */ - after = URI_FUNC(ParseDecOctet)(&parser, after + 1, afterLast); - if (after != afterLast) { - return URI_ERROR_SYNTAX; - } - uriStackToOctet(&parser, octetOutput + 3); - - return URI_SUCCESS; -} - - - -/* - * [decOctet]-><0> - * [decOctet]-><1>[decOctetOne] - * [decOctet]-><2>[decOctetTwo] - * [decOctet]-><3>[decOctetThree] - * [decOctet]-><4>[decOctetThree] - * [decOctet]-><5>[decOctetThree] - * [decOctet]-><6>[decOctetThree] - * [decOctet]-><7>[decOctetThree] - * [decOctet]-><8>[decOctetThree] - * [decOctet]-><9>[decOctetThree] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseDecOctet)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return NULL; - } - - switch (*first) { - case _UT('0'): - uriPushToStack(parser, 0); - return first + 1; - - case _UT('1'): - uriPushToStack(parser, 1); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetOne)(parser, first + 1, afterLast); - - case _UT('2'): - uriPushToStack(parser, 2); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetTwo)(parser, first + 1, afterLast); - - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1, afterLast); - - default: - return NULL; - } -} - - - -/* - * [decOctetOne]-> - * [decOctetOne]->[DIGIT][decOctetThree] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseDecOctetOne)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1, afterLast); - - default: - return first; - } -} - - - -/* - * [decOctetTwo]-> - * [decOctetTwo]-><0>[decOctetThree] - * [decOctetTwo]-><1>[decOctetThree] - * [decOctetTwo]-><2>[decOctetThree] - * [decOctetTwo]-><3>[decOctetThree] - * [decOctetTwo]-><4>[decOctetThree] - * [decOctetTwo]-><5>[decOctetFour] - * [decOctetTwo]-><6> - * [decOctetTwo]-><7> - * [decOctetTwo]-><8> - * [decOctetTwo]-><9> -*/ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseDecOctetTwo)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1, afterLast); - - case _UT('5'): - uriPushToStack(parser, 5); - return (const URI_CHAR *)URI_FUNC(ParseDecOctetFour)(parser, first + 1, afterLast); - - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return first + 1; - - default: - return first; - } -} - - - -/* - * [decOctetThree]-> - * [decOctetThree]->[DIGIT] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseDecOctetThree)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return first + 1; - - default: - return first; - } -} - - - -/* - * [decOctetFour]-> - * [decOctetFour]-><0> - * [decOctetFour]-><1> - * [decOctetFour]-><2> - * [decOctetFour]-><3> - * [decOctetFour]-><4> - * [decOctetFour]-><5> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseDecOctetFour)(UriIp4Parser * parser, - const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); - return first + 1; - - default: - return first; - } -} - - - -#endif diff --git a/external/uriparser/src/UriIp4Base.c b/external/uriparser/src/UriIp4Base.c deleted file mode 100644 index ded7c32..0000000 --- a/external/uriparser/src/UriIp4Base.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriIp4Base.c - * Holds code independent of the encoding pass. - */ - -#ifndef URI_DOXYGEN -# include "UriIp4Base.h" -#endif - - - -void uriStackToOctet(UriIp4Parser * parser, unsigned char * octet) { - switch (parser->stackCount) { - case 1: - *octet = parser->stackOne; - break; - - case 2: - *octet = parser->stackOne * 10 - + parser->stackTwo; - break; - - case 3: - *octet = parser->stackOne * 100 - + parser->stackTwo * 10 - + parser->stackThree; - break; - - default: - ; - } - parser->stackCount = 0; -} - - - -void uriPushToStack(UriIp4Parser * parser, unsigned char digit) { - switch (parser->stackCount) { - case 0: - parser->stackOne = digit; - parser->stackCount = 1; - break; - - case 1: - parser->stackTwo = digit; - parser->stackCount = 2; - break; - - case 2: - parser->stackThree = digit; - parser->stackCount = 3; - break; - - default: - ; - } -} diff --git a/external/uriparser/src/UriIp4Base.h b/external/uriparser/src/UriIp4Base.h deleted file mode 100644 index 4867850..0000000 --- a/external/uriparser/src/UriIp4Base.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_IP4_BASE_H -#define URI_IP4_BASE_H 1 - - - -typedef struct UriIp4ParserStruct { - unsigned char stackCount; - unsigned char stackOne; - unsigned char stackTwo; - unsigned char stackThree; -} UriIp4Parser; - - - -void uriPushToStack(UriIp4Parser * parser, unsigned char digit); -void uriStackToOctet(UriIp4Parser * parser, unsigned char * octet); - - - -#endif /* URI_IP4_BASE_H */ diff --git a/external/uriparser/src/UriMemory.c b/external/uriparser/src/UriMemory.c deleted file mode 100644 index baed204..0000000 --- a/external/uriparser/src/UriMemory.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Weijia Song - * Copyright (C) 2018, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriMemory.c - * Holds memory manager implementation. - */ - -#include - -#ifdef HAVE_REALLOCARRAY -# ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -# endif -#endif - -#include -#include - - - -#ifndef URI_DOXYGEN -# include "UriMemory.h" -#endif - - - -#define URI_CHECK_ALLOC_OVERFLOW(total_size, nmemb, size) \ - do { \ - /* check for unsigned overflow */ \ - if ((nmemb != 0) && (total_size / nmemb != size)) { \ - errno = ENOMEM; \ - return NULL; \ - } \ - } while (0) - - - -static void * uriDefaultMalloc(UriMemoryManager * URI_UNUSED(memory), - size_t size) { - return malloc(size); -} - - - -static void * uriDefaultCalloc(UriMemoryManager * URI_UNUSED(memory), - size_t nmemb, size_t size) { - return calloc(nmemb, size); -} - - - -static void * uriDefaultRealloc(UriMemoryManager * URI_UNUSED(memory), - void * ptr, size_t size) { - return realloc(ptr, size); -} - - - -static void * uriDefaultReallocarray(UriMemoryManager * URI_UNUSED(memory), - void * ptr, size_t nmemb, size_t size) { -#ifdef HAVE_REALLOCARRAY - return reallocarray(ptr, nmemb, size); -#else - const size_t total_size = nmemb * size; - - URI_CHECK_ALLOC_OVERFLOW(total_size, nmemb, size); /* may return */ - - return realloc(ptr, total_size); -#endif -} - - - -static void uriDefaultFree(UriMemoryManager * URI_UNUSED(memory), - void * ptr) { - free(ptr); -} - - - -UriBool uriMemoryManagerIsComplete(const UriMemoryManager * memory) { - return (memory - && memory->malloc - && memory->calloc - && memory->realloc - && memory->reallocarray - && memory->free) ? URI_TRUE : URI_FALSE; -} - - - -void * uriEmulateCalloc(UriMemoryManager * memory, size_t nmemb, size_t size) { - void * buffer; - const size_t total_size = nmemb * size; - - if (memory == NULL) { - errno = EINVAL; - return NULL; - } - - URI_CHECK_ALLOC_OVERFLOW(total_size, nmemb, size); /* may return */ - - buffer = memory->malloc(memory, total_size); - if (buffer == NULL) { - /* errno set by malloc */ - return NULL; - } - memset(buffer, 0, total_size); - return buffer; -} - - - -void * uriEmulateReallocarray(UriMemoryManager * memory, - void * ptr, size_t nmemb, size_t size) { - const size_t total_size = nmemb * size; - - if (memory == NULL) { - errno = EINVAL; - return NULL; - } - - URI_CHECK_ALLOC_OVERFLOW(total_size, nmemb, size); /* may return */ - - return memory->realloc(memory, ptr, total_size); -} - - - -static void * uriDecorateMalloc(UriMemoryManager * memory, - size_t size) { - UriMemoryManager * backend; - const size_t extraBytes = sizeof(size_t); - void * buffer; - - if (memory == NULL) { - errno = EINVAL; - return NULL; - } - - /* check for unsigned overflow */ - if (size > ((size_t)-1) - extraBytes) { - errno = ENOMEM; - return NULL; - } - - backend = (UriMemoryManager *)memory->userData; - if (backend == NULL) { - errno = EINVAL; - return NULL; - } - - buffer = backend->malloc(backend, extraBytes + size); - if (buffer == NULL) { - return NULL; - } - - *(size_t *)buffer = size; - - return (char *)buffer + extraBytes; -} - - - -static void * uriDecorateRealloc(UriMemoryManager * memory, - void * ptr, size_t size) { - void * newBuffer; - size_t prevSize; - - if (memory == NULL) { - errno = EINVAL; - return NULL; - } - - /* man realloc: "If ptr is NULL, then the call is equivalent to - * malloc(size), for *all* values of size" */ - if (ptr == NULL) { - return memory->malloc(memory, size); - } - - /* man realloc: "If size is equal to zero, and ptr is *not* NULL, - * then the call is equivalent to free(ptr)." */ - if (size == 0) { - memory->free(memory, ptr); - return NULL; - } - - prevSize = *((size_t *)((char *)ptr - sizeof(size_t))); - - /* Anything to do? */ - if (size <= prevSize) { - return ptr; - } - - newBuffer = memory->malloc(memory, size); - if (newBuffer == NULL) { - /* errno set by malloc */ - return NULL; - } - - memcpy(newBuffer, ptr, prevSize); - - memory->free(memory, ptr); - - return newBuffer; -} - - - -static void uriDecorateFree(UriMemoryManager * memory, void * ptr) { - UriMemoryManager * backend; - - if ((ptr == NULL) || (memory == NULL)) { - return; - } - - backend = (UriMemoryManager *)memory->userData; - if (backend == NULL) { - return; - } - - backend->free(backend, (char *)ptr - sizeof(size_t)); -} - - - -int uriCompleteMemoryManager(UriMemoryManager * memory, - UriMemoryManager * backend) { - if ((memory == NULL) || (backend == NULL)) { - return URI_ERROR_NULL; - } - - if ((backend->malloc == NULL) || (backend->free == NULL)) { - return URI_ERROR_MEMORY_MANAGER_INCOMPLETE; - } - - memory->calloc = uriEmulateCalloc; - memory->reallocarray = uriEmulateReallocarray; - - memory->malloc = uriDecorateMalloc; - memory->realloc = uriDecorateRealloc; - memory->free = uriDecorateFree; - - memory->userData = backend; - - return URI_SUCCESS; -} - - - -int uriTestMemoryManager(UriMemoryManager * memory) { - const size_t mallocSize = 7; - const size_t callocNmemb = 3; - const size_t callocSize = 5; - const size_t callocTotalSize = callocNmemb * callocSize; - const size_t reallocSize = 11; - const size_t reallocarrayNmemb = 5; - const size_t reallocarraySize = 7; - const size_t reallocarrayTotal = reallocarrayNmemb * reallocarraySize; - size_t index; - char * buffer; - - if (memory == NULL) { - return URI_ERROR_NULL; - } - - if (uriMemoryManagerIsComplete(memory) != URI_TRUE) { - return URI_ERROR_MEMORY_MANAGER_INCOMPLETE; - } - - /* malloc + free*/ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xF1'; - memory->free(memory, buffer); - buffer = NULL; - - /* calloc + free */ - buffer = memory->calloc(memory, callocNmemb, callocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - for (index = 0; index < callocTotalSize; index++) { /* all zeros? */ - if (buffer[index] != '\0') { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - } - buffer[callocTotalSize - 1] = '\xF2'; - memory->free(memory, buffer); - buffer = NULL; - - /* malloc + realloc + free */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - for (index = 0; index < mallocSize; index++) { - buffer[index] = '\xF3'; - } - buffer = memory->realloc(memory, buffer, reallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - for (index = 0; index < mallocSize; index++) { /* previous content? */ - if (buffer[index] != '\xF3') { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - } - buffer[reallocSize - 1] = '\xF4'; - memory->free(memory, buffer); - buffer = NULL; - - /* malloc + realloc ptr!=NULL size==0 (equals free) */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xF5'; - memory->realloc(memory, buffer, 0); - buffer = NULL; - - /* realloc ptr==NULL size!=0 (equals malloc) + free */ - buffer = memory->realloc(memory, NULL, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xF6'; - memory->free(memory, buffer); - buffer = NULL; - - /* realloc ptr==NULL size==0 (equals malloc) + free */ - buffer = memory->realloc(memory, NULL, 0); - if (buffer != NULL) { - memory->free(memory, buffer); - buffer = NULL; - } - - /* malloc + reallocarray + free */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - for (index = 0; index < mallocSize; index++) { - buffer[index] = '\xF7'; - } - buffer = memory->reallocarray(memory, buffer, reallocarrayNmemb, - reallocarraySize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - for (index = 0; index < mallocSize; index++) { /* previous content? */ - if (buffer[index] != '\xF7') { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - } - buffer[reallocarrayTotal - 1] = '\xF8'; - memory->free(memory, buffer); - buffer = NULL; - - /* malloc + reallocarray ptr!=NULL nmemb==0 size!=0 (equals free) */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xF9'; - memory->reallocarray(memory, buffer, 0, reallocarraySize); - buffer = NULL; - - /* malloc + reallocarray ptr!=NULL nmemb!=0 size==0 (equals free) */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xFA'; - memory->reallocarray(memory, buffer, reallocarrayNmemb, 0); - buffer = NULL; - - /* malloc + reallocarray ptr!=NULL nmemb==0 size==0 (equals free) */ - buffer = memory->malloc(memory, mallocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[mallocSize - 1] = '\xFB'; - memory->reallocarray(memory, buffer, 0, 0); - buffer = NULL; - - /* reallocarray ptr==NULL nmemb!=0 size!=0 (equals malloc) + free */ - buffer = memory->reallocarray(memory, NULL, callocNmemb, callocSize); - if (buffer == NULL) { - return URI_ERROR_MEMORY_MANAGER_FAULTY; - } - buffer[callocTotalSize - 1] = '\xFC'; - memory->free(memory, buffer); - buffer = NULL; - - /* reallocarray ptr==NULL nmemb==0 size!=0 (equals malloc) + free */ - buffer = memory->reallocarray(memory, NULL, 0, callocSize); - if (buffer != NULL) { - memory->free(memory, buffer); - buffer = NULL; - } - - /* reallocarray ptr==NULL nmemb!=0 size==0 (equals malloc) + free */ - buffer = memory->reallocarray(memory, NULL, callocNmemb, 0); - if (buffer != NULL) { - memory->free(memory, buffer); - buffer = NULL; - } - - /* reallocarray ptr==NULL nmemb==0 size==0 (equals malloc) + free */ - buffer = memory->reallocarray(memory, NULL, 0, 0); - if (buffer != NULL) { - memory->free(memory, buffer); - buffer = NULL; - } - - return URI_SUCCESS; -} - - - -/*extern*/ UriMemoryManager defaultMemoryManager = { - uriDefaultMalloc, - uriDefaultCalloc, - uriDefaultRealloc, - uriDefaultReallocarray, - uriDefaultFree, - NULL /* userData */ -}; diff --git a/external/uriparser/src/UriMemory.h b/external/uriparser/src/UriMemory.h deleted file mode 100644 index a930f93..0000000 --- a/external/uriparser/src/UriMemory.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Weijia Song - * Copyright (C) 2018, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_MEMORY_H -#define URI_MEMORY_H 1 - - - -#ifndef URI_DOXYGEN -# include -#endif - - - -#define URI_CHECK_MEMORY_MANAGER(memory) \ - do { \ - if (memory == NULL) { \ - memory = &defaultMemoryManager; \ - } else if (uriMemoryManagerIsComplete(memory) != URI_TRUE) { \ - return URI_ERROR_MEMORY_MANAGER_INCOMPLETE; \ - } \ - } while (0) - - - -#ifdef __cplusplus -# define URIPARSER_EXTERN extern "C" -#else -# define URIPARSER_EXTERN extern -#endif - -URIPARSER_EXTERN UriMemoryManager defaultMemoryManager; - -#undef URIPARSER_EXTERN - - - -UriBool uriMemoryManagerIsComplete(const UriMemoryManager * memory); - - - -#endif /* URI_MEMORY_H */ diff --git a/external/uriparser/src/UriNormalize.c b/external/uriparser/src/UriNormalize.c deleted file mode 100644 index 04a8e5f..0000000 --- a/external/uriparser/src/UriNormalize.c +++ /dev/null @@ -1,802 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriNormalize.c - * Holds the RFC 3986 %URI normalization implementation. - * NOTE: This source file includes itself twice. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriNormalize.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriNormalize.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriNormalizeBase.h" -# include "UriCommon.h" -# include "UriMemory.h" -#endif - - - -#include - - - -static int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri, unsigned int inMask, - unsigned int * outMask, UriMemoryManager * memory); - -static UriBool URI_FUNC(MakeRangeOwner)(unsigned int * doneMask, - unsigned int maskTest, URI_TYPE(TextRange) * range, - UriMemoryManager * memory); -static UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, - unsigned int * doneMask, UriMemoryManager * memory); - -static void URI_FUNC(FixPercentEncodingInplace)(const URI_CHAR * first, - const URI_CHAR ** afterLast); -static UriBool URI_FUNC(FixPercentEncodingMalloc)(const URI_CHAR ** first, - const URI_CHAR ** afterLast, UriMemoryManager * memory); -static void URI_FUNC(FixPercentEncodingEngine)( - const URI_CHAR * inFirst, const URI_CHAR * inAfterLast, - const URI_CHAR * outFirst, const URI_CHAR ** outAfterLast); - -static UriBool URI_FUNC(ContainsUppercaseLetters)(const URI_CHAR * first, - const URI_CHAR * afterLast); -static UriBool URI_FUNC(ContainsUglyPercentEncoding)(const URI_CHAR * first, - const URI_CHAR * afterLast); - -static void URI_FUNC(LowercaseInplace)(const URI_CHAR * first, - const URI_CHAR * afterLast); -static UriBool URI_FUNC(LowercaseMalloc)(const URI_CHAR ** first, - const URI_CHAR ** afterLast, UriMemoryManager * memory); - -static void URI_FUNC(PreventLeakage)(URI_TYPE(Uri) * uri, - unsigned int revertMask, UriMemoryManager * memory); - - - -static URI_INLINE void URI_FUNC(PreventLeakage)(URI_TYPE(Uri) * uri, - unsigned int revertMask, UriMemoryManager * memory) { - if (revertMask & URI_NORMALIZE_SCHEME) { - memory->free(memory, (URI_CHAR *)uri->scheme.first); - uri->scheme.first = NULL; - uri->scheme.afterLast = NULL; - } - - if (revertMask & URI_NORMALIZE_USER_INFO) { - memory->free(memory, (URI_CHAR *)uri->userInfo.first); - uri->userInfo.first = NULL; - uri->userInfo.afterLast = NULL; - } - - if (revertMask & URI_NORMALIZE_HOST) { - if (uri->hostData.ipFuture.first != NULL) { - /* IPvFuture */ - memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first); - uri->hostData.ipFuture.first = NULL; - uri->hostData.ipFuture.afterLast = NULL; - uri->hostText.first = NULL; - uri->hostText.afterLast = NULL; - } else if ((uri->hostText.first != NULL) - && (uri->hostData.ip4 == NULL) - && (uri->hostData.ip6 == NULL)) { - /* Regname */ - memory->free(memory, (URI_CHAR *)uri->hostText.first); - uri->hostText.first = NULL; - uri->hostText.afterLast = NULL; - } - } - - /* NOTE: Port cannot happen! */ - - if (revertMask & URI_NORMALIZE_PATH) { - URI_TYPE(PathSegment) * walker = uri->pathHead; - while (walker != NULL) { - URI_TYPE(PathSegment) * const next = walker->next; - if (walker->text.afterLast > walker->text.first) { - memory->free(memory, (URI_CHAR *)walker->text.first); - } - memory->free(memory, walker); - walker = next; - } - uri->pathHead = NULL; - uri->pathTail = NULL; - } - - if (revertMask & URI_NORMALIZE_QUERY) { - memory->free(memory, (URI_CHAR *)uri->query.first); - uri->query.first = NULL; - uri->query.afterLast = NULL; - } - - if (revertMask & URI_NORMALIZE_FRAGMENT) { - memory->free(memory, (URI_CHAR *)uri->fragment.first); - uri->fragment.first = NULL; - uri->fragment.afterLast = NULL; - } -} - - - -static URI_INLINE UriBool URI_FUNC(ContainsUppercaseLetters)(const URI_CHAR * first, - const URI_CHAR * afterLast) { - if ((first != NULL) && (afterLast != NULL) && (afterLast > first)) { - const URI_CHAR * i = first; - for (; i < afterLast; i++) { - /* 6.2.2.1 Case Normalization: uppercase letters in scheme or host */ - if ((*i >= _UT('A')) && (*i <= _UT('Z'))) { - return URI_TRUE; - } - } - } - return URI_FALSE; -} - - - -static URI_INLINE UriBool URI_FUNC(ContainsUglyPercentEncoding)(const URI_CHAR * first, - const URI_CHAR * afterLast) { - if ((first != NULL) && (afterLast != NULL) && (afterLast > first)) { - const URI_CHAR * i = first; - for (; i + 2 < afterLast; i++) { - if (i[0] == _UT('%')) { - /* 6.2.2.1 Case Normalization: * - * lowercase percent-encodings */ - if (((i[1] >= _UT('a')) && (i[1] <= _UT('f'))) - || ((i[2] >= _UT('a')) && (i[2] <= _UT('f')))) { - return URI_TRUE; - } else { - /* 6.2.2.2 Percent-Encoding Normalization: * - * percent-encoded unreserved characters */ - const unsigned char left = URI_FUNC(HexdigToInt)(i[1]); - const unsigned char right = URI_FUNC(HexdigToInt)(i[2]); - const int code = 16 * left + right; - if (uriIsUnreserved(code)) { - return URI_TRUE; - } - } - } - } - } - return URI_FALSE; -} - - - -static URI_INLINE void URI_FUNC(LowercaseInplace)(const URI_CHAR * first, - const URI_CHAR * afterLast) { - if ((first != NULL) && (afterLast != NULL) && (afterLast > first)) { - URI_CHAR * i = (URI_CHAR *)first; - const int lowerUpperDiff = (_UT('a') - _UT('A')); - for (; i < afterLast; i++) { - if ((*i >= _UT('A')) && (*i <=_UT('Z'))) { - *i = (URI_CHAR)(*i + lowerUpperDiff); - } - } - } -} - - - -static URI_INLINE UriBool URI_FUNC(LowercaseMalloc)(const URI_CHAR ** first, - const URI_CHAR ** afterLast, UriMemoryManager * memory) { - int lenInChars; - const int lowerUpperDiff = (_UT('a') - _UT('A')); - URI_CHAR * buffer; - int i = 0; - - if ((first == NULL) || (afterLast == NULL) || (*first == NULL) - || (*afterLast == NULL)) { - return URI_FALSE; - } - - lenInChars = (int)(*afterLast - *first); - if (lenInChars == 0) { - return URI_TRUE; - } else if (lenInChars < 0) { - return URI_FALSE; - } - - buffer = memory->malloc(memory, lenInChars * sizeof(URI_CHAR)); - if (buffer == NULL) { - return URI_FALSE; - } - - for (; i < lenInChars; i++) { - if (((*first)[i] >= _UT('A')) && ((*first)[i] <=_UT('Z'))) { - buffer[i] = (URI_CHAR)((*first)[i] + lowerUpperDiff); - } else { - buffer[i] = (*first)[i]; - } - } - - *first = buffer; - *afterLast = buffer + lenInChars; - return URI_TRUE; -} - - - -/* NOTE: Implementation must stay inplace-compatible */ -static URI_INLINE void URI_FUNC(FixPercentEncodingEngine)( - const URI_CHAR * inFirst, const URI_CHAR * inAfterLast, - const URI_CHAR * outFirst, const URI_CHAR ** outAfterLast) { - URI_CHAR * write = (URI_CHAR *)outFirst; - const int lenInChars = (int)(inAfterLast - inFirst); - int i = 0; - - /* All but last two */ - for (; i + 2 < lenInChars; i++) { - if (inFirst[i] != _UT('%')) { - write[0] = inFirst[i]; - write++; - } else { - /* 6.2.2.2 Percent-Encoding Normalization: * - * percent-encoded unreserved characters */ - const URI_CHAR one = inFirst[i + 1]; - const URI_CHAR two = inFirst[i + 2]; - const unsigned char left = URI_FUNC(HexdigToInt)(one); - const unsigned char right = URI_FUNC(HexdigToInt)(two); - const int code = 16 * left + right; - if (uriIsUnreserved(code)) { - write[0] = (URI_CHAR)(code); - write++; - } else { - /* 6.2.2.1 Case Normalization: * - * lowercase percent-encodings */ - write[0] = _UT('%'); - write[1] = URI_FUNC(HexToLetter)(left); - write[2] = URI_FUNC(HexToLetter)(right); - write += 3; - } - - i += 2; /* For the two chars of the percent group we just ate */ - } - } - - /* Last two */ - for (; i < lenInChars; i++) { - write[0] = inFirst[i]; - write++; - } - - *outAfterLast = write; -} - - - -static URI_INLINE void URI_FUNC(FixPercentEncodingInplace)(const URI_CHAR * first, - const URI_CHAR ** afterLast) { - /* Death checks */ - if ((first == NULL) || (afterLast == NULL) || (*afterLast == NULL)) { - return; - } - - /* Fix inplace */ - URI_FUNC(FixPercentEncodingEngine)(first, *afterLast, first, afterLast); -} - - - -static URI_INLINE UriBool URI_FUNC(FixPercentEncodingMalloc)(const URI_CHAR ** first, - const URI_CHAR ** afterLast, UriMemoryManager * memory) { - int lenInChars; - URI_CHAR * buffer; - - /* Death checks */ - if ((first == NULL) || (afterLast == NULL) - || (*first == NULL) || (*afterLast == NULL)) { - return URI_FALSE; - } - - /* Old text length */ - lenInChars = (int)(*afterLast - *first); - if (lenInChars == 0) { - return URI_TRUE; - } else if (lenInChars < 0) { - return URI_FALSE; - } - - /* New buffer */ - buffer = memory->malloc(memory, lenInChars * sizeof(URI_CHAR)); - if (buffer == NULL) { - return URI_FALSE; - } - - /* Fix on copy */ - URI_FUNC(FixPercentEncodingEngine)(*first, *afterLast, buffer, afterLast); - *first = buffer; - return URI_TRUE; -} - - - -static URI_INLINE UriBool URI_FUNC(MakeRangeOwner)(unsigned int * doneMask, - unsigned int maskTest, URI_TYPE(TextRange) * range, - UriMemoryManager * memory) { - if (((*doneMask & maskTest) == 0) - && (range->first != NULL) - && (range->afterLast != NULL) - && (range->afterLast > range->first)) { - const int lenInChars = (int)(range->afterLast - range->first); - const int lenInBytes = lenInChars * sizeof(URI_CHAR); - URI_CHAR * dup = memory->malloc(memory, lenInBytes); - if (dup == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - memcpy(dup, range->first, lenInBytes); - range->first = dup; - range->afterLast = dup + lenInChars; - *doneMask |= maskTest; - } - return URI_TRUE; -} - - - -static URI_INLINE UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, - unsigned int * doneMask, UriMemoryManager * memory) { - URI_TYPE(PathSegment) * walker = uri->pathHead; - if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_SCHEME, - &(uri->scheme), memory) - || !URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_USER_INFO, - &(uri->userInfo), memory) - || !URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_QUERY, - &(uri->query), memory) - || !URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_FRAGMENT, - &(uri->fragment), memory)) { - return URI_FALSE; /* Raises malloc error */ - } - - /* Host */ - if ((*doneMask & URI_NORMALIZE_HOST) == 0) { - if ((uri->hostData.ip4 == NULL) - && (uri->hostData.ip6 == NULL)) { - if (uri->hostData.ipFuture.first != NULL) { - /* IPvFuture */ - if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST, - &(uri->hostData.ipFuture), memory)) { - return URI_FALSE; /* Raises malloc error */ - } - uri->hostText.first = uri->hostData.ipFuture.first; - uri->hostText.afterLast = uri->hostData.ipFuture.afterLast; - } else if (uri->hostText.first != NULL) { - /* Regname */ - if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST, - &(uri->hostText), memory)) { - return URI_FALSE; /* Raises malloc error */ - } - } - } - } - - /* Path */ - if ((*doneMask & URI_NORMALIZE_PATH) == 0) { - while (walker != NULL) { - if (!URI_FUNC(MakeRangeOwner)(doneMask, 0, &(walker->text), memory)) { - /* Free allocations done so far and kill path */ - - /* Kill path to one before walker (if any) */ - URI_TYPE(PathSegment) * ranger = uri->pathHead; - while (ranger != walker) { - URI_TYPE(PathSegment) * const next = ranger->next; - if ((ranger->text.first != NULL) - && (ranger->text.afterLast != NULL) - && (ranger->text.afterLast > ranger->text.first)) { - memory->free(memory, (URI_CHAR *)ranger->text.first); - } - memory->free(memory, ranger); - ranger = next; - } - - /* Kill path from walker */ - while (walker != NULL) { - URI_TYPE(PathSegment) * const next = walker->next; - memory->free(memory, walker); - walker = next; - } - - uri->pathHead = NULL; - uri->pathTail = NULL; - return URI_FALSE; /* Raises malloc error */ - } - walker = walker->next; - } - *doneMask |= URI_NORMALIZE_PATH; - } - - /* Port text, must come last so we don't have to undo that one if it fails. * - * Otherwise we would need and extra enum flag for it although the port * - * cannot go unnormalized... */ - if (!URI_FUNC(MakeRangeOwner)(doneMask, 0, &(uri->portText), memory)) { - return URI_FALSE; /* Raises malloc error */ - } - - return URI_TRUE; -} - - - -unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)(const URI_TYPE(Uri) * uri) { - unsigned int outMask = URI_NORMALIZED; /* for NULL uri */ - URI_FUNC(NormalizeSyntaxMaskRequiredEx)(uri, &outMask); - return outMask; -} - - - -int URI_FUNC(NormalizeSyntaxMaskRequiredEx)(const URI_TYPE(Uri) * uri, - unsigned int * outMask) { - UriMemoryManager * const memory = NULL; /* no use of memory manager */ - -#if defined(__GNUC__) && ((__GNUC__ > 4) \ - || ((__GNUC__ == 4) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 2))) - /* Slower code that fixes a warning, not sure if this is a smart idea */ - URI_TYPE(Uri) writeableClone; -#endif - - if ((uri == NULL) || (outMask == NULL)) { - return URI_ERROR_NULL; - } - -#if defined(__GNUC__) && ((__GNUC__ > 4) \ - || ((__GNUC__ == 4) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 2))) - /* Slower code that fixes a warning, not sure if this is a smart idea */ - memcpy(&writeableClone, uri, 1 * sizeof(URI_TYPE(Uri))); - URI_FUNC(NormalizeSyntaxEngine)(&writeableClone, 0, outMask, memory); -#else - URI_FUNC(NormalizeSyntaxEngine)((URI_TYPE(Uri) *)uri, 0, outMask, memory); -#endif - return URI_SUCCESS; -} - - - -int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, unsigned int mask) { - return URI_FUNC(NormalizeSyntaxExMm)(uri, mask, NULL); -} - - - -int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, unsigned int mask, - UriMemoryManager * memory) { - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - return URI_FUNC(NormalizeSyntaxEngine)(uri, mask, NULL, memory); -} - - - -int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri) { - return URI_FUNC(NormalizeSyntaxEx)(uri, (unsigned int)-1); -} - - - -static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri, - unsigned int inMask, unsigned int * outMask, - UriMemoryManager * memory) { - unsigned int doneMask = URI_NORMALIZED; - - /* Not just doing inspection? -> memory manager required! */ - if (outMask == NULL) { - assert(memory != NULL); - } - - if (uri == NULL) { - if (outMask != NULL) { - *outMask = URI_NORMALIZED; - return URI_SUCCESS; - } else { - return URI_ERROR_NULL; - } - } - - if (outMask != NULL) { - /* Reset mask */ - *outMask = URI_NORMALIZED; - } else if (inMask == URI_NORMALIZED) { - /* Nothing to do */ - return URI_SUCCESS; - } - - /* Scheme, host */ - if (outMask != NULL) { - const UriBool normalizeScheme = URI_FUNC(ContainsUppercaseLetters)( - uri->scheme.first, uri->scheme.afterLast); - const UriBool normalizeHostCase = URI_FUNC(ContainsUppercaseLetters)( - uri->hostText.first, uri->hostText.afterLast); - if (normalizeScheme) { - *outMask |= URI_NORMALIZE_SCHEME; - } - - if (normalizeHostCase) { - *outMask |= URI_NORMALIZE_HOST; - } else { - const UriBool normalizeHostPrecent = URI_FUNC(ContainsUglyPercentEncoding)( - uri->hostText.first, uri->hostText.afterLast); - if (normalizeHostPrecent) { - *outMask |= URI_NORMALIZE_HOST; - } - } - } else { - /* Scheme */ - if ((inMask & URI_NORMALIZE_SCHEME) && (uri->scheme.first != NULL)) { - if (uri->owner) { - URI_FUNC(LowercaseInplace)(uri->scheme.first, uri->scheme.afterLast); - } else { - if (!URI_FUNC(LowercaseMalloc)(&(uri->scheme.first), &(uri->scheme.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_SCHEME; - } - } - - /* Host */ - if (inMask & URI_NORMALIZE_HOST) { - if (uri->hostData.ipFuture.first != NULL) { - /* IPvFuture */ - if (uri->owner) { - URI_FUNC(LowercaseInplace)(uri->hostData.ipFuture.first, - uri->hostData.ipFuture.afterLast); - } else { - if (!URI_FUNC(LowercaseMalloc)(&(uri->hostData.ipFuture.first), - &(uri->hostData.ipFuture.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_HOST; - } - uri->hostText.first = uri->hostData.ipFuture.first; - uri->hostText.afterLast = uri->hostData.ipFuture.afterLast; - } else if ((uri->hostText.first != NULL) - && (uri->hostData.ip4 == NULL) - && (uri->hostData.ip6 == NULL)) { - /* Regname */ - if (uri->owner) { - URI_FUNC(FixPercentEncodingInplace)(uri->hostText.first, - &(uri->hostText.afterLast)); - } else { - if (!URI_FUNC(FixPercentEncodingMalloc)( - &(uri->hostText.first), - &(uri->hostText.afterLast), - memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_HOST; - } - - URI_FUNC(LowercaseInplace)(uri->hostText.first, - uri->hostText.afterLast); - } - } - } - - /* User info */ - if (outMask != NULL) { - const UriBool normalizeUserInfo = URI_FUNC(ContainsUglyPercentEncoding)( - uri->userInfo.first, uri->userInfo.afterLast); - if (normalizeUserInfo) { - *outMask |= URI_NORMALIZE_USER_INFO; - } - } else { - if ((inMask & URI_NORMALIZE_USER_INFO) && (uri->userInfo.first != NULL)) { - if (uri->owner) { - URI_FUNC(FixPercentEncodingInplace)(uri->userInfo.first, &(uri->userInfo.afterLast)); - } else { - if (!URI_FUNC(FixPercentEncodingMalloc)(&(uri->userInfo.first), - &(uri->userInfo.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_USER_INFO; - } - } - } - - /* Path */ - if (outMask != NULL) { - const URI_TYPE(PathSegment) * walker = uri->pathHead; - while (walker != NULL) { - const URI_CHAR * const first = walker->text.first; - const URI_CHAR * const afterLast = walker->text.afterLast; - if ((first != NULL) - && (afterLast != NULL) - && (afterLast > first) - && ( - (((afterLast - first) == 1) - && (first[0] == _UT('.'))) - || - (((afterLast - first) == 2) - && (first[0] == _UT('.')) - && (first[1] == _UT('.'))) - || - URI_FUNC(ContainsUglyPercentEncoding)(first, afterLast) - )) { - *outMask |= URI_NORMALIZE_PATH; - break; - } - walker = walker->next; - } - } else if (inMask & URI_NORMALIZE_PATH) { - URI_TYPE(PathSegment) * walker; - const UriBool relative = ((uri->scheme.first == NULL) - && !uri->absolutePath) ? URI_TRUE : URI_FALSE; - - /* Fix percent-encoding for each segment */ - walker = uri->pathHead; - if (uri->owner) { - while (walker != NULL) { - URI_FUNC(FixPercentEncodingInplace)(walker->text.first, &(walker->text.afterLast)); - walker = walker->next; - } - } else { - while (walker != NULL) { - if (!URI_FUNC(FixPercentEncodingMalloc)(&(walker->text.first), - &(walker->text.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - walker = walker->next; - } - doneMask |= URI_NORMALIZE_PATH; - } - - /* 6.2.2.3 Path Segment Normalization */ - if (!URI_FUNC(RemoveDotSegmentsEx)(uri, relative, - (uri->owner == URI_TRUE) - || ((doneMask & URI_NORMALIZE_PATH) != 0), - memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - URI_FUNC(FixEmptyTrailSegment)(uri, memory); - } - - /* Query, fragment */ - if (outMask != NULL) { - const UriBool normalizeQuery = URI_FUNC(ContainsUglyPercentEncoding)( - uri->query.first, uri->query.afterLast); - const UriBool normalizeFragment = URI_FUNC(ContainsUglyPercentEncoding)( - uri->fragment.first, uri->fragment.afterLast); - if (normalizeQuery) { - *outMask |= URI_NORMALIZE_QUERY; - } - - if (normalizeFragment) { - *outMask |= URI_NORMALIZE_FRAGMENT; - } - } else { - /* Query */ - if ((inMask & URI_NORMALIZE_QUERY) && (uri->query.first != NULL)) { - if (uri->owner) { - URI_FUNC(FixPercentEncodingInplace)(uri->query.first, &(uri->query.afterLast)); - } else { - if (!URI_FUNC(FixPercentEncodingMalloc)(&(uri->query.first), - &(uri->query.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_QUERY; - } - } - - /* Fragment */ - if ((inMask & URI_NORMALIZE_FRAGMENT) && (uri->fragment.first != NULL)) { - if (uri->owner) { - URI_FUNC(FixPercentEncodingInplace)(uri->fragment.first, &(uri->fragment.afterLast)); - } else { - if (!URI_FUNC(FixPercentEncodingMalloc)(&(uri->fragment.first), - &(uri->fragment.afterLast), memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - doneMask |= URI_NORMALIZE_FRAGMENT; - } - } - } - - /* Dup all not duped yet */ - if ((outMask == NULL) && !uri->owner) { - if (!URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - uri->owner = URI_TRUE; - } - - return URI_SUCCESS; -} - - - -int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) { - unsigned int doneMask = URI_NORMALIZED; - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - if (uri == NULL) { - return URI_ERROR_NULL; - } - - if (uri->owner == URI_TRUE) { - return URI_SUCCESS; - } - - if (! URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - - uri->owner = URI_TRUE; - - return URI_SUCCESS; -} - - - -int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri) { - return URI_FUNC(MakeOwnerMm)(uri, NULL); -} - - - -#endif diff --git a/external/uriparser/src/UriNormalizeBase.c b/external/uriparser/src/UriNormalizeBase.c deleted file mode 100644 index a74fcd3..0000000 --- a/external/uriparser/src/UriNormalizeBase.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_DOXYGEN -# include "UriNormalizeBase.h" -#endif - - - -UriBool uriIsUnreserved(int code) { - switch (code) { - case L'a': /* ALPHA */ - case L'A': - case L'b': - case L'B': - case L'c': - case L'C': - case L'd': - case L'D': - case L'e': - case L'E': - case L'f': - case L'F': - case L'g': - case L'G': - case L'h': - case L'H': - case L'i': - case L'I': - case L'j': - case L'J': - case L'k': - case L'K': - case L'l': - case L'L': - case L'm': - case L'M': - case L'n': - case L'N': - case L'o': - case L'O': - case L'p': - case L'P': - case L'q': - case L'Q': - case L'r': - case L'R': - case L's': - case L'S': - case L't': - case L'T': - case L'u': - case L'U': - case L'v': - case L'V': - case L'w': - case L'W': - case L'x': - case L'X': - case L'y': - case L'Y': - case L'z': - case L'Z': - case L'0': /* DIGIT */ - case L'1': - case L'2': - case L'3': - case L'4': - case L'5': - case L'6': - case L'7': - case L'8': - case L'9': - case L'-': /* "-" / "." / "_" / "~" */ - case L'.': - case L'_': - case L'~': - return URI_TRUE; - - default: - return URI_FALSE; - } -} diff --git a/external/uriparser/src/UriNormalizeBase.h b/external/uriparser/src/UriNormalizeBase.h deleted file mode 100644 index 8651c86..0000000 --- a/external/uriparser/src/UriNormalizeBase.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_NORMALIZE_BASE_H -#define URI_NORMALIZE_BASE_H 1 - - - -#include - - - -UriBool uriIsUnreserved(int code); - - - -#endif /* URI_NORMALIZE_BASE_H */ diff --git a/external/uriparser/src/UriParse.c b/external/uriparser/src/UriParse.c deleted file mode 100644 index 0bc8f0a..0000000 --- a/external/uriparser/src/UriParse.c +++ /dev/null @@ -1,2410 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file UriParse.c - * Holds the RFC 3986 %URI parsing implementation. - * NOTE: This source file includes itself twice. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriParse.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriParse.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include -# include "UriCommon.h" -# include "UriMemory.h" -# include "UriParseBase.h" -#endif - - - -#define URI_SET_DIGIT \ - _UT('0'): \ - case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -#define URI_SET_HEX_LETTER_UPPER \ - _UT('A'): \ - case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -#define URI_SET_HEX_LETTER_LOWER \ - _UT('a'): \ - case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -#define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -#define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - - - -static const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseIpLit2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnHost)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePartHelperTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePathAbsNoLeadSlash)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePathRootless)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePchar)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePctEncoded)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseSegment)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseSegmentNz)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseUriReference)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseUriTail)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseUriTailTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); - -static UriBool URI_FUNC(OnExitOwnHost2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory); -static UriBool URI_FUNC(OnExitOwnHostUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory); -static UriBool URI_FUNC(OnExitOwnPortUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory); -static UriBool URI_FUNC(OnExitSegmentNzNcOrScheme2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory); -static void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state); - -static void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState) * state); - -static UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory); - -static void URI_FUNC(StopSyntax)(URI_TYPE(ParserState) * state, const URI_CHAR * errorPos, UriMemoryManager * memory); -static void URI_FUNC(StopMalloc)(URI_TYPE(ParserState) * state, UriMemoryManager * memory); - -static int URI_FUNC(ParseUriExMm)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory); - - - -static URI_INLINE void URI_FUNC(StopSyntax)(URI_TYPE(ParserState) * state, - const URI_CHAR * errorPos, UriMemoryManager * memory) { - URI_FUNC(FreeUriMembersMm)(state->uri, memory); - state->errorPos = errorPos; - state->errorCode = URI_ERROR_SYNTAX; -} - - - -static URI_INLINE void URI_FUNC(StopMalloc)(URI_TYPE(ParserState) * state, UriMemoryManager * memory) { - URI_FUNC(FreeUriMembersMm)(state->uri, memory); - state->errorPos = NULL; - state->errorCode = URI_ERROR_MALLOC; -} - - - -/* - * [authority]-><[>[ipLit2][authorityTwo] - * [authority]->[ownHostUserInfoNz] - * [authority]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseAuthority)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - /* "" regname host */ - state->uri->hostText.first = URI_FUNC(SafeToPointTo); - state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo); - return afterLast; - } - - switch (*first) { - case _UT('['): - { - const URI_CHAR * const afterIpLit2 - = URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory); - if (afterIpLit2 == NULL) { - return NULL; - } - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast); - } - - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - state->uri->userInfo.first = first; /* USERINFO BEGIN */ - return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory); - - default: - /* "" regname host */ - state->uri->hostText.first = URI_FUNC(SafeToPointTo); - state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo); - return first; - } -} - - - -/* - * [authorityTwo]-><:>[port] - * [authorityTwo]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT(':'): - { - const URI_CHAR * const afterPort = URI_FUNC(ParsePort)(state, first + 1, afterLast); - if (afterPort == NULL) { - return NULL; - } - state->uri->portText.first = first + 1; /* PORT BEGIN */ - state->uri->portText.afterLast = afterPort; /* PORT END */ - return afterPort; - } - - default: - return first; - } -} - - - -/* - * [hexZero]->[HEXDIG][hexZero] - * [hexZero]-> - */ -static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case URI_SET_HEXDIG: - return URI_FUNC(ParseHexZero)(state, first + 1, afterLast); - - default: - return first; - } -} - - - -/* - * [hierPart]->[pathRootless] - * [hierPart]->[partHelperTwo] - * [hierPart]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseHierPart)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory); - - case _UT('/'): - return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory); - - default: - return first; - } -} - - - -/* - * [ipFutLoop]->[subDelims][ipFutStopGo] - * [ipFutLoop]->[unreserved][ipFutStopGo] - * [ipFutLoop]-><:>[ipFutStopGo] - */ -static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseIpFutStopGo)(state, first + 1, afterLast, memory); - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -/* - * [ipFutStopGo]->[ipFutLoop] - * [ipFutStopGo]-> - */ -static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory); - - default: - return first; - } -} - - - -/* - * [ipFuture]->[HEXDIG][hexZero]<.>[ipFutLoop] - */ -static const URI_CHAR * URI_FUNC(ParseIpFuture)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - /* - First character has already been - checked before entering this rule. - - switch (*first) { - case _UT('v'): - */ - if (first + 1 >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (first[1]) { - case URI_SET_HEXDIG: - { - const URI_CHAR * afterIpFutLoop; - const URI_CHAR * const afterHexZero - = URI_FUNC(ParseHexZero)(state, first + 2, afterLast); - if (afterHexZero == NULL) { - return NULL; - } - if (afterHexZero >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - if (*afterHexZero != _UT('.')) { - URI_FUNC(StopSyntax)(state, afterHexZero, memory); - return NULL; - } - state->uri->hostText.first = first; /* HOST BEGIN */ - state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */ - afterIpFutLoop = URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory); - if (afterIpFutLoop == NULL) { - return NULL; - } - state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */ - state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */ - return afterIpFutLoop; - } - - default: - URI_FUNC(StopSyntax)(state, first + 1, memory); - return NULL; - } - - /* - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - */ -} - - - -/* - * [ipLit2]->[ipFuture]<]> - * [ipLit2]->[IPv6address2] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseIpLit2)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('v'): - { - const URI_CHAR * const afterIpFuture - = URI_FUNC(ParseIpFuture)(state, first, afterLast, memory); - if (afterIpFuture == NULL) { - return NULL; - } - if (afterIpFuture >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - if (*afterIpFuture != _UT(']')) { - URI_FUNC(StopSyntax)(state, afterIpFuture, memory); - return NULL; - } - return afterIpFuture + 1; - } - - case _UT(':'): - case _UT(']'): - case URI_SET_HEXDIG: - state->uri->hostData.ip6 = memory->malloc(memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */ - if (state->uri->hostData.ip6 == NULL) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory); - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -/* - * [IPv6address2]->..<]> - */ -static const URI_CHAR * URI_FUNC(ParseIPv6address2)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - int zipperEver = 0; - int quadsDone = 0; - int digitCount = 0; - unsigned char digitHistory[4]; - int ip4OctetsDone = 0; - - unsigned char quadsAfterZipper[14]; - int quadsAfterZipperCount = 0; - - - for (;;) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - /* Inside IPv4 part? */ - if (ip4OctetsDone > 0) { - /* Eat rest of IPv4 address */ - for (;;) { - switch (*first) { - case URI_SET_DIGIT: - if (digitCount == 4) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9')); - break; - - case _UT('.'): - if ((ip4OctetsDone == 4) /* NOTE! */ - || (digitCount == 0) - || (digitCount == 4)) { - /* Invalid digit or octet count */ - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } else if ((digitCount > 1) - && (digitHistory[0] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount, memory); - return NULL; - } else if ((digitCount > 2) - && (digitHistory[1] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount + 1, memory); - return NULL; - } else if ((digitCount == 3) - && (100 * digitHistory[0] - + 10 * digitHistory[1] - + digitHistory[2] > 255)) { - /* Octet value too large */ - if (digitHistory[0] > 2) { - URI_FUNC(StopSyntax)(state, first - 3, memory); - } else if (digitHistory[1] > 5) { - URI_FUNC(StopSyntax)(state, first - 2, memory); - } else { - URI_FUNC(StopSyntax)(state, first - 1, memory); - } - return NULL; - } - - /* Copy IPv4 octet */ - state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] = uriGetOctetValue(digitHistory, digitCount); - digitCount = 0; - ip4OctetsDone++; - break; - - case _UT(']'): - if ((ip4OctetsDone != 3) /* NOTE! */ - || (digitCount == 0) - || (digitCount == 4)) { - /* Invalid digit or octet count */ - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } else if ((digitCount > 1) - && (digitHistory[0] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount, memory); - return NULL; - } else if ((digitCount > 2) - && (digitHistory[1] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount + 1, memory); - return NULL; - } else if ((digitCount == 3) - && (100 * digitHistory[0] - + 10 * digitHistory[1] - + digitHistory[2] > 255)) { - /* Octet value too large */ - if (digitHistory[0] > 2) { - URI_FUNC(StopSyntax)(state, first - 3, memory); - } else if (digitHistory[1] > 5) { - URI_FUNC(StopSyntax)(state, first - 2, memory); - } else { - URI_FUNC(StopSyntax)(state, first - 1, memory); - } - return NULL; - } - - state->uri->hostText.afterLast = first; /* HOST END */ - - /* Copy missing quads right before IPv4 */ - memcpy(state->uri->hostData.ip6->data + 16 - 4 - 2 * quadsAfterZipperCount, - quadsAfterZipper, 2 * quadsAfterZipperCount); - - /* Copy last IPv4 octet */ - state->uri->hostData.ip6->data[16 - 4 + 3] = uriGetOctetValue(digitHistory, digitCount); - - return first + 1; - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - first++; - - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - } - } else { - /* Eat while no dot in sight */ - int letterAmong = 0; - int walking = 1; - do { - switch (*first) { - case URI_SET_HEX_LETTER_LOWER: - letterAmong = 1; - if (digitCount == 4) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f')); - digitCount++; - break; - - case URI_SET_HEX_LETTER_UPPER: - letterAmong = 1; - if (digitCount == 4) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F')); - digitCount++; - break; - - case URI_SET_DIGIT: - if (digitCount == 4) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9')); - digitCount++; - break; - - case _UT(':'): - { - int setZipper = 0; - - if (digitCount > 0) { - if (zipperEver) { - uriWriteQuadToDoubleByte(digitHistory, digitCount, quadsAfterZipper + 2 * quadsAfterZipperCount); - quadsAfterZipperCount++; - } else { - uriWriteQuadToDoubleByte(digitHistory, digitCount, state->uri->hostData.ip6->data + 2 * quadsDone); - } - quadsDone++; - digitCount = 0; - } - letterAmong = 0; - - /* Too many quads? */ - if (quadsDone >= 8 - zipperEver) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - - /* "::"? */ - if (first + 1 >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - if (first[1] == _UT(':')) { - const int resetOffset = 2 * (quadsDone + (digitCount > 0)); - - first++; - if (zipperEver) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; /* "::.+::" */ - } - - /* Zero everything after zipper */ - memset(state->uri->hostData.ip6->data + resetOffset, 0, 16 - resetOffset); - setZipper = 1; - - /* ":::+"? */ - if (first + 1 >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; /* No ']' yet */ - } - if (first[1] == _UT(':')) { - URI_FUNC(StopSyntax)(state, first + 1, memory); - return NULL; /* ":::+ "*/ - } - } - - if (setZipper) { - zipperEver = 1; - } - } - break; - - case _UT('.'): - if ((quadsDone > 6) /* NOTE */ - || (!zipperEver && (quadsDone < 6)) - || letterAmong - || (digitCount == 0) - || (digitCount == 4)) { - /* Invalid octet before */ - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } else if ((digitCount > 1) - && (digitHistory[0] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount, memory); - return NULL; - } else if ((digitCount > 2) - && (digitHistory[1] == 0)) { - /* Leading zero */ - URI_FUNC(StopSyntax)(state, first - digitCount + 1, memory); - return NULL; - } else if ((digitCount == 3) - && (100 * digitHistory[0] - + 10 * digitHistory[1] - + digitHistory[2] > 255)) { - /* Octet value too large */ - if (digitHistory[0] > 2) { - URI_FUNC(StopSyntax)(state, first - 3, memory); - } else if (digitHistory[1] > 5) { - URI_FUNC(StopSyntax)(state, first - 2, memory); - } else { - URI_FUNC(StopSyntax)(state, first - 1, memory); - } - return NULL; - } - - /* Copy first IPv4 octet */ - state->uri->hostData.ip6->data[16 - 4] = uriGetOctetValue(digitHistory, digitCount); - digitCount = 0; - - /* Switch over to IPv4 loop */ - ip4OctetsDone = 1; - walking = 0; - break; - - case _UT(']'): - /* Too little quads? */ - if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) { - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - - if (digitCount > 0) { - if (zipperEver) { - uriWriteQuadToDoubleByte(digitHistory, digitCount, quadsAfterZipper + 2 * quadsAfterZipperCount); - quadsAfterZipperCount++; - } else { - uriWriteQuadToDoubleByte(digitHistory, digitCount, state->uri->hostData.ip6->data + 2 * quadsDone); - } - /* - quadsDone++; - digitCount = 0; - */ - } - - /* Copy missing quads to the end */ - memcpy(state->uri->hostData.ip6->data + 16 - 2 * quadsAfterZipperCount, - quadsAfterZipper, 2 * quadsAfterZipperCount); - - state->uri->hostText.afterLast = first; /* HOST END */ - return first + 1; /* Fine */ - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - first++; - - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; /* No ']' yet */ - } - } while (walking); - } - } -} - - - -/* - * [mustBeSegmentNzNc]->[pctEncoded][mustBeSegmentNzNc] - * [mustBeSegmentNzNc]->[subDelims][mustBeSegmentNzNc] - * [mustBeSegmentNzNc]->[unreserved][mustBeSegmentNzNc] - * [mustBeSegmentNzNc]->[uriTail] // can take - * [mustBeSegmentNzNc]->[segment][zeroMoreSlashSegs][uriTail] - * [mustBeSegmentNzNc]-><@>[mustBeSegmentNzNc] - */ -static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - state->uri->scheme.first = NULL; /* Not a scheme, reset */ - return afterLast; - } - - switch (*first) { - case _UT('%'): - { - const URI_CHAR * const afterPctEncoded - = URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - if (afterPctEncoded == NULL) { - return NULL; - } - return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast, memory); - } - - case _UT('@'): - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory); - - case _UT('/'): - { - const URI_CHAR * afterZeroMoreSlashSegs; - const URI_CHAR * afterSegment; - if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - state->uri->scheme.first = NULL; /* Not a scheme, reset */ - afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory); - if (afterSegment == NULL) { - return NULL; - } - if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - afterZeroMoreSlashSegs - = URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory); - if (afterZeroMoreSlashSegs == NULL) { - return NULL; - } - return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory); - } - - default: - if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - state->uri->scheme.first = NULL; /* Not a scheme, reset */ - return URI_FUNC(ParseUriTail)(state, first, afterLast, memory); - } -} - - - -/* - * [ownHost]-><[>[ipLit2][authorityTwo] - * [ownHost]->[ownHost2] // can take - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseOwnHost)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - state->uri->hostText.afterLast = afterLast; /* HOST END */ - return afterLast; - } - - switch (*first) { - case _UT('['): - { - const URI_CHAR * const afterIpLit2 - = URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory); - if (afterIpLit2 == NULL) { - return NULL; - } - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast); - } - - default: - return URI_FUNC(ParseOwnHost2)(state, first, afterLast, memory); - } -} - - - -static URI_INLINE UriBool URI_FUNC(OnExitOwnHost2)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - UriMemoryManager * memory) { - state->uri->hostText.afterLast = first; /* HOST END */ - - /* Valid IPv4 or just a regname? */ - state->uri->hostData.ip4 = memory->malloc(memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */ - if (state->uri->hostData.ip4 == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data, - state->uri->hostText.first, state->uri->hostText.afterLast)) { - /* Not IPv4 */ - memory->free(memory, state->uri->hostData.ip4); - state->uri->hostData.ip4 = NULL; - } - return URI_TRUE; /* Success */ -} - - - -/* - * [ownHost2]->[authorityTwo] // can take - * [ownHost2]->[pctSubUnres][ownHost2] - */ -static const URI_CHAR * URI_FUNC(ParseOwnHost2)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterPctSubUnres - = URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); - if (afterPctSubUnres == NULL) { - return NULL; - } - return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory); - } - - default: - if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast); - } -} - - - -static URI_INLINE UriBool URI_FUNC(OnExitOwnHostUserInfo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - UriMemoryManager * memory) { - state->uri->hostText.first = state->uri->userInfo.first; /* Host instead of userInfo, update */ - state->uri->userInfo.first = NULL; /* Not a userInfo, reset */ - state->uri->hostText.afterLast = first; /* HOST END */ - - /* Valid IPv4 or just a regname? */ - state->uri->hostData.ip4 = memory->malloc(memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */ - if (state->uri->hostData.ip4 == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data, - state->uri->hostText.first, state->uri->hostText.afterLast)) { - /* Not IPv4 */ - memory->free(memory, state->uri->hostData.ip4); - state->uri->hostData.ip4 = NULL; - } - return URI_TRUE; /* Success */ -} - - - -/* - * [ownHostUserInfo]->[ownHostUserInfoNz] - * [ownHostUserInfo]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseOwnHostUserInfo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory); - - default: - if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return first; - } -} - - - -/* - * [ownHostUserInfoNz]->[pctSubUnres][ownHostUserInfo] - * [ownHostUserInfoNz]-><:>[ownPortUserInfo] - * [ownHostUserInfoNz]-><@>[ownHost] - */ -static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterPctSubUnres - = URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); - if (afterPctSubUnres == NULL) { - return NULL; - } - return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory); - } - - case _UT(':'): - state->uri->hostText.afterLast = first; /* HOST END */ - state->uri->portText.first = first + 1; /* PORT BEGIN */ - return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory); - - case _UT('@'): - state->uri->userInfo.afterLast = first; /* USERINFO END */ - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory); - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -static URI_INLINE UriBool URI_FUNC(OnExitOwnPortUserInfo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - UriMemoryManager * memory) { - state->uri->hostText.first = state->uri->userInfo.first; /* Host instead of userInfo, update */ - state->uri->userInfo.first = NULL; /* Not a userInfo, reset */ - state->uri->portText.afterLast = first; /* PORT END */ - - /* Valid IPv4 or just a regname? */ - state->uri->hostData.ip4 = memory->malloc(memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */ - if (state->uri->hostData.ip4 == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data, - state->uri->hostText.first, state->uri->hostText.afterLast)) { - /* Not IPv4 */ - memory->free(memory, state->uri->hostData.ip4); - state->uri->hostData.ip4 = NULL; - } - return URI_TRUE; /* Success */ -} - - - -/* - * [ownPortUserInfo]->[ALPHA][ownUserInfo] - * [ownPortUserInfo]->[DIGIT][ownPortUserInfo] - * [ownPortUserInfo]-><.>[ownUserInfo] - * [ownPortUserInfo]-><_>[ownUserInfo] - * [ownPortUserInfo]-><~>[ownUserInfo] - * [ownPortUserInfo]-><->[ownUserInfo] - * [ownPortUserInfo]->[subDelims][ownUserInfo] - * [ownPortUserInfo]->[pctEncoded][ownUserInfo] - * [ownPortUserInfo]-><:>[ownUserInfo] - * [ownPortUserInfo]-><@>[ownHost] - * [ownPortUserInfo]-> - */ -static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return afterLast; - } - - switch (*first) { - /* begin sub-delims */ - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('\''): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT('+'): - case _UT(','): - case _UT(';'): - case _UT('='): - /* end sub-delims */ - /* begin unreserved (except alpha and digit) */ - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - /* end unreserved (except alpha and digit) */ - case _UT(':'): - case URI_SET_ALPHA: - state->uri->hostText.afterLast = NULL; /* Not a host, reset */ - state->uri->portText.first = NULL; /* Not a port, reset */ - return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory); - - case URI_SET_DIGIT: - return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory); - - case _UT('%'): - state->uri->portText.first = NULL; /* Not a port, reset */ - { - const URI_CHAR * const afterPct - = URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - if (afterPct == NULL) { - return NULL; - } - return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory); - } - - case _UT('@'): - state->uri->hostText.afterLast = NULL; /* Not a host, reset */ - state->uri->portText.first = NULL; /* Not a port, reset */ - state->uri->userInfo.afterLast = first; /* USERINFO END */ - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory); - - default: - if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return first; - } -} - - - -/* - * [ownUserInfo]->[pctSubUnres][ownUserInfo] - * [ownUserInfo]-><:>[ownUserInfo] - * [ownUserInfo]-><@>[ownHost] - */ -static const URI_CHAR * URI_FUNC(ParseOwnUserInfo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterPctSubUnres - = URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); - if (afterPctSubUnres == NULL) { - return NULL; - } - return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory); - } - - case _UT(':'): - return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory); - - case _UT('@'): - /* SURE */ - state->uri->userInfo.afterLast = first; /* USERINFO END */ - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory); - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) { - state->uri->absolutePath = URI_TRUE; -} - - - -/* - * [partHelperTwo]->[pathAbsNoLeadSlash] // can take - * [partHelperTwo]->[authority][pathAbsEmpty] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParsePartHelperTwo)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(OnExitPartHelperTwo)(state); - return afterLast; - } - - switch (*first) { - case _UT('/'): - { - const URI_CHAR * const afterAuthority - = URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory); - const URI_CHAR * afterPathAbsEmpty; - if (afterAuthority == NULL) { - return NULL; - } - afterPathAbsEmpty = URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory); - - URI_FUNC(FixEmptyTrailSegment)(state->uri, memory); - - return afterPathAbsEmpty; - } - - default: - URI_FUNC(OnExitPartHelperTwo)(state); - return URI_FUNC(ParsePathAbsNoLeadSlash)(state, first, afterLast, memory); - } -} - - - -/* - * [pathAbsEmpty]->[segment][pathAbsEmpty] - * [pathAbsEmpty]-> - */ -static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('/'): - { - const URI_CHAR * const afterSegment - = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory); - if (afterSegment == NULL) { - return NULL; - } - if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory); - } - - default: - return first; - } -} - - - -/* - * [pathAbsNoLeadSlash]->[segmentNz][zeroMoreSlashSegs] - * [pathAbsNoLeadSlash]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParsePathAbsNoLeadSlash)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterSegmentNz - = URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory); - if (afterSegmentNz == NULL) { - return NULL; - } - if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory); - } - - default: - return first; - } -} - - - -/* - * [pathRootless]->[segmentNz][zeroMoreSlashSegs] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParsePathRootless)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - const URI_CHAR * const afterSegmentNz - = URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory); - if (afterSegmentNz == NULL) { - return NULL; - } else { - if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - } - return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory); -} - - - -/* - * [pchar]->[pctEncoded] - * [pchar]->[subDelims] - * [pchar]->[unreserved] - * [pchar]-><:> - * [pchar]-><@> - */ -static const URI_CHAR * URI_FUNC(ParsePchar)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('%'): - return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - - case _UT(':'): - case _UT('@'): - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return first + 1; - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -/* - * [pctEncoded]-><%>[HEXDIG][HEXDIG] - */ -static const URI_CHAR * URI_FUNC(ParsePctEncoded)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - /* - First character has already been - checked before entering this rule. - - switch (*first) { - case _UT('%'): - */ - if (first + 1 >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (first[1]) { - case URI_SET_HEXDIG: - if (first + 2 >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (first[2]) { - case URI_SET_HEXDIG: - return first + 3; - - default: - URI_FUNC(StopSyntax)(state, first + 2, memory); - return NULL; - } - - default: - URI_FUNC(StopSyntax)(state, first + 1, memory); - return NULL; - } - - /* - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } - */ -} - - - -/* - * [pctSubUnres]->[pctEncoded] - * [pctSubUnres]->[subDelims] - * [pctSubUnres]->[unreserved] - */ -static const URI_CHAR * URI_FUNC(ParsePctSubUnres)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } - - switch (*first) { - case _UT('%'): - return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return first + 1; - - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; - } -} - - - -/* - * [port]->[DIGIT][port] - * [port]-> - */ -static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case URI_SET_DIGIT: - return URI_FUNC(ParsePort)(state, first + 1, afterLast); - - default: - return first; - } -} - - - -/* - * [queryFrag]->[pchar][queryFrag] - * [queryFrag]->[queryFrag] - * [queryFrag]->[queryFrag] - * [queryFrag]-> - */ -static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterPchar - = URI_FUNC(ParsePchar)(state, first, afterLast, memory); - if (afterPchar == NULL) { - return NULL; - } - return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory); - } - - case _UT('/'): - case _UT('?'): - return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory); - - default: - return first; - } -} - - - -/* - * [segment]->[pchar][segment] - * [segment]-> - */ -static const URI_CHAR * URI_FUNC(ParseSegment)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - { - const URI_CHAR * const afterPchar - = URI_FUNC(ParsePchar)(state, first, afterLast, memory); - if (afterPchar == NULL) { - return NULL; - } - return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory); - } - - default: - return first; - } -} - - - -/* - * [segmentNz]->[pchar][segment] - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseSegmentNz)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - const URI_CHAR * const afterPchar - = URI_FUNC(ParsePchar)(state, first, afterLast, memory); - if (afterPchar == NULL) { - return NULL; - } - return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory); -} - - - -static URI_INLINE UriBool URI_FUNC(OnExitSegmentNzNcOrScheme2)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - UriMemoryManager * memory) { - if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ - return URI_FALSE; /* Raises malloc error*/ - } - state->uri->scheme.first = NULL; /* Not a scheme, reset */ - return URI_TRUE; /* Success */ -} - - - -/* - * [segmentNzNcOrScheme2]->[ALPHA][segmentNzNcOrScheme2] - * [segmentNzNcOrScheme2]->[DIGIT][segmentNzNcOrScheme2] - * [segmentNzNcOrScheme2]->[pctEncoded][mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]->[uriTail] // can take - * [segmentNzNcOrScheme2]->[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><$>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><&>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><(>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><)>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><*>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><,>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><.>[segmentNzNcOrScheme2] - * [segmentNzNcOrScheme2]->[segment][zeroMoreSlashSegs][uriTail] - * [segmentNzNcOrScheme2]-><:>[hierPart][uriTail] - * [segmentNzNcOrScheme2]-><;>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><@>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><_>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><~>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><+>[segmentNzNcOrScheme2] - * [segmentNzNcOrScheme2]-><=>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><'>[mustBeSegmentNzNc] - * [segmentNzNcOrScheme2]-><->[segmentNzNcOrScheme2] - */ -static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return afterLast; - } - - switch (*first) { - case _UT('.'): - case _UT('+'): - case _UT('-'): - case URI_SET_ALPHA: - case URI_SET_DIGIT: - return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory); - - case _UT('%'): - { - const URI_CHAR * const afterPctEncoded - = URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - if (afterPctEncoded == NULL) { - return NULL; - } - return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast, memory); - } - - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('@'): - case _UT('_'): - case _UT('~'): - case _UT('='): - case _UT('\''): - return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory); - - case _UT('/'): - { - const URI_CHAR * afterZeroMoreSlashSegs; - const URI_CHAR * const afterSegment - = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory); - if (afterSegment == NULL) { - return NULL; - } - if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - state->uri->scheme.first = NULL; /* Not a scheme, reset */ - if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - afterZeroMoreSlashSegs - = URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory); - if (afterZeroMoreSlashSegs == NULL) { - return NULL; - } - return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory); - } - - case _UT(':'): - { - const URI_CHAR * const afterHierPart - = URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory); - state->uri->scheme.afterLast = first; /* SCHEME END */ - if (afterHierPart == NULL) { - return NULL; - } - return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory); - } - - default: - if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParseUriTail)(state, first, afterLast, memory); - } -} - - - -/* - * [uriReference]->[ALPHA][segmentNzNcOrScheme2] - * [uriReference]->[DIGIT][mustBeSegmentNzNc] - * [uriReference]->[pctEncoded][mustBeSegmentNzNc] - * [uriReference]->[subDelims][mustBeSegmentNzNc] - * [uriReference]->[uriTail] // can take - * [uriReference]-><.>[mustBeSegmentNzNc] - * [uriReference]->[partHelperTwo][uriTail] - * [uriReference]-><@>[mustBeSegmentNzNc] - * [uriReference]-><_>[mustBeSegmentNzNc] - * [uriReference]-><~>[mustBeSegmentNzNc] - * [uriReference]-><->[mustBeSegmentNzNc] - */ -static const URI_CHAR * URI_FUNC(ParseUriReference)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case URI_SET_ALPHA: - state->uri->scheme.first = first; /* SCHEME BEGIN */ - return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory); - - case URI_SET_DIGIT: - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case _UT('-'): - case _UT('@'): - state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */ - return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory); - - case _UT('%'): - { - const URI_CHAR * const afterPctEncoded - = URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - if (afterPctEncoded == NULL) { - return NULL; - } - state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */ - return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast, memory); - } - - case _UT('/'): - { - const URI_CHAR * const afterPartHelperTwo - = URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory); - if (afterPartHelperTwo == NULL) { - return NULL; - } - return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory); - } - - default: - return URI_FUNC(ParseUriTail)(state, first, afterLast, memory); - } -} - - - -/* - * [uriTail]-><#>[queryFrag] - * [uriTail]->[queryFrag][uriTailTwo] - * [uriTail]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseUriTail)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('#'): - { - const URI_CHAR * const afterQueryFrag = URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory); - if (afterQueryFrag == NULL) { - return NULL; - } - state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */ - state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */ - return afterQueryFrag; - } - - case _UT('?'): - { - const URI_CHAR * const afterQueryFrag - = URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory); - if (afterQueryFrag == NULL) { - return NULL; - } - state->uri->query.first = first + 1; /* QUERY BEGIN */ - state->uri->query.afterLast = afterQueryFrag; /* QUERY END */ - return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory); - } - - default: - return first; - } -} - - - -/* - * [uriTailTwo]-><#>[queryFrag] - * [uriTailTwo]-> - */ -static URI_INLINE const URI_CHAR * URI_FUNC(ParseUriTailTwo)( - URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('#'): - { - const URI_CHAR * const afterQueryFrag = URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory); - if (afterQueryFrag == NULL) { - return NULL; - } - state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */ - state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */ - return afterQueryFrag; - } - - default: - return first; - } -} - - - -/* - * [zeroMoreSlashSegs]->[segment][zeroMoreSlashSegs] - * [zeroMoreSlashSegs]-> - */ -static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; - } - - switch (*first) { - case _UT('/'): - { - const URI_CHAR * const afterSegment - = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory); - if (afterSegment == NULL) { - return NULL; - } - if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment, memory)) { /* SEGMENT BOTH */ - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory); - } - - default: - return first; - } -} - - - -static URI_INLINE void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState) * state) { - URI_TYPE(Uri) * const uriBackup = state->uri; - memset(state, 0, sizeof(URI_TYPE(ParserState))); - state->uri = uriBackup; -} - - - -static URI_INLINE UriBool URI_FUNC(PushPathSegment)( - URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - URI_TYPE(PathSegment) * segment = memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment))); - if (segment == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - if (first == afterLast) { - segment->text.first = URI_FUNC(SafeToPointTo); - segment->text.afterLast = URI_FUNC(SafeToPointTo); - } else { - segment->text.first = first; - segment->text.afterLast = afterLast; - } - - /* First segment ever? */ - if (state->uri->pathHead == NULL) { - /* First segment ever, set head and tail */ - state->uri->pathHead = segment; - state->uri->pathTail = segment; - } else { - /* Append, update tail */ - state->uri->pathTail->next = segment; - state->uri->pathTail = segment; - } - - return URI_TRUE; /* Success */ -} - - - -int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast) { - return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL); -} - - - -static int URI_FUNC(ParseUriExMm)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - const URI_CHAR * afterUriReference; - URI_TYPE(Uri) * uri; - - /* Check params */ - if ((state == NULL) || (first == NULL) || (afterLast == NULL)) { - return URI_ERROR_NULL; - } - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - uri = state->uri; - - /* Init parser */ - URI_FUNC(ResetParserStateExceptUri)(state); - URI_FUNC(ResetUri)(uri); - - /* Parse */ - afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory); - if (afterUriReference == NULL) { - /* Waterproof errorPos <= afterLast */ - if (state->errorPos && (state->errorPos > afterLast)) { - state->errorPos = afterLast; - } - return state->errorCode; - } - if (afterUriReference != afterLast) { - if (afterUriReference < afterLast) { - URI_FUNC(StopSyntax)(state, afterUriReference, memory); - } else { - URI_FUNC(StopSyntax)(state, afterLast, memory); - } - return state->errorCode; - } - return URI_SUCCESS; -} - - - -int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) { - if ((state == NULL) || (text == NULL)) { - return URI_ERROR_NULL; - } - return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text)); -} - - - -int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, const URI_CHAR * text, - const URI_CHAR ** errorPos) { - return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos); -} - - - -int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos) { - if ((afterLast == NULL) && (first != NULL)) { - afterLast = first + URI_STRLEN(first); - } - return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL); -} - - - -int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos, UriMemoryManager * memory) { - URI_TYPE(ParserState) state; - int res; - - /* Check params */ - if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) { - return URI_ERROR_NULL; - } - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - state.uri = uri; - - res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory); - - if (res != URI_SUCCESS) { - if (errorPos != NULL) { - *errorPos = state.errorPos; - } - URI_FUNC(FreeUriMembersMm)(uri, memory); - } - - return res; -} - - - -void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) { - URI_FUNC(FreeUriMembersMm)(uri, NULL); -} - - - -int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) { - if (uri == NULL) { - return URI_ERROR_NULL; - } - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - if (uri->owner) { - /* Scheme */ - if (uri->scheme.first != NULL) { - if (uri->scheme.first != uri->scheme.afterLast) { - memory->free(memory, (URI_CHAR *)uri->scheme.first); - } - uri->scheme.first = NULL; - uri->scheme.afterLast = NULL; - } - - /* User info */ - if (uri->userInfo.first != NULL) { - if (uri->userInfo.first != uri->userInfo.afterLast) { - memory->free(memory, (URI_CHAR *)uri->userInfo.first); - } - uri->userInfo.first = NULL; - uri->userInfo.afterLast = NULL; - } - - /* Host data - IPvFuture */ - if (uri->hostData.ipFuture.first != NULL) { - if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) { - memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first); - } - uri->hostData.ipFuture.first = NULL; - uri->hostData.ipFuture.afterLast = NULL; - uri->hostText.first = NULL; - uri->hostText.afterLast = NULL; - } - - /* Host text (if regname, after IPvFuture!) */ - if ((uri->hostText.first != NULL) - && (uri->hostData.ip4 == NULL) - && (uri->hostData.ip6 == NULL)) { - /* Real regname */ - if (uri->hostText.first != uri->hostText.afterLast) { - memory->free(memory, (URI_CHAR *)uri->hostText.first); - } - uri->hostText.first = NULL; - uri->hostText.afterLast = NULL; - } - } - - /* Host data - IPv4 */ - if (uri->hostData.ip4 != NULL) { - memory->free(memory, uri->hostData.ip4); - uri->hostData.ip4 = NULL; - } - - /* Host data - IPv6 */ - if (uri->hostData.ip6 != NULL) { - memory->free(memory, uri->hostData.ip6); - uri->hostData.ip6 = NULL; - } - - /* Port text */ - if (uri->owner && (uri->portText.first != NULL)) { - if (uri->portText.first != uri->portText.afterLast) { - memory->free(memory, (URI_CHAR *)uri->portText.first); - } - uri->portText.first = NULL; - uri->portText.afterLast = NULL; - } - - /* Path */ - if (uri->pathHead != NULL) { - URI_TYPE(PathSegment) * segWalk = uri->pathHead; - while (segWalk != NULL) { - URI_TYPE(PathSegment) * const next = segWalk->next; - if (uri->owner && (segWalk->text.first != NULL) - && (segWalk->text.first < segWalk->text.afterLast)) { - memory->free(memory, (URI_CHAR *)segWalk->text.first); - } - memory->free(memory, segWalk); - segWalk = next; - } - uri->pathHead = NULL; - uri->pathTail = NULL; - } - - if (uri->owner) { - /* Query */ - if (uri->query.first != NULL) { - if (uri->query.first != uri->query.afterLast) { - memory->free(memory, (URI_CHAR *)uri->query.first); - } - uri->query.first = NULL; - uri->query.afterLast = NULL; - } - - /* Fragment */ - if (uri->fragment.first != NULL) { - if (uri->fragment.first != uri->fragment.afterLast) { - memory->free(memory, (URI_CHAR *)uri->fragment.first); - } - uri->fragment.first = NULL; - uri->fragment.afterLast = NULL; - } - } - - return URI_SUCCESS; -} - - - -UriBool URI_FUNC(_TESTING_ONLY_ParseIpSix)(const URI_CHAR * text) { - UriMemoryManager * const memory = &defaultMemoryManager; - URI_TYPE(Uri) uri; - URI_TYPE(ParserState) parser; - const URI_CHAR * const afterIpSix = text + URI_STRLEN(text); - const URI_CHAR * res; - - URI_FUNC(ResetUri)(&uri); - parser.uri = &uri; - URI_FUNC(ResetParserStateExceptUri)(&parser); - parser.uri->hostData.ip6 = memory->malloc(memory, 1 * sizeof(UriIp6)); - res = URI_FUNC(ParseIPv6address2)(&parser, text, afterIpSix, memory); - URI_FUNC(FreeUriMembersMm)(&uri, memory); - return res == afterIpSix ? URI_TRUE : URI_FALSE; -} - - - -UriBool URI_FUNC(_TESTING_ONLY_ParseIpFour)(const URI_CHAR * text) { - unsigned char octets[4]; - int res = URI_FUNC(ParseIpFourAddress)(octets, text, text + URI_STRLEN(text)); - return (res == URI_SUCCESS) ? URI_TRUE : URI_FALSE; -} - - - -#undef URI_SET_DIGIT -#undef URI_SET_HEX_LETTER_UPPER -#undef URI_SET_HEX_LETTER_LOWER -#undef URI_SET_HEXDIG -#undef URI_SET_ALPHA - - - -#endif diff --git a/external/uriparser/src/UriParseBase.c b/external/uriparser/src/UriParseBase.c deleted file mode 100644 index 3a4aa08..0000000 --- a/external/uriparser/src/UriParseBase.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_DOXYGEN -# include "UriParseBase.h" -#endif - - - -void uriWriteQuadToDoubleByte(const unsigned char * hexDigits, int digitCount, unsigned char * output) { - switch (digitCount) { - case 1: - /* 0x___? -> \x00 \x0? */ - output[0] = 0; - output[1] = hexDigits[0]; - break; - - case 2: - /* 0x__?? -> \0xx \x?? */ - output[0] = 0; - output[1] = 16 * hexDigits[0] + hexDigits[1]; - break; - - case 3: - /* 0x_??? -> \0x? \x?? */ - output[0] = hexDigits[0]; - output[1] = 16 * hexDigits[1] + hexDigits[2]; - break; - - case 4: - /* 0x???? -> \0?? \x?? */ - output[0] = 16 * hexDigits[0] + hexDigits[1]; - output[1] = 16 * hexDigits[2] + hexDigits[3]; - break; - - } -} - - - -unsigned char uriGetOctetValue(const unsigned char * digits, int digitCount) { - switch (digitCount) { - case 1: - return digits[0]; - - case 2: - return 10 * digits[0] + digits[1]; - - case 3: - default: - return 100 * digits[0] + 10 * digits[1] + digits[2]; - - } -} diff --git a/external/uriparser/src/UriParseBase.h b/external/uriparser/src/UriParseBase.h deleted file mode 100644 index 6d7379d..0000000 --- a/external/uriparser/src/UriParseBase.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef URI_PARSE_BASE_H -#define URI_PARSE_BASE_H 1 - - - -#include - - - -void uriWriteQuadToDoubleByte(const unsigned char * hexDigits, int digitCount, - unsigned char * output); -unsigned char uriGetOctetValue(const unsigned char * digits, int digitCount); - - - -#endif /* URI_PARSE_BASE_H */ diff --git a/external/uriparser/src/UriQuery.c b/external/uriparser/src/UriQuery.c deleted file mode 100644 index b2734bc..0000000 --- a/external/uriparser/src/UriQuery.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriQuery.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriQuery.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -# include "UriMemory.h" -#endif - - - -#include - - - -static int URI_FUNC(ComposeQueryEngine)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, - int maxChars, int * charsWritten, int * charsRequired, - UriBool spaceToPlus, UriBool normalizeBreaks); - -static UriBool URI_FUNC(AppendQueryItem)(URI_TYPE(QueryList) ** prevNext, - int * itemCount, const URI_CHAR * keyFirst, const URI_CHAR * keyAfter, - const URI_CHAR * valueFirst, const URI_CHAR * valueAfter, - UriBool plusToSpace, UriBreakConversion breakConversion, - UriMemoryManager * memory); - - - -int URI_FUNC(ComposeQueryCharsRequired)(const URI_TYPE(QueryList) * queryList, - int * charsRequired) { - const UriBool spaceToPlus = URI_TRUE; - const UriBool normalizeBreaks = URI_TRUE; - - return URI_FUNC(ComposeQueryCharsRequiredEx)(queryList, charsRequired, - spaceToPlus, normalizeBreaks); -} - - - -int URI_FUNC(ComposeQueryCharsRequiredEx)(const URI_TYPE(QueryList) * queryList, - int * charsRequired, UriBool spaceToPlus, UriBool normalizeBreaks) { - if ((queryList == NULL) || (charsRequired == NULL)) { - return URI_ERROR_NULL; - } - - return URI_FUNC(ComposeQueryEngine)(NULL, queryList, 0, NULL, - charsRequired, spaceToPlus, normalizeBreaks); -} - - - -int URI_FUNC(ComposeQuery)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten) { - const UriBool spaceToPlus = URI_TRUE; - const UriBool normalizeBreaks = URI_TRUE; - - return URI_FUNC(ComposeQueryEx)(dest, queryList, maxChars, charsWritten, - spaceToPlus, normalizeBreaks); -} - - - -int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten, - UriBool spaceToPlus, UriBool normalizeBreaks) { - if ((dest == NULL) || (queryList == NULL)) { - return URI_ERROR_NULL; - } - - if (maxChars < 1) { - return URI_ERROR_OUTPUT_TOO_LARGE; - } - - return URI_FUNC(ComposeQueryEngine)(dest, queryList, maxChars, - charsWritten, NULL, spaceToPlus, normalizeBreaks); -} - - - -int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList) { - const UriBool spaceToPlus = URI_TRUE; - const UriBool normalizeBreaks = URI_TRUE; - - return URI_FUNC(ComposeQueryMallocEx)(dest, queryList, - spaceToPlus, normalizeBreaks); -} - - - -int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks) { - return URI_FUNC(ComposeQueryMallocExMm)(dest, queryList, spaceToPlus, - normalizeBreaks, NULL); -} - - - -int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks, - UriMemoryManager * memory) { - int charsRequired; - int res; - URI_CHAR * queryString; - - if (dest == NULL) { - return URI_ERROR_NULL; - } - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - /* Calculate space */ - res = URI_FUNC(ComposeQueryCharsRequiredEx)(queryList, &charsRequired, - spaceToPlus, normalizeBreaks); - if (res != URI_SUCCESS) { - return res; - } - charsRequired++; - - /* Allocate space */ - queryString = memory->malloc(memory, charsRequired * sizeof(URI_CHAR)); - if (queryString == NULL) { - return URI_ERROR_MALLOC; - } - - /* Put query in */ - res = URI_FUNC(ComposeQueryEx)(queryString, queryList, charsRequired, - NULL, spaceToPlus, normalizeBreaks); - if (res != URI_SUCCESS) { - memory->free(memory, queryString); - return res; - } - - *dest = queryString; - return URI_SUCCESS; -} - - - -int URI_FUNC(ComposeQueryEngine)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, - int maxChars, int * charsWritten, int * charsRequired, - UriBool spaceToPlus, UriBool normalizeBreaks) { - UriBool firstItem = URI_TRUE; - int ampersandLen = 0; /* increased to 1 from second item on */ - URI_CHAR * write = dest; - - /* Subtract terminator */ - if (dest == NULL) { - *charsRequired = 0; - } else { - maxChars--; - } - - while (queryList != NULL) { - const URI_CHAR * const key = queryList->key; - const URI_CHAR * const value = queryList->value; - const int worstCase = (normalizeBreaks == URI_TRUE ? 6 : 3); - const int keyLen = (key == NULL) ? 0 : (int)URI_STRLEN(key); - int keyRequiredChars; - const int valueLen = (value == NULL) ? 0 : (int)URI_STRLEN(value); - int valueRequiredChars; - - if ((keyLen >= INT_MAX / worstCase) || (valueLen >= INT_MAX / worstCase)) { - return URI_ERROR_OUTPUT_TOO_LARGE; - } - keyRequiredChars = worstCase * keyLen; - valueRequiredChars = worstCase * valueLen; - - if (dest == NULL) { - (*charsRequired) += ampersandLen + keyRequiredChars + ((value == NULL) - ? 0 - : 1 + valueRequiredChars); - - if (firstItem == URI_TRUE) { - ampersandLen = 1; - firstItem = URI_FALSE; - } - } else { - if ((write - dest) + ampersandLen + keyRequiredChars > maxChars) { - return URI_ERROR_OUTPUT_TOO_LARGE; - } - - /* Copy key */ - if (firstItem == URI_TRUE) { - ampersandLen = 1; - firstItem = URI_FALSE; - } else { - write[0] = _UT('&'); - write++; - } - write = URI_FUNC(EscapeEx)(key, key + keyLen, - write, spaceToPlus, normalizeBreaks); - - if (value != NULL) { - if ((write - dest) + 1 + valueRequiredChars > maxChars) { - return URI_ERROR_OUTPUT_TOO_LARGE; - } - - /* Copy value */ - write[0] = _UT('='); - write++; - write = URI_FUNC(EscapeEx)(value, value + valueLen, - write, spaceToPlus, normalizeBreaks); - } - } - - queryList = queryList->next; - } - - if (dest != NULL) { - write[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = (int)(write - dest) + 1; /* .. for terminator */ - } - } - - return URI_SUCCESS; -} - - - -UriBool URI_FUNC(AppendQueryItem)(URI_TYPE(QueryList) ** prevNext, - int * itemCount, const URI_CHAR * keyFirst, const URI_CHAR * keyAfter, - const URI_CHAR * valueFirst, const URI_CHAR * valueAfter, - UriBool plusToSpace, UriBreakConversion breakConversion, - UriMemoryManager * memory) { - const int keyLen = (int)(keyAfter - keyFirst); - const int valueLen = (int)(valueAfter - valueFirst); - URI_CHAR * key; - URI_CHAR * value; - - if ((prevNext == NULL) || (itemCount == NULL) - || (keyFirst == NULL) || (keyAfter == NULL) - || (keyFirst > keyAfter) || (valueFirst > valueAfter) - || ((keyFirst == keyAfter) - && (valueFirst == NULL) && (valueAfter == NULL))) { - return URI_TRUE; - } - - /* Append new empty item */ - *prevNext = memory->malloc(memory, 1 * sizeof(URI_TYPE(QueryList))); - if (*prevNext == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - (*prevNext)->next = NULL; - - - /* Fill key */ - key = memory->malloc(memory, (keyLen + 1) * sizeof(URI_CHAR)); - if (key == NULL) { - memory->free(memory, *prevNext); - *prevNext = NULL; - return URI_FALSE; /* Raises malloc error */ - } - - key[keyLen] = _UT('\0'); - if (keyLen > 0) { - /* Copy 1:1 */ - memcpy(key, keyFirst, keyLen * sizeof(URI_CHAR)); - - /* Unescape */ - URI_FUNC(UnescapeInPlaceEx)(key, plusToSpace, breakConversion); - } - (*prevNext)->key = key; - - - /* Fill value */ - if (valueFirst != NULL) { - value = memory->malloc(memory, (valueLen + 1) * sizeof(URI_CHAR)); - if (value == NULL) { - memory->free(memory, key); - memory->free(memory, *prevNext); - *prevNext = NULL; - return URI_FALSE; /* Raises malloc error */ - } - - value[valueLen] = _UT('\0'); - if (valueLen > 0) { - /* Copy 1:1 */ - memcpy(value, valueFirst, valueLen * sizeof(URI_CHAR)); - - /* Unescape */ - URI_FUNC(UnescapeInPlaceEx)(value, plusToSpace, breakConversion); - } - (*prevNext)->value = value; - } else { - value = NULL; - } - (*prevNext)->value = value; - - (*itemCount)++; - return URI_TRUE; -} - - - -void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList) { - URI_FUNC(FreeQueryListMm)(queryList, NULL); -} - - - -int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, - UriMemoryManager * memory) { - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - while (queryList != NULL) { - URI_TYPE(QueryList) * nextBackup = queryList->next; - memory->free(memory, (URI_CHAR *)queryList->key); /* const cast */ - memory->free(memory, (URI_CHAR *)queryList->value); /* const cast */ - memory->free(memory, queryList); - queryList = nextBackup; - } - return URI_SUCCESS; -} - - - -int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, int * itemCount, - const URI_CHAR * first, const URI_CHAR * afterLast) { - const UriBool plusToSpace = URI_TRUE; - const UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; - - return URI_FUNC(DissectQueryMallocEx)(dest, itemCount, first, afterLast, - plusToSpace, breakConversion); -} - - - -int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, int * itemCount, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion) { - return URI_FUNC(DissectQueryMallocExMm)(dest, itemCount, first, afterLast, - plusToSpace, breakConversion, NULL); -} - - - -int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, int * itemCount, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion, - UriMemoryManager * memory) { - const URI_CHAR * walk = first; - const URI_CHAR * keyFirst = first; - const URI_CHAR * keyAfter = NULL; - const URI_CHAR * valueFirst = NULL; - const URI_CHAR * valueAfter = NULL; - URI_TYPE(QueryList) ** prevNext = dest; - int nullCounter; - int * itemsAppended = (itemCount == NULL) ? &nullCounter : itemCount; - - if ((dest == NULL) || (first == NULL) || (afterLast == NULL)) { - return URI_ERROR_NULL; - } - - if (first > afterLast) { - return URI_ERROR_RANGE_INVALID; - } - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - *dest = NULL; - *itemsAppended = 0; - - /* Parse query string */ - for (; walk < afterLast; walk++) { - switch (*walk) { - case _UT('&'): - if (valueFirst != NULL) { - valueAfter = walk; - } else { - keyAfter = walk; - } - - if (URI_FUNC(AppendQueryItem)(prevNext, itemsAppended, - keyFirst, keyAfter, valueFirst, valueAfter, - plusToSpace, breakConversion, memory) - == URI_FALSE) { - /* Free list we built */ - *itemsAppended = 0; - URI_FUNC(FreeQueryListMm)(*dest, memory); - return URI_ERROR_MALLOC; - } - - /* Make future items children of the current */ - if ((prevNext != NULL) && (*prevNext != NULL)) { - prevNext = &((*prevNext)->next); - } - - if (walk + 1 < afterLast) { - keyFirst = walk + 1; - } else { - keyFirst = NULL; - } - keyAfter = NULL; - valueFirst = NULL; - valueAfter = NULL; - break; - - case _UT('='): - /* NOTE: WE treat the first '=' as a separator, */ - /* all following go into the value part */ - if (keyAfter == NULL) { - keyAfter = walk; - if (walk + 1 <= afterLast) { - valueFirst = walk + 1; - valueAfter = walk + 1; - } - } - break; - - default: - break; - } - } - - if (valueFirst != NULL) { - /* Must be key/value pair */ - valueAfter = walk; - } else { - /* Must be key only */ - keyAfter = walk; - } - - if (URI_FUNC(AppendQueryItem)(prevNext, itemsAppended, keyFirst, keyAfter, - valueFirst, valueAfter, plusToSpace, breakConversion, memory) - == URI_FALSE) { - /* Free list we built */ - *itemsAppended = 0; - URI_FUNC(FreeQueryListMm)(*dest, memory); - return URI_ERROR_MALLOC; - } - - return URI_SUCCESS; -} - - - -#endif diff --git a/external/uriparser/src/UriRecompose.c b/external/uriparser/src/UriRecompose.c deleted file mode 100644 index 5027eca..0000000 --- a/external/uriparser/src/UriRecompose.c +++ /dev/null @@ -1,577 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriRecompose.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriRecompose.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -#endif - - - -static int URI_FUNC(ToStringEngine)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, - int maxChars, int * charsWritten, int * charsRequired); - - - -int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, - int * charsRequired) { - const int MAX_CHARS = ((unsigned int)-1) >> 1; - return URI_FUNC(ToStringEngine)(NULL, uri, MAX_CHARS, NULL, charsRequired); -} - - - -int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, - int maxChars, int * charsWritten) { - return URI_FUNC(ToStringEngine)(dest, uri, maxChars, charsWritten, NULL); -} - - - -static URI_INLINE int URI_FUNC(ToStringEngine)(URI_CHAR * dest, - const URI_TYPE(Uri) * uri, int maxChars, int * charsWritten, - int * charsRequired) { - int written = 0; - if ((uri == NULL) || ((dest == NULL) && (charsRequired == NULL))) { - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_NULL; - } - - if (maxChars < 1) { - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - maxChars--; /* So we don't have to subtract 1 for '\0' all the time */ - - /* [01/19] result = "" */ - if (dest != NULL) { - dest[0] = _UT('\0'); - } else { - (*charsRequired) = 0; - } - /* [02/19] if defined(scheme) then */ - if (uri->scheme.first != NULL) { - /* [03/19] append scheme to result; */ - const int charsToWrite - = (int)(uri->scheme.afterLast - uri->scheme.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->scheme.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite; - } - /* [04/19] append ":" to result; */ - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT(":"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - /* [05/19] endif; */ - } - /* [06/19] if defined(authority) then */ - if (URI_FUNC(IsHostSet)(uri)) { - /* [07/19] append "//" to result; */ - if (dest != NULL) { - if (written + 2 <= maxChars) { - memcpy(dest + written, _UT("//"), - 2 * sizeof(URI_CHAR)); - written += 2; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 2; - } - /* [08/19] append authority to result; */ - /* UserInfo */ - if (uri->userInfo.first != NULL) { - const int charsToWrite = (int)(uri->userInfo.afterLast - uri->userInfo.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->userInfo.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("@"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite + 1; - } - } - - /* Host */ - if (uri->hostData.ip4 != NULL) { - /* IPv4 */ - int i = 0; - for (; i < 4; i++) { - const unsigned char value = uri->hostData.ip4->data[i]; - const int charsToWrite = (value > 99) ? 3 : ((value > 9) ? 2 : 1); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - URI_CHAR text[4]; - if (value > 99) { - text[0] = _UT('0') + (value / 100); - text[1] = _UT('0') + ((value % 100) / 10); - text[2] = _UT('0') + (value % 10); - } else if (value > 9) { - text[0] = _UT('0') + (value / 10); - text[1] = _UT('0') + (value % 10); - } else { - text[0] = _UT('0') + value; - } - text[charsToWrite] = _UT('\0'); - memcpy(dest + written, text, charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - if (i < 3) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("."), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } - } else { - (*charsRequired) += charsToWrite + ((i == 3) ? 0 : 1); - } - } - } else if (uri->hostData.ip6 != NULL) { - /* IPv6 */ - int i = 0; - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("["), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - - for (; i < 16; i++) { - const unsigned char value = uri->hostData.ip6->data[i]; - if (dest != NULL) { - if (written + 2 <= maxChars) { - URI_CHAR text[3]; - text[0] = URI_FUNC(HexToLetterEx)(value / 16, URI_FALSE); - text[1] = URI_FUNC(HexToLetterEx)(value % 16, URI_FALSE); - text[2] = _UT('\0'); - memcpy(dest + written, text, 2 * sizeof(URI_CHAR)); - written += 2; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 2; - } - if (((i & 1) == 1) && (i < 15)) { - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT(":"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - } - } - - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("]"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - } else if (uri->hostData.ipFuture.first != NULL) { - /* IPvFuture */ - const int charsToWrite = (int)(uri->hostData.ipFuture.afterLast - - uri->hostData.ipFuture.first); - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("["), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->hostData.ipFuture.first, charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("]"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1 + charsToWrite + 1; - } - } else if (uri->hostText.first != NULL) { - /* Regname */ - const int charsToWrite = (int)(uri->hostText.afterLast - uri->hostText.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->hostText.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite; - } - } - - /* Port */ - if (uri->portText.first != NULL) { - const int charsToWrite = (int)(uri->portText.afterLast - uri->portText.first); - if (dest != NULL) { - /* Leading ':' */ - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT(":"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - - /* Port number */ - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->portText.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1 + charsToWrite; - } - } - /* [09/19] endif; */ - } - /* [10/19] append path to result; */ - /* Slash needed here? */ - if (uri->absolutePath || ((uri->pathHead != NULL) - && URI_FUNC(IsHostSet)(uri))) { - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("/"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - } - - if (uri->pathHead != NULL) { - URI_TYPE(PathSegment) * walker = uri->pathHead; - do { - const int charsToWrite = (int)(walker->text.afterLast - walker->text.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, walker->text.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite; - } - - /* Not last segment -> append slash */ - if (walker->next != NULL) { - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("/"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - } - - walker = walker->next; - } while (walker != NULL); - } - /* [11/19] if defined(query) then */ - if (uri->query.first != NULL) { - /* [12/19] append "?" to result; */ - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("?"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - /* [13/19] append query to result; */ - { - const int charsToWrite - = (int)(uri->query.afterLast - uri->query.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->query.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite; - } - } - /* [14/19] endif; */ - } - /* [15/19] if defined(fragment) then */ - if (uri->fragment.first != NULL) { - /* [16/19] append "#" to result; */ - if (dest != NULL) { - if (written + 1 <= maxChars) { - memcpy(dest + written, _UT("#"), - 1 * sizeof(URI_CHAR)); - written += 1; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += 1; - } - /* [17/19] append fragment to result; */ - { - const int charsToWrite - = (int)(uri->fragment.afterLast - uri->fragment.first); - if (dest != NULL) { - if (written + charsToWrite <= maxChars) { - memcpy(dest + written, uri->fragment.first, - charsToWrite * sizeof(URI_CHAR)); - written += charsToWrite; - } else { - dest[0] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = 0; - } - return URI_ERROR_TOSTRING_TOO_LONG; - } - } else { - (*charsRequired) += charsToWrite; - } - } - /* [18/19] endif; */ - } - /* [19/19] return result; */ - if (dest != NULL) { - dest[written++] = _UT('\0'); - if (charsWritten != NULL) { - *charsWritten = written; - } - } - return URI_SUCCESS; -} - - - -#endif diff --git a/external/uriparser/src/UriResolve.c b/external/uriparser/src/UriResolve.c deleted file mode 100644 index 80031a8..0000000 --- a/external/uriparser/src/UriResolve.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriResolve.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriResolve.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -# include "UriMemory.h" -#endif - - - -/* Appends a relative URI to an absolute. The last path segment of - * the absolute URI is replaced. */ -static URI_INLINE UriBool URI_FUNC(MergePath)(URI_TYPE(Uri) * absWork, - const URI_TYPE(Uri) * relAppend, UriMemoryManager * memory) { - URI_TYPE(PathSegment) * sourceWalker; - URI_TYPE(PathSegment) * destPrev; - if (relAppend->pathHead == NULL) { - return URI_TRUE; - } - - /* Replace last segment ("" if trailing slash) with first of append chain */ - if (absWork->pathHead == NULL) { - URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); - if (dup == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - dup->next = NULL; - absWork->pathHead = dup; - absWork->pathTail = dup; - } - absWork->pathTail->text.first = relAppend->pathHead->text.first; - absWork->pathTail->text.afterLast = relAppend->pathHead->text.afterLast; - - /* Append all the others */ - sourceWalker = relAppend->pathHead->next; - if (sourceWalker == NULL) { - return URI_TRUE; - } - destPrev = absWork->pathTail; - - for (;;) { - URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); - if (dup == NULL) { - destPrev->next = NULL; - absWork->pathTail = destPrev; - return URI_FALSE; /* Raises malloc error */ - } - dup->text = sourceWalker->text; - destPrev->next = dup; - - if (sourceWalker->next == NULL) { - absWork->pathTail = dup; - absWork->pathTail->next = NULL; - break; - } - destPrev = dup; - sourceWalker = sourceWalker->next; - } - - return URI_TRUE; -} - - -static int URI_FUNC(ResolveAbsolutePathFlag)(URI_TYPE(Uri) * absWork, - UriMemoryManager * memory) { - if (absWork == NULL) { - return URI_ERROR_NULL; - } - - if (URI_FUNC(IsHostSet)(absWork) && absWork->absolutePath) { - /* Empty segment needed, instead? */ - if (absWork->pathHead == NULL) { - URI_TYPE(PathSegment) * const segment = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); - if (segment == NULL) { - return URI_ERROR_MALLOC; - } - segment->text.first = URI_FUNC(SafeToPointTo); - segment->text.afterLast = URI_FUNC(SafeToPointTo); - segment->next = NULL; - - absWork->pathHead = segment; - absWork->pathTail = segment; - } - - absWork->absolutePath = URI_FALSE; - } - - return URI_SUCCESS; -} - - -static int URI_FUNC(AddBaseUriImpl)(URI_TYPE(Uri) * absDest, - const URI_TYPE(Uri) * relSource, - const URI_TYPE(Uri) * absBase, - UriResolutionOptions options, UriMemoryManager * memory) { - UriBool relSourceHasScheme; - - if (absDest == NULL) { - return URI_ERROR_NULL; - } - URI_FUNC(ResetUri)(absDest); - - if ((relSource == NULL) || (absBase == NULL)) { - return URI_ERROR_NULL; - } - - /* absBase absolute? */ - if (absBase->scheme.first == NULL) { - return URI_ERROR_ADDBASE_REL_BASE; - } - - /* [00/32] -- A non-strict parser may ignore a scheme in the reference */ - /* [00/32] -- if it is identical to the base URI's scheme. */ - /* [00/32] if ((not strict) and (R.scheme == Base.scheme)) then */ - relSourceHasScheme = (relSource->scheme.first != NULL) ? URI_TRUE : URI_FALSE; - if ((options & URI_RESOLVE_IDENTICAL_SCHEME_COMPAT) - && (absBase->scheme.first != NULL) - && (relSource->scheme.first != NULL) - && (0 == URI_FUNC(CompareRange)(&(absBase->scheme), &(relSource->scheme)))) { - /* [00/32] undefine(R.scheme); */ - relSourceHasScheme = URI_FALSE; - /* [00/32] endif; */ - } - - /* [01/32] if defined(R.scheme) then */ - if (relSourceHasScheme) { - /* [02/32] T.scheme = R.scheme; */ - absDest->scheme = relSource->scheme; - /* [03/32] T.authority = R.authority; */ - if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [04/32] T.path = remove_dot_segments(R.path); */ - if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { - return URI_ERROR_MALLOC; - } - /* [05/32] T.query = R.query; */ - absDest->query = relSource->query; - /* [06/32] else */ - } else { - /* [07/32] if defined(R.authority) then */ - if (URI_FUNC(IsHostSet)(relSource)) { - /* [08/32] T.authority = R.authority; */ - if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [09/32] T.path = remove_dot_segments(R.path); */ - if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { - return URI_ERROR_MALLOC; - } - /* [10/32] T.query = R.query; */ - absDest->query = relSource->query; - /* [11/32] else */ - } else { - /* [28/32] T.authority = Base.authority; */ - if (!URI_FUNC(CopyAuthority)(absDest, absBase, memory)) { - return URI_ERROR_MALLOC; - } - /* [12/32] if (R.path == "") then */ - if (relSource->pathHead == NULL && !relSource->absolutePath) { - /* [13/32] T.path = Base.path; */ - if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { - return URI_ERROR_MALLOC; - } - /* [14/32] if defined(R.query) then */ - if (relSource->query.first != NULL) { - /* [15/32] T.query = R.query; */ - absDest->query = relSource->query; - /* [16/32] else */ - } else { - /* [17/32] T.query = Base.query; */ - absDest->query = absBase->query; - /* [18/32] endif; */ - } - /* [19/32] else */ - } else { - /* [20/32] if (R.path starts-with "/") then */ - if (relSource->absolutePath) { - int res; - /* [21/32] T.path = remove_dot_segments(R.path); */ - if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - res = URI_FUNC(ResolveAbsolutePathFlag)(absDest, memory); - if (res != URI_SUCCESS) { - return res; - } - if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { - return URI_ERROR_MALLOC; - } - /* [22/32] else */ - } else { - /* [23/32] T.path = merge(Base.path, R.path); */ - if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { - return URI_ERROR_MALLOC; - } - if (!URI_FUNC(MergePath)(absDest, relSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [24/32] T.path = remove_dot_segments(T.path); */ - if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { - return URI_ERROR_MALLOC; - } - - if (!URI_FUNC(FixAmbiguity)(absDest, memory)) { - return URI_ERROR_MALLOC; - } - /* [25/32] endif; */ - } - /* [26/32] T.query = R.query; */ - absDest->query = relSource->query; - /* [27/32] endif; */ - } - URI_FUNC(FixEmptyTrailSegment)(absDest, memory); - /* [29/32] endif; */ - } - /* [30/32] T.scheme = Base.scheme; */ - absDest->scheme = absBase->scheme; - /* [31/32] endif; */ - } - /* [32/32] T.fragment = R.fragment; */ - absDest->fragment = relSource->fragment; - - return URI_SUCCESS; - -} - - - -int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absDest, - const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase) { - const UriResolutionOptions options = URI_RESOLVE_STRICTLY; - return URI_FUNC(AddBaseUriEx)(absDest, relSource, absBase, options); -} - - - -int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absDest, - const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase, - UriResolutionOptions options) { - return URI_FUNC(AddBaseUriExMm)(absDest, relSource, absBase, options, NULL); -} - - - -int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absDest, - const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase, - UriResolutionOptions options, UriMemoryManager * memory) { - int res; - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - res = URI_FUNC(AddBaseUriImpl)(absDest, relSource, absBase, options, memory); - if ((res != URI_SUCCESS) && (absDest != NULL)) { - URI_FUNC(FreeUriMembersMm)(absDest, memory); - } - return res; -} - - - -#endif diff --git a/external/uriparser/src/UriShorten.c b/external/uriparser/src/UriShorten.c deleted file mode 100644 index d2f8935..0000000 --- a/external/uriparser/src/UriShorten.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* What encodings are enabled? */ -#include -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) -/* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriShorten.c" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriShorten.c" -# undef URI_PASS_UNICODE -# endif -#else -# ifdef URI_PASS_ANSI -# include -# else -# include -# include -# endif - - - -#ifndef URI_DOXYGEN -# include -# include "UriCommon.h" -# include "UriMemory.h" -#endif - - - -static URI_INLINE UriBool URI_FUNC(AppendSegment)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - UriMemoryManager * memory) { - /* Create segment */ - URI_TYPE(PathSegment) * segment = memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment))); - if (segment == NULL) { - return URI_FALSE; /* Raises malloc error */ - } - segment->next = NULL; - segment->text.first = first; - segment->text.afterLast = afterLast; - - /* Put into chain */ - if (uri->pathTail == NULL) { - uri->pathHead = segment; - } else { - uri->pathTail->next = segment; - } - uri->pathTail = segment; - - return URI_TRUE; -} - - - -static URI_INLINE UriBool URI_FUNC(EqualsAuthority)(const URI_TYPE(Uri) * first, - const URI_TYPE(Uri) * second) { - /* IPv4 */ - if (first->hostData.ip4 != NULL) { - return ((second->hostData.ip4 != NULL) - && !memcmp(first->hostData.ip4->data, - second->hostData.ip4->data, 4)) ? URI_TRUE : URI_FALSE; - } - - /* IPv6 */ - if (first->hostData.ip6 != NULL) { - return ((second->hostData.ip6 != NULL) - && !memcmp(first->hostData.ip6->data, - second->hostData.ip6->data, 16)) ? URI_TRUE : URI_FALSE; - } - - /* IPvFuture */ - if (first->hostData.ipFuture.first != NULL) { - return ((second->hostData.ipFuture.first != NULL) - && !URI_FUNC(CompareRange)(&first->hostData.ipFuture, - &second->hostData.ipFuture)) ? URI_TRUE : URI_FALSE; - } - - return !URI_FUNC(CompareRange)(&first->hostText, &second->hostText) - ? URI_TRUE : URI_FALSE; -} - - - -static int URI_FUNC(RemoveBaseUriImpl)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absSource, - const URI_TYPE(Uri) * absBase, - UriBool domainRootMode, UriMemoryManager * memory) { - if (dest == NULL) { - return URI_ERROR_NULL; - } - URI_FUNC(ResetUri)(dest); - - if ((absSource == NULL) || (absBase == NULL)) { - return URI_ERROR_NULL; - } - - /* absBase absolute? */ - if (absBase->scheme.first == NULL) { - return URI_ERROR_REMOVEBASE_REL_BASE; - } - - /* absSource absolute? */ - if (absSource->scheme.first == NULL) { - return URI_ERROR_REMOVEBASE_REL_SOURCE; - } - - /* [01/50] if (A.scheme != Base.scheme) then */ - if (URI_FUNC(CompareRange)(&absSource->scheme, &absBase->scheme)) { - /* [02/50] T.scheme = A.scheme; */ - dest->scheme = absSource->scheme; - /* [03/50] T.authority = A.authority; */ - if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [04/50] T.path = A.path; */ - if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [05/50] else */ - } else { - /* [06/50] undef(T.scheme); */ - /* NOOP */ - /* [07/50] if (A.authority != Base.authority) then */ - if (!URI_FUNC(EqualsAuthority)(absSource, absBase)) { - /* [08/50] T.authority = A.authority; */ - if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [09/50] T.path = A.path; */ - if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { - return URI_ERROR_MALLOC; - } - /* [10/50] else */ - } else { - /* [11/50] if domainRootMode then */ - if (domainRootMode == URI_TRUE) { - /* [12/50] undef(T.authority); */ - /* NOOP */ - /* [13/50] if (first(A.path) == "") then */ - /* GROUPED */ - /* [14/50] T.path = "/." + A.path; */ - /* GROUPED */ - /* [15/50] else */ - /* GROUPED */ - /* [16/50] T.path = A.path; */ - /* GROUPED */ - /* [17/50] endif; */ - if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { - return URI_ERROR_MALLOC; - } - dest->absolutePath = URI_TRUE; - - if (!URI_FUNC(FixAmbiguity)(dest, memory)) { - return URI_ERROR_MALLOC; - } - /* [18/50] else */ - } else { - const URI_TYPE(PathSegment) * sourceSeg = absSource->pathHead; - const URI_TYPE(PathSegment) * baseSeg = absBase->pathHead; - /* [19/50] bool pathNaked = true; */ - UriBool pathNaked = URI_TRUE; - /* [20/50] undef(last(Base.path)); */ - /* NOOP */ - /* [21/50] T.path = ""; */ - dest->absolutePath = URI_FALSE; - /* [22/50] while (first(A.path) == first(Base.path)) do */ - while ((sourceSeg != NULL) && (baseSeg != NULL) - && !URI_FUNC(CompareRange)(&sourceSeg->text, &baseSeg->text) - && !((sourceSeg->text.first == sourceSeg->text.afterLast) - && ((sourceSeg->next == NULL) != (baseSeg->next == NULL)))) { - /* [23/50] A.path++; */ - sourceSeg = sourceSeg->next; - /* [24/50] Base.path++; */ - baseSeg = baseSeg->next; - /* [25/50] endwhile; */ - } - /* [26/50] while defined(first(Base.path)) do */ - while ((baseSeg != NULL) && (baseSeg->next != NULL)) { - /* [27/50] Base.path++; */ - baseSeg = baseSeg->next; - /* [28/50] T.path += "../"; */ - if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstParent), - URI_FUNC(ConstParent) + 2, memory)) { - return URI_ERROR_MALLOC; - } - /* [29/50] pathNaked = false; */ - pathNaked = URI_FALSE; - /* [30/50] endwhile; */ - } - /* [31/50] while defined(first(A.path)) do */ - while (sourceSeg != NULL) { - /* [32/50] if pathNaked then */ - if (pathNaked == URI_TRUE) { - /* [33/50] if (first(A.path) contains ":") then */ - UriBool containsColon = URI_FALSE; - const URI_CHAR * ch = sourceSeg->text.first; - for (; ch < sourceSeg->text.afterLast; ch++) { - if (*ch == _UT(':')) { - containsColon = URI_TRUE; - break; - } - } - - if (containsColon) { - /* [34/50] T.path += "./"; */ - if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstPwd), - URI_FUNC(ConstPwd) + 1, memory)) { - return URI_ERROR_MALLOC; - } - /* [35/50] elseif (first(A.path) == "") then */ - } else if (sourceSeg->text.first == sourceSeg->text.afterLast) { - /* [36/50] T.path += "/."; */ - if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstPwd), - URI_FUNC(ConstPwd) + 1, memory)) { - return URI_ERROR_MALLOC; - } - /* [37/50] endif; */ - } - /* [38/50] endif; */ - } - /* [39/50] T.path += first(A.path); */ - if (!URI_FUNC(AppendSegment)(dest, sourceSeg->text.first, - sourceSeg->text.afterLast, memory)) { - return URI_ERROR_MALLOC; - } - /* [40/50] pathNaked = false; */ - pathNaked = URI_FALSE; - /* [41/50] A.path++; */ - sourceSeg = sourceSeg->next; - /* [42/50] if defined(first(A.path)) then */ - /* NOOP */ - /* [43/50] T.path += + "/"; */ - /* NOOP */ - /* [44/50] endif; */ - /* NOOP */ - /* [45/50] endwhile; */ - } - /* [46/50] endif; */ - } - /* [47/50] endif; */ - } - /* [48/50] endif; */ - } - /* [49/50] T.query = A.query; */ - dest->query = absSource->query; - /* [50/50] T.fragment = A.fragment; */ - dest->fragment = absSource->fragment; - - return URI_SUCCESS; -} - - - -int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absSource, - const URI_TYPE(Uri) * absBase, - UriBool domainRootMode) { - return URI_FUNC(RemoveBaseUriMm)(dest, absSource, absBase, - domainRootMode, NULL); -} - - - -int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absSource, - const URI_TYPE(Uri) * absBase, - UriBool domainRootMode, UriMemoryManager * memory) { - int res; - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - res = URI_FUNC(RemoveBaseUriImpl)(dest, absSource, - absBase, domainRootMode, memory); - if ((res != URI_SUCCESS) && (dest != NULL)) { - URI_FUNC(FreeUriMembersMm)(dest, memory); - } - return res; -} - - - -#endif diff --git a/external/uriparser/test/COPYING b/external/uriparser/test/COPYING deleted file mode 100644 index c176226..0000000 --- a/external/uriparser/test/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/external/uriparser/test/FourSuite.cpp b/external/uriparser/test/FourSuite.cpp deleted file mode 100644 index 466a94c..0000000 --- a/external/uriparser/test/FourSuite.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include - - - -// All testcases in this file are coming from -// http://cvs.4suite.org/viewcvs/4Suite/test/Lib/test_uri.py - - -namespace { - -bool testAddOrRemoveBaseHelper(const char * ref, const char * base, - const char * expected, bool add = true, bool domainRootMode = false) { - UriParserStateA stateA; - - // Base - UriUriA baseUri; - stateA.uri = &baseUri; - int res = uriParseUriA(&stateA, base); - if (res != 0) { - return false; - } - - // Rel - UriUriA relUri; - stateA.uri = &relUri; - res = uriParseUriA(&stateA, ref); - if (res != 0) { - uriFreeUriMembersA(&baseUri); - return false; - } - - // Expected result - UriUriA expectedUri; - stateA.uri = &expectedUri; - res = uriParseUriA(&stateA, expected); - if (res != 0) { - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - // Transform - UriUriA transformedUri; - if (add) { - res = uriAddBaseUriA(&transformedUri, &relUri, &baseUri); - } else { - res = uriRemoveBaseUriA(&transformedUri, &relUri, &baseUri, - domainRootMode ? URI_TRUE : URI_FALSE); - } - if (res != 0) { - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - uriFreeUriMembersA(&transformedUri); - return false; - } - - const bool equal = (URI_TRUE == uriEqualsUriA(&transformedUri, &expectedUri)); - if (!equal) { - char transformedUriText[1024 * 8]; - char expectedUriText[1024 * 8]; - uriToStringA(transformedUriText, &transformedUri, 1024 * 8, NULL); - uriToStringA(expectedUriText, &expectedUri, 1024 * 8, NULL); - printf("\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); - } - - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - uriFreeUriMembersA(&transformedUri); - return equal; -} - -} // namespace - - -TEST(FourSuite, AbsolutizeTestCases) { - const char * const BASE_URI[] = { - "http://a/b/c/d;p?q", - "http://a/b/c/d;p?q=1/2", - "http://a/b/c/d;p=1/2?q", - "fred:///s//a/b/c", - "http:///s//a/b/c"}; - - // ref, base, exptected - - // http://lists.w3.org/Archives/Public/uri/2004Feb/0114.html - ASSERT_TRUE(testAddOrRemoveBaseHelper("../c", "foo:a/b", "foo:c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo:.", "foo:a", "foo:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../../../bar", "zz:abc", "zz:/bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../bar", "zz:abc", "zz:/bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../../../bar", "zz:abc", "zz:bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../bar", "zz:abc", "zz:bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("zz:.", "zz:abc", "zz:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/.", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/.foo", BASE_URI[0], "http://a/.foo")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".foo", BASE_URI[0], "http://a/b/c/.foo")); - - // http://gbiv.com/protocols/uri/test/rel_examples1.html - // examples from RFC 2396 - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[0], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[0], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[0], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[0], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[0], "http://g")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[0], "http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[0], "http://a/b/c/g?y")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("#s", BASE_URI[0], "http://a/b/c/d;p?q#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[0], "http://a/b/c/g#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y#s", BASE_URI[0], "http://a/b/c/g?y#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[0], "http://a/b/c/;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[0], "http://a/b/c/g;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x?y#s", BASE_URI[0], "http://a/b/c/g;x?y#s")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("", BASE_URI[0], "http://a/b/c/d;p?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".", BASE_URI[0], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[0], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..", BASE_URI[0], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[0], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[0], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../..", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[0], "http://a/g")); // http://a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[0], "http://a/g")); // http://a/../../g - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("/./g", BASE_URI[0], "http://a/g")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("/../g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g.", BASE_URI[0], "http://a/b/c/g.")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".g", BASE_URI[0], "http://a/b/c/.g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g..", BASE_URI[0], "http://a/b/c/g..")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..g", BASE_URI[0], "http://a/b/c/..g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./../g", BASE_URI[0], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g/.", BASE_URI[0], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/./h", BASE_URI[0], "http://a/b/c/g/h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/../h", BASE_URI[0], "http://a/b/c/h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[0], "http://a/b/c/g;x=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[0], "http://a/b/c/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[0], "http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[0], "http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[0], "http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[0], "http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:g", BASE_URI[0], "http:g")); // http://a/b/c/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:", BASE_URI[0], "http:")); // BASE_URI[0] - - // not sure where this one originated - ASSERT_TRUE(testAddOrRemoveBaseHelper("/a/b/c/./../../g", BASE_URI[0], "http://a/a/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples2.html - // slashes in base URI's query args - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[1], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[1], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[1], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[1], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[1], "http://g")); - - // changed in RFC 2396bis - // ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[1], "http://a/b/c/g?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[1], "http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[1], "http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[1], "http://a/b/c/g#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[1], "http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[1], "http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[1], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[1], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[1], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[1], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[1], "http://a/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples3.html - // slashes in path params - // all of these changed in RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[2], "http://a/b/c/d;p=1/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[2], "http://a/b/c/d;p=1/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[2], "http://a/b/c/d;p=1/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[2], "http://a/b/c/d;p=1/g?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[2], "http://a/b/c/d;p=1/;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[2], "http://a/b/c/d;p=1/g;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[2], "http://a/b/c/d;p=1/g;x=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[2], "http://a/b/c/d;p=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[2], "http://a/b/c/d;p=1/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[2], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[2], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[2], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[2], "http://a/b/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples4.html - // double and triple slash, unknown scheme - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[3], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[3], "fred:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[3], "fred:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[3], "fred:///s//a/b/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[3], "fred://g")); // may change to fred:///s//g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[3], "fred://g/x")); // may change to fred:///s//g/x - ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[3], "fred:///g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[3], "fred:///s//a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[3], "fred:///s//a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[3], "fred:///s//a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[3], "fred:///s//")); // may change to fred:///s//a/../ - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[3], "fred:///s//g")); // may change to fred:///s//a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[3], "fred:///s/g")); // may change to fred:///s//a/../../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/../../../g - - // http://gbiv.com/protocols/uri/test/rel_examples5.html - // double and triple slash, well-known scheme - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[4], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[4], "http:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[4], "http:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[4], "http:///s//a/b/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[4], "http:///g")); // may change to http:///s//a/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[4], "http://g")); // may change to http:///s//g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[4], "http://g/x")); // may change to http:///s//g/x - ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[4], "http:///g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[4], "http:///s//a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[4], "http:///s//a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[4], "http:///s//a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[4], "http:///s//")); // may change to http:///s//a/../ - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[4], "http:///s//g")); // may change to http:///s//a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[4], "http:///s/g")); // may change to http:///s//a/../../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[4], "http:///g")); // may change to http:///s//a/../../../g - - // from Dan Connelly's tests in http://www.w3.org/2000/10/swap/uripath.py - ASSERT_TRUE(testAddOrRemoveBaseHelper("bar:abc", "foo:xyz", "bar:abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "http://example/x/y/z", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/x/abc", "http://example2/x/y/z", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "http://ex/x/y/z", "http://ex/x/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "http://ex/x/y", "http://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "http://ex/x/y", "http://ex/x/q/r#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "http://ex/x/y", "http://ex/x/q/r#s/t")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "http://ex/x/y", "ftp://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y", "http://ex/x/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/", "http://ex/x/y/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/pdq", "http://ex/x/y/pdq")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "http://ex/x/y/", "http://ex/x/y/z/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("#Animal", "file:/swap/test/animal.rdf", "file:/swap/test/animal.rdf#Animal")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "file:/e/x/y/z", "file:/e/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/example/x/abc", "file:/example2/x/y/z", "file:/example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "file:/ex/x/y/z", "file:/ex/x/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/r", "file:/ex/x/y/z", "file:/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "file:/ex/x/y", "file:/ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "file:/ex/x/y", "file:/ex/x/q/r#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#", "file:/ex/x/y", "file:/ex/x/q/r#")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "file:/ex/x/y", "file:/ex/x/q/r#s/t")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "file:/ex/x/y", "ftp://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y", "file:/ex/x/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/", "file:/ex/x/y/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/pdq", "file:/ex/x/y/pdq")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "file:/ex/x/y/", "file:/ex/x/y/z/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/devel/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./#blort", "file:/some/dir/foo", "file:/some/dir/#blort")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./#", "file:/some/dir/foo", "file:/some/dir/#")); - - // Ryan Lee - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", "http://example/x/abc.efg", "http://example/x/")); - - // Graham Klyne's tests - // http://www.ninebynine.org/Software/HaskellUtils/Network/UriTest.xls - // 01-31 are from Connelly's cases - - // 32-49 - ASSERT_TRUE(testAddOrRemoveBaseHelper("./q:r", "http://ex/x/y", "http://ex/x/q:r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./p=q:r", "http://ex/x/y", "http://ex/x/p=q:r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?pp/rr", "http://ex/x/y?pp/qq", "http://ex/x/y?pp/rr")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("y/z", "http://ex/x/y?pp/qq", "http://ex/x/y/z")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local/qual@domain.org#frag", "mailto:local", "mailto:local/qual@domain.org#frag")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("more/qual2@domain2.org#frag", "mailto:local/qual1@domain1.org", "mailto:local/more/qual2@domain2.org#frag")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("y?q", "http://ex/x/y?q", "http://ex/x/y?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x/y?q", "http://ex?p", "http://ex/x/y?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("c/d", "foo:a/b", "foo:a/c/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/c/d", "foo:a/b", "foo:/c/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "foo:a/b?c#d", "foo:a/b?c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c", "foo:a", "foo:b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:/a/y/z", "foo:/a/b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./b/c", "foo:a", "foo:b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/./b/c", "foo:a", "foo:/b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../d", "foo://a//b/c", "foo://a/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".", "foo:a", "foo:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..", "foo:a", "foo:")); - - // 50-57 (cf. TimBL comments -- - // http://lists.w3.org/Archives/Public/uri/2003Feb/0028.html, - // http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html) - ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x/y%2Fz", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../x%2Fabc", "http://example/a/x/y/z", "http://example/a/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../x%2Fabc", "http://example/a/x/y%2Fz", "http://example/a/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x%2Fy/z", "http://example/x%2Fy/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q%3Ar", "http://ex/x/y", "http://ex/x/q%3Ar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y/z", "http://example/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); - - // 70-77 - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2", "mailto:local1@domain1?query1", "mailto:local2@domain2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1", "mailto:local2@domain2?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1?query1", "mailto:local2@domain2?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local@domain?query2", "mailto:?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b?c/../d", "foo:bar", "http://example/a/b?c/../d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b#c/../d", "foo:bar", "http://example/a/b#c/../d")); - - // 82-88 - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http://example.org/base/uri", "http:this")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http:base", "http:this")); - // Whole in the URI spec, see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html - // ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f://g")); // ORIGINAL - ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f:/.//g")); // FIXED ONE - ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c//d/e", "f://example.org/base/a", "f://example.org/base/b/c//d/e")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("m2@example.ord/c2@example.org", "mid:m@example.ord/c@example.org", "mid:m@example.ord/m2@example.ord/c2@example.org")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("mini1.xml", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/mini1.xml")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:a/y/z", "foo:a/b/c")); -} - - - -TEST(FourSuite, RelativizeTestCases) { - const bool REMOVE_MODE = false; - const bool DOMAIN_ROOT_MODE = true; - - // to convert, base, exptected - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d", "b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/b/c", "s://ex/a/d", "/b/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/b/", "c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://other.ex/a/b/", "s://ex/a/d", "//other.ex/a/b/", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://other.ex/a/d", "//ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("t://ex/a/b/c", "s://ex/a/d", "t://ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "t://ex/a/d", "s://ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a", "s://ex/b/c/d", "/a", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/c/d", "s://ex/a", "b/c/d", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h", "s://ex/a/d?w", "b/c?h", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c#h", "s://ex/a/d#w", "b/c#h", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h#i", "s://ex/a/d?w#j", "b/c?h#i", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a#i", "s://ex/a", "#i", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a?i", "s://ex/a", "?i", REMOVE_MODE)); - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/b/", "", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a/b", "", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/", "s://ex/", "", REMOVE_MODE)); - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d/c", "../b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/", "s://ex/a/d/c", "../b/c/", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/d", "s://ex/a/d/c/d", "../../b/c/d", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/d/e/f", "/a/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/c/d/e", "../../b/", REMOVE_MODE)); - - // Some tests to ensure that empty path segments don't cause problems. - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a//b/c", "../../b", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a///b", "s://ex/a/", ".///b", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/", "s://ex/a///b", "../../", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a//b/c", "s://ex/a/b", ".//b/c", REMOVE_MODE)); -} - - -namespace { - -int testParseUri(const char * uriText, const char ** expectedErrorPos = NULL) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - int res = uriParseUriA(&state, uriText); - if (expectedErrorPos != NULL) { - *expectedErrorPos = state.errorPos; - } - uriFreeUriMembersA(&uri); - return res; -} - - - -bool testGoodUri(const char * uriText) { - return (testParseUri(uriText) == 0); -} - - - -bool testBadUri(const char * uriText, int expectedErrorOffset = -1) { - const char * errorPos = NULL; - const int ret = testParseUri(uriText, &errorPos); - return ((ret == URI_ERROR_SYNTAX) - && (errorPos != NULL) - && ( - (expectedErrorOffset == -1) - || (errorPos == (uriText + expectedErrorOffset)) - )); -} - -} // namespace - - - -TEST(FourSuite, GoodUriReferences) { - ASSERT_TRUE(testGoodUri("file:///foo/bar")); - ASSERT_TRUE(testGoodUri("mailto:user@host?subject=blah")); - ASSERT_TRUE(testGoodUri("dav:")); // empty opaque part / rel-path allowed by RFC 2396bis - ASSERT_TRUE(testGoodUri("about:")); // empty opaque part / rel-path allowed by RFC 2396bis - - // the following test cases are from a Perl script by David A. Wheeler - // at http://www.dwheeler.com/secure-programs/url.pl - ASSERT_TRUE(testGoodUri("http://www.yahoo.com")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("http://1.2.3.4/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%20world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi+wan&status=jedi")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?onery")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com#bottom")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#bottom")); - ASSERT_TRUE(testGoodUri("https://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/hello")); - ASSERT_TRUE(testGoodUri("demo.txt")); - ASSERT_TRUE(testGoodUri("demo/hello.txt")); - ASSERT_TRUE(testGoodUri("demo/hello.txt?query=hello#fragment")); - ASSERT_TRUE(testGoodUri("/cgi-bin/query?query=hello#fragment")); - ASSERT_TRUE(testGoodUri("/demo.txt")); - ASSERT_TRUE(testGoodUri("/hello/demo.txt")); - ASSERT_TRUE(testGoodUri("hello/demo.txt")); - ASSERT_TRUE(testGoodUri("/")); - ASSERT_TRUE(testGoodUri("")); - ASSERT_TRUE(testGoodUri("#")); - ASSERT_TRUE(testGoodUri("#here")); - - // Wheeler's script says these are invalid, but they aren't - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=%00%01")); - ASSERT_TRUE(testGoodUri("http://www.yaho%6f.com")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%00world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello+world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&type=")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#")); - ASSERT_TRUE(testGoodUri("//")); - - // the following test cases are from a Haskell program by Graham Klyne - // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs - ASSERT_TRUE(testGoodUri("http://example.org/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("mailto:local@domain.org")); - ASSERT_TRUE(testGoodUri("mailto:local@domain.org#frag")); - ASSERT_TRUE(testGoodUri("HTTP://EXAMPLE.ORG/AAA/BBB#CCC")); - ASSERT_TRUE(testGoodUri("//example.org/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("bbb#ccc")); - ASSERT_TRUE(testGoodUri("#ccc")); - ASSERT_TRUE(testGoodUri("#")); - ASSERT_TRUE(testGoodUri("A'C")); - - // escapes - ASSERT_TRUE(testGoodUri("http://example.org/aaa%2fbbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org/aaa%2Fbbb#ccc")); - ASSERT_TRUE(testGoodUri("%2F")); - ASSERT_TRUE(testGoodUri("aaa%2Fbbb")); - - // ports - ASSERT_TRUE(testGoodUri("http://example.org:80/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org:/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org./aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.123./aaa/bbb#ccc")); - - // bare authority - ASSERT_TRUE(testGoodUri("http://example.org")); - - // IPv6 literals (from RFC2732): - ASSERT_TRUE(testGoodUri("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html")); - ASSERT_TRUE(testGoodUri("http://[1080:0:0:0:8:800:200C:417A]/index.html")); - ASSERT_TRUE(testGoodUri("http://[3ffe:2a00:100:7031::1]")); - ASSERT_TRUE(testGoodUri("http://[1080::8:800:200C:417A]/foo")); - ASSERT_TRUE(testGoodUri("http://[::192.9.5.5]/ipng")); - ASSERT_TRUE(testGoodUri("http://[::FFFF:129.144.52.38]:80/index.html")); - ASSERT_TRUE(testGoodUri("http://[2010:836B:4179::836B:4179]")); - ASSERT_TRUE(testGoodUri("//[2010:836B:4179::836B:4179]")); - - // Random other things that crop up - ASSERT_TRUE(testGoodUri("http://example/Andrȷ")); - ASSERT_TRUE(testGoodUri("file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/")); -} - - - -TEST(FourSuite, BadUriReferences) { - ASSERT_TRUE(testBadUri("beepbeep\x07\x07", 8)); - ASSERT_TRUE(testBadUri("\n", 0)); - ASSERT_TRUE(testBadUri("::", 0)); // not OK, per Roy Fielding on the W3C uri list on 2004-04-01 - - // the following test cases are from a Perl script by David A. Wheeler - // at http://www.dwheeler.com/secure-programs/url.pl - ASSERT_TRUE(testBadUri("http://www yahoo.com", 10)); - ASSERT_TRUE(testBadUri("http://www.yahoo.com/hello world/", 26)); - ASSERT_TRUE(testBadUri("http://www.yahoo.com/yelp.html#\"", 31)); - - // the following test cases are from a Haskell program by Graham Klyne - // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs - ASSERT_TRUE(testBadUri("[2010:836B:4179::836B:4179]", 0)); - ASSERT_TRUE(testBadUri(" ", 0)); - ASSERT_TRUE(testBadUri("%", 1)); - ASSERT_TRUE(testBadUri("A%Z", 2)); - ASSERT_TRUE(testBadUri("%ZZ", 1)); - ASSERT_TRUE(testBadUri("%AZ", 2)); - ASSERT_TRUE(testBadUri("A C", 1)); - ASSERT_TRUE(testBadUri("A\\'C", 1)); // r"A\'C" - ASSERT_TRUE(testBadUri("A`C", 1)); - ASSERT_TRUE(testBadUri("AC", 1)); - ASSERT_TRUE(testBadUri("A^C", 1)); - ASSERT_TRUE(testBadUri("A\\\\C", 1)); // r'A\\C' - ASSERT_TRUE(testBadUri("A{C", 1)); - ASSERT_TRUE(testBadUri("A|C", 1)); - ASSERT_TRUE(testBadUri("A}C", 1)); - ASSERT_TRUE(testBadUri("A[C", 1)); - ASSERT_TRUE(testBadUri("A]C", 1)); - ASSERT_TRUE(testBadUri("A[**]C", 1)); - ASSERT_TRUE(testBadUri("http://[xyz]/", 8)); - ASSERT_TRUE(testBadUri("http://]/", 7)); - ASSERT_TRUE(testBadUri("http://example.org/[2010:836B:4179::836B:4179]", 19)); - ASSERT_TRUE(testBadUri("http://example.org/abc#[2010:836B:4179::836B:4179]", 23)); - ASSERT_TRUE(testBadUri("http://example.org/xxx/[qwerty]#a[b]", 23)); - - // from a post to the W3C uri list on 2004-02-17 - // breaks at 22 instead of 17 because everything up to that point is a valid userinfo - ASSERT_TRUE(testBadUri("http://w3c.org:80path1/path2", 22)); -} - - - -namespace { - -bool normalizeAndCompare(const char * uriText, - const char * expectedNormalized) { - UriParserStateA stateA; - int res; - - UriUriA testUri; - stateA.uri = &testUri; - res = uriParseUriA(&stateA, uriText); - if (res != 0) { - uriFreeUriMembersA(&testUri); - return false; - } - - // Expected result - UriUriA expectedUri; - stateA.uri = &expectedUri; - res = uriParseUriA(&stateA, expectedNormalized); - if (res != 0) { - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - res = uriNormalizeSyntaxA(&testUri); - if (res != 0) { - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - const bool equalAfter = (URI_TRUE == uriEqualsUriA(&testUri, &expectedUri)); - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return equalAfter; -} - -} // namespace - - - -TEST(FourSuite, CaseNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("HTTP://www.EXAMPLE.com/", "http://www.example.com/")); - ASSERT_TRUE(normalizeAndCompare("example://A/b/c/%7bfoo%7d", "example://a/b/c/%7Bfoo%7D")); -} - - - -TEST(FourSuite, PctEncNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("http://host/%7Euser/x/y/z", "http://host/~user/x/y/z")); - ASSERT_TRUE(normalizeAndCompare("http://host/%7euser/x/y/z", "http://host/~user/x/y/z")); -} - - - -TEST(FourSuite, PathSegmentNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("/a/b/../../c", "/c")); - // ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "a/b/../../c")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "c")); - ASSERT_TRUE(normalizeAndCompare("/a/b/././c", "/a/b/c")); - // ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/././c")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/c")); - ASSERT_TRUE(normalizeAndCompare("/a/b/../c/././d", "/a/c/d")); - // ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/b/../c/././d")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/c/d")); -} diff --git a/external/uriparser/test/MemoryManagerSuite.cpp b/external/uriparser/test/MemoryManagerSuite.cpp deleted file mode 100644 index a828d76..0000000 --- a/external/uriparser/test/MemoryManagerSuite.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#undef NDEBUG // because we rely on assert(3) further down - -#include -#include -#include // memcpy -#include - -#include - -// For defaultMemoryManager -extern "C" { -#include "../src/UriMemory.h" -} - - -namespace { - -class CallCountLog { -public: - unsigned int callCountFree; - - CallCountLog() : callCountFree(0) { - // no-op - } -}; - - - -static void * failingMalloc(UriMemoryManager * URI_UNUSED(memory), - size_t URI_UNUSED(size)) { - return NULL; -} - - - -static void * failingCalloc(UriMemoryManager * URI_UNUSED(memory), - size_t URI_UNUSED(nmemb), size_t URI_UNUSED(size)) { - return NULL; -} - - - -static void * failingRealloc(UriMemoryManager * URI_UNUSED(memory), - void * URI_UNUSED(ptr), size_t URI_UNUSED(size)) { - return NULL; -} - - - -static void * failingReallocarray(UriMemoryManager * URI_UNUSED(memory), - void * URI_UNUSED(ptr), size_t URI_UNUSED(nmemb), - size_t URI_UNUSED(size)) { - return NULL; -} - - - -static void countingFree(UriMemoryManager * memory, void * ptr) { - static_cast(memory->userData)->callCountFree++; - free(ptr); -} - - - -class FailingMemoryManager { -private: - UriMemoryManager memoryManager; - CallCountLog callCountLog; - -public: - FailingMemoryManager() { - this->memoryManager.malloc = failingMalloc; - this->memoryManager.calloc = failingCalloc; - this->memoryManager.realloc = failingRealloc; - this->memoryManager.reallocarray = failingReallocarray; - this->memoryManager.free = countingFree; - this->memoryManager.userData = &(this->callCountLog); - } - - UriMemoryManager * operator&() { - return &(this->memoryManager); - } - - unsigned int getCallCountFree() const { - return this->callCountLog.callCountFree; - } -}; - - - -static UriUriA parse(const char * sourceUriString) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - assert(uriParseUriA(&state, sourceUriString) == URI_SUCCESS); - return uri; -} - - - -static UriQueryListA * parseQueryList(const char * queryString) { - UriQueryListA * queryList; - const char * const first = queryString; - const char * const afterLast = first + strlen(first); - assert(uriDissectQueryMallocA(&queryList, NULL, first, afterLast) - == URI_SUCCESS); - return queryList; -} - -} // namespace - - - -TEST(MemoryManagerCompletenessSuite, AllFunctionMembersRequired) { - UriUriA uri = parse("whatever"); - UriMemoryManager memory; - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.malloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.calloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.realloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.reallocarray = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.free = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), URI_SUCCESS); -} - - - -TEST(MemoryManagerCompletenessSuite, MallocAndFreeRequiredOnly) { - UriMemoryManager memory; - UriMemoryManager backend; - - memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); - backend.malloc = NULL; - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); - backend.free = NULL; - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); -} - - - -TEST(MemoryManagerTestingSuite, DefaultMemoryManager) { - ASSERT_EQ(uriTestMemoryManager(&defaultMemoryManager), URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingSuite, CompleteMemoryManager) { - UriMemoryManager memory; - UriMemoryManager backend; - - memset(&backend, 0, sizeof(UriMemoryManager)); - backend.malloc = defaultMemoryManager.malloc; - backend.free = defaultMemoryManager.free; - - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_SUCCESS); - - ASSERT_EQ(uriTestMemoryManager(&memory), URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingSuite, EmulateCalloc) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.calloc = uriEmulateCalloc; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingSuite, EmulateReallocarray) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateCalloc) { - EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); - - errno = 0; - ASSERT_EQ(NULL, uriEmulateCalloc( - &defaultMemoryManager, (size_t)-1, (size_t)-1)); - ASSERT_EQ(errno, ENOMEM); -} - - - -TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateReallocarray) { - EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); - - errno = 0; - ASSERT_EQ(NULL, uriEmulateReallocarray( - &defaultMemoryManager, NULL, (size_t)-1, (size_t)-1)); - ASSERT_EQ(errno, ENOMEM); -} - - - -TEST(MemoryManagerTestingSuite, EmulateCallocAndReallocarray) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.calloc = uriEmulateCalloc; - partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(FailingMemoryManagerSuite, AddBaseUriExMm) { - UriUriA absoluteDest; - UriUriA relativeSource = parse("foo"); - UriUriA absoluteBase = parse("http://example.org/bar"); - const UriResolutionOptions options = URI_RESOLVE_STRICTLY; - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriAddBaseUriExMmA(&absoluteDest, &relativeSource, - &absoluteBase, options, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeUriMembersA(&relativeSource); - uriFreeUriMembersA(&absoluteBase); -} - - - -TEST(FailingMemoryManagerSuite, ComposeQueryMallocExMm) { - char * dest = NULL; - UriQueryListA * const queryList = parseQueryList("k1=v1"); - UriBool spaceToPlus = URI_TRUE; // not of interest - UriBool normalizeBreaks = URI_TRUE; // not of interest - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriComposeQueryMallocExMmA(&dest, queryList, - spaceToPlus, normalizeBreaks, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeQueryListA(queryList); -} - - - -TEST(FailingMemoryManagerSuite, DissectQueryMallocExMm) { - UriQueryListA * queryList; - int itemCount; - const char * const first = "k1=v1&k2=v2"; - const char * const afterLast = first + strlen(first); - const UriBool plusToSpace = URI_TRUE; // not of interest - const UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; // not o. i. - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriDissectQueryMallocExMmA(&queryList, &itemCount, - first, afterLast, plusToSpace, breakConversion, - &failingMemoryManager), - URI_ERROR_MALLOC); -} - - - -TEST(FailingMemoryManagerSuite, FreeQueryListMm) { - UriQueryListA * const queryList = parseQueryList("k1=v1"); - FailingMemoryManager failingMemoryManager; - ASSERT_EQ(failingMemoryManager.getCallCountFree(), 0); - - uriFreeQueryListMmA(queryList, &failingMemoryManager); - - ASSERT_GE(failingMemoryManager.getCallCountFree(), 1); -} - - - -TEST(FailingMemoryManagerSuite, FreeUriMembersMm) { - UriUriA uri = parse("http://example.org/"); - FailingMemoryManager failingMemoryManager; - ASSERT_EQ(failingMemoryManager.getCallCountFree(), 0); - - uriFreeUriMembersMmA(&uri, &failingMemoryManager); - - ASSERT_GE(failingMemoryManager.getCallCountFree(), 1); - uriFreeUriMembersA(&uri); -} - - - -TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMm) { - UriUriA uri = parse("hTTp://example.org/path"); - const unsigned int mask = URI_NORMALIZE_SCHEME; // anything but URI_NORMALIZED - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriNormalizeSyntaxExMmA(&uri, mask, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeUriMembersA(&uri); -} - - - -TEST(FailingMemoryManagerSuite, ParseSingleUriExMm) { - UriUriA uri; - const char * const first = "k1=v1&k2=v2"; - const char * const afterLast = first + strlen(first); - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriParseSingleUriExMmA(&uri, first, afterLast, NULL, - &failingMemoryManager), - URI_ERROR_MALLOC); -} - - - -TEST(FailingMemoryManagerSuite, RemoveBaseUriMm) { - UriUriA dest; - UriUriA absoluteSource = parse("http://example.org/a/b/c/"); - UriUriA absoluteBase = parse("http://example.org/a/"); - const UriBool domainRootMode = URI_TRUE; // not of interest - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriRemoveBaseUriMmA(&dest, &absoluteSource, &absoluteBase, - domainRootMode, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeUriMembersA(&absoluteSource); - uriFreeUriMembersA(&absoluteBase); -} diff --git a/external/uriparser/test/VersionSuite.cpp b/external/uriparser/test/VersionSuite.cpp deleted file mode 100644 index a46f0d5..0000000 --- a/external/uriparser/test/VersionSuite.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2014, Sebastian Pipping - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include - - -#include // for PACKAGE_VERSION -#include - - -TEST(VersionSuite, EnsureVersionDefinesInSync) { - char INSIDE_VERSION[256]; - const int bytes_printed = sprintf(INSIDE_VERSION, "%d.%d.%d%s", - URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_ANSI); - ASSERT_TRUE(bytes_printed != -1); - - const bool equal = !strcmp(INSIDE_VERSION, PACKAGE_VERSION); - if (! equal) { - printf("Inside/outside version mismatch detected:\n"); - printf(" Tarball version: <%s>\n", PACKAGE_VERSION); - printf(" Header defines version: <%s>\n", INSIDE_VERSION); - } - ASSERT_TRUE(equal); -} diff --git a/external/uriparser/test/test.cpp b/external/uriparser/test/test.cpp deleted file mode 100644 index 4b156a4..0000000 --- a/external/uriparser/test/test.cpp +++ /dev/null @@ -1,2294 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song - * Copyright (C) 2007, Sebastian Pipping - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - - - -extern "C" { -UriBool uri_TESTING_ONLY_ParseIpSixA(const char * text); -UriBool uri_TESTING_ONLY_ParseIpFourA(const char * text); -int uriCompareRangeA(const UriTextRangeA * a, const UriTextRangeA * b); -} - - - -#define URI_TEST_IP_FOUR_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpFourA(x)) -#define URI_TEST_IP_FOUR_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpFourA(x)) - -// Note the closing brackets! TODO -#define URI_TEST_IP_SIX_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpSixA(x "]")) -#define URI_TEST_IP_SIX_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpSixA(x "]")) - -#define URI_EXPECT_BETWEEN(candidate, first, afterLast) \ - EXPECT_TRUE((candidate >= first) && (candidate <= afterLast)) - -#define URI_EXPECT_OUTSIDE(candidate, first, afterLast) \ - EXPECT_TRUE((candidate < first) || (candidate > afterLast)) - -#define URI_EXPECT_RANGE_BETWEEN(range, uriFirst, uriAfterLast) \ - URI_EXPECT_BETWEEN(range.first, uriFirst, uriAfterLast); \ - URI_EXPECT_BETWEEN(range.afterLast, uriFirst, uriAfterLast) - -#define URI_EXPECT_RANGE_OUTSIDE(range, uriFirst, uriAfterLast) \ - URI_EXPECT_OUTSIDE(range.first, uriFirst, uriAfterLast); \ - URI_EXPECT_OUTSIDE(range.afterLast, uriFirst, uriAfterLast) - -#define URI_EXPECT_RANGE_EMPTY(range) \ - EXPECT_TRUE((range.first != NULL) \ - && (range.afterLast != NULL) \ - && (range.first == range.afterLast)) - -namespace { - bool testDistinctionHelper(const char * uriText, bool expectedHostSet, - bool expectedAbsPath, bool expectedEmptyTailSegment) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - - int res = uriParseUriA(&state, uriText); - if (res != URI_SUCCESS) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedHostSet != (uri.hostText.first != NULL)) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedAbsPath != (uri.absolutePath == URI_TRUE)) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedEmptyTailSegment != ((uri.pathTail != NULL) - && (uri.pathTail->text.first == uri.pathTail->text.afterLast))) { - uriFreeUriMembersA(&uri); - return false; - } - - uriFreeUriMembersA(&uri); - return true; - } -} // namespace - - -TEST(UriSuite, TestDistinction) { - /* -============================================================================ -Rule | Example | hostSet | absPath | emptySeg -------------------------------------|---------|---------|---------|--------- -1) URI = scheme ":" hier-part ... | | | | - 1) "//" authority path-abempty | "s://" | true | false | false - | "s:///" | true | false | true - | "s://a" | true | false | false - | "s://a/"| true | false | true - 2) path-absolute | "s:/" | false | true | false - 3) path-rootless | "s:a" | false | false | false - | "s:a/" | false | false | true - 4) path-empty | "s:" | false | false | false -------------------------------------|---------|---------|---------|--------- -2) relative-ref = relative-part ... | | | | - 1) "//" authority path-abempty | "//" | true | false | false - | "///" | true | false | true - 2) path-absolute | "/" | false | true | false - 3) path-noscheme | "a" | false | false | false - | "a/" | false | false | true - 4) path-empty | "" | false | false | false -============================================================================ - */ - ASSERT_TRUE(testDistinctionHelper("s://", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("s:///", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("s://a", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("s://a/", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("s:/", false, true, false)); - ASSERT_TRUE(testDistinctionHelper("s:a", false, false, false)); - ASSERT_TRUE(testDistinctionHelper("s:a/", false, false, true)); - ASSERT_TRUE(testDistinctionHelper("s:", false, false, false)); - - ASSERT_TRUE(testDistinctionHelper("//", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("///", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("/", false, true, false)); - ASSERT_TRUE(testDistinctionHelper("a", false, false, false)); - ASSERT_TRUE(testDistinctionHelper("a/", false, false, true)); - ASSERT_TRUE(testDistinctionHelper("", false, false, false)); -} - -TEST(UriSuite, TestIpFour) { - URI_TEST_IP_FOUR_FAIL("01.0.0.0"); - URI_TEST_IP_FOUR_FAIL("001.0.0.0"); - URI_TEST_IP_FOUR_FAIL("00.0.0.0"); - URI_TEST_IP_FOUR_FAIL("000.0.0.0"); - URI_TEST_IP_FOUR_FAIL("256.0.0.0"); - URI_TEST_IP_FOUR_FAIL("300.0.0.0"); - URI_TEST_IP_FOUR_FAIL("1111.0.0.0"); - URI_TEST_IP_FOUR_FAIL("-1.0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0.0."); - URI_TEST_IP_FOUR_FAIL("0.0.0.0."); - URI_TEST_IP_FOUR_FAIL("0.0.0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0..0"); - URI_TEST_IP_FOUR_FAIL(".0.0.0"); - - URI_TEST_IP_FOUR_PASS("255.0.0.0"); - URI_TEST_IP_FOUR_PASS("0.0.0.0"); - URI_TEST_IP_FOUR_PASS("1.0.0.0"); - URI_TEST_IP_FOUR_PASS("2.0.0.0"); - URI_TEST_IP_FOUR_PASS("3.0.0.0"); - URI_TEST_IP_FOUR_PASS("30.0.0.0"); -} - -TEST(UriSuite, TestIpSixPass) { - // Quad length - URI_TEST_IP_SIX_PASS("abcd::"); - - URI_TEST_IP_SIX_PASS("abcd::1"); - URI_TEST_IP_SIX_PASS("abcd::12"); - URI_TEST_IP_SIX_PASS("abcd::123"); - URI_TEST_IP_SIX_PASS("abcd::1234"); - - // Full length - URI_TEST_IP_SIX_PASS("2001:0db8:0100:f101:0210:a4ff:fee3:9566"); // lower hex - URI_TEST_IP_SIX_PASS("2001:0DB8:0100:F101:0210:A4FF:FEE3:9566"); // Upper hex - URI_TEST_IP_SIX_PASS("2001:db8:100:f101:210:a4ff:fee3:9566"); - URI_TEST_IP_SIX_PASS("2001:0db8:100:f101:0:0:0:1"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:255.255.255.255"); - - // Legal IPv4 - URI_TEST_IP_SIX_PASS("::1.2.3.4"); - URI_TEST_IP_SIX_PASS("3:4::5:1.2.3.4"); - URI_TEST_IP_SIX_PASS("::ffff:1.2.3.4"); - URI_TEST_IP_SIX_PASS("::0.0.0.0"); // Min IPv4 - URI_TEST_IP_SIX_PASS("::255.255.255.255"); // Max IPv4 - - // Zipper position - URI_TEST_IP_SIX_PASS("::1:2:3:4:5:6:7"); - URI_TEST_IP_SIX_PASS("1::1:2:3:4:5:6"); - URI_TEST_IP_SIX_PASS("1:2::1:2:3:4:5"); - URI_TEST_IP_SIX_PASS("1:2:3::1:2:3:4"); - URI_TEST_IP_SIX_PASS("1:2:3:4::1:2:3"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5::1:2"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6::1"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:7::"); - - // Zipper length - URI_TEST_IP_SIX_PASS("1:1:1::1:1:1:1"); - URI_TEST_IP_SIX_PASS("1:1:1::1:1:1"); - URI_TEST_IP_SIX_PASS("1:1:1::1:1"); - URI_TEST_IP_SIX_PASS("1:1::1:1"); - URI_TEST_IP_SIX_PASS("1:1::1"); - URI_TEST_IP_SIX_PASS("1::1"); - URI_TEST_IP_SIX_PASS("::1"); // == localhost - URI_TEST_IP_SIX_PASS("::"); // == all addresses - - // A few more variations - URI_TEST_IP_SIX_PASS("21ff:abcd::1"); - URI_TEST_IP_SIX_PASS("2001:db8:100:f101::1"); - URI_TEST_IP_SIX_PASS("a:b:c::12:1"); - URI_TEST_IP_SIX_PASS("a:b::0:1:2:3"); -} - -TEST(UriSuite, TestIpSixFail) { - // 5 char quad - URI_TEST_IP_SIX_FAIL("::12345"); - - // Two zippers - URI_TEST_IP_SIX_FAIL("abcd::abcd::abcd"); - - // Triple-colon zipper - URI_TEST_IP_SIX_FAIL(":::1234"); - URI_TEST_IP_SIX_FAIL("1234:::1234:1234"); - URI_TEST_IP_SIX_FAIL("1234:1234:::1234"); - URI_TEST_IP_SIX_FAIL("1234:::"); - - // No quads, just IPv4 - URI_TEST_IP_SIX_FAIL("1.2.3.4"); - URI_TEST_IP_SIX_FAIL("0001.0002.0003.0004"); - - // Five quads - URI_TEST_IP_SIX_FAIL("0000:0000:0000:0000:0000:1.2.3.4"); - - // Seven quads - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0"); - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:"); - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:1.2.3.4"); - - // Nine quads (or more) - URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8:9"); - URI_TEST_IP_SIX_FAIL("::2:3:4:5:6:7:8:9"); - URI_TEST_IP_SIX_FAIL("1:2:3:4::6:7:8:9"); - URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8::"); - - // Invalid IPv4 part - URI_TEST_IP_SIX_FAIL("::ffff:001.02.03.004"); // Leading zeros - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.1111"); // Four char octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.256"); // > 255 - URI_TEST_IP_SIX_FAIL("::ffff:311.2.3.4"); // > 155 - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3:4"); // Not a dot - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3"); // Missing octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3."); // Missing octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3a.4"); // Hex in octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.4:123"); // Crap input - - // Nonhex - URI_TEST_IP_SIX_FAIL("g:0:0:0:0:0:0"); -} - -TEST(UriSuite, TestIpSixOverread) { - UriUriA uri; - const char * errorPos; - - // NOTE: This string is designed to not have a terminator - char uriText[2 + 3 + 2 + 1 + 1]; - strncpy(uriText, "//[::44.1", sizeof(uriText)); - - EXPECT_EQ(uriParseSingleUriExA(&uri, uriText, - uriText + sizeof(uriText), &errorPos), URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriText + sizeof(uriText)); -} - -TEST(UriSuite, TestUri) { - UriParserStateA stateA; - UriParserStateW stateW; - UriUriA uriA; - UriUriW uriW; - - stateA.uri = &uriA; - stateW.uri = &uriW; - - // On/off for each - ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@[::1]:80/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://[::1]:80/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html?query")); - uriFreeUriMembersA(&uriA); - - // Schema, port, one segment - ASSERT_TRUE(0 == uriParseUriA(&stateA, "ftp://host:21/gnu/")); - uriFreeUriMembersA(&uriA); - - // Relative - ASSERT_TRUE(0 == uriParseUriA(&stateA, "one/two/three")); - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "/one/two/three")); - ASSERT_TRUE(uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three")); - uriFreeUriMembersA(&uriA); - - // Both narrow and wide string version - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriW(&stateW, L"http://www.example.com/")); - uriFreeUriMembersW(&uriW); - - // Real life examples - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/projects/uriparser/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/project/platformdownload.php?group_id=182840")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "mailto:test@example.com")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "../../")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "/")); - ASSERT_TRUE(uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "")); - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "file:///bin/bash")); - uriFreeUriMembersA(&uriA); - - // Percent encoding - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/name%20with%20spaces/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 != uriParseUriA(&stateA, "http://www.example.com/name with spaces/")); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriComponents) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 15 01 0 7 01 - const char * const input = "http" "://" "sourceforge.net" "/" "project" "/" - // 0 20 01 0 15 - "platformdownload.php" "?" "group_id=182840"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.scheme.first == input); - ASSERT_TRUE(uriA.scheme.afterLast == input + 4); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 15); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - - ASSERT_TRUE(uriA.pathHead->text.first == input + 4 + 3 + 15 + 1); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 4 + 3 + 15 + 1 + 7); - ASSERT_TRUE(uriA.pathHead->next->text.first == input + 4 + 3 + 15 + 1 + 7 + 1); - ASSERT_TRUE(uriA.pathHead->next->text.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20); - ASSERT_TRUE(uriA.pathHead->next->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); - - ASSERT_TRUE(uriA.query.first == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1); - ASSERT_TRUE(uriA.query.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1 + 15); - ASSERT_TRUE(uriA.fragment.first == NULL); - ASSERT_TRUE(uriA.fragment.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriComponentsBug20070701) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 01 01 01 - const char * const input = "a" ":" "b"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.scheme.first == input); - ASSERT_TRUE(uriA.scheme.afterLast == input + 1); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == NULL); - ASSERT_TRUE(uriA.hostText.afterLast == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - - ASSERT_TRUE(uriA.pathHead->text.first == input + 1 + 1); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 1 + 1 + 1); - ASSERT_TRUE(uriA.pathHead->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead); - - ASSERT_TRUE(uriA.query.first == NULL); - ASSERT_TRUE(uriA.query.afterLast == NULL); - ASSERT_TRUE(uriA.fragment.first == NULL); - ASSERT_TRUE(uriA.fragment.afterLast == NULL); - - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort1) { - // User info with ":", no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abc:def" "@" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort2) { - // User info with ":", with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abc:def" "@" "localhost" - // 01 0 3 - ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort22Bug1948038) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - - res = uriParseUriA(&stateA, "http://user:21@host/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:21", 7 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 7); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://user:1234@192.168.0.1:1234/foo.com"); - ASSERT_TRUE(URI_SUCCESS == res); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo/"); - ASSERT_TRUE(URI_ERROR_SYNTAX == res); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo:21/"); - ASSERT_TRUE(URI_ERROR_SYNTAX == res); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198One) { - // User info with ":", with port, with escaped chars in password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 10 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "user:%2F21" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:%2F21", 10 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 10); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Two) { - // User info with ":", with port, with escaped chars in user name and password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 13 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "%2Fuser:%2F21" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "%2Fuser:%2F21", 13 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 13); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Three) { - // User info with ":", with port, with escaped chars in password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 16 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "user:!$&'()*+,;=" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:!$&'()*+,;=", 16 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 16); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Four) { - // User info with ":", with port, with escaped chars in user name and password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 20 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "!$&'()*+,;=:password" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "!$&'()*+,;=:password", 20 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 20); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOne) { - // Empty user info - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.afterLast != NULL); - ASSERT_TRUE(uriA.userInfo.first != NULL); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 0); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOneTwo) { - // Empty user info - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 7 01 - res = uriParseUriA(&stateA, "http" "://" "%2Fhost" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "%2Fhost", 7 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 7); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedTwo) { - // Several colons in userinfo - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 2 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "::" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "::", 2 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 2); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort3) { - // User info without ":", no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abcdefg" "@" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort4) { - // User info without ":", with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abcdefg" "@" "localhost" - // 01 0 3 - ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort5) { - // No user info, no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 9 - const char * const input = "http" "://" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort6) { - // No user info, with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 9 01 0 3 - const char * const input = "http" "://" "localhost" ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostRegname) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 11 - const char * const input = "http" "://" "example.com"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 11); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFour1) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 2 - const char * const input = "http" "://" "1.2.3.4" ":" "80"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostData.ip4 != NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFour2) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 - const char * const input = "http" "://" "1.2.3.4"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostData.ip4 != NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpSix1) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 45 01 0 2 - const char * const input = "http" "://" "[::1]" ":" "80"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 != NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpSix2) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 45 - const char * const input = "http" "://" "[::1]"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 != NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostEmpty) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 0 3 - const char * const input = "http" "://" ":" "123"; - const int res = uriParseUriA(&stateA, input); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first != NULL); - ASSERT_TRUE(uriA.hostText.afterLast != NULL); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 0); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFuture) { - // TODO -} - -namespace { - bool testEscapingHelper(const wchar_t * in, const wchar_t * expectedOut, - bool spaceToPlus = false, bool normalizeBreaks = false) { - wchar_t * const buffer = new wchar_t[(normalizeBreaks ? 6 : 3) - * wcslen(in) + 1]; - if (uriEscapeW(in, buffer, spaceToPlus, normalizeBreaks) - != buffer + wcslen(expectedOut)) { - delete [] buffer; - return false; - } - - const bool equal = !wcscmp(buffer, expectedOut); - delete [] buffer; - return equal; - } -} // namespace - -TEST(UriSuite, TestEscaping) { - const bool SPACE_TO_PLUS = true; - const bool SPACE_TO_PERCENT = false; - const bool KEEP_UNMODIFIED = false; - const bool NORMALIZE = true; - - // '+' to ' ' - ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc+def", SPACE_TO_PLUS)); - ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc%20def", SPACE_TO_PERCENT)); - - // Percent encoding - ASSERT_TRUE(testEscapingHelper(L"\x00", L"\0")); - ASSERT_TRUE(testEscapingHelper(L"\x01", L"%01")); - ASSERT_TRUE(testEscapingHelper(L"\xff", L"%FF")); - - // Linebreak normalization - ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0D%0A%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0A%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); -} - -namespace { - bool testUnescapingHelper(const wchar_t * input, const wchar_t * output, - bool plusToSpace = false, UriBreakConversion breakConversion = URI_BR_DONT_TOUCH) { - wchar_t * working = new wchar_t[URI_STRLEN(input) + 1]; - wcscpy(working, input); - const wchar_t * newTermZero = uriUnescapeInPlaceExW(working, - plusToSpace ? URI_TRUE : URI_FALSE, breakConversion); - const bool success = ((newTermZero == working + wcslen(output)) - && !wcscmp(working, output)); - delete[] working; - return success; - } -} // namespace - -TEST(UriSuite, TestUnescaping) { - const bool PLUS_TO_SPACE = true; - const bool PLUS_DONT_TOUCH = false; - - - // Proper - ASSERT_TRUE(testUnescapingHelper(L"abc%20%41BC", L"abc ABC")); - ASSERT_TRUE(testUnescapingHelper(L"%20", L" ")); - - // Incomplete - ASSERT_TRUE(testUnescapingHelper(L"%0", L"%0")); - - // Nonhex - ASSERT_TRUE(testUnescapingHelper(L"%0g", L"%0g")); - ASSERT_TRUE(testUnescapingHelper(L"%G0", L"%G0")); - - // No double decoding - ASSERT_TRUE(testUnescapingHelper(L"%2520", L"%20")); - - // Decoding of '+' - ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc+def", PLUS_DONT_TOUCH)); - ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc def", PLUS_TO_SPACE)); - - // Line break conversion - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); -} - -namespace { - bool testAddBaseHelper(const wchar_t * base, const wchar_t * rel, const wchar_t * expectedResult, bool backward_compatibility = false) { - UriParserStateW stateW; - - // Base - UriUriW baseUri; - stateW.uri = &baseUri; - int res = uriParseUriW(&stateW, base); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - return false; - } - - // Rel - UriUriW relUri; - stateW.uri = &relUri; - res = uriParseUriW(&stateW, rel); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - return false; - } - - // Expected result - UriUriW expectedUri; - stateW.uri = &expectedUri; - res = uriParseUriW(&stateW, expectedResult); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - // Transform - UriUriW transformedUri; - if (backward_compatibility) { - res = uriAddBaseUriExW(&transformedUri, &relUri, &baseUri, URI_RESOLVE_IDENTICAL_SCHEME_COMPAT); - } else { - res = uriAddBaseUriW(&transformedUri, &relUri, &baseUri); - } - - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - uriFreeUriMembersW(&transformedUri); - return false; - } - - const bool equal = (URI_TRUE == uriEqualsUriW(&transformedUri, &expectedUri)); - if (!equal) { - wchar_t transformedUriText[1024 * 8]; - wchar_t expectedUriText[1024 * 8]; - uriToStringW(transformedUriText, &transformedUri, 1024 * 8, NULL); - uriToStringW(expectedUriText, &expectedUri, 1024 * 8, NULL); -#ifdef HAVE_WPRINTF - wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); -#endif - } - - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - uriFreeUriMembersW(&transformedUri); - return equal; - } -} // namespace - -TEST(UriSuite, TestTrailingSlash) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 3 01 - const char * const input = "abc" "/"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.pathHead->text.first == input); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 3); - ASSERT_TRUE(uriA.pathHead->next->text.first == uriA.pathHead->next->text.afterLast); - ASSERT_TRUE(uriA.pathHead->next->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestAddBase) { - // 5.4.1. Normal Examples - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g:h", L"g:h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g", L"http://a/b/c/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g", L"http://a/b/c/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/", L"http://a/b/c/g/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"//g", L"http://g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"?y", L"http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y", L"http://a/b/c/g?y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"#s", L"http://a/b/c/d;p?q#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s", L"http://a/b/c/g#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y#s", L"http://a/b/c/g?y#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L";x", L"http://a/b/c/;x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x", L"http://a/b/c/g;x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x?y#s", L"http://a/b/c/g;x?y#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"", L"http://a/b/c/d;p?q")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".", L"http://a/b/c/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./", L"http://a/b/c/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..", L"http://a/b/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../", L"http://a/b/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../g", L"http://a/b/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../..", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../g", L"http://a/g")); - - // 5.4.2. Abnormal Examples - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/./g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g.", L"http://a/b/c/g.")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".g", L"http://a/b/c/.g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g..", L"http://a/b/c/g..")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..g", L"http://a/b/c/..g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./../g", L"http://a/b/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g/.", L"http://a/b/c/g/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/./h", L"http://a/b/c/g/h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/../h", L"http://a/b/c/h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/./y", L"http://a/b/c/g;x=1/y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/../y", L"http://a/b/c/y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/./x", L"http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/../x", L"http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/./x", L"http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/../x", L"http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g")); - - // Backward compatibility (feature request #4, RFC3986 5.4.2) - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g", false)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http://a/b/c/g", true)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g?q#f", L"http://a/b/c/g?q#f", true)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"other:g?q#f", L"other:g?q#f", true)); - - // Bug related to absolutePath flag set despite presence of host - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g/", L"http://a/g/")); - - // GitHub issue #92 - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../..", L"http://a/")); - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../../", L"http://a/")); - - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../..", L"http://a/")); - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../../", L"http://a/")); - - EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../..", L"http://a/")); - EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../../", L"http://a/")); - - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../..", L"http://a/")); - EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../", L"http://a/")); -} - -namespace { - bool testToStringHelper(const wchar_t * text) { - // Parse - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, text); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Back to string, _huge_ limit - wchar_t shouldbeTheSame[1024 * 8]; - res = uriToStringW(shouldbeTheSame, &uri, 1024 * 8, NULL); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Compare - bool equals = (0 == wcscmp(shouldbeTheSame, text)); - if (!equals) { -#ifdef HAVE_WPRINTF - wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", text, shouldbeTheSame); -#endif - } - - // Back to string, _exact_ limit - const int len = static_cast(wcslen(text)); - int charsWritten; - res = uriToStringW(shouldbeTheSame, &uri, len + 1, &charsWritten); - if ((res != 0) || (charsWritten != len + 1)) { - uriFreeUriMembersW(&uri); - return false; - } - - // Back to string, _too small_ limit - res = uriToStringW(shouldbeTheSame, &uri, len, &charsWritten); - if ((res == 0) || (charsWritten >= len + 1)) { - uriFreeUriMembersW(&uri); - return false; - } - - uriFreeUriMembersW(&uri); - return equals; - } -} // namespace - -TEST(UriSuite, TestToString) { - // Scheme - ASSERT_TRUE(testToStringHelper(L"ftp://localhost/")); - // UserInfo - ASSERT_TRUE(testToStringHelper(L"http://user:pass@localhost/")); - // IPv4 - ASSERT_TRUE(testToStringHelper(L"http://123.0.1.255/")); - // IPv6 - ASSERT_TRUE(testToStringHelper(L"http://[abcd:abcd:abcd:abcd:abcd:abcd:abcd:abcd]/")); - // IPvFuture - ASSERT_TRUE(testToStringHelper(L"http://[vA.123456]/")); - // Port - ASSERT_TRUE(testToStringHelper(L"http://example.com:123/")); - // Path - ASSERT_TRUE(testToStringHelper(L"http://example.com")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com//")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/./..")); - // Query - ASSERT_TRUE(testToStringHelper(L"http://example.com/?abc")); - // Fragment - ASSERT_TRUE(testToStringHelper(L"http://example.com/#abc")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/?def#abc")); - - // Relative - ASSERT_TRUE(testToStringHelper(L"a")); - ASSERT_TRUE(testToStringHelper(L"a/")); - ASSERT_TRUE(testToStringHelper(L"/a")); - ASSERT_TRUE(testToStringHelper(L"/a/")); - ASSERT_TRUE(testToStringHelper(L"abc")); - ASSERT_TRUE(testToStringHelper(L"abc/")); - ASSERT_TRUE(testToStringHelper(L"/abc")); - ASSERT_TRUE(testToStringHelper(L"/abc/")); - ASSERT_TRUE(testToStringHelper(L"a/def")); - ASSERT_TRUE(testToStringHelper(L"a/def/")); - ASSERT_TRUE(testToStringHelper(L"/a/def")); - ASSERT_TRUE(testToStringHelper(L"/a/def/")); - ASSERT_TRUE(testToStringHelper(L"abc/def")); - ASSERT_TRUE(testToStringHelper(L"abc/def/")); - ASSERT_TRUE(testToStringHelper(L"/abc/def")); - ASSERT_TRUE(testToStringHelper(L"/abc/def/")); - ASSERT_TRUE(testToStringHelper(L"/")); - ASSERT_TRUE(testToStringHelper(L"//a/")); - ASSERT_TRUE(testToStringHelper(L".")); - ASSERT_TRUE(testToStringHelper(L"./")); - ASSERT_TRUE(testToStringHelper(L"/.")); - ASSERT_TRUE(testToStringHelper(L"/./")); - ASSERT_TRUE(testToStringHelper(L"")); - ASSERT_TRUE(testToStringHelper(L"./abc/def")); - ASSERT_TRUE(testToStringHelper(L"?query")); - ASSERT_TRUE(testToStringHelper(L"#fragment")); - ASSERT_TRUE(testToStringHelper(L"?query#fragment")); - - // Tests for bugs from the past - ASSERT_TRUE(testToStringHelper(L"f:/.//g")); -} - -TEST(UriSuite, TestToStringBug1950126) { - UriParserStateW state; - UriUriW uriOne; - UriUriW uriTwo; - const wchar_t * const uriOneString = L"http://e.com/"; - const wchar_t * const uriTwoString = L"http://e.com"; - state.uri = &uriOne; - ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriOneString)); - state.uri = &uriTwo; - ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriTwoString)); - ASSERT_TRUE(URI_FALSE == uriEqualsUriW(&uriOne, &uriTwo)); - uriFreeUriMembersW(&uriOne); - uriFreeUriMembersW(&uriTwo); - - ASSERT_TRUE(testToStringHelper(uriOneString)); - ASSERT_TRUE(testToStringHelper(uriTwoString)); -} - -namespace { - bool testToStringCharsRequiredHelper(const wchar_t * text) { - // Parse - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, text); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Required space? - int charsRequired; - if (uriToStringCharsRequiredW(&uri, &charsRequired) != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - EXPECT_EQ(charsRequired, wcslen(text)); - - // Minimum - wchar_t * buffer = new wchar_t[charsRequired + 1]; - if (uriToStringW(buffer, &uri, charsRequired + 1, NULL) != 0) { - uriFreeUriMembersW(&uri); - delete [] buffer; - return false; - } - - // One less than minimum - if (uriToStringW(buffer, &uri, charsRequired, NULL) == 0) { - uriFreeUriMembersW(&uri); - delete [] buffer; - return false; - } - - uriFreeUriMembersW(&uri); - delete [] buffer; - return true; - } -} // namespace - -TEST(UriSuite, TestToStringCharsRequired) { - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://12.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://123.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.12.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.123.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.12.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.123.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.12/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.123/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com:80/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://user:pass@www.example.com/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/index.html")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/#def")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc#def")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"/test")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"test")); -} - -namespace { - bool testNormalizeMaskHelper(const wchar_t * uriText, unsigned int expectedMask) { - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, uriText); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - const unsigned int maskBefore = uriNormalizeSyntaxMaskRequiredW(&uri); - if (maskBefore != expectedMask) { - uriFreeUriMembersW(&uri); - return false; - } - - res = uriNormalizeSyntaxW(&uri); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - const unsigned int maskAfter = uriNormalizeSyntaxMaskRequiredW(&uri); - uriFreeUriMembersW(&uri); - - // Second call should be no problem - uriFreeUriMembersW(&uri); - - return (maskAfter == URI_NORMALIZED); - } -} // namespace - -TEST(UriSuite, TestNormalizeSyntaxMaskRequired) { - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/", URI_NORMALIZED)); - ASSERT_TRUE(testNormalizeMaskHelper(L"httP://localhost/", URI_NORMALIZE_SCHEME)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://%0d@localhost/", URI_NORMALIZE_USER_INFO)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhosT/", URI_NORMALIZE_HOST)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/./abc", URI_NORMALIZE_PATH)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/?AB%43", URI_NORMALIZE_QUERY)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/#AB%43", URI_NORMALIZE_FRAGMENT)); -} - -namespace { - bool testNormalizeSyntaxHelper(const wchar_t * uriText, const wchar_t * expectedNormalized, - unsigned int mask = static_cast(-1)) { - UriParserStateW stateW; - int res; - - UriUriW testUri; - stateW.uri = &testUri; - res = uriParseUriW(&stateW, uriText); - if (res != 0) { - uriFreeUriMembersW(&testUri); - return false; - } - - // Expected result - UriUriW expectedUri; - stateW.uri = &expectedUri; - res = uriParseUriW(&stateW, expectedNormalized); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - // First run - res = uriNormalizeSyntaxExW(&testUri, mask); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - bool equalAfter = (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); - - // Second run - res = uriNormalizeSyntaxExW(&testUri, mask); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - equalAfter = equalAfter - && (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); - - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return equalAfter; - } -} // namespace - -TEST(UriSuite, TestNormalizeSyntax) { - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"eXAMPLE://a/./b/../b/%63/%7bfoo%7d", - L"example://a/b/c/%7Bfoo%7D")); - - // Testcase by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://examp%4Ce.com/", - L"http://example.com/")); - - // Testcase by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://example.com/a/b/%2E%2E/", - L"http://example.com/a/")); - - // Reported by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://user:pass@SOMEHOST.COM:123", - L"http://user:pass@somehost.com:123")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://a:b@HOST:123/./1/2/../%41?abc#def", - L"http://a:b@host:123/1/A?abc#def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc", - L"../../abc")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/..", - L"../../")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/../def", - L"../../def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"abc/..", - L"")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"abc/../", - L"")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/./def", - L"../../abc/def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"./def", - L"def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"def/.", - L"def/")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"./abc:def", - L"./abc:def")); -} - -TEST(UriSuite, TestNormalizeSyntaxComponents) { - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"http://%41@EXAMPLE.ORG/../a?%41#%41", - URI_NORMALIZE_SCHEME)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://A@EXAMPLE.ORG/../a?%41#%41", - URI_NORMALIZE_USER_INFO)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@example.org/../a?%41#%41", - URI_NORMALIZE_HOST)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/a?%41#%41", - URI_NORMALIZE_PATH)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/../a?A#%41", - URI_NORMALIZE_QUERY)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/../a?%41#A", - URI_NORMALIZE_FRAGMENT)); -} - -TEST(UriSuite, TestNormalizeSyntaxPath) { - // These are from GitHub issue #92 - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/b/c/../../..", - L"http://a/", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/b/../c/../..", - L"http://a/", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/b/c/../../..", - L"http://a/", - URI_NORMALIZE_PATH)); - - // .. and these are related - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/..", - L"http://a/", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"/..", - L"/", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/..///", - L"http://a///", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"http://a/..///..", - L"http://a//", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"a/b/c/../../..", - L"", - URI_NORMALIZE_PATH)); - EXPECT_TRUE(testNormalizeSyntaxHelper( - L"a/b/../../c/..", - L"", - URI_NORMALIZE_PATH)); -} - -TEST(UriSuite, TestNormalizeCrashBug20080224) { - UriParserStateW stateW; - int res; - UriUriW testUri; - stateW.uri = &testUri; - - res = uriParseUriW(&stateW, L"http://example.org/abc//../def"); - ASSERT_TRUE(res == 0); - - // First call will make us owner of copied memory - res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_SCHEME); - ASSERT_TRUE(res == 0); - res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_HOST); - ASSERT_TRUE(res == 0); - - // Frees empty path segment -> crash - res = uriNormalizeSyntaxW(&testUri); - ASSERT_TRUE(res == 0); - - uriFreeUriMembersW(&testUri); -} - -namespace { - void testFilenameUriConversionHelper(const wchar_t * filename, - const wchar_t * uriString, bool forUnix, - const wchar_t * expectedUriString = NULL) { - const int prefixLen = forUnix ? 7 : 8; - if (! expectedUriString) { - expectedUriString = uriString; - } - - // Filename to URI string - const size_t uriBufferLen = prefixLen + 3 * wcslen(filename) + 1; - wchar_t * uriBuffer = new wchar_t[uriBufferLen]; - if (forUnix) { - uriUnixFilenameToUriStringW(filename, uriBuffer); - } else { - uriWindowsFilenameToUriStringW(filename, uriBuffer); - } -#ifdef HAVE_WPRINTF - // wprintf(L"1 [%s][%s]\n", uriBuffer, expectedUriString); -#endif - ASSERT_TRUE(!wcscmp(uriBuffer, expectedUriString)); - delete [] uriBuffer; - - // URI string to filename - const size_t filenameBufferLen = wcslen(uriString) + 1; - wchar_t * filenameBuffer = new wchar_t[filenameBufferLen]; - if (forUnix) { - uriUriStringToUnixFilenameW(uriString, filenameBuffer); - } else { - uriUriStringToWindowsFilenameW(uriString, filenameBuffer); - } -#ifdef HAVE_WPRINTF - // wprintf(L"2 [%s][%s]\n", filenameBuffer, filename); -#endif - ASSERT_TRUE(!wcscmp(filenameBuffer, filename)); - delete [] filenameBuffer; - } -} // namespace - -TEST(UriSuite, TestFilenameUriConversion) { - const bool FOR_UNIX = true; - const bool FOR_WINDOWS = false; - testFilenameUriConversionHelper(L"/bin/bash", L"file:///bin/bash", FOR_UNIX); - testFilenameUriConversionHelper(L"/bin/bash", L"file:/bin/bash", FOR_UNIX, L"file:///bin/bash"); - testFilenameUriConversionHelper(L"./configure", L"./configure", FOR_UNIX); - - testFilenameUriConversionHelper(L"E:\\Documents and Settings", L"file:///E:/Documents%20and%20Settings", FOR_WINDOWS); - testFilenameUriConversionHelper(L"c:\\path\\to\\file.txt", L"file:c:/path/to/file.txt", FOR_WINDOWS, L"file:///c:/path/to/file.txt"); - - testFilenameUriConversionHelper(L".\\Readme.txt", L"./Readme.txt", FOR_WINDOWS); - - testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_WINDOWS); - testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_UNIX); - - testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_WINDOWS); - testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_UNIX); - - testFilenameUriConversionHelper(L"\\\\Server01\\user\\docs\\Letter.txt", L"file://Server01/user/docs/Letter.txt", FOR_WINDOWS); -} - -TEST(UriSuite, TestCrashFreeUriMembersBug20080116) { - // Testcase by Adrian Manrique - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - uriParseUriA(&state, "http://test/?"); - uriNormalizeSyntaxA(&uri); - uriFreeUriMembersA(&uri); - - ASSERT_TRUE(true); -} - -namespace { - void helperTestQueryString(char const * uriString, int pairsExpected); -} - -TEST(UriSuite, TestCrashReport2418192) { - // Testcase by Harvey Vrsalovic - helperTestQueryString("http://svcs.cnn.com/weather/wrapper.jsp?&csiID=csi1", 1); -} - -TEST(UriSuite, TestPervertedQueryString) { - helperTestQueryString("http://example.org/?&&=&&&=&&&&==&===&====", 5); -} - -TEST(UriSuite, TestQueryStringEndingInEqualSignNonBug32) { - const char * queryString = "firstname=sdsd&lastname="; - - UriQueryListA * queryList = NULL; - int itemCount = 0; - const int res = uriDissectQueryMallocA(&queryList, &itemCount, - queryString, queryString + strlen(queryString)); - - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(itemCount == 2); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(strcmp(queryList->key, "firstname") == 0); - ASSERT_TRUE(strcmp(queryList->value, "sdsd") == 0); - ASSERT_TRUE(strcmp(queryList->next->key, "lastname") == 0); - ASSERT_TRUE(strcmp(queryList->next->value, "") == 0); - ASSERT_TRUE(queryList->next->next == NULL); - - uriFreeQueryListA(queryList); -} - -namespace { - void helperTestQueryString(char const * uriString, int pairsExpected) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - int res = uriParseUriA(&state, uriString); - ASSERT_TRUE(res == URI_SUCCESS); - - UriQueryListA * queryList = NULL; - int itemCount = 0; - - res = uriDissectQueryMallocA(&queryList, &itemCount, - uri.query.first, uri.query.afterLast); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == pairsExpected); - uriFreeQueryListA(queryList); - uriFreeUriMembersA(&uri); - } -} // namespace - -TEST(UriSuite, TestCrashMakeOwnerBug20080207) { - // Testcase by Adrian Manrique - UriParserStateA state; - UriUriA sourceUri; - state.uri = &sourceUri; - const char * const sourceUriString = "http://user:pass@somehost.com:80/"; - if (uriParseUriA(&state, sourceUriString) != 0) { - ASSERT_TRUE(false); - } - if (uriNormalizeSyntaxA(&sourceUri) != 0) { - ASSERT_TRUE(false); - } - uriFreeUriMembersA(&sourceUri); - ASSERT_TRUE(true); -} - -namespace { - void testQueryListHelper(const wchar_t * input, int expectedItemCount) { - int res; - - UriBool spacePlusConversion = URI_TRUE; - UriBool normalizeBreaks = URI_FALSE; - UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; - - int itemCount; - UriQueryListW * queryList; - res = uriDissectQueryMallocExW(&queryList, &itemCount, - input, input + wcslen(input), spacePlusConversion, breakConversion); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(itemCount == expectedItemCount); - ASSERT_TRUE((queryList == NULL) == (expectedItemCount == 0)); - - if (expectedItemCount != 0) { - // First - int charsRequired; - res = uriComposeQueryCharsRequiredExW(queryList, &charsRequired, spacePlusConversion, - normalizeBreaks); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(charsRequired >= (int)wcslen(input)); - - wchar_t * recomposed = new wchar_t[charsRequired + 1]; - int charsWritten; - res = uriComposeQueryExW(recomposed, queryList, charsRequired + 1, - &charsWritten, spacePlusConversion, normalizeBreaks); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(charsWritten <= charsRequired); - ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); - ASSERT_TRUE(!wcscmp(input, recomposed)); - delete [] recomposed; - - recomposed = NULL; - res = uriComposeQueryMallocW(&recomposed, queryList); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(recomposed != NULL); - ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); - ASSERT_TRUE(!wcscmp(input, recomposed)); - free(recomposed); - } - - uriFreeQueryListW(queryList); - } -} // namespace - -TEST(UriSuite, QueryList) { - testQueryListHelper(L"one=ONE&two=TWO", 2); - testQueryListHelper(L"one=ONE&two=&three=THREE", 3); - testQueryListHelper(L"one=ONE&two&three=THREE", 3); - testQueryListHelper(L"one=ONE", 1); - testQueryListHelper(L"one", 1); - testQueryListHelper(L"", 0); -} - -namespace { - void testQueryListPairHelper(const char * pair, const char * unescapedKey, - const char * unescapedValue, const char * fixed = NULL) { - int res; - UriQueryListA * queryList; - int itemCount; - - res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == 1); - ASSERT_TRUE(!strcmp(queryList->key, unescapedKey)); - ASSERT_TRUE(!strcmp(queryList->value, unescapedValue)); - - char * recomposed; - res = uriComposeQueryMallocA(&recomposed, queryList); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(recomposed != NULL); - ASSERT_TRUE(!strcmp(recomposed, (fixed != NULL) ? fixed : pair)); - free(recomposed); - uriFreeQueryListA(queryList); - } -} // namespace - -TEST(UriSuite, TestQueryListPair) { - testQueryListPairHelper("one+two+%26+three=%2B", "one two & three", "+"); - testQueryListPairHelper("one=two=three", "one", "two=three", "one=two%3Dthree"); - testQueryListPairHelper("one=two=three=four", "one", "two=three=four", "one=two%3Dthree%3Dfour"); -} - -TEST(UriSuite, TestQueryDissectionBug3590761) { - int res; - UriQueryListA * queryList; - int itemCount; - const char * const pair = "q=hello&x=&y="; - - res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == 3); - - ASSERT_TRUE(!strcmp(queryList->key, "q")); - ASSERT_TRUE(!strcmp(queryList->value, "hello")); - - ASSERT_TRUE(!strcmp(queryList->next->key, "x")); - ASSERT_TRUE(!strcmp(queryList->next->value, "")); - - ASSERT_TRUE(!strcmp(queryList->next->next->key, "y")); - ASSERT_TRUE(!strcmp(queryList->next->next->value, "")); - - ASSERT_TRUE(! queryList->next->next->next); - - uriFreeQueryListA(queryList); -} - -TEST(UriSuite, TestQueryCompositionMathCalc) { - UriQueryListA second = { /*.key =*/ "k2", /*.value =*/ "v2", /*.next =*/ NULL }; - UriQueryListA first = { /*.key =*/ "k1", /*.value =*/ "v1", /*.next =*/ &second }; - - int charsRequired; - ASSERT_TRUE(uriComposeQueryCharsRequiredA(&first, &charsRequired) - == URI_SUCCESS); - - const int FACTOR = 6; /* due to escaping with normalizeBreaks */ - ASSERT_TRUE((unsigned)charsRequired == - FACTOR * strlen(first.key) + 1 + FACTOR * strlen(first.value) - + 1 - + FACTOR * strlen(second.key) + 1 + FACTOR * strlen(second.value) - ); -} - -TEST(UriSuite, TestQueryCompositionMathWriteGoogleAutofuzz113244572) { - UriQueryListA second = { /*.key =*/ "\x11", /*.value =*/ NULL, /*.next =*/ NULL }; - UriQueryListA first = { /*.key =*/ "\x01", /*.value =*/ "\x02", /*.next =*/ &second }; - - const UriBool spaceToPlus = URI_TRUE; - const UriBool normalizeBreaks = URI_FALSE; /* for factor 3 but 6 */ - - const int charsRequired = (3 + 1 + 3) + 1 + (3); - - { - // Minimum space to hold everything fine - const char * const expected = "%01=%02" "&" "%11"; - char dest[charsRequired + 1]; - int charsWritten; - ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), - &charsWritten, spaceToPlus, normalizeBreaks) - == URI_SUCCESS); - ASSERT_TRUE(! strcmp(dest, expected)); - ASSERT_TRUE(charsWritten == strlen(expected) + 1); - } - - { - // Previous math failed to take ampersand into account - char dest[charsRequired + 1 - 1]; - int charsWritten; - ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), - &charsWritten, spaceToPlus, normalizeBreaks) - == URI_ERROR_OUTPUT_TOO_LARGE); - } -} - -TEST(UriSuite, TestFreeCrashBug20080827) { - char const * const sourceUri = "abc"; - char const * const baseUri = "http://www.example.org/"; - - int res; - UriParserStateA state; - UriUriA absoluteDest; - UriUriA relativeSource; - UriUriA absoluteBase; - - state.uri = &relativeSource; - res = uriParseUriA(&state, sourceUri); - ASSERT_TRUE(res == URI_SUCCESS); - - state.uri = &absoluteBase; - res = uriParseUriA(&state, baseUri); - ASSERT_TRUE(res == URI_SUCCESS); - - res = uriRemoveBaseUriA(&absoluteDest, &relativeSource, &absoluteBase, URI_FALSE); - ASSERT_TRUE(res == URI_ERROR_REMOVEBASE_REL_SOURCE); - - uriFreeUriMembersA(&relativeSource); - uriFreeUriMembersA(&absoluteBase); - uriFreeUriMembersA(&absoluteDest); // Crashed here -} - -TEST(UriSuite, TestInvalidInputBug16) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - const char * const input = "A>B"; - - const int res = uriParseUriA(&stateA, input); - - ASSERT_TRUE(res == URI_ERROR_SYNTAX); - ASSERT_TRUE(stateA.errorPos == input + 1); - ASSERT_TRUE(stateA.errorCode == URI_ERROR_SYNTAX); /* failed previously */ - - uriFreeUriMembersA(&uriA); -} - -namespace { - void testEqualsHelper(const char * uri_to_test) { - UriParserStateA state; - UriUriA uriOne; - UriUriA uriTwo; - state.uri = &uriOne; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); - state.uri = &uriTwo; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); - ASSERT_TRUE(URI_TRUE == uriEqualsUriA(&uriOne, &uriTwo)); - uriFreeUriMembersA(&uriOne); - uriFreeUriMembersA(&uriTwo); - } -} // namespace - -TEST(UriSuite, TestEquals) { - testEqualsHelper("http://host"); - testEqualsHelper("http://host:123"); - testEqualsHelper("http://foo:bar@host:123"); - testEqualsHelper("http://foo:bar@host:123/"); - testEqualsHelper("http://foo:bar@host:123/path"); - testEqualsHelper("http://foo:bar@host:123/path?query"); - testEqualsHelper("http://foo:bar@host:123/path?query#fragment"); - - testEqualsHelper("path"); - testEqualsHelper("/path"); - testEqualsHelper("/path/"); - testEqualsHelper("//path/"); - testEqualsHelper("//host"); - testEqualsHelper("//host:123"); -} - -TEST(UriSuite, TestHostTextTerminationIssue15) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - - // Empty host and port - const char * const emptyHostWithPortUri = "//:123"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, emptyHostWithPortUri)); - ASSERT_TRUE(uri.hostText.first == emptyHostWithPortUri + strlen("//")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - ASSERT_TRUE(uri.portText.first == emptyHostWithPortUri - + strlen("//:")); - ASSERT_TRUE(uri.portText.afterLast == uri.portText.first - + strlen("123")); - uriFreeUriMembersA(&uri); - - // Non-empty host and port - const char * const hostWithPortUri = "//h:123"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostWithPortUri)); - ASSERT_TRUE(uri.hostText.first == hostWithPortUri + strlen("//")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first - + strlen("h")); - ASSERT_TRUE(uri.portText.first == hostWithPortUri + strlen("//h:")); - ASSERT_TRUE(uri.portText.afterLast == uri.portText.first - + strlen("123")); - uriFreeUriMembersA(&uri); - - // Empty host, empty user info - const char * const emptyHostEmptyUserInfoUri = "//@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, - emptyHostEmptyUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == emptyHostEmptyUserInfoUri - + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); - ASSERT_TRUE(uri.hostText.first == emptyHostEmptyUserInfoUri - + strlen("//@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); - - // Non-empty host, empty user info - const char * const hostEmptyUserInfoUri = "//@h"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostEmptyUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == hostEmptyUserInfoUri + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); - ASSERT_TRUE(uri.hostText.first == hostEmptyUserInfoUri - + strlen("//@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first - + strlen("h")); - uriFreeUriMembersA(&uri); - - // Empty host, non-empty user info - const char * const emptyHostWithUserInfoUri = "//:@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, - emptyHostWithUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == emptyHostWithUserInfoUri - + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 1); - ASSERT_TRUE(uri.hostText.first == emptyHostWithUserInfoUri - + strlen("//:@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); - - // Exact case from issue #15 - const char * const issue15Uri = "//:%aa@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, issue15Uri)); - ASSERT_TRUE(uri.userInfo.first == issue15Uri + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first - + strlen(":%aa")); - ASSERT_TRUE(uri.hostText.first == issue15Uri + strlen("//:%aa@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); -} - -namespace { - void testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) { - UriTextRangeA ra; - UriTextRangeA rb; - - if (a) { - ra.first = a; - ra.afterLast = a + strlen(a); - } else { - ra.first = NULL; - ra.afterLast = NULL; - } - - if (b) { - rb.first = b; - rb.afterLast = b + strlen(b); - } else { - rb.first = NULL; - rb.afterLast = NULL; - } - - const int received = uriCompareRangeA( - ((a == NULL) && avoidNullRange) ? NULL : &ra, - ((b == NULL) && avoidNullRange) ? NULL : &rb); - if (received != expected) { - printf("Comparing <%s> to <%s> yields %d, expected %d.\n", - a, b, received, expected); - } - ASSERT_TRUE(received == expected); - } -} // namespace - -TEST(UriSuite, TestRangeComparison) { - testCompareRangeHelper("", "", 0); - testCompareRangeHelper("a", "", 1); - testCompareRangeHelper("", "a", -1); - - testCompareRangeHelper("a", "a", 0); - testCompareRangeHelper("a", "b", -1); - testCompareRangeHelper("b", "a", 1); - - testCompareRangeHelper("a", "aa", -1); - testCompareRangeHelper("aa", "a", 1); - - // Fixed with 0.8.1: - testCompareRangeHelper(NULL, "a", -1); - testCompareRangeHelper("a", NULL, 1); - testCompareRangeHelper(NULL, NULL, 0); - - // Fixed with 0.8.3 - const bool KEEP_NULL_RANGE = false; - const bool AVOID_NULL_RANGE = true; - testCompareRangeHelper(NULL, "", -1, AVOID_NULL_RANGE); - testCompareRangeHelper(NULL, "", -1, KEEP_NULL_RANGE); - testCompareRangeHelper("", NULL, 1, AVOID_NULL_RANGE); - testCompareRangeHelper("", NULL, 1, KEEP_NULL_RANGE); -} - -namespace { - void testRemoveBaseUriHelper(const char * expected, - const char * absSourceStr, - const char * absBaseStr) { - UriParserStateA state; - UriUriA absSource; - UriUriA absBase; - UriUriA dest; - - state.uri = &absSource; - ASSERT_TRUE(uriParseUriA(&state, absSourceStr) == URI_SUCCESS); - - state.uri = &absBase; - ASSERT_TRUE(uriParseUriA(&state, absBaseStr) == URI_SUCCESS); - - ASSERT_TRUE(uriRemoveBaseUriA(&dest, &absSource, &absBase, URI_FALSE) - == URI_SUCCESS); - - int size = 0; - ASSERT_TRUE(uriToStringCharsRequiredA(&dest, &size) == URI_SUCCESS); - char * const buffer = (char *)malloc(size + 1); - ASSERT_TRUE(buffer); - ASSERT_TRUE(uriToStringA(buffer, &dest, size + 1, &size) - == URI_SUCCESS); - if (strcmp(buffer, expected)) { - printf("Expected \"%s\" but got \"%s\"\n", expected, buffer); - ASSERT_TRUE(0); - } - free(buffer); - - uriFreeUriMembersA(&absSource); - uriFreeUriMembersA(&absBase); - uriFreeUriMembersA(&dest); - } -} // namespace - -TEST(UriSuite, TestRangeComparisonRemoveBaseUriIssue19) { - // scheme - testRemoveBaseUriHelper("scheme://host/source", - "scheme://host/source", - "schemelonger://host/base"); - testRemoveBaseUriHelper("schemelonger://host/source", - "schemelonger://host/source", - "scheme://host/base"); - - // hostText - testRemoveBaseUriHelper("//host/source", - "http://host/source", - "http://hostlonger/base"); - testRemoveBaseUriHelper("//hostlonger/source", - "http://hostlonger/source", - "http://host/base"); - - // hostData.ipFuture - testRemoveBaseUriHelper("//[v7.host]/source", - "http://[v7.host]/source", - "http://[v7.hostlonger]/base"); - testRemoveBaseUriHelper("//[v7.hostlonger]/source", - "http://[v7.hostlonger]/source", - "http://host/base"); - - // path - testRemoveBaseUriHelper("path1", - "http://host/path1", - "http://host/path111"); - testRemoveBaseUriHelper("../path1/path2", - "http://host/path1/path2", - "http://host/path111/path222"); - testRemoveBaseUriHelper("path111", - "http://host/path111", - "http://host/path1"); - testRemoveBaseUriHelper("../path111/path222", - "http://host/path111/path222", - "http://host/path1/path2"); - - // Exact issue #19 - testRemoveBaseUriHelper("//example/x/abc", - "http://example/x/abc", - "http://example2/x/y/z"); -} - -TEST(ErrorPosSuite, TestErrorPosIPvFuture) { - UriUriA uri; - const char * errorPos; - - const char * const uriText = "http://[vA.123456"; // missing "]" - EXPECT_EQ(uriParseSingleUriA(&uri, uriText, &errorPos), - URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriText + strlen(uriText)); -} - -TEST(UriParseSingleSuite, Success) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), - URI_SUCCESS); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorSyntaxParseErrorSetsErrorPos) { - UriUriA uri; - const char * errorPos; - const char * const uriString = "abc{}def"; - - EXPECT_EQ(uriParseSingleUriA(&uri, uriString, &errorPos), - URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriString + strlen("abc")); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorNullFirstDetected) { - UriUriA uri; - const char * errorPos; - - EXPECT_EQ(uriParseSingleUriExA(&uri, NULL, "notnull", &errorPos), - URI_ERROR_NULL); -} - -TEST(UriParseSingleSuite, ErrorNullAfterLastDetected) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriExA(&uri, "foo", NULL, NULL), URI_SUCCESS); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorNullMemoryManagerDetected) { - UriUriA uri; - const char * errorPos; - const char * const uriString = "somethingwellformed"; - - EXPECT_EQ(uriParseSingleUriExMmA(&uri, - uriString, - uriString + strlen(uriString), - &errorPos, NULL), URI_SUCCESS); - - EXPECT_EQ(uriFreeUriMembersMmA(&uri, NULL), URI_SUCCESS); -} - -TEST(FreeUriMembersSuite, MultiFreeWorksFine) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), - URI_SUCCESS); - - UriUriA uriBackup = uri; - EXPECT_EQ(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); - - uriFreeUriMembersA(&uri); - - // Did some pointers change (to NULL)? - EXPECT_NE(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); - - uriFreeUriMembersA(&uri); // second time -} - -TEST(MakeOwnerSuite, MakeOwner) { - const char * const uriString = "scheme://user:pass@[v7.X]:55555/path/../path/?query#fragment"; - UriUriA uri; - char * uriFirst = strdup(uriString); - const size_t uriLen = strlen(uriFirst); - char * uriAfterLast = uriFirst + uriLen; - - EXPECT_EQ(uriParseSingleUriExA(&uri, uriFirst, uriAfterLast, NULL), URI_SUCCESS); - - // After plain parse, all strings should point inside the original URI string - EXPECT_EQ(uri.owner, URI_FALSE); - URI_EXPECT_RANGE_BETWEEN(uri.scheme, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.userInfo, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.hostText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.hostData.ipFuture, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.portText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); - EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); - URI_EXPECT_RANGE_BETWEEN(uri.query, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.fragment, uriFirst, uriAfterLast); - - EXPECT_EQ(uriMakeOwnerA(&uri), URI_SUCCESS); - - // After making owner, *none* of the strings should point inside the original URI string - EXPECT_EQ(uri.owner, URI_TRUE); - URI_EXPECT_RANGE_OUTSIDE(uri.scheme, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.userInfo, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.hostText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.hostData.ipFuture, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.portText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); - EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); - URI_EXPECT_RANGE_OUTSIDE(uri.query, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.fragment, uriFirst, uriAfterLast); - - // Free originally used memory so we'd get violations on access with ASan - uriAfterLast = NULL; - free(uriFirst); - uriFirst = NULL; - - // Can we recompose the URI without accessing any old freed memory? - int charsRequired; - EXPECT_EQ(uriToStringCharsRequiredA(&uri, &charsRequired), URI_SUCCESS); - EXPECT_TRUE((charsRequired >= 0) && (charsRequired >= static_cast(uriLen))); - char * const uriRemake = new char[charsRequired + 1]; - EXPECT_TRUE(uriRemake != NULL); - EXPECT_EQ(uriToStringA(uriRemake, &uri, charsRequired + 1, NULL), URI_SUCCESS); - EXPECT_TRUE(! strcmp(uriString, uriRemake)); - delete [] uriRemake; - - uriFreeUriMembersA(&uri); -} - -TEST(ParseIpFourAddressSuite, FourSaneOctets) { - unsigned char octetOutput[4]; - const char * const ipAddressText = "111.22.3.40"; - const int res = uriParseIpFourAddressA(octetOutput, ipAddressText, - ipAddressText + strlen(ipAddressText)); - EXPECT_EQ(res, URI_SUCCESS); - EXPECT_EQ(octetOutput[0], 111); - EXPECT_EQ(octetOutput[1], 22); - EXPECT_EQ(octetOutput[2], 3); - EXPECT_EQ(octetOutput[3], 40); -} - - -int main(int argc, char ** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/external/uriparser/tool/uriparse.c b/external/uriparser/tool/uriparse.c deleted file mode 100644 index 421f99a..0000000 --- a/external/uriparser/tool/uriparse.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2013, Radu Hociung - * Copyright (C) 2013, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include - -#ifdef _WIN32 -# include -# include -# ifdef __MINGW32__ -WINSOCK_API_LINKAGE const char WSAAPI inet_ntop( - int af, const void *src, char *dst, socklen_t size); -# endif -#else -# include -# include -# include -#endif - - -#define RANGE(x) (int)((x).afterLast-(x).first), ((x).first) - - -void usage() { - printf("Usage: uriparse URI [..]\n"); -} - - -int main(int argc, char *argv[]) { - int retval = EXIT_SUCCESS; - int i = 1; - - if (argc < 2) { - usage(); - exit(1); - } - - for (; i < argc; i++) { - UriParserStateA state; - UriUriA uri; - char ipstr[INET6_ADDRSTRLEN]; - - state.uri = &uri; - printf("uri: %s\n", argv[i]); - if (uriParseUriA(&state, argv[i]) != URI_SUCCESS) { - /* Failure */ - printf("Failure: %s @ '%.18s' (#%lu)\n", - (state.errorCode == URI_ERROR_SYNTAX) - ? "syntax" - : (state.errorCode == URI_ERROR_MALLOC) - ? "not enough memory" - : "liburiparser bug (please report)", - state.errorPos, - (long unsigned int)(state.errorPos - argv[i])); - retval = EXIT_FAILURE; - } else { - if (uri.scheme.first) { - printf("scheme: %.*s\n", RANGE(uri.scheme)); - } - if (uri.userInfo.first) { - printf("userInfo: %.*s\n", RANGE(uri.userInfo)); - } - if (uri.hostText.first) { - printf("hostText: %.*s\n", RANGE(uri.hostText)); - } - if (uri.hostData.ip4) { - inet_ntop(AF_INET, uri.hostData.ip4->data, ipstr, sizeof ipstr); - printf("hostData.ip4: %s\n", ipstr); - } - if (uri.hostData.ip6) { - inet_ntop(AF_INET6, uri.hostData.ip6->data, ipstr, sizeof ipstr); - printf("hostData.ip6: %s\n", ipstr); - } - if (uri.portText.first) { - printf("portText: %.*s\n", RANGE(uri.portText)); - } - if (uri.pathHead) { - const UriPathSegmentA * p = uri.pathHead; - for (; p; p = p->next) { - printf(" .. pathSeg: %.*s\n", RANGE(p->text)); - } - } - if (uri.query.first) { - printf("query: %.*s\n", RANGE(uri.query)); - } - if (uri.fragment.first) { - printf("fragment: %.*s\n", RANGE(uri.fragment)); - } - { - const char * const absolutePathLabel = "absolutePath: "; - printf("%s%s\n", absolutePathLabel, - (uri.absolutePath == URI_TRUE) ? "true" : "false"); - if (uri.hostText.first != NULL) { - printf("%*s%s\n", (int)strlen(absolutePathLabel), "", - "(always false for URIs with host)"); - } - } - } - printf("\n"); - - uriFreeUriMembersA(&uri); - } - return retval; -} diff --git a/jsonld-cpp/CMakeLists.txt b/jsonld-cpp/CMakeLists.txt index 7c54336..d633c21 100644 --- a/jsonld-cpp/CMakeLists.txt +++ b/jsonld-cpp/CMakeLists.txt @@ -1,184 +1,69 @@ -cmake_minimum_required(VERSION 3.14 FATAL_ERROR) - -## set default install prefix if we are top-level project -#if(NOT WIN32 AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) -# set(CMAKE_INSTALL_PREFIX "/opt/contract.design/jsonld-cpp") -#endif() - -project(jsonld-cpp-library VERSION ${JSONLDCPP_VERSION} - LANGUAGES CXX ) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS_DEBUG_INIT -fno-limit-debug-info) -include(GNUInstallDirs) - -find_package(uriparser 0.9.5 CONFIG REQUIRED char wchar_t) - - -# Define library target - -set(LIB_HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Context.h - ${CMAKE_CURRENT_SOURCE_DIR}/ContextProcessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/DocumentLoader.h - ${CMAKE_CURRENT_SOURCE_DIR}/DoubleFormatter.h - ${CMAKE_CURRENT_SOURCE_DIR}/ExpansionProcessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/FileLoader.h - ${CMAKE_CURRENT_SOURCE_DIR}/JSONDocument.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdConsts.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdError.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdOptions.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdProcessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdUrl.h - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdUtils.h - ${CMAKE_CURRENT_SOURCE_DIR}/MediaType.h - ${CMAKE_CURRENT_SOURCE_DIR}/Permutator.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFCanonicalizationProcessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDataset.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDatasetUtils.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDatasetComparison.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDocument.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFNode.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFSerializationProcessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFTriple.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFRegex.h - ${CMAKE_CURRENT_SOURCE_DIR}/RDFQuad.h - ${CMAKE_CURRENT_SOURCE_DIR}/RemoteDocument.h - ${CMAKE_CURRENT_SOURCE_DIR}/BlankNodeNames.h - ${CMAKE_CURRENT_SOURCE_DIR}/Uri.h - ${CMAKE_CURRENT_SOURCE_DIR}/UriParser.h - ${CMAKE_CURRENT_SOURCE_DIR}/json.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/jsoninc.h - ${CMAKE_CURRENT_SOURCE_DIR}/sha256.h - ) - -set(LIB_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Context.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ContextProcessor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DocumentLoader.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DoubleFormatter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ExpansionProcessor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FileLoader.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JSONDocument.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdError.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdOptions.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdProcessor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdUrl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/JsonLdUtils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MediaType.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Permutator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFCanonicalizationProcessor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDataset.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDatasetUtils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDatasetComparison.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFDocument.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFNode.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFSerializationProcessor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFTriple.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RDFQuad.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RemoteDocument.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BlankNodeNames.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Uri.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/UriParser.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/sha256.cpp) - -add_library(jsonld-cpp STATIC ${LIB_HEADER_FILES} ${LIB_SOURCE_FILES}) -add_library(jsonld-cpp::jsonld-cpp ALIAS jsonld-cpp) - - -set_property( - TARGET jsonld-cpp - PROPERTY PUBLIC_HEADER ${LIB_HEADER_FILES} ${LIB_INT_HEADER_FILES} -) - -# Set include directory - -target_include_directories(jsonld-cpp - PUBLIC - $ - $ - ) - -# Link libraries - -target_link_libraries(jsonld-cpp PUBLIC uriparser::uriparser) - -# Misc properties - -target_compile_features(jsonld-cpp PRIVATE cxx_std_11) -set_target_properties(jsonld-cpp PROPERTIES CXX_EXTENSIONS OFF) - -# Set version - -target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_MAJOR=${JSONLDCPP_VERSION_MAJOR}) -target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_MINOR=${JSONLDCPP_VERSION_MINOR}) -target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_PATCH=${JSONLDCPP_VERSION_PATCH}) - -if(JSONLDCPP_BUILD_TESTS) - enable_testing() - # Set options to build googletest and rapidcheck or not. Other - # projects that embed libjsonld-cpp and already use googletest and/or - # rapidcheck could set these options to OFF - option(JSONLDCPP_BUILD_GOOGLETEST "Build googletest" ${JSONLDCPP_BUILD_GOOGLETEST}) - option(JSONLDCPP_BUILD_RAPIDCHECK "Build rapidcheck" ${JSONLDCPP_BUILD_RAPIDCHECK}) - add_subdirectory(test) -endif() - -if(INSTALL_JSONLDCPP) - - # Configuration - - set(version_config "${CMAKE_CURRENT_BINARY_DIR}/jsonld-cppConfigVersion.cmake") - set(project_config "${CMAKE_CURRENT_BINARY_DIR}/jsonld-cppConfig.cmake") - set(namespace "jsonld-cpp::") - - # Include module with function 'write_basic_package_version_file' and - # 'configure_package_config_file' - include(CMakePackageConfigHelpers) - - # Configure 'ConfigVersion.cmake' - # Note: PROJECT_VERSION is used as a VERSION - write_basic_package_version_file( - "${version_config}" - COMPATIBILITY SameMajorVersion - ) - - # Install 'ConfigVersion.cmake' - install( - FILES ${version_config} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/jsonld-cpp) - - # Configure 'Config.cmake' from .in file - configure_package_config_file( - "${PROJECT_SOURCE_DIR}/cmake/jsonld-cppConfig.cmake.in" - ${project_config} - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/jsonld-cpp - ) - - # Install 'Config.cmake' - install(FILES ${project_config} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/jsonld-cpp - ) - - # Install Targets - - install( - EXPORT jsonld-cpp_Targets - FILE ${PROJECT_NAME}Targets.cmake - NAMESPACE ${namespace} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/jsonld-cpp - ) - - - install( - TARGETS jsonld-cpp - EXPORT jsonld-cpp_Targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jsonld-cpp - ) - - -endif() - +find_package(nlohmann_json REQUIRED) +find_package(uriparser 0.9.7 CONFIG REQUIRED char wchar_t) +#find_package(cpr REQUIRED) +#find_package(http-link-header-cpp REQUIRED) + +set(TARGET_jsonldcpp jsonld-cpp) + +set(Jsonldcpp_sources + src/Context.cpp + src/ContextProcessor.cpp + src/DocumentLoader.cpp + src/DoubleFormatter.cpp + src/ExpansionProcessor.cpp + src/FileLoader.cpp + src/JSONDocument.cpp + src/JsonLdError.cpp + src/JsonLdOptions.cpp + src/JsonLdProcessor.cpp + src/JsonLdUrl.cpp + src/JsonLdUtils.cpp + src/MediaType.cpp + src/Permutator.cpp + src/RDFCanonicalizationProcessor.cpp + src/RDFDataset.cpp + src/RDFDatasetUtils.cpp + src/RDFDatasetComparison.cpp + src/RDFDocument.cpp + src/RDFNode.cpp + src/RDFSerializationProcessor.cpp + src/RDFTriple.cpp + src/RDFQuad.cpp + src/RemoteDocument.cpp + src/BlankNodeNames.cpp + src/Uri.cpp + src/UriParser.cpp + src/sha256.cpp) + +set_source_files_properties(${Jsonldcpp_sources} PROPERTIES LANGUAGE "CXX") + +add_library(${TARGET_jsonldcpp} SHARED ${Jsonldcpp_sources}) + +target_include_directories(${TARGET_jsonldcpp} + INTERFACE + nlohmann_json::nlohmann_json + PUBLIC + $ + $) + +target_link_libraries(${TARGET_jsonldcpp} + PUBLIC + uriparser::uriparser + nlohmann_json::nlohmann_json + #PRIVATE + #cpr::cpr # unused ? + #http-link-header-cpp::http-link-header-cpp # unused ? + ) + +target_compile_definitions(${TARGET_jsonldcpp} + PRIVATE + -DJSONLDCPP_VERSION_MAJOR=${JSONLDCPP_VERSION_MAJOR} + -DJSONLDCPP_VERSION_MINOR=${JSONLDCPP_VERSION_MINOR} + -DJSONLDCPP_VERSION_PATCH=${JSONLDCPP_VERSION_PATCH}) + +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/jsonld-cpp" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +install(TARGETS "${TARGET_jsonldcpp}" + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) \ No newline at end of file diff --git a/jsonld-cpp/cmake/jsonld-cppConfig.cmake.in b/jsonld-cpp/cmake/jsonld-cppConfig.cmake.in deleted file mode 100644 index 9d800f8..0000000 --- a/jsonld-cpp/cmake/jsonld-cppConfig.cmake.in +++ /dev/null @@ -1,7 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -find_dependency(uriparser) - -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") -check_required_components("@PROJECT_NAME@") diff --git a/jsonld-cpp/BlankNodeNames.h b/jsonld-cpp/include/jsonld-cpp/BlankNodeNames.h similarity index 100% rename from jsonld-cpp/BlankNodeNames.h rename to jsonld-cpp/include/jsonld-cpp/BlankNodeNames.h diff --git a/jsonld-cpp/Context.h b/jsonld-cpp/include/jsonld-cpp/Context.h similarity index 94% rename from jsonld-cpp/Context.h rename to jsonld-cpp/include/jsonld-cpp/Context.h index a7f7ae3..77f007d 100644 --- a/jsonld-cpp/Context.h +++ b/jsonld-cpp/include/jsonld-cpp/Context.h @@ -1,9 +1,9 @@ #ifndef LIBJSONLD_CPP_CONTEXT_H #define LIBJSONLD_CPP_CONTEXT_H -#include "jsonld-cpp/jsoninc.h" -#include "jsonld-cpp/JsonLdConsts.h" -#include "jsonld-cpp/JsonLdOptions.h" +#include +#include +#include #include #include diff --git a/jsonld-cpp/ContextProcessor.h b/jsonld-cpp/include/jsonld-cpp/ContextProcessor.h similarity index 94% rename from jsonld-cpp/ContextProcessor.h rename to jsonld-cpp/include/jsonld-cpp/ContextProcessor.h index e3943df..6b14e92 100644 --- a/jsonld-cpp/ContextProcessor.h +++ b/jsonld-cpp/include/jsonld-cpp/ContextProcessor.h @@ -1,8 +1,8 @@ #ifndef JSONLD_CPP_LIBRARY_CONTEXTPROCESSOR_H #define JSONLD_CPP_LIBRARY_CONTEXTPROCESSOR_H -#include "jsonld-cpp/Context.h" -#include "jsonld-cpp/jsoninc.h" +#include +#include #include struct ContextProcessor { diff --git a/jsonld-cpp/DocumentLoader.h b/jsonld-cpp/include/jsonld-cpp/DocumentLoader.h similarity index 100% rename from jsonld-cpp/DocumentLoader.h rename to jsonld-cpp/include/jsonld-cpp/DocumentLoader.h diff --git a/jsonld-cpp/DoubleFormatter.h b/jsonld-cpp/include/jsonld-cpp/DoubleFormatter.h similarity index 100% rename from jsonld-cpp/DoubleFormatter.h rename to jsonld-cpp/include/jsonld-cpp/DoubleFormatter.h diff --git a/jsonld-cpp/ExpansionProcessor.h b/jsonld-cpp/include/jsonld-cpp/ExpansionProcessor.h similarity index 97% rename from jsonld-cpp/ExpansionProcessor.h rename to jsonld-cpp/include/jsonld-cpp/ExpansionProcessor.h index 4ff57de..574ce6b 100644 --- a/jsonld-cpp/ExpansionProcessor.h +++ b/jsonld-cpp/include/jsonld-cpp/ExpansionProcessor.h @@ -1,7 +1,7 @@ #ifndef JSONLD_CPP_LIBRARY_EXPANSIONPROCESSOR_H #define JSONLD_CPP_LIBRARY_EXPANSIONPROCESSOR_H -#include "jsonld-cpp/jsoninc.h" +#include class Context; diff --git a/jsonld-cpp/FileLoader.h b/jsonld-cpp/include/jsonld-cpp/FileLoader.h similarity index 90% rename from jsonld-cpp/FileLoader.h rename to jsonld-cpp/include/jsonld-cpp/FileLoader.h index 22fac60..9825a62 100644 --- a/jsonld-cpp/FileLoader.h +++ b/jsonld-cpp/include/jsonld-cpp/FileLoader.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_FILELOADER_H #define LIBJSONLD_CPP_FILELOADER_H -#include "jsonld-cpp/DocumentLoader.h" +#include class RemoteDocument; diff --git a/jsonld-cpp/JSONDocument.h b/jsonld-cpp/include/jsonld-cpp/JSONDocument.h similarity index 96% rename from jsonld-cpp/JSONDocument.h rename to jsonld-cpp/include/jsonld-cpp/JSONDocument.h index 97f5b8e..bbda36b 100644 --- a/jsonld-cpp/JSONDocument.h +++ b/jsonld-cpp/include/jsonld-cpp/JSONDocument.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_JSONDOCUMENT_H #define LIBJSONLD_CPP_JSONDOCUMENT_H -#include "jsonld-cpp/RemoteDocument.h" +#include namespace RDF { class RDFDataset; diff --git a/jsonld-cpp/JsonLdConsts.h b/jsonld-cpp/include/jsonld-cpp/JsonLdConsts.h similarity index 100% rename from jsonld-cpp/JsonLdConsts.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdConsts.h diff --git a/jsonld-cpp/JsonLdError.h b/jsonld-cpp/include/jsonld-cpp/JsonLdError.h similarity index 98% rename from jsonld-cpp/JsonLdError.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdError.h index e30881f..4ec7068 100644 --- a/jsonld-cpp/JsonLdError.h +++ b/jsonld-cpp/include/jsonld-cpp/JsonLdError.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_JSONLDERROR_H #define LIBJSONLD_CPP_JSONLDERROR_H -#include "jsonld-cpp/jsoninc.h" +#include class JsonLdError : public std::runtime_error { public: diff --git a/jsonld-cpp/JsonLdOptions.h b/jsonld-cpp/include/jsonld-cpp/JsonLdOptions.h similarity index 99% rename from jsonld-cpp/JsonLdOptions.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdOptions.h index 2090f1d..737bcce 100644 --- a/jsonld-cpp/JsonLdOptions.h +++ b/jsonld-cpp/include/jsonld-cpp/JsonLdOptions.h @@ -4,9 +4,9 @@ // The JsonLdOptions type as specified in "JSON-LD-API specification": // https://www.w3.org/TR/json-ld-api/#the-jsonldoptions-type -#include "jsonld-cpp/jsoninc.h" -#include "jsonld-cpp/DocumentLoader.h" -#include "jsonld-cpp/JsonLdConsts.h" +#include +#include +#include #include #include diff --git a/jsonld-cpp/JsonLdProcessor.h b/jsonld-cpp/include/jsonld-cpp/JsonLdProcessor.h similarity index 96% rename from jsonld-cpp/JsonLdProcessor.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdProcessor.h index b5642f0..e92ffbc 100644 --- a/jsonld-cpp/JsonLdProcessor.h +++ b/jsonld-cpp/include/jsonld-cpp/JsonLdProcessor.h @@ -1,8 +1,8 @@ #ifndef LIBJSONLD_CPP_JSONLDPROCESSOR_H #define LIBJSONLD_CPP_JSONLDPROCESSOR_H -#include "jsonld-cpp/jsoninc.h" -#include "jsonld-cpp/JsonLdOptions.h" +#include +#include namespace RDF { class RDFDataset; diff --git a/jsonld-cpp/JsonLdUrl.h b/jsonld-cpp/include/jsonld-cpp/JsonLdUrl.h similarity index 100% rename from jsonld-cpp/JsonLdUrl.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdUrl.h diff --git a/jsonld-cpp/JsonLdUtils.h b/jsonld-cpp/include/jsonld-cpp/JsonLdUtils.h similarity index 97% rename from jsonld-cpp/JsonLdUtils.h rename to jsonld-cpp/include/jsonld-cpp/JsonLdUtils.h index 7a1902a..f5dbf9c 100644 --- a/jsonld-cpp/JsonLdUtils.h +++ b/jsonld-cpp/include/jsonld-cpp/JsonLdUtils.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_JSONLDUTILS_H #define LIBJSONLD_CPP_JSONLDUTILS_H -#include "jsonld-cpp/jsoninc.h" +#include namespace JsonLdUtils { diff --git a/jsonld-cpp/MediaType.h b/jsonld-cpp/include/jsonld-cpp/MediaType.h similarity index 100% rename from jsonld-cpp/MediaType.h rename to jsonld-cpp/include/jsonld-cpp/MediaType.h diff --git a/jsonld-cpp/Permutator.h b/jsonld-cpp/include/jsonld-cpp/Permutator.h similarity index 100% rename from jsonld-cpp/Permutator.h rename to jsonld-cpp/include/jsonld-cpp/Permutator.h diff --git a/jsonld-cpp/RDFCanonicalizationProcessor.h b/jsonld-cpp/include/jsonld-cpp/RDFCanonicalizationProcessor.h similarity index 100% rename from jsonld-cpp/RDFCanonicalizationProcessor.h rename to jsonld-cpp/include/jsonld-cpp/RDFCanonicalizationProcessor.h diff --git a/jsonld-cpp/RDFDataset.h b/jsonld-cpp/include/jsonld-cpp/RDFDataset.h similarity index 95% rename from jsonld-cpp/RDFDataset.h rename to jsonld-cpp/include/jsonld-cpp/RDFDataset.h index 8f86580..a5dffad 100644 --- a/jsonld-cpp/RDFDataset.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFDataset.h @@ -1,9 +1,9 @@ #ifndef LIBJSONLD_CPP_RDFDATASET_H #define LIBJSONLD_CPP_RDFDATASET_H -#include "jsonld-cpp/RDFTriple.h" -#include "jsonld-cpp/RDFQuad.h" -#include "jsonld-cpp/JsonLdOptions.h" +#include +#include +#include #include #include #include diff --git a/jsonld-cpp/RDFDatasetComparison.h b/jsonld-cpp/include/jsonld-cpp/RDFDatasetComparison.h similarity index 89% rename from jsonld-cpp/RDFDatasetComparison.h rename to jsonld-cpp/include/jsonld-cpp/RDFDatasetComparison.h index 2c3e679..c80fd8f 100644 --- a/jsonld-cpp/RDFDatasetComparison.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFDatasetComparison.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_RDFDATASETCOMPARISON_H #define LIBJSONLD_CPP_RDFDATASETCOMPARISON_H -#include "jsonld-cpp/RDFDataset.h" +#include // Thanks to titanium-json-ld for this class diff --git a/jsonld-cpp/RDFDatasetUtils.h b/jsonld-cpp/include/jsonld-cpp/RDFDatasetUtils.h similarity index 100% rename from jsonld-cpp/RDFDatasetUtils.h rename to jsonld-cpp/include/jsonld-cpp/RDFDatasetUtils.h diff --git a/jsonld-cpp/RDFDocument.h b/jsonld-cpp/include/jsonld-cpp/RDFDocument.h similarity index 89% rename from jsonld-cpp/RDFDocument.h rename to jsonld-cpp/include/jsonld-cpp/RDFDocument.h index 282165a..4c5a38d 100644 --- a/jsonld-cpp/RDFDocument.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFDocument.h @@ -1,9 +1,9 @@ #ifndef LIBJSONLD_CPP_RDFDOCUMENT_H #define LIBJSONLD_CPP_RDFDOCUMENT_H -#include "jsonld-cpp/RemoteDocument.h" -#include "jsonld-cpp/RDFDataset.h" -#include "jsonld-cpp/MediaType.h" +#include +#include +#include class RDFDocument : public RemoteDocument { diff --git a/jsonld-cpp/RDFNode.h b/jsonld-cpp/include/jsonld-cpp/RDFNode.h similarity index 98% rename from jsonld-cpp/RDFNode.h rename to jsonld-cpp/include/jsonld-cpp/RDFNode.h index 23ad663..c2011a6 100644 --- a/jsonld-cpp/RDFNode.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFNode.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_RDFNODE_H #define LIBJSONLD_CPP_RDFNODE_H -#include "jsonld-cpp/jsoninc.h" +#include #include #include diff --git a/jsonld-cpp/RDFQuad.h b/jsonld-cpp/include/jsonld-cpp/RDFQuad.h similarity index 98% rename from jsonld-cpp/RDFQuad.h rename to jsonld-cpp/include/jsonld-cpp/RDFQuad.h index 371e65a..3ae6277 100644 --- a/jsonld-cpp/RDFQuad.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFQuad.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_RDFQUAD_H #define LIBJSONLD_CPP_RDFQUAD_H -#include "jsonld-cpp/RDFNode.h" +#include #include #include diff --git a/jsonld-cpp/RDFRegex.h b/jsonld-cpp/include/jsonld-cpp/RDFRegex.h similarity index 100% rename from jsonld-cpp/RDFRegex.h rename to jsonld-cpp/include/jsonld-cpp/RDFRegex.h diff --git a/jsonld-cpp/RDFSerializationProcessor.h b/jsonld-cpp/include/jsonld-cpp/RDFSerializationProcessor.h similarity index 96% rename from jsonld-cpp/RDFSerializationProcessor.h rename to jsonld-cpp/include/jsonld-cpp/RDFSerializationProcessor.h index 82c284a..f5ffc55 100644 --- a/jsonld-cpp/RDFSerializationProcessor.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFSerializationProcessor.h @@ -1,7 +1,7 @@ #ifndef JSONLD_CPP_LIBRARY_RDFSERIALIZATIONPROCESSOR_H #define JSONLD_CPP_LIBRARY_RDFSERIALIZATIONPROCESSOR_H -#include "jsonld-cpp/jsoninc.h" +#include class JsonLdOptions; diff --git a/jsonld-cpp/RDFTriple.h b/jsonld-cpp/include/jsonld-cpp/RDFTriple.h similarity index 98% rename from jsonld-cpp/RDFTriple.h rename to jsonld-cpp/include/jsonld-cpp/RDFTriple.h index 976f4e4..c08f293 100644 --- a/jsonld-cpp/RDFTriple.h +++ b/jsonld-cpp/include/jsonld-cpp/RDFTriple.h @@ -1,7 +1,7 @@ #ifndef LIBJSONLD_CPP_RDFTRIPLE_H #define LIBJSONLD_CPP_RDFTRIPLE_H -#include "jsonld-cpp/RDFNode.h" +#include #include #include diff --git a/jsonld-cpp/RemoteDocument.h b/jsonld-cpp/include/jsonld-cpp/RemoteDocument.h similarity index 92% rename from jsonld-cpp/RemoteDocument.h rename to jsonld-cpp/include/jsonld-cpp/RemoteDocument.h index 862b961..c86e75b 100644 --- a/jsonld-cpp/RemoteDocument.h +++ b/jsonld-cpp/include/jsonld-cpp/RemoteDocument.h @@ -1,8 +1,8 @@ #ifndef LIBJSONLD_CPP_REMOTEDOCUMENT_H #define LIBJSONLD_CPP_REMOTEDOCUMENT_H -#include "jsonld-cpp/jsoninc.h" -#include "jsonld-cpp/MediaType.h" +#include +#include #include namespace RDF { diff --git a/jsonld-cpp/Uri.h b/jsonld-cpp/include/jsonld-cpp/Uri.h similarity index 100% rename from jsonld-cpp/Uri.h rename to jsonld-cpp/include/jsonld-cpp/Uri.h diff --git a/jsonld-cpp/UriParser.h b/jsonld-cpp/include/jsonld-cpp/UriParser.h similarity index 100% rename from jsonld-cpp/UriParser.h rename to jsonld-cpp/include/jsonld-cpp/UriParser.h diff --git a/jsonld-cpp/sha256.h b/jsonld-cpp/include/jsonld-cpp/sha256.h similarity index 100% rename from jsonld-cpp/sha256.h rename to jsonld-cpp/include/jsonld-cpp/sha256.h diff --git a/jsonld-cpp/json.hpp b/jsonld-cpp/json.hpp deleted file mode 100644 index 4d1a37a..0000000 --- a/jsonld-cpp/json.hpp +++ /dev/null @@ -1,24596 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -/****************************************************************************\ - * Note on documentation: The source files contain links to the online * - * documentation of the public API at https://json.nlohmann.me. This URL * - * contains the most recent documentation and should also be applicable to * - * previous versions; documentation for deprecated functions is not * - * removed, but marked deprecated. See "Generate documentation" section in * - * file docs/README.md. * -\****************************************************************************/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#include // all_of, find, for_each -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#ifndef JSON_NO_IO - #include // istream, ostream -#endif // JSON_NO_IO -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// This file contains all macro definitions affecting or depending on the ABI - -#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK - #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) - #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 - #warning "Already included a different version of the library!" - #endif - #endif -#endif - -#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - -#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -#endif - -#if JSON_DIAGNOSTICS - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag -#else - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS -#endif - -#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp -#else - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION - #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 -#endif - -// Construct the namespace ABI tags component -#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) - -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) - -// Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v ## major ## _ ## minor ## _ ## patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) - -#if NLOHMANN_JSON_NAMESPACE_NO_VERSION -#define NLOHMANN_JSON_NAMESPACE_VERSION -#else -#define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) -#endif - -// Combine namespace components -#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) - -#ifndef NLOHMANN_JSON_NAMESPACE -#define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN -#define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann \ - { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) \ - { -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_END -#define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ - } // namespace nlohmann -#endif - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // nullptr_t -#include // exception -#include // runtime_error -#include // to_string -#include // vector - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // array -#include // size_t -#include // uint8_t -#include // string - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // declval, pair -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// https://en.cppreference.com/w/cpp/experimental/is_detected -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - - -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson -// SPDX-License-Identifier: MIT - -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 15 - -#if defined(JSON_HEDLEY_STRINGIFY_EX) - #undef JSON_HEDLEY_STRINGIFY_EX -#endif -#define JSON_HEDLEY_STRINGIFY_EX(x) #x - -#if defined(JSON_HEDLEY_STRINGIFY) - #undef JSON_HEDLEY_STRINGIFY -#endif -#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) - -#if defined(JSON_HEDLEY_CONCAT_EX) - #undef JSON_HEDLEY_CONCAT_EX -#endif -#define JSON_HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(JSON_HEDLEY_CONCAT) - #undef JSON_HEDLEY_CONCAT -#endif -#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) - -#if defined(JSON_HEDLEY_CONCAT3_EX) - #undef JSON_HEDLEY_CONCAT3_EX -#endif -#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c - -#if defined(JSON_HEDLEY_CONCAT3) - #undef JSON_HEDLEY_CONCAT3 -#endif -#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) - -#if defined(JSON_HEDLEY_VERSION_ENCODE) - #undef JSON_HEDLEY_VERSION_ENCODE -#endif -#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef JSON_HEDLEY_VERSION_DECODE_MINOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef JSON_HEDLEY_VERSION_DECODE_REVISION -#endif -#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(JSON_HEDLEY_GNUC_VERSION) - #undef JSON_HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef JSON_HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GNUC_VERSION) - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION) - #undef JSON_HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef JSON_HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(JSON_HEDLEY_MSVC_VERSION) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION) - #undef JSON_HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_VERSION) - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #undef JSON_HEDLEY_INTEL_CL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) - #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION) - #undef JSON_HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) - #undef JSON_HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PGI_VERSION) - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #undef JSON_HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION) - #undef JSON_HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) - #undef JSON_HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_ARM_VERSION) - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION) - #undef JSON_HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) - #undef JSON_HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IBM_VERSION) - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_VERSION) - #undef JSON_HEDLEY_TI_VERSION -#endif -#if \ - defined(__TI_COMPILER_VERSION__) && \ - ( \ - defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__) \ - ) -#if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif -#endif - -#if defined(JSON_HEDLEY_TI_VERSION_CHECK) - #undef JSON_HEDLEY_TI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_VERSION) - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #undef JSON_HEDLEY_TI_CL2000_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #undef JSON_HEDLEY_TI_CL430_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #undef JSON_HEDLEY_TI_ARMCL_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) - #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #undef JSON_HEDLEY_TI_CL6X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #undef JSON_HEDLEY_TI_CL7X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #undef JSON_HEDLEY_TI_CLPRU_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION) - #undef JSON_HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) - #if defined(_RELEASE_PATCHLEVEL) - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) - #else - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef JSON_HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_CRAY_VERSION) - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION) - #undef JSON_HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) - #if __VER__ > 1000 - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) - #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) - #undef JSON_HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IAR_VERSION) - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION) - #undef JSON_HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) - #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef JSON_HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION) - #undef JSON_HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) - #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) - #undef JSON_HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_DMC_VERSION) - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #undef JSON_HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION) - #undef JSON_HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) - #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef JSON_HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PELLES_VERSION) - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #undef JSON_HEDLEY_MCST_LCC_VERSION -#endif -#if defined(__LCC__) && defined(__LCC_MINOR__) - #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) - #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION) - #undef JSON_HEDLEY_GCC_VERSION -#endif -#if \ - defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ - !defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_ATTRIBUTE -#endif -#if \ - defined(__has_attribute) && \ - ( \ - (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ - ) -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if \ - defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#endif -#if !defined(__cplusplus) || !defined(__has_cpp_attribute) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#elif \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_BUILTIN) - #undef JSON_HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else - #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef JSON_HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_FEATURE) - #undef JSON_HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else - #define JSON_HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef JSON_HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) - #undef JSON_HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_EXTENSION) - #undef JSON_HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else - #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef JSON_HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_WARNING) - #undef JSON_HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else - #define JSON_HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) - #undef JSON_HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_WARNING) - #undef JSON_HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - -/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# endif -#endif -#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#endif - -#if defined(JSON_HEDLEY_CONST_CAST) - #undef JSON_HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_REINTERPRET_CAST) - #undef JSON_HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_STATIC_CAST) - #undef JSON_HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else - #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_CPP_CAST) - #undef JSON_HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - ((T) (expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) -# endif -#else -# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif - -#if defined(JSON_HEDLEY_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else - #define JSON_HEDLEY_DEPRECATED(since) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(JSON_HEDLEY_UNAVAILABLE) - #undef JSON_HEDLEY_UNAVAILABLE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else - #define JSON_HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) -#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) -#endif - -#if defined(JSON_HEDLEY_SENTINEL) - #undef JSON_HEDLEY_SENTINEL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else - #define JSON_HEDLEY_SENTINEL(position) -#endif - -#if defined(JSON_HEDLEY_NO_RETURN) - #undef JSON_HEDLEY_NO_RETURN -#endif -#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NO_RETURN __noreturn -#elif \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define JSON_HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#else - #define JSON_HEDLEY_NO_RETURN -#endif - -#if defined(JSON_HEDLEY_NO_ESCAPE) - #undef JSON_HEDLEY_NO_ESCAPE -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) - #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) -#else - #define JSON_HEDLEY_NO_ESCAPE -#endif - -#if defined(JSON_HEDLEY_UNREACHABLE) - #undef JSON_HEDLEY_UNREACHABLE -#endif -#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #undef JSON_HEDLEY_UNREACHABLE_RETURN -#endif -#if defined(JSON_HEDLEY_ASSUME) - #undef JSON_HEDLEY_ASSUME -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif defined(JSON_HEDLEY_ASSUME) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif -#if !defined(JSON_HEDLEY_ASSUME) - #if defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) - #else - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) - #endif -#endif -#if defined(JSON_HEDLEY_UNREACHABLE) - #if \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) - #else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() - #endif -#else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif - -JSON_HEDLEY_DIAGNOSTIC_PUSH -#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") - #pragma clang diagnostic ignored "-Wpedantic" -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) - #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(JSON_HEDLEY_GCC_VERSION) - #pragma GCC diagnostic ignored "-Wvariadic-macros" - #endif -#endif -#if defined(JSON_HEDLEY_NON_NULL) - #undef JSON_HEDLEY_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else - #define JSON_HEDLEY_NON_NULL(...) -#endif -JSON_HEDLEY_DIAGNOSTIC_POP - -#if defined(JSON_HEDLEY_PRINTF_FORMAT) - #undef JSON_HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(JSON_HEDLEY_CONSTEXPR) - #undef JSON_HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) - #endif -#endif -#if !defined(JSON_HEDLEY_CONSTEXPR) - #define JSON_HEDLEY_CONSTEXPR -#endif - -#if defined(JSON_HEDLEY_PREDICT) - #undef JSON_HEDLEY_PREDICT -#endif -#if defined(JSON_HEDLEY_LIKELY) - #undef JSON_HEDLEY_LIKELY -#endif -#if defined(JSON_HEDLEY_UNLIKELY) - #undef JSON_HEDLEY_UNLIKELY -#endif -#if defined(JSON_HEDLEY_UNPREDICTABLE) - #undef JSON_HEDLEY_UNPREDICTABLE -#endif -#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(JSON_HEDLEY_UNPREDICTABLE) - #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(JSON_HEDLEY_MALLOC) - #undef JSON_HEDLEY_MALLOC -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_MALLOC __declspec(restrict) -#else - #define JSON_HEDLEY_MALLOC -#endif - -#if defined(JSON_HEDLEY_PURE) - #undef JSON_HEDLEY_PURE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) -# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ - ) -# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_CONST) - #undef JSON_HEDLEY_CONST -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_CONST __attribute__((__const__)) -#elif \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_CONST _Pragma("no_side_effect") -#else - #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_RESTRICT) - #undef JSON_HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT restrict -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RESTRICT __restrict -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT _Restrict -#else - #define JSON_HEDLEY_RESTRICT -#endif - -#if defined(JSON_HEDLEY_INLINE) - #undef JSON_HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define JSON_HEDLEY_INLINE inline -#elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define JSON_HEDLEY_INLINE __inline__ -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_INLINE __inline -#else - #define JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_ALWAYS_INLINE) - #undef JSON_HEDLEY_ALWAYS_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) -# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ - ) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_NEVER_INLINE) - #undef JSON_HEDLEY_NEVER_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#else - #define JSON_HEDLEY_NEVER_INLINE -#endif - -#if defined(JSON_HEDLEY_PRIVATE) - #undef JSON_HEDLEY_PRIVATE -#endif -#if defined(JSON_HEDLEY_PUBLIC) - #undef JSON_HEDLEY_PUBLIC -#endif -#if defined(JSON_HEDLEY_IMPORT) - #undef JSON_HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC __declspec(dllexport) -# define JSON_HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - ( \ - defined(__TI_EABI__) && \ - ( \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ - ) \ - ) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC -# endif -# define JSON_HEDLEY_IMPORT extern -#endif - -#if defined(JSON_HEDLEY_NO_THROW) - #undef JSON_HEDLEY_NO_THROW -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NO_THROW __declspec(nothrow) -#else - #define JSON_HEDLEY_NO_THROW -#endif - -#if defined(JSON_HEDLEY_FALL_THROUGH) - #undef JSON_HEDLEY_FALL_THROUGH -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) -#elif defined(__fallthrough) /* SAL */ - #define JSON_HEDLEY_FALL_THROUGH __fallthrough -#else - #define JSON_HEDLEY_FALL_THROUGH -#endif - -#if defined(JSON_HEDLEY_RETURNS_NON_NULL) - #undef JSON_HEDLEY_RETURNS_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ - #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else - #define JSON_HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(JSON_HEDLEY_ARRAY_PARAM) - #undef JSON_HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_ARRAY_PARAM(name) (name) -#else - #define JSON_HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(JSON_HEDLEY_IS_CONSTANT) - #undef JSON_HEDLEY_IS_CONSTANT -#endif -#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#endif -/* JSON_HEDLEY_IS_CONSTEXPR_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #undef JSON_HEDLEY_IS_CONSTEXPR_ -#endif -#if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -#endif -# elif \ - ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -#endif -# elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) -# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ -((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) -#else - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) (0) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(JSON_HEDLEY_BEGIN_C_DECLS) - #undef JSON_HEDLEY_BEGIN_C_DECLS -#endif -#if defined(JSON_HEDLEY_END_C_DECLS) - #undef JSON_HEDLEY_END_C_DECLS -#endif -#if defined(JSON_HEDLEY_C_DECL) - #undef JSON_HEDLEY_C_DECL -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define JSON_HEDLEY_END_C_DECLS } - #define JSON_HEDLEY_C_DECL extern "C" -#else - #define JSON_HEDLEY_BEGIN_C_DECLS - #define JSON_HEDLEY_END_C_DECLS - #define JSON_HEDLEY_C_DECL -#endif - -#if defined(JSON_HEDLEY_STATIC_ASSERT) - #undef JSON_HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) -#else -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(JSON_HEDLEY_NULL) - #undef JSON_HEDLEY_NULL -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) - #elif defined(NULL) - #define JSON_HEDLEY_NULL NULL - #else - #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) - #endif -#elif defined(NULL) - #define JSON_HEDLEY_NULL NULL -#else - #define JSON_HEDLEY_NULL ((void*) 0) -#endif - -#if defined(JSON_HEDLEY_MESSAGE) - #undef JSON_HEDLEY_MESSAGE -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) -#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_WARNING) - #undef JSON_HEDLEY_WARNING -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_REQUIRE) - #undef JSON_HEDLEY_REQUIRE -#endif -#if defined(JSON_HEDLEY_REQUIRE_MSG) - #undef JSON_HEDLEY_REQUIRE_MSG -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) -# endif -#else -# define JSON_HEDLEY_REQUIRE(expr) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) -#endif - -#if defined(JSON_HEDLEY_FLAGS) - #undef JSON_HEDLEY_FLAGS -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#else - #define JSON_HEDLEY_FLAGS -#endif - -#if defined(JSON_HEDLEY_FLAGS_CAST) - #undef JSON_HEDLEY_FLAGS_CAST -#endif -#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(JSON_HEDLEY_EMPTY_BASES) - #undef JSON_HEDLEY_EMPTY_BASES -#endif -#if \ - (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else - #define JSON_HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#endif -#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) - -#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef JSON_HEDLEY_CLANG_HAS_FEATURE -#endif -#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) - -#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#endif -#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) - -#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) - #undef JSON_HEDLEY_CLANG_HAS_WARNING -#endif -#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ - - -// This file contains all internal macro definitions (except those affecting ABI) -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// #include - - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -// if the user manually specified the used c++ version this is skipped -#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) - #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 - #endif - // the cpp 11 flag is always specified because it is the minimal required version - #define JSON_HAS_CPP_11 -#endif - -#ifdef __has_include - #if __has_include() - #include - #endif -#endif - -#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) - #ifdef JSON_HAS_CPP_17 - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #endif - - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__clang_major__) && __clang_major__ < 7 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support - #if defined(_MSC_VER) && _MSC_VER < 1914 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - #endif -#endif - -#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_FILESYSTEM - #define JSON_HAS_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ - && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L - #define JSON_HAS_THREE_WAY_COMPARISON 1 - #else - #define JSON_HAS_THREE_WAY_COMPARISON 0 - #endif -#endif - -#ifndef JSON_HAS_RANGES - // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error - #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 - #define JSON_HAS_RANGES 0 - #elif defined(__cpp_lib_ranges) - #define JSON_HAS_RANGES 1 - #else - #define JSON_HAS_RANGES 0 - #endif -#endif - -#ifdef JSON_HAS_CPP_17 - #define JSON_INLINE_VARIABLE inline -#else - #define JSON_INLINE_VARIABLE -#endif - -#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) - #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] -#else - #define JSON_NO_UNIQUE_ADDRESS -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdocumentation" - #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" -#endif - -// allow disabling exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow overriding assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); -#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - - -// inspired from https://stackoverflow.com/a/26745591 -// allows to call any std function as if (e.g. with begin): -// using std::begin; begin(x); -// -// it allows using the detected idiom to retrieve the return type -// of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DISABLE_ENUM_SERIALIZATION - #define JSON_DISABLE_ENUM_SERIALIZATION 0 -#endif - -#ifndef JSON_USE_GLOBAL_UDLS - #define JSON_USE_GLOBAL_UDLS 1 -#endif - -#if JSON_HAS_THREE_WAY_COMPARISON - #include // partial_ordering -#endif - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/////////////////////////// -// JSON type enumeration // -/////////////////////////// - -/*! -@brief the JSON type enumeration - -This enumeration collects the different JSON types. It is internally used to -distinguish the stored values, and the functions @ref basic_json::is_null(), -@ref basic_json::is_object(), @ref basic_json::is_array(), -@ref basic_json::is_string(), @ref basic_json::is_boolean(), -@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), -@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), -@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and -@ref basic_json::is_structured() rely on it. - -@note There are three enumeration entries (number_integer, number_unsigned, and -number_float), because the library distinguishes these three types for numbers: -@ref basic_json::number_unsigned_t is used for unsigned integers, -@ref basic_json::number_integer_t is used for signed integers, and -@ref basic_json::number_float_t is used for floating-point numbers or to -approximate integers which do not fit in the limits of their respective type. - -@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON -value with the default value for a given type - -@since version 1.0.0 -*/ -enum class value_t : std::uint8_t -{ - null, ///< null value - object, ///< object (unordered set of name/value pairs) - array, ///< array (ordered collection of values) - string, ///< string value - boolean, ///< boolean value - number_integer, ///< number value (signed integer) - number_unsigned, ///< number value (unsigned integer) - number_float, ///< number value (floating-point) - binary, ///< binary array (ordered collection of bytes) - discarded ///< discarded by the parser callback function -}; - -/*! -@brief comparison operator for JSON types - -Returns an ordering that is similar to Python: -- order: null < boolean < number < object < array < string < binary -- furthermore, each type is not smaller than itself -- discarded values are not comparable -- binary is represented as a b"" string in python and directly comparable to a - string; however, making a binary array directly comparable with a string would - be surprising behavior in a JSON file. - -@since version 1.0.0 -*/ -#if JSON_HAS_THREE_WAY_COMPARISON - inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* -#else - inline bool operator<(const value_t lhs, const value_t rhs) noexcept -#endif -{ - static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, - 6 /* binary */ - } - }; - - const auto l_index = static_cast(lhs); - const auto r_index = static_cast(rhs); -#if JSON_HAS_THREE_WAY_COMPARISON - if (l_index < order.size() && r_index < order.size()) - { - return order[l_index] <=> order[r_index]; // *NOPAD* - } - return std::partial_ordering::unordered; -#else - return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; -#endif -} - -// GCC selects the built-in operator< over an operator rewritten from -// a user-defined spaceship operator -// Clang, MSVC, and ICC select the rewritten candidate -// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) -#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) -inline bool operator<(const value_t lhs, const value_t rhs) noexcept -{ - return std::is_lt(lhs <=> rhs); // *NOPAD* -} -#endif - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/*! -@brief replace all occurrences of a substring by another string - -@param[in,out] s the string to manipulate; changed so that all - occurrences of @a f are replaced with @a t -@param[in] f the substring to replace with @a t -@param[in] t the string to replace @a f - -@pre The search string @a f must not be empty. **This precondition is -enforced with an assertion.** - -@since version 2.0.0 -*/ -template -inline void replace_substring(StringType& s, const StringType& f, - const StringType& t) -{ - JSON_ASSERT(!f.empty()); - for (auto pos = s.find(f); // find first occurrence of f - pos != StringType::npos; // make sure f was found - s.replace(pos, f.size(), t), // replace with t, and - pos = s.find(f, pos + t.size())) // find next occurrence of f - {} -} - -/*! - * @brief string escaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to escape - * @return escaped string - * - * Note the order of escaping "~" to "~0" and "/" to "~1" is important. - */ -template -inline StringType escape(StringType s) -{ - replace_substring(s, StringType{"~"}, StringType{"~0"}); - replace_substring(s, StringType{"/"}, StringType{"~1"}); - return s; -} - -/*! - * @brief string unescaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to unescape - * @return unescaped string - * - * Note the order of escaping "~1" to "/" and "~0" to "~" is important. - */ -template -static void unescape(StringType& s) -{ - replace_substring(s, StringType{"~1"}, StringType{"/"}); - replace_substring(s, StringType{"~0"}, StringType{"~"}); -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // size_t - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-FileCopyrightText: 2018 The Abseil Authors -// SPDX-License-Identifier: MIT - - - -#include // array -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h -// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. - -//// START OF CODE FROM GOOGLE ABSEIL - -// integer_sequence -// -// Class template representing a compile-time integer sequence. An instantiation -// of `integer_sequence` has a sequence of integers encoded in its -// type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed -// to be a drop-in replacement for C++14's `std::integer_sequence`. -// -// Example: -// -// template< class T, T... Ints > -// void user_function(integer_sequence); -// -// int main() -// { -// // user_function's `T` will be deduced to `int` and `Ints...` -// // will be deduced to `0, 1, 2, 3, 4`. -// user_function(make_integer_sequence()); -// } -template -struct integer_sequence -{ - using value_type = T; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -// index_sequence -// -// A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's -// `std::index_sequence`. -template -using index_sequence = integer_sequence; - -namespace utility_internal -{ - -template -struct Extend; - -// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template -struct Extend, SeqSize, 0> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; -}; - -template -struct Extend, SeqSize, 1> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; -}; - -// Recursion helper for 'make_integer_sequence'. -// 'Gen::type' is an alias for 'integer_sequence'. -template -struct Gen -{ - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; -}; - -template -struct Gen -{ - using type = integer_sequence; -}; - -} // namespace utility_internal - -// Compile-time sequences of integers - -// make_integer_sequence -// -// This template alias is equivalent to -// `integer_sequence`, and is designed to be a drop-in -// replacement for C++14's `std::make_integer_sequence`. -template -using make_integer_sequence = typename utility_internal::Gen::type; - -// make_index_sequence -// -// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, -// and is designed to be a drop-in replacement for C++14's -// `std::make_index_sequence`. -template -using make_index_sequence = make_integer_sequence; - -// index_sequence_for -// -// Converts a typename pack into an index sequence of the same length, and -// is designed to be a drop-in replacement for C++14's -// `std::index_sequence_for()` -template -using index_sequence_for = make_index_sequence; - -//// END OF CODE FROM GOOGLE ABSEIL - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static JSON_INLINE_VARIABLE constexpr T value{}; -}; - -#ifndef JSON_HAS_CPP_17 - template - constexpr T static_const::value; -#endif - -template -inline constexpr std::array make_array(Args&& ... args) -{ - return std::array {{static_cast(std::forward(args))...}}; -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include // random_access_iterator_tag - -// #include - -// #include - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); - -NLOHMANN_JSON_NAMESPACE_END - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -// #include - - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); - -NLOHMANN_JSON_NAMESPACE_END - -// #include - -// #include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ - #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - #include // int64_t, uint64_t - #include // map - #include // allocator - #include // string - #include // vector - - // #include - - - /*! - @brief namespace for Niels Lohmann - @see https://github.com/nlohmann - @since version 1.0.0 - */ - NLOHMANN_JSON_NAMESPACE_BEGIN - - /*! - @brief default JSONSerializer template argument - - This serializer ignores the template arguments and uses ADL - ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) - for serialization. - */ - template - struct adl_serializer; - - /// a class to store JSON values - /// @sa https://json.nlohmann.me/api/basic_json/ - template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> - class basic_json; - - /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document - /// @sa https://json.nlohmann.me/api/json_pointer/ - template - class json_pointer; - - /*! - @brief default specialization - @sa https://json.nlohmann.me/api/json/ - */ - using json = basic_json<>; - - /// @brief a minimal map-like container that preserves insertion order - /// @sa https://json.nlohmann.me/api/ordered_map/ - template - struct ordered_map; - - /// @brief specialization that maintains the insertion order of object keys - /// @sa https://json.nlohmann.me/api/ordered_json/ - using ordered_json = basic_json; - - NLOHMANN_JSON_NAMESPACE_END - -#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - -NLOHMANN_JSON_NAMESPACE_BEGIN -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ - -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -// used by exceptions create() member functions -// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t -// false_type otherwise -template -struct is_basic_json_context : - std::integral_constant < bool, - is_basic_json::type>::type>::value - || std::is_same::value > -{}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -template -using detect_key_compare = typename T::key_compare; - -template -struct has_key_compare : std::integral_constant::value> {}; - -// obtains the actual object key comparator -template -struct actual_object_comparator -{ - using object_t = typename BasicJsonType::object_t; - using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional < has_key_compare::value, - typename object_t::key_compare, object_comparator_t>::type; -}; - -template -using actual_object_comparator_t = typename actual_object_comparator::type; - -/////////////////// -// is_ functions // -/////////////////// - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B { }; -template -struct conjunction -: std::conditional(B::value), conjunction, B>::type {}; - -// https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; - -// Reimplementation of is_constructible and is_default_constructible, due to them being broken for -// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). -// This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - - -template -struct is_constructible : std::is_constructible {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -template -struct is_range -{ - private: - using t_ref = typename std::add_lvalue_reference::type; - - using iterator = detected_t; - using sentinel = detected_t; - - // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator - // and https://en.cppreference.com/w/cpp/iterator/sentinel_for - // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; - - public: - static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; -}; - -template -using iterator_t = enable_if_t::value, result_of_begin())>>; - -template -using range_value_t = value_type_t>>; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_constructible_string_type -{ - // launder type through decltype() to fix compilation failure on ICPC -#ifdef __INTEL_COMPILER - using laundered_type = decltype(std::declval()); -#else - using laundered_type = ConstructibleStringType; -#endif - - static constexpr auto value = - conjunction < - is_constructible, - is_detected_exact>::value; -}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> -{ - using value_type = range_value_t; - - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; - -template -struct is_json_iterator_of : std::false_type {}; - -template -struct is_json_iterator_of : std::true_type {}; - -template -struct is_json_iterator_of : std::true_type -{}; - -// checks if a given type T is a template specialization of Primary -template