diff --git a/CrowLeer.sln b/CrowLeer.sln index 630a5e4..910e145 100644 --- a/CrowLeer.sln +++ b/CrowLeer.sln @@ -1,26 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.15 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrowLeer", "CrowLeer\CrowLeer.vcxproj", "{A886CD9F-F24D-41A1-9E82-870548A0B2B8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Debug|x64.ActiveCfg = Debug|x64 {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Debug|x64.Build.0 = Debug|x64 - {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Debug|x86.ActiveCfg = Debug|Win32 - {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Debug|x86.Build.0 = Debug|Win32 {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Release|x64.ActiveCfg = Release|x64 {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Release|x64.Build.0 = Release|x64 - {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Release|x86.ActiveCfg = Release|Win32 - {A886CD9F-F24D-41A1-9E82-870548A0B2B8}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CrowLeer/CrowLeer.vcxproj b/CrowLeer/CrowLeer.vcxproj index 826614a..0a3fda6 100644 --- a/CrowLeer/CrowLeer.vcxproj +++ b/CrowLeer/CrowLeer.vcxproj @@ -72,28 +72,43 @@ - D:\git\CrowLeer\CrowLeer\curl;$(IncludePath) - D:\git\CrowLeer\CrowLeer\curl;$(LibraryPath) + D:\git\CrowLeer\CrowLeer\cpp-netlib;D:\git\CrowLeer\CrowLeer\curl;$(IncludePath) + D:\git\CrowLeer\CrowLeer\cpp-netlib;D:\git\CrowLeer\CrowLeer\curl;$(LibraryPath) - D:\git\CrowLeer\CrowLeer\curl;$(IncludePath) - D:\git\CrowLeer\CrowLeer\curl;$(LibraryPath) + D:\git\CrowLeer\CrowLeer\cpp-netlib;D:\git\CrowLeer\CrowLeer\curl;$(IncludePath) + D:\git\CrowLeer\CrowLeer\cpp-netlib;D:\git\CrowLeer\CrowLeer\curl;$(LibraryPath) + + + D:\git\CrowLeer\CrowLeer\cpp-netlib86;D:\git\CrowLeer\CrowLeer\curl86;$(IncludePath) + D:\git\CrowLeer\CrowLeer\cpp-netlib86;D:\git\CrowLeer\CrowLeer\curl86;$(LibraryPath) + + + D:\git\CrowLeer\CrowLeer\cpp-netlib86;D:\git\CrowLeer\CrowLeer\curl86;$(IncludePath) + D:\git\CrowLeer\CrowLeer\cpp-netlib86;D:\git\CrowLeer\CrowLeer\curl86;$(LibraryPath) Level3 Disabled true + MultiThreadedDebug + + libcurl_a_debug.lib;network-urid.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + Level3 Disabled true - MultiThreadedDebugDLL + MultiThreadedDebug _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + libcurl_a_debug.lib;network-urid.lib;%(AdditionalDependencies) + @@ -102,10 +117,12 @@ true true true + MultiThreaded true true + libcurl_a_debug.lib;network-urid.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -115,12 +132,13 @@ true true true - MultiThreadedDLL + MultiThreaded _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true + libcurl_a.lib;network-uri.lib;%(AdditionalDependencies) diff --git a/CrowLeer/CrowLeer.vcxproj.filters b/CrowLeer/CrowLeer.vcxproj.filters index e3788eb..c07b341 100644 --- a/CrowLeer/CrowLeer.vcxproj.filters +++ b/CrowLeer/CrowLeer.vcxproj.filters @@ -21,20 +21,17 @@ Source Files - - Source Files - Source Files Source Files + + Source Files + - - Header Files - Header Files @@ -50,6 +47,9 @@ Header Files + + Header Files + diff --git a/CrowLeer/cpp-netlib/LICENSE_1_0.txt b/CrowLeer/cpp-netlib/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/CrowLeer/cpp-netlib/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/CrowLeer/cpp-netlib/network-uri.lib b/CrowLeer/cpp-netlib/network-uri.lib new file mode 100644 index 0000000..ad5f546 Binary files /dev/null and b/CrowLeer/cpp-netlib/network-uri.lib differ diff --git a/CrowLeer/cpp-netlib/network-urid.lib b/CrowLeer/cpp-netlib/network-urid.lib new file mode 100644 index 0000000..6d6bd9b Binary files /dev/null and b/CrowLeer/cpp-netlib/network-urid.lib differ diff --git a/CrowLeer/cpp-netlib/network/optional.hpp b/CrowLeer/cpp-netlib/network/optional.hpp new file mode 100644 index 0000000..43b1cf1 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/optional.hpp @@ -0,0 +1,711 @@ +// Copyright 2016 Glyn Matthews. +// Copyright (C) 2011 - 2012 Andrzej Krzemienski. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * \file + * \brief Contains an implementation of C++17 optional (n3793). + * + * \sa https://github.com/akrzemi1/Optional + * \sa http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3848.html + */ + +#ifndef NETWORK_OPTIONAL_INC +#define NETWORK_OPTIONAL_INC + +#include +#include +#include +#include +#include + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +#ifdef NDEBUG +#define NETWORK_ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR) +#else +#define NETWORK_ASSERTED_EXPRESSION(CHECK, EXPR) \ + ((CHECK) ? (EXPR) : (fail(#CHECK, __FILE__, __LINE__), (EXPR))) +inline void fail(const char*, const char*, unsigned) {} +#endif // NDEBUG +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +namespace network { +/** + * \ingroup optional + * \class nullopt_t optional.hpp network/uri.hpp + * \brief Disengaged state indicator. + * \sa optional + */ +struct nullopt_t { +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + struct init {}; + constexpr nullopt_t(init) {} +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) +}; + +/** + * \ingroup optional + * \brief Used to indicate a *disengaged* state for optional objects. + */ +constexpr nullopt_t nullopt{nullopt_t::init{}}; + +/** + * \ingroup optional + * \class bad_optional_access optional.hpp network/uri.hpp + * \brief Exception thrown when the value member function is called when the + * optional object is disengaged. + */ +class bad_optional_access : public std::logic_error { + public: + + /** + * \brief Constructor. + * \param what_arg The error message. + */ + explicit bad_optional_access(const std::string& what_arg) + : std::logic_error(what_arg) {} + + /** + * \brief Constructor. + * \param what_arg The error message. + */ + explicit bad_optional_access(const char* what_arg) + : std::logic_error(what_arg) {} +}; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +namespace details { +struct dummy_t {}; + +template +union trivially_destructible_optional_storage { + static_assert(std::is_trivially_destructible::value, ""); + + dummy_t dummy_; + T value_; + + constexpr trivially_destructible_optional_storage() : dummy_{} {} + + constexpr trivially_destructible_optional_storage(const T& v) : value_{v} {} + + ~trivially_destructible_optional_storage() = default; +}; + +template +union optional_storage { + dummy_t dummy_; + T value_; + + constexpr optional_storage() : dummy_{} {} + + constexpr optional_storage(const T& v) : value_{v} {} + + ~optional_storage() {} +}; + +template +class trivially_destructible_optional_base { +public: + typedef T value_type; + + constexpr trivially_destructible_optional_base() noexcept + : init_(false), + storage_{} {} + + constexpr trivially_destructible_optional_base(const T& v) + : init_(true), storage_{v} {} + + constexpr trivially_destructible_optional_base(T&& v) + : init_(true), storage_{std::move(v)} {} + + ~trivially_destructible_optional_base() = default; + +protected: + + bool init_; + optional_storage storage_; +}; + +template +class optional_base { +public: + typedef T value_type; + + constexpr optional_base() noexcept + : init_(false), + storage_{} {} + + constexpr optional_base(const T& v) + : init_(true), storage_{v} {} + + constexpr optional_base(T&& v) + : init_(true), storage_{std::move(v)} {} + + ~optional_base() { + if (init_) { + storage_.value_.T::~T(); + } + } + +protected: + + bool init_; + optional_storage storage_; +}; +} // namespace details +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +/** + * \ingroup optional + * \class optional optional.hpp network/uri.hpp + * \brief An implementation of C++17 optional (n3793) + */ +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +template +using optional_base = typename std::conditional< + std::is_trivially_destructible::value, + details::trivially_destructible_optional_base, + details::optional_base>::type; +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +template +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +class optional : optional_base { +#else +class optional { +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + typedef optional_base base_type; + + public: + /** + * \brief Optional value type. + */ + typedef T value_type; + + /** + * \brief Constructor. + * \post *disengaged*. + */ + constexpr optional() : optional_base() {} + + /** + * \brief Constructor. + * \post *disengaged*. + */ + constexpr optional(nullopt_t) noexcept : optional_base() {} + + /** + * \brief Copy constructor. + * \param other The other optional object. + */ + optional(const optional& other) { + if (other) { + ::new(static_cast(ptr())) T(*other); + base_type::init_ = true; + } + } + + /** + * \brief Move constructor. + * \param other The other optional object. + */ + optional(optional&& other) noexcept { + if (other) { + ::new(static_cast(ptr())) T(std::move(other.storage_.value_)); + base_type::init_ = true; + } + } + + /** + * \brief Constructor. + * \param value The value with which to initialize the optional object. + * \post *engaged* + */ + constexpr optional(const T& value) : optional_base(value) {} + + /** + * \brief Constructor. + * \param value The value with which to initialize the optional object. + * \post *engaged* + */ + constexpr optional(T&& value) : optional_base(std::move(value)) {} + + /** + * \brief Assignment operator. + * \post *disengaged*. + * \returns \c *this. + */ + optional& operator=(nullopt_t) noexcept { + if (base_type::init_) { + ptr()->T::~T(); + } + base_type::init_ = false; + return *this; + } + + /** + * \brief Copy assignment operator. + * \param other The other optional object. + * \returns \c *this. + */ + optional& operator=(const optional& other) { + if (bool(*this) && !other) { + ptr()->T::~T(); + base_type::init_ = false; + } + else if (!(*this) && bool(other)) { + ::new(static_cast(ptr())) T(*other); + base_type::init_ = true; + } + else if (bool(*this) && bool(other)) { + base_type::storage_.value_ = *other; + } + return *this; + } + + /** + * \brief Move assignment operator. + * \param other The other optional object. + * \returns \c *this. + */ + optional& operator=(optional&& other) noexcept { + if (bool(*this) && !other) { + ptr()->T::~T(); + base_type::init_ = false; + } + else if (!(*this) && bool(other)) { + ::new(static_cast(ptr())) T(std::move(*other)); + base_type::init_ = true; + } + else if (bool(*this) && bool(other)) { + base_type::storage_.value_ = std::move(*other); + } + return *this; + } + + /** + * \brief Destructor. + */ + ~optional() = default; + + /** + * \brief Swap function. + * \param other The other optional object. + */ + void swap(optional& other) noexcept { + if (bool(*this) && !other) { + ::new(static_cast(other.ptr())) T(std::move(**this)); + ptr()->T::~T(); + std::swap(base_type::init_, other.base_type::init_); + } + else if (!(*this) && bool(other)) { + ::new(static_cast(ptr())) T(std::move(*other)); + other.ptr()->T::~T(); + std::swap(base_type::init_, other.init_); + } + else if (bool(*this) && bool(other)) { + std::swap(**this, *other); + } + } + + /** + * \brief Observer. + * \pre *engaged* + * \returns The underlying optional value. + */ + constexpr T const* operator->() const { + return NETWORK_ASSERTED_EXPRESSION(bool(*this), ptr()); + } + + /** + * \brief Observer. + * \pre *engaged* + * \returns The underlying optional value. + */ + T* operator->() { + return NETWORK_ASSERTED_EXPRESSION(bool(*this), ptr()); + } + + /** + * \brief Observer. + * \pre *engaged* + * \returns The underlying optional value. + */ + constexpr T const& operator*() const { + return NETWORK_ASSERTED_EXPRESSION(bool(*this), base_type::storage_.value_); + } + + /** + * \brief Observer. + * \pre *engaged* + * \returns The underlying optional value. + */ + T& operator*() { + return NETWORK_ASSERTED_EXPRESSION(bool(*this), base_type::storage_.value_); + } + + /** + * \brief Operator bool overloads. + * \returns \c true if the optional is *engaged*, \c false if it is *disengaged*. + */ + constexpr explicit operator bool() const noexcept { return base_type::init_; } + + /** + * \returns The underlying optional value, if \c bool(*this). + * \throws A bad_optional_access if \c !*this. + */ + constexpr T const& value() const { + return *this ? base_type::storage_.value_ + : (throw bad_optional_access("Uninitialized optional value"), + base_type::storage_.value_); + } + /** + * \returns The underlying optional value, if \c bool(*this). + * \throws A bad_optional_access if \c !*this. + */ + T& value() { + return *this ? base_type::storage_.value_ + : (throw bad_optional_access("Uninitialized optional value"), + base_type::storage_.value_); + } + + /** + * \returns bool(*this) ? **this : static_cast(std::forward(v)). + * \pre \c std::is_copy_constructible::value is \c true and std::is_convertible::value is \c true. + */ + template + T value_or(U&& other) const & { + static_assert(std::is_copy_constructible::value, "Must be copy constructible."); + static_assert(std::is_convertible::value, "U must be convertible to T."); + return bool(*this) ? **this : static_cast(std::forward(other)); + } + + /** + * \returns bool(*this) ? std::move(**this) : static_cast(std::forward(v)). + * \pre std::is_move_constructible::value is \c true and std::is_convertible::value is \c true. + */ + template + T value_or(U&& other) && { + static_assert(std::is_copy_constructible::value, "Must be copy constructible."); + static_assert(std::is_convertible::value, "U must be convertible to T."); + return bool(*this) ? std::move(**this) : static_cast(std::forward(other)); + } + + private: + + T* ptr() { + return std::addressof(base_type::storage_.value_); + } + +}; + +/** + * \brief Equality operator. + */ +template +bool operator==(const optional& lhs, const optional& rhs) { + if (bool(lhs) != bool(rhs)) { + return false; + } else if (!bool(lhs)) { + return true; + } else { + return *lhs == *rhs; + } +} + +/** + * \brief Inequality operator. + */ +template +bool operator!=(const optional& lhs, const optional& rhs) { + return !(lhs == rhs); +} + +/** + * \brief Comparison operator. + */ +template +bool operator<(const optional& lhs, const optional& rhs) { + if (!rhs) { + return false; + } else if (!lhs) { + return true; + } else { + return *lhs < *rhs; + } +} + +/** + * \brief Comparison operator. + * \returns rhs < lhs. + */ +template +bool operator>(const optional& lhs, const optional& rhs) { + return rhs < lhs; +} + +/** + * \brief Comparison operator. + * \returns !(rhs < lhs). + */ +template +bool operator<=(const optional& lhs, const optional& rhs) { + return !(rhs < lhs); +} + +/** + * \brief Comparison operator. + * \returns !(rhs > lhs). + */ +template +bool operator>=(const optional& lhs, const optional& rhs) { + return !(lhs < rhs); +} + +/** + * \brief Equality operator. + * \returns \c !x. + */ +template +bool operator==(const optional& x, nullopt_t) noexcept { + return !x; +} + +/** + * \brief Equality operator. + * \returns \c !x. + */ +template +bool operator==(nullopt_t, const optional& x) noexcept { + return !x; +} + +/** + * \brief Inequality operator. + * \returns \c bool(x). + */ +template +bool operator!=(const optional& x, nullopt_t) noexcept { + return bool(x); +} + +/** + * \brief Inequality operator. + * \returns \c bool(x). + */ +template +bool operator!=(nullopt_t, const optional& x) noexcept { + return bool(x); +} + +/** + * \brief Comparison operator. + * \returns \c false. + */ +template +bool operator<(const optional& x, nullopt_t) noexcept { + return false; +} + +/** + * \brief Comparison operator. + * \returns \c bool(x). + */ +template +bool operator<(nullopt_t, const optional& x) noexcept { + return bool(x); +} + +/** + * \brief Comparison operator. + * \returns \c !x. + */ +template +bool operator<=(const optional& x, nullopt_t) noexcept { + return !x; +} + +/** + * \brief Comparison operator. + * \returns \c true. + */ +template +bool operator<=(nullopt_t, const optional& x) noexcept { + return true; +} + +/** + * \brief Comparison operator. + * \returns \c bool(x). + */ +template +bool operator>(const optional& x, nullopt_t) noexcept { + return bool(x); +} + +/** + * \brief Comparison operator. + * \returns \c false. + */ +template +bool operator>(nullopt_t, const optional& x) noexcept { + return false; +} + +/** + * \brief Comparison operator. + * \returns \c true. + */ +template +bool operator>=(const optional& x, nullopt_t) noexcept { + return true; +} + +/** + * \brief Comparison operator. + * \returns \c !x. + */ +template +bool operator>=(nullopt_t, const optional& x) noexcept { + return !x; +} + +/** + * \brief Equality operator. + * \returns bool(x) ? *x == v : false. + */ +template +bool operator==(const optional& x, const T& v) { + return bool(x) ? *x == v : false; +} + +/** + * \brief Equality operator. + * \returns bool(x) ? v == *x : false. + */ +template +bool operator==(const T& v, const optional& x) { + return bool(x) ? v == *x : false; +} + +/** + * \brief Inequality operator. + * \returns bool(x) ? !(*x == v) : true. + */ +template +bool operator!=(const optional& x, const T& v) { + return bool(x) ? !(*x == v) : true; +} + +/** + * \brief Inequality operator. + * \returns bool(x) ? !(v == *x) : true. + */ +template +bool operator!=(const T& v, const optional& x) { + return bool(x) ? !(v == *x) : true; +} + +/** + * \brief Comparison operator. + * \returns bool(x) ? *x < v : true. + */ +template +bool operator<(const optional& x, const T& v) { + return bool(x) ? *x < v : true; +} + +/** + * \brief Comparison operator. + * \returns bool(x) ? v < *x : false. + */ +template +bool operator<(const T& v, const optional& x) { + return bool(x) ? v < *x : false; +} + +/** + * \brief Comparison operator. + * \returns bool(x) ? *x < v : true. + */ +template +bool operator>(const optional& x, const T& v) { + return bool(x) ? *x < v : true; +} + +/** + * \brief Comparison operator. + * \returns bool(x) ? v < *x : false. + */ +template +bool operator>(const T& v, const optional& x) { + return bool(x) ? v < *x : false; +} + +/** + * \brief Comparison operator. + * \returns !(x < v). + */ +template +bool operator>=(const optional& x, const T& v) { + return !(x < v); +} + +/** + * \brief Comparison operator. + * \returns !(v < x). + */ +template +bool operator>=(const T& v, const optional& x) { + return !(v < x); +} + +/** + * \brief Comparison operator. + * \returns !(x > v). + */ +template +bool operator<=(const optional& x, const T& v) { + return !(x > v); +} + +/** + * \brief Comparison operator. + * \returns !(v > x). + */ +template +bool operator<=(const T& v, const optional& x) { + return !(v > x); +} + +/** + * \ingroup optional + * \brief Swap function. + * \param lhs The first optional object. + * \param rhs The second optional object. + * + * Calls: + * \code{.cpp} + * lhs.swap(rhs); + * \endcode + */ +template +inline void swap(optional& lhs, + optional& rhs) noexcept(noexcept(lhs.swap(rhs))) { + return lhs.swap(rhs); +} + +/** + * \ingroup optional + * \brief A helper function to contruct an optional object. + * \returns optional::type>(std::forward(value)). + */ +template +inline constexpr optional::type> make_optional(T&& value) { + return optional::type>(std::forward(value)); +} +} // namespace network + +#endif // NETWORK_OPTIONAL_INC diff --git a/CrowLeer/cpp-netlib/network/string_view.hpp b/CrowLeer/cpp-netlib/network/string_view.hpp new file mode 100644 index 0000000..cce9029 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/string_view.hpp @@ -0,0 +1,268 @@ +// Copyright 2016 Glyn Matthews. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_STRING_VIEW_INC +#define NETWORK_STRING_VIEW_INC + +/** + * \file + * \brief Contains an implementation of C++17 string_view (n3921). + */ + +#include +#include +#include +#include +#include + +namespace network { +/** + * \class basic_string_view string_view.hpp network/uri/string_view.hpp + * \brief An implementation of C++17 string_view (n3921) + */ +template > +class basic_string_view { + public: + typedef traits traits_type; + typedef charT value_type; + typedef charT* pointer; + typedef const charT* const_pointer; + typedef charT& reference; + typedef const charT& const_reference; + typedef const charT* const_iterator; + typedef const_iterator iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + static constexpr size_type npos = size_type(-1); + + /** + * \brief Constructor. + */ + constexpr basic_string_view() noexcept : data_(nullptr), size_(0) {} + + /** + * \brief Copy constructor. + */ + constexpr basic_string_view(const basic_string_view&) noexcept = default; + + /** + * \brief Assignment operator. + */ + basic_string_view& operator=(const basic_string_view&) noexcept = default; + + /** + * \brief Constructor. + */ + template + basic_string_view( + const std::basic_string& str) noexcept + : data_(str.data()), + size_(str.size()) {} + + /** + * \brief Constructor. + */ + constexpr basic_string_view(const charT* str) + : data_(str), size_(traits::length(str)) {} + + /** + * \brief Constructor. + */ + constexpr basic_string_view(const charT* str, size_type len) + : data_(str), size_(len) {} + + constexpr const_iterator begin() const noexcept { return data_; } + + constexpr const_iterator end() const noexcept { return data_ + size_; } + + constexpr const_iterator cbegin() const noexcept { return begin(); } + + constexpr const_iterator cend() const noexcept { return end(); } + + const_reverse_iterator rbegin() const noexcept { + return const_reverse_iterator(end()); + } + const_reverse_iterator rend() const noexcept { + return const_reverse_iterator(begin()); + } + const_reverse_iterator crbegin() const noexcept { return rbegin(); } + + const_reverse_iterator crend() const noexcept { return rend(); } + + constexpr size_type size() const noexcept { return size_; } + + constexpr size_type length() const noexcept { return size_; } + + constexpr size_type max_size() const noexcept { return size_; } + + constexpr bool empty() const noexcept { return size_ == 0; } + + constexpr const_reference operator[](size_type pos) const { + return data_[pos]; + } + + const_reference at(size_type pos) const { + if (pos >= size_) { + throw std::out_of_range("Index out of range."); + } + return data_[pos]; + } + + const_reference front() const { return *begin(); } + + const_reference back() const { + auto last = (end()) - 1; + return *last; + } + + constexpr const_pointer data() const noexcept { return data_; } + + void clear() noexcept { + data_ = nullptr; + size_ = 0; + } + + void remove_prefix(size_type n) { + data_ += n; + size_ -= n; + } + + void remove_suffix(size_type n) { size_ -= n; } + + void swap(basic_string_view& s) noexcept { + std::swap(data_, s.data_); + std::swap(size_, s.size_); + } + + template + explicit operator std::basic_string() const { + return to_string(); + } + + template > + std::basic_string to_string( + const Allocator& a = Allocator()) const { + return std::basic_string(begin(), end(), a); + } + + size_type copy(charT* s, size_type n, size_type pos = 0) const { + size_type rlen = std::min(n, size() - pos); + std::copy_n(begin() + pos, rlen, s); + return rlen; + } + + constexpr basic_string_view substr(size_type pos = 0, + size_type n = npos) const { + return basic_string_view(data() + pos, std::min(n, size() - pos)); + } + + constexpr int compare(basic_string_view s) const noexcept { + return traits::compare(data(), s.data(), std::min(size(), s.size())); + } + + constexpr int compare(size_type pos1, size_type n1, + basic_string_view s) const { + return substr(pos1, n1).compare(s); + } + + constexpr int compare(size_type pos1, size_type n1, basic_string_view s, + size_type pos2, size_type n2) const { + return substr(pos1, n1).compare(s.substr(pos2, n2)); + } + + constexpr int compare(const charT* s) const { + return compare(basic_string_view(s)); + } + + constexpr int compare(size_type pos1, size_type n1, const charT* s) const { + return substr(pos1, n1).compare(basic_string_view(s)); + } + + constexpr int compare(size_type pos1, size_type n1, const charT* s, + size_type n2) const { + return substr(pos1, n1).compare(basic_string_view(s, n2)); + } + + private: + const_pointer data_; + size_type size_; +}; + +/** + * \brief Equality operator. + * \returns lhs.compare(rhs) == 0. + */ +template +constexpr bool operator==(basic_string_view lhs, + basic_string_view rhs) noexcept { + return lhs.compare(rhs) == 0; +} + +/** + * \brief Inequality operator. + * \returns !(lhs == rhs). + */ +template +constexpr bool operator!=(basic_string_view lhs, + basic_string_view rhs) noexcept { + return !(lhs == rhs); +} + +/** + * \brief Comparison operator. + * \returns lhs.compare(rhs) < 0. + */ +template +constexpr bool operator<(basic_string_view lhs, + basic_string_view rhs) noexcept { + return lhs.compare(rhs) < 0; +} + +/** + * \brief Comparison operator. + * \returns rhs < lhs. + */ +template +constexpr bool operator>(basic_string_view lhs, + basic_string_view rhs) noexcept { + return rhs < lhs; +} + +/** + * \brief Comparison operator. + * \returns !(lhs > rhs). + */ +template +constexpr bool operator<=(basic_string_view lhs, + basic_string_view rhs) noexcept { + return !(lhs > rhs); +} + +/** + * \brief Comparison operator. + * \returns !(lhs < rhs). + */ +template +constexpr bool operator>=(basic_string_view lhs, + basic_string_view rhs) noexcept { + return !(lhs < rhs); +} + +/** + * \brief Output stream operator. + */ +template +std::basic_ostream& operator<<( + std::basic_ostream& os, + basic_string_view str) { + return os << str.to_string(); +} + +typedef basic_string_view string_view; +} // namespace network + +#endif // NETWORK_STRING_VIEW_INC diff --git a/CrowLeer/cpp-netlib/network/uri.hpp b/CrowLeer/cpp-netlib/network/uri.hpp new file mode 100644 index 0000000..f3d86e0 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri.hpp @@ -0,0 +1,38 @@ +// Copyright (c) Glyn Matthews 2012-2016. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_HPP +#define NETWORK_URI_HPP + +/** + * \defgroup uri URI + * + * This module contains a class encapsulating a URI, a URI builder and + * percent encoding and decoding functions. + * + * \defgroup optional Optional + * + * This module contains a utility to represent optional values. + * + * \defgroup string String + * + * This module contains a class for a non-owning reference to a string. + * + * \namespace network + * + * The \c network namespace contains all the classes and functions for + * the URI in this library. + * + * \file + * \brief Contains the uri, uri_builder classes and functions + * for percent encoding and decoding. + */ + +#include +#include + +#endif // NETWORK_URI_HPP diff --git a/CrowLeer/cpp-netlib/network/uri/config.hpp b/CrowLeer/cpp-netlib/network/uri/config.hpp new file mode 100644 index 0000000..39c3b58 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/config.hpp @@ -0,0 +1,20 @@ +// Copyright (c) Glyn Matthews 2012-2016. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * \file + * \brief Contains macros to configure compiler or platform-specific workarounds. + */ + +#ifndef NETWORK_URI_CONFIG_INC +#define NETWORK_URI_CONFIG_INC + +#ifdef _MSC_VER +#define NETWORK_URI_MSVC _MSC_VER +#endif // _MSC_VER + +#endif // NETWORK_URI_CONFIG_INC diff --git a/CrowLeer/cpp-netlib/network/uri/detail/decode.hpp b/CrowLeer/cpp-netlib/network/uri/detail/decode.hpp new file mode 100644 index 0000000..4e92bb7 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/detail/decode.hpp @@ -0,0 +1,82 @@ +// Copyright (c) Glyn Matthews 2011-2016. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_DECODE_INC +#define NETWORK_URI_DECODE_INC + +#include +#include +#include + +namespace network { +namespace detail { +template +CharT letter_to_hex(CharT in) { + if ((in >= '0') && (in <= '9')) { + return in - '0'; + } + + if ((in >= 'a') && (in <= 'f')) { + return in + 10 - 'a'; + } + + if ((in >= 'A') && (in <= 'F')) { + return in + 10 - 'A'; + } + + throw percent_decoding_error(uri_error::non_hex_input); +} + +template +InputIterator decode_char(InputIterator it, charT *out) { + assert(*it == '%'); + ++it; + auto h0 = *it; + auto v0 = detail::letter_to_hex(h0); + ++it; + auto h1 = *it; + auto v1 = detail::letter_to_hex(h1); + if (h0 >= '8') { + // unable to decode characters outside the ASCII character set. + throw percent_decoding_error(uri_error::conversion_failed); + } + ++it; + *out = static_cast((0x10 * v0) + v1); + return it; +} + +template +OutputIterator decode(InputIterator in_begin, InputIterator in_end, + OutputIterator out_begin) { + auto it = in_begin; + auto out = out_begin; + while (it != in_end) { + if (*it == '%') { + if (std::distance(it, in_end) < 3) { + throw percent_decoding_error(uri_error::not_enough_input); + } + char c = '\0'; + it = decode_char(it, &c); + out = c; + ++out; + } else { + *out++ = *it++; + } + } + return out; +} + +template +String decode(const String &source) { + String unencoded; + decode(std::begin(source), std::end(source), std::back_inserter(unencoded)); + return unencoded; +} +} // namespace detail +} // namespace network + +#endif // NETWORK_URI_DECODE_INC diff --git a/CrowLeer/cpp-netlib/network/uri/detail/encode.hpp b/CrowLeer/cpp-netlib/network/uri/detail/encode.hpp new file mode 100644 index 0000000..794f393 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/detail/encode.hpp @@ -0,0 +1,166 @@ +// Copyright (c) Glyn Matthews 2011-2016. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_ENCODE_INC +#define NETWORK_URI_ENCODE_INC + +#include +#include +#include +#include +#include + +namespace network { +namespace detail { +template +inline CharT hex_to_letter(CharT in) { + if ((in >= 0) && (in < 10)) { + return in + '0'; + } + + if ((in >= 10) && (in < 16)) { + return in - 10 + 'A'; + } + + return in; +} + +template +void encode_char(charT in, OutputIterator &out, const char *ignore = "") { + if (((in >= 'a') && (in <= 'z')) || + ((in >= 'A') && (in <= 'Z')) || + ((in >= '0') && (in <= '9')) || + (in == '-') || + (in == '.') || + (in == '_') || + (in == '~')) { + out++ = in; + } else { + auto first = ignore, last = ignore + std::strlen(ignore); + if (std::find(first, last, in) != last) { + out++ = in; + } else { + out++ = '%'; + out++ = hex_to_letter((in >> 4) & 0x0f); + out++ = hex_to_letter(in & 0x0f); + } + } +} + +template +OutputIterator encode_user_info(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out, ":"); + ++it; + } + return out; +} + +template +OutputIterator encode_host(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out, "[:]"); + ++it; + } + return out; +} + +template +OutputIterator encode_port(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out); + ++it; + } + return out; +} + +template +OutputIterator encode_path(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out, "/.@%;="); + ++it; + } + return out; +} + +template +OutputIterator encode_query(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out, "/.@&%;="); + ++it; + } + return out; +} + +template +OutputIterator encode_fragment(InputIterator first, InputIterator last, + OutputIterator out) { + auto it = first; + while (it != last) { + detail::encode_char(*it, out, "/.@&l;=%"); + ++it; + } + return out; +} + +template +String encode_user_info(const String &user_info) { + String encoded; + encode_user_info(std::begin(user_info), std::end(user_info), + std::back_inserter(encoded)); + return encoded; +} + +template +String encode_host(const String &host) { + String encoded; + encode_host(std::begin(host), std::end(host), std::back_inserter(encoded)); + return encoded; +} + +template +String encode_port(const String &port) { + String encoded; + encode_port(std::begin(port), std::end(port), std::back_inserter(encoded)); + return encoded; +} + +template +String encode_path(const String &path) { + String encoded; + encode_path(std::begin(path), std::end(path), std::back_inserter(encoded)); + return encoded; +} + +template +String encode_query(const String &query) { + String encoded; + encode_query(std::begin(query), std::end(query), std::back_inserter(encoded)); + return encoded; +} + +template +String encode_fragment(const String &fragment) { + String encoded; + encode_fragment(std::begin(fragment), std::end(fragment), + std::back_inserter(encoded)); + return encoded; +} +} // namespace detail +} // namespace network + +#endif // NETWORK_URI_ENCODE_INC diff --git a/CrowLeer/cpp-netlib/network/uri/detail/translate.hpp b/CrowLeer/cpp-netlib/network/uri/detail/translate.hpp new file mode 100644 index 0000000..7566c25 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/detail/translate.hpp @@ -0,0 +1,89 @@ +// Copyright (c) Glyn Matthews 2012-2016. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_DETAIL_TRANSLATE_INC +#define NETWORK_URI_DETAIL_TRANSLATE_INC + +#include + +namespace network { +namespace detail { +template +struct translate_impl; + +template <> +struct translate_impl { + std::string operator()(const std::string &source) const { return source; } +}; + +template +struct translate_impl { + std::string operator()(const char *source) const { return source; } +}; + +template <> +struct translate_impl { + std::string operator()(const char *source) const { return source; } +}; + +template <> +struct translate_impl { + std::string operator()(const char *source) const { return source; } +}; + +template +struct translate_impl { + std::string operator()(const char *source) const { return source; } +}; + +template <> +struct translate_impl { + std::string operator()(const std::wstring &source) const { + return std::string(std::begin(source), std::end(source)); + } +}; + +template +struct translate_impl { + std::string operator()(const wchar_t *source) const { + translate_impl impl; + return impl(source); + } +}; + +template +struct translate_impl { + std::string operator()(const wchar_t *source) const { + translate_impl impl; + return impl(source); + } +}; + +template <> +struct translate_impl { + std::string operator()(const wchar_t *source) const { + translate_impl impl; + return impl(source); + } +}; + +template <> +struct translate_impl { + std::string operator()(const wchar_t *source) const { + translate_impl impl; + return impl(source); + } +}; + +template +inline std::string translate(const Source &source) { + translate_impl impl; + return impl(source); +} + +} // namespace detail +} // namespace network + +#endif // NETWORK_URI_DETAIL_TRANSLATE_INC diff --git a/CrowLeer/cpp-netlib/network/uri/detail/uri_parts.hpp b/CrowLeer/cpp-netlib/network/uri/detail/uri_parts.hpp new file mode 100644 index 0000000..731e30d --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/detail/uri_parts.hpp @@ -0,0 +1,74 @@ +// Copyright 2016 Glyn Matthews. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_DETAIL_URI_PARTS_INC +#define NETWORK_DETAIL_URI_PARTS_INC + +#include +#include +#include +#include +#include + +namespace network { +namespace detail { +class uri_part { + public: + typedef string_view::value_type value_type; + typedef string_view::iterator iterator; + typedef string_view::const_iterator const_iterator; + typedef string_view::const_pointer const_pointer; + typedef string_view::size_type size_type; + typedef string_view::difference_type difference_type; + + uri_part() noexcept = default; + + uri_part(const_iterator first, const_iterator last) noexcept + : first(first), last(last) {} + + const_iterator begin() const noexcept { return first; } + + const_iterator end() const noexcept { return last; } + + bool empty() const noexcept { return first == last; } + + std::string to_string() const { return std::string(first, last); } + + const_pointer ptr() const noexcept { + assert(first != last); + return first; + } + + difference_type length() const noexcept { + return last - first; + } + + string_view to_string_view() const noexcept { return string_view(ptr(), length()); } + + private: + const_iterator first, last; +}; + +struct hierarchical_part { + hierarchical_part() = default; + + optional user_info; + optional host; + optional port; + optional path; +}; + +struct uri_parts { + uri_parts() = default; + + optional scheme; + hierarchical_part hier_part; + optional query; + optional fragment; +}; +} // namespace detail +} // namespace network + +#endif // NETWORK_DETAIL_URI_PARTS_INC diff --git a/CrowLeer/cpp-netlib/network/uri/uri.hpp b/CrowLeer/cpp-netlib/network/uri/uri.hpp new file mode 100644 index 0000000..66fb752 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/uri.hpp @@ -0,0 +1,711 @@ +// Copyright 2009-2010 Jeroen Habraken. +// Copyright 2009-2017 Dean Michael Berris, Glyn Matthews. +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_INC +#define NETWORK_URI_INC + +/** + * \file + * \brief Contains the uri class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef NETWORK_URI_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +namespace network { +/** + * \enum uri_comparison_level + * \brief Defines the steps on the URI comparison ladder. + */ +enum class uri_comparison_level { + string_comparison, + syntax_based, + scheme_based, +}; + +/** + * \ingroup uri + * \class uri_builder network/uri/uri_builder.hpp network/uri.hpp + * \brief A class that allows complex uri objects to be constructed. + * \sa uri + */ +class uri_builder; + +/** + * \ingroup uri + * \class uri network/uri/uri.hpp network/uri.hpp + * \brief A class that parses a URI (Uniform Resource Identifier) + * into its component parts. + * + * This class conforms to a URI as defined by RFC 3986, RFC 3987 and + * RFC 2732, including scoped IDs. It provides member functions for + * normalizing, comparing and resolving URIs. + * + * A URI has the syntax: + * + * \code + * [scheme:][user_info@][host][:port][path][?query][#fragment] + * \endcode + * + * Example: + * + * \code + * network::uri instance("http://cpp-netlib.org/"); + * assert(instance.is_absolute()); + * assert(!instance.is_opaque()); + * assert(instance.scheme()); + * assert("http" == *instance.scheme()); + * assert(instance.host()); + * assert("cpp-netlib.org" == *instance.host()); + * assert(instance.path()); + * assert("/" == *instance.path()); + * \endcode + */ +class uri { +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + friend class uri_builder; +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + + public: + /** + * \brief The URI string_type. + */ + typedef std::string string_type; + + /** + * \brief A reference to the underlying string_type parts. + */ + typedef network::string_view string_view; + + /** + * \brief The char traits. + */ + typedef string_view::traits_type traits_type; + + /** + * \brief The URI const_iterator type. + */ + typedef string_view::const_iterator const_iterator; + + /** + * \brief The URI iterator type. + */ + typedef const_iterator iterator; + + /** + * \brief The URI value_type. + */ + typedef std::iterator_traits::value_type value_type; + + /** + * + */ + class query_iterator { + public: + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = const value_type *; + using reference = const value_type &; + using iterator_category = std::forward_iterator_tag; + + query_iterator(); + explicit query_iterator(optional); + query_iterator(const query_iterator &); + query_iterator &operator=(const query_iterator &); + reference operator++() noexcept; + value_type operator++(int) noexcept; + reference operator*() const noexcept; + pointer operator->() const noexcept; + bool operator==(const query_iterator &) const noexcept; + inline bool operator!=(const query_iterator &other) const noexcept { + return !(*this == other); + } + + private: + void swap(query_iterator &) noexcept; + void advance_to_next_kvp() noexcept; + void assign_kvp() noexcept; + void increment() noexcept; + + optional query_; + value_type kvp_; + }; + + /** + * \brief Default constructor. + */ + uri(); + + /** + * \brief Constructor. + * \param first The first element in a string sequence. + * \param last The end + 1th element in a string sequence. + * \throws uri_syntax_error if the sequence is not a valid URI. + * \throws std::bad_alloc If the underlying string cannot be allocated. + */ + template + uri(InputIter first, InputIter last) { + if (!initialize(string_type(first, last))) { + throw uri_syntax_error(); + } + } + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + template + explicit uri(InputIter first, InputIter last, std::error_code &ec) { + if (!initialize(string_type(first, last))) { + ec = make_error_code(uri_error::invalid_syntax); + } + } +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + + /** + * \brief Constructor. + * \param source A source string that is to be parsed as a URI. + * \throws uri_syntax_error if the source is not a valid URI. + * \throws std::bad_alloc If the underlying string cannot be allocated. + */ + template + explicit uri(const Source &source) { + if (!initialize(detail::translate(source))) { + throw uri_syntax_error(); + } + } + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + template + explicit uri(const Source &source, std::error_code &ec) { + if (!initialize(detail::translate(source))) { + ec = make_error_code(uri_error::invalid_syntax); + } + } +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + explicit uri(const uri_builder &builder); +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + + /** + * \brief Copy constructor. + * \throws std::bad_alloc If the underlying string cannot be allocated. + */ + uri(const uri &other); + + /** + * \brief Move constructor. + */ + uri(uri &&other) noexcept; + + /** + * \brief Destructor. + */ + ~uri(); + + /** + * \brief Assignment operator. + * \throws std::bad_alloc If the underlying string cannot be allocated. + */ + uri &operator=(uri other); + + /** + * \brief Swaps one uri object with another. + * \param other The other uri object. + */ + void swap(uri &other) noexcept; + + /** + * \brief Returns an iterator at the first element in the + * underlying sequence. + * \return An iterator starting at the first element. + */ + const_iterator begin() const noexcept; + + /** + * \brief Returns an iterator at the end + 1th element in the + * underlying sequence. + * \return An iterator starting at the end + 1th element. + */ + const_iterator end() const noexcept; + + /** + * \brief Tests whether this URI has a scheme component. + * \return \c true if the URI has a scheme, \c false otherwise. + */ + bool has_scheme() const noexcept; + + /** + * \brief Returns the URI scheme. + * \return The scheme. + * \pre has_scheme() + */ + string_view scheme() const noexcept; + + /** + * \brief Tests whether this URI has a user info component. + * \return \c true if the URI has a user info, \c false otherwise. + */ + bool has_user_info() const noexcept; + + /** + * \brief Returns the URI user info. + * \return The user info. + * \pre has_user_info() + */ + string_view user_info() const noexcept; + + /** + * \brief Tests whether this URI has a host component. + * \return \c true if the URI has a host, \c false otherwise. + */ + bool has_host() const noexcept; + + /** + * \brief Returns the URI host. + * \return The host. + * \pre has_host() + */ + string_view host() const noexcept; + + /** + * \brief Tests whether this URI has a port component. + * \return \c true if the URI has a port, \c false otherwise. + */ + bool has_port() const noexcept; + + /** + * \brief Returns the URI port. + * \return The port. + * \pre has_port() + */ + string_view port() const noexcept; + + /** + * \brief Returns the URI port as an integer. + * \return The port number. + * \pre has_port() + */ + template + intT port(typename std::is_integral::type * = 0) const { + assert(has_port()); + auto p = port(); + const char *port_first = std::addressof(*p.begin()); + char *port_last = 0; + return static_cast(std::strtoul(port_first, &port_last, 10)); + } + + /** + * \brief Tests whether this URI has a path component. + * \return \c true if the URI has a path, \c false otherwise. + */ + bool has_path() const noexcept; + + /** + * \brief Returns the URI path. + * \return The path. + * \pre has_path() + */ + string_view path() const noexcept; + + /** + * \brief Tests whether this URI has a query component. + * \return \c true if the URI has a query, \c false otherwise. + */ + bool has_query() const noexcept; + + /** + * \brief Returns the URI query. + * \return The query. + * \pre has_query() + */ + string_view query() const noexcept; + + /** + * \brief Returns an iterator to the first key-value pair in the query + * component. + * + * \return query_iterator. + */ + query_iterator query_begin() const noexcept; + + /** + * \brief Returns an iterator to the last key-value pair in the query + * component. + * + * \return query_iterator. + */ + query_iterator query_end() const noexcept; + + /** + * \brief Tests whether this URI has a fragment component. + * \return \c true if the URI has a fragment, \c false otherwise. + */ + bool has_fragment() const noexcept; + + /** + * \brief Returns the URI fragment. + * \return The fragment. + * \pre has_fragment() + */ + string_view fragment() const noexcept; + + /** + * \brief Tests whether this URI has a valid authority. + * \return \c true if the URI has an authority, \c false otherwise. + */ + bool has_authority() const noexcept; + + /** + * \brief Returns the URI authority. + * \return The authority. + */ + string_view authority() const noexcept; + + /** + * \brief Returns the URI as a std::basic_string object. + * \return A URI string. + */ + template , + class Allocator = std::allocator > + std::basic_string to_string( + const Allocator &alloc = Allocator()) const { + return std::basic_string(begin(), end()); + } + + /** + * \brief Returns the URI as a std::string object. + * \returns A URI string. + */ + std::string string() const; + + /** + * \brief Returns the URI as a std::wstring object. + * \returns A URI string. + */ + std::wstring wstring() const; + + /** + * \brief Returns the URI as a std::u16string object. + * \returns A URI string. + */ + std::u16string u16string() const; + + /** + * \brief Returns the URI as a std::u32string object. + * \returns A URI string. + */ + std::u32string u32string() const; + + /** + * \brief Checks if the uri object is empty, i.e. it has no parts. + * \returns \c true if there are no parts, \c false otherwise. + */ + bool empty() const noexcept; + + /** + * \brief Checks if the uri is absolute, i.e. it has a scheme. + * \returns \c true if it is absolute, \c false if it is relative. + */ + bool is_absolute() const noexcept; + + /** + * \brief Checks if the uri is opaque, i.e. if it doesn't have an + * authority. + * \returns \c true if it is opaque, \c false if it is hierarchical. + */ + bool is_opaque() const noexcept; + + /** + * \brief Normalizes a uri object at a given level in the + * comparison ladder. + * \param level The comparison level. + * \returns A normalized uri. + * \post compare(normalize(uri, level), level) == 0 + * \throws std::bad_alloc + */ + uri normalize(uri_comparison_level level) const; + + /** + * \brief Returns a relative reference against the base URI. + * \param base The base URI. + * \returns A relative reference of this URI against the base. + * \throws std::bad_alloc + */ + uri make_relative(const uri &base) const; + + /** + * \brief Resolves a relative reference against the given URI. + * \param base The base URI to resolve against. + * \returns An absolute URI. + * \throws std::bad_alloc + */ + uri resolve(const uri &base) const; + + /** + * \brief Compares this URI against another, corresponding to the + * level in the comparison ladder. + * \param other The other URI. + * \param level The level in the comparison ladder. + * \returns \c 0 if the URIs are considered equal, \c -1 if this is + * less than other and and 1 if this is greater than + * other. + */ + int compare(const uri &other, uri_comparison_level level) const noexcept; + + /** + * \brief Encodes a sequence according to the rules for encoding a + * user info part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_user_info(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_user_info(first, last, out); + } + + /** + * \brief Encodes a sequence according to the rules for encoding a + * host part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_host(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_host(first, last, out); + } + + /** + * \brief Encodes a sequence according to the rules for encoding a + * port part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_port(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_port(first, last, out); + } + + /** + * \brief Encodes a sequence according to the rules for encoding a + * path part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_path(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_path(first, last, out); + } + + /** + * \brief Encodes a sequence according to the rules for encoding a + * query part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_query(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_query(first, last, out); + } + + /** + * \brief Encodes a sequence according to the rules for encoding a + * fragment part. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter encode_fragment(InputIter first, InputIter last, + OutputIter out) { + return detail::encode_fragment(first, last, out); + } + + /** + * \brief Decodes a sequence according to the percent decoding + * rules. + * \param first The iterator at first element in the input + * sequence. + * \param last The iterator at end + 1th element in the input + * sequence. + * \param out The iterator at the first element in the output + * sequence. + * \returns The iterator at the end + 1th in the output sequence. + */ + template + static OutputIter decode(InputIter first, InputIter last, OutputIter out) { + return detail::decode(first, last, out); + } + + private: + bool initialize(const string_type &uri); + + void initialize(optional scheme, optional user_info, + optional host, optional port, + optional path, optional query, + optional fragment); + + string_type uri_; + string_view uri_view_; + detail::uri_parts uri_parts_; +}; + +/** + * \brief \c uri factory function. + * \param first The first element in a string sequence. + * \param last The end + 1th element in a string sequence. + * \param ec Error code set if the sequence is not a valid URI. + */ +template +inline uri make_uri(InputIter first, InputIter last, std::error_code &ec) { + return uri(first, last, ec); +} + +/** + * \brief \c uri factory function. + * \param source A source string that is to be parsed as a URI. + * \param ec Error code set if the source is not a valid URI. + */ +template +inline uri make_uri(const Source &source, std::error_code &ec) { + return uri(source, ec); +} + +/** + * \brief Swaps one uri object with another. + */ +void swap(uri &lhs, uri &rhs) noexcept; + +/** +* \brief Equality operator for the \c uri. +*/ +bool operator==(const uri &lhs, const uri &rhs) noexcept; + +/** + * \brief Equality operator for the \c uri. + */ +bool operator==(const uri &lhs, const char *rhs) noexcept; + +/** + * \brief Equality operator for the \c uri. + */ +inline bool operator==(const char *lhs, const uri &rhs) noexcept { + return rhs == lhs; +} + +/** + * \brief Inequality operator for the \c uri. + */ +inline bool operator!=(const uri &lhs, const uri &rhs) noexcept { + return !(lhs == rhs); +} + +/** + * \brief Less-than operator for the \c uri. + */ +bool operator<(const uri &lhs, const uri &rhs) noexcept; + +/** + * \brief Greater-than operator for the \c uri. + */ +inline bool operator>(const uri &lhs, const uri &rhs) noexcept { + return rhs < lhs; +} + +/** + * \brief Less-than-or-equal-to operator for the \c uri. + */ +inline bool operator<=(const uri &lhs, const uri &rhs) noexcept { + return !(rhs < lhs); +} + +/** + * \brief Greater-than-or-equal-to operator for the \c uri. + */ +inline bool operator>=(const uri &lhs, const uri &rhs) noexcept { + return !(lhs < rhs); +} +} // namespace network + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +namespace std { +template <> +struct is_error_code_enum : public true_type {}; +} // namespace std + +namespace std { +template <> +struct hash { + std::size_t operator()(const network::uri &uri_) const { + std::size_t seed = 0; + std::for_each(std::begin(uri_), std::end(uri_), + [&seed](network::uri::value_type v) { + std::hash hasher; + seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + }); + return seed; + } +}; +} // namespace std +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +#ifdef NETWORK_URI_MSVC +#pragma warning(pop) +#endif + +#include + +#endif // NETWORK_URI_INC diff --git a/CrowLeer/cpp-netlib/network/uri/uri_builder.hpp b/CrowLeer/cpp-netlib/network/uri/uri_builder.hpp new file mode 100644 index 0000000..fd73e30 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/uri_builder.hpp @@ -0,0 +1,267 @@ +// Copyright (c) Glyn Matthews 2012-2016. +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * \file + * \brief Contains the definition of the uri_builder. + */ + +#ifndef NETWORK_URI_BUILDER_INC +#define NETWORK_URI_BUILDER_INC + +#include +#include +#include +#include + +#ifdef NETWORK_URI_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +namespace network { +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +namespace detail { + +template +struct host_converter { + uri::string_type operator()(const T &host) const { + return detail::translate(host); + } +}; + +template +struct port_converter { + uri::string_type operator()(const T &port) const { + return detail::translate(port); + } +}; + +template +struct port_converter::type>::value>::type> { + uri::string_type operator()(std::uint16_t port) const { + return std::to_string(port); + } +}; + +template +struct path_converter { + uri::string_type operator()(const T &path) const { + return detail::translate(path); + } +}; +} // namespace detail +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + +/** + * \ingroup uri + * \class uri_builder network/uri/uri_builder.hpp network/uri.hpp + * \brief A class that allows complex uri objects to be constructed. + * \sa uri + */ +class uri_builder { +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + friend class uri; +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + + uri_builder(const uri_builder &) = delete; + uri_builder &operator=(const uri_builder &) = delete; + + public: + /** + * \brief The uri_builder string_type. + */ + using string_type = network::uri::string_type; + + /** + * \brief Constructor. + */ + uri_builder() = default; + + /** + * \brief Constructor. + * \param base A URI that is the base on which a new URI is built. + */ + explicit uri_builder(const uri &base); + + /** + * \brief Destructor. + */ + ~uri_builder() noexcept; + + /** + * \brief Adds a new scheme to the uri_builder. + * \param scheme The scheme. + * \returns \c *this + */ + template + uri_builder &scheme(const Source &scheme) { + set_scheme(detail::translate(scheme)); + return *this; + } + + /** + * \brief Adds a new user info to the uri_builder. + * \param user_info The user info. + * \returns \c *this + */ + template + uri_builder &user_info(const Source &user_info) { + set_user_info(detail::translate(user_info)); + return *this; + } + + /** + * \brief Clears the URI user_info part. + * \returns \c *this + */ + uri_builder &clear_user_info(); + + /** + * \brief Adds a new host to the uri_builder. + * \param host The host. + * \returns \c *this + */ + template + uri_builder &host(const Source &host) { + detail::host_converter convert; + set_host(convert(host)); + return *this; + } + + /** + * \brief Adds a new port to the uri_builder. + * \param port The port. + * \returns \c *this + */ + template + uri_builder &port(const Source &port) { + detail::port_converter convert; + set_port(convert(port)); + return *this; + } + + /** + * \brief Clears the URI port part. + * \returns \c *this + */ + uri_builder &clear_port(); + + /** + * \brief Adds a new authority to the uri_builder. + * \param authority The authority. + * \returns \c *this + */ + template + uri_builder &authority(const Source &authority) { + set_authority(detail::translate(authority)); + return *this; + } + + /** + * \brief Adds a new path to the uri_builder. + * \param path The path. + * \returns \c *this + */ + template + uri_builder &path(const Source &path) { + detail::path_converter convert; + set_path(convert(path)); + return *this; + } + + /** + * \brief Clears the URI path part. + * \returns \c *this + */ + uri_builder &clear_path(); + + /** + * \brief Adds a new query to the uri_builder. + * \param query The query. + * \returns \c *this + */ + template + uri_builder &append_query(const Source &query) { + append_query(detail::translate(query)); + return *this; + } + + /** + * \brief Clears the URI query part. + * \returns \c *this + */ + uri_builder &clear_query(); + + /** + * \brief Adds a new query to the uri_builder. + * \param key The query key. + * \param value The query value. + * \returns \c *this + */ + template + uri_builder &append_query_key_value_pair(const Key &key, const Value &value) { + if (!query_) { + query_ = string_type(); + } + else { + query_->append("&"); + } + string_type query_pair = detail::translate(key) + "=" + detail::translate(value); + network::uri::encode_query(std::begin(query_pair), std::end(query_pair), + std::back_inserter(*query_)); + return *this; + } + + /** + * \brief Adds a new fragment to the uri_builder. + * \param fragment The fragment. + * \returns \c *this + */ + template + uri_builder &fragment(const Source &fragment) { + set_fragment(detail::translate(fragment)); + return *this; + } + + /** + * \brief Clears the URI fragment part. + * \returns \c *this + */ + uri_builder &clear_fragment(); + + /** + * \brief Builds a new uri object. + * \returns A valid uri object. + * \throws uri_builder_error if the uri_builder is unable to build + * a valid URI. + * \throws std::bad_alloc If the underlying string cannot be + * allocated. + */ + network::uri uri() const; + + private: + void set_scheme(string_type scheme); + void set_user_info(string_type user_info); + void set_host(string_type host); + void set_port(string_type port); + void set_authority(string_type authority); + void set_path(string_type path); + void append_query(string_type query); + void set_fragment(string_type fragment); + + optional scheme_, user_info_, host_, port_, path_, query_, + fragment_; +}; +} // namespace network + +#ifdef NETWORK_URI_MSVC +#pragma warning(pop) +#endif + +#endif // NETWORK_URI_BUILDER_INC diff --git a/CrowLeer/cpp-netlib/network/uri/uri_errors.hpp b/CrowLeer/cpp-netlib/network/uri/uri_errors.hpp new file mode 100644 index 0000000..a192533 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/uri_errors.hpp @@ -0,0 +1,122 @@ +// Copyright 2013-2016 Glyn Matthews. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef NETWORK_URI_ERRORS_INC +#define NETWORK_URI_ERRORS_INC + +/** + * \file + * \brief Contains functions and exceptions for URI error handling. + */ + +#include +#include + +#ifdef NETWORK_URI_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) + // Disable C4275 too because it's "essentially noise and can be silenced" + // according to Stephen T. Lavavej at Microsoft. See: + // https://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports. +# pragma warning(disable : 4275) +#endif + +namespace network { + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + enum class uri_error { + + // parser errors + invalid_syntax = 1, + + // builder errors + invalid_uri, + invalid_scheme, + invalid_user_info, + invalid_host, + invalid_port, + invalid_path, + invalid_query, + invalid_fragment, + + // encoding errors + not_enough_input, + non_hex_input, + conversion_failed, + }; + + const std::error_category &uri_category(); + + std::error_code make_error_code(uri_error e); +#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS) + + /** + * \class uri_syntax_error uri.hpp network/uri.hpp + * \brief An exception thrown by the \c uri constructor when a URI + * cannot be parsed. + */ + class uri_syntax_error : public std::system_error { + + public: + + /** + * \brief Constructor. + */ + uri_syntax_error(); + + /** + * \brief Destructor. + */ + virtual ~uri_syntax_error() noexcept; + + }; + + /** + * \class uri_builder_error uri.hpp network/uri.hpp + * \brief An exception thrown when the \c uri_builder cannot build a + * valid URI. + */ + class uri_builder_error : public std::system_error { + + public: + + /** + * \brief Constructor. + */ + uri_builder_error(); + + /** + * \brief Destructor. + */ + virtual ~uri_builder_error() noexcept; + + }; + + /** + * \class percent_decoding_error uri.hpp network/uri.hpp + * \brief An exception thrown when during percent decoding. + */ + class percent_decoding_error : public std::system_error { + + public: + + /** + * \brief Constructor. + */ + explicit percent_decoding_error(uri_error error); + + /** + * \brief Destructor. + */ + virtual ~percent_decoding_error() noexcept; + + }; +} // namespace network + +#ifdef NETWORK_URI_MSVC +#pragma warning(pop) +#endif + +#endif // NETWORK_URI_ERRORS_INC diff --git a/CrowLeer/cpp-netlib/network/uri/uri_io.hpp b/CrowLeer/cpp-netlib/network/uri/uri_io.hpp new file mode 100644 index 0000000..cb9b243 --- /dev/null +++ b/CrowLeer/cpp-netlib/network/uri/uri_io.hpp @@ -0,0 +1,62 @@ +// Copyright (c) Glyn Matthews 2011-2016 +// Copyright 2012 Dean Michael Berris +// Copyright 2012 Google, Inc. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * \file + * \brief Defines stream overloads for the uri class. + */ + +#ifndef NETWORK_URI_URI_IO_INC +#define NETWORK_URI_URI_IO_INC + +#include +#include +#include + +namespace network { +#if !defined(NETWORK_URI_MSVC) +template > +std::basic_ostream &operator<<( + std::basic_ostream &os, const uri &uri_) { + return os << uri_.to_string(); +} + +template > +std::basic_istream &operator>>( + std::basic_istream &is, uri &uri_) { + std::basic_string uri_string; + is >> uri_string; + uri_ = uri(uri_string); + return is; +} +#else +inline std::ostream &operator<<(std::ostream &os, const uri &uri_) { + return os << uri_.string(); +} + +inline std::wostream &operator<<(std::wostream &os, const uri &uri_) { + return os << uri_.wstring(); +} + +inline std::istream &operator>>(std::istream &is, uri &uri_) { + std::string uri_string; + is >> uri_string; + uri_ = uri(uri_string); + return is; +} + +inline std::wistream &operator>>(std::wistream &is, uri &uri_) { + std::wstring uri_string; + is >> uri_string; + uri_ = uri(uri_string); + return is; +} +#endif // !defined(NETWORK_URI_MSVC) + +} // namespace network + +#endif // NETWORK_URI_URI_IO_INC diff --git a/CrowLeer/curl/LICENSE.txt b/CrowLeer/curl/LICENSE.txt new file mode 100644 index 0000000..976cd1b --- /dev/null +++ b/CrowLeer/curl/LICENSE.txt @@ -0,0 +1,11 @@ +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2017, Daniel Stenberg, daniel@haxx.se, and many contributors, see the THANKS file. + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +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 OF THIRD PARTY RIGHTS. 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. + +Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. \ No newline at end of file diff --git a/CrowLeer/curl/curl.h b/CrowLeer/curl/curl.h index 82fb8ae..9ad5c20 100644 --- a/CrowLeer/curl/curl.h +++ b/CrowLeer/curl/curl.h @@ -74,6 +74,7 @@ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ + defined(__CYGWIN__) || \ (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) #include #endif @@ -132,6 +133,27 @@ typedef int curl_socket_t; #define curl_socket_typedef #endif /* curl_socket_typedef */ +/* enum for the different supported SSL backends */ +typedef enum { + CURLSSLBACKEND_NONE = 0, + CURLSSLBACKEND_OPENSSL = 1, + CURLSSLBACKEND_GNUTLS = 2, + CURLSSLBACKEND_NSS = 3, + CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ + CURLSSLBACKEND_GSKIT = 5, + CURLSSLBACKEND_POLARSSL = 6, + CURLSSLBACKEND_WOLFSSL = 7, + CURLSSLBACKEND_SCHANNEL = 8, + CURLSSLBACKEND_DARWINSSL = 9, + CURLSSLBACKEND_AXTLS = 10, + CURLSSLBACKEND_MBEDTLS = 11 +} curl_sslbackend; + +/* aliases for library clones and renames */ +#define CURLSSLBACKEND_LIBRESSL CURLSSLBACKEND_OPENSSL +#define CURLSSLBACKEND_BORINGSSL CURLSSLBACKEND_OPENSSL +#define CURLSSLBACKEND_CYASSL CURLSSLBACKEND_WOLFSSL + struct curl_httppost { struct curl_httppost *next; /* next entry in the list */ char *name; /* pointer to allocated name */ @@ -335,7 +357,7 @@ typedef size_t (*curl_read_callback)(char *buffer, size_t nitems, void *instream); -typedef enum { +typedef enum { CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ CURLSOCKTYPE_LAST /* never use */ @@ -377,7 +399,7 @@ typedef enum { CURLIOE_LAST /* never use */ } curlioerr; -typedef enum { +typedef enum { CURLIOCMD_NOP, /* no operation */ CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ CURLIOCMD_LAST /* never use */ @@ -1788,6 +1810,12 @@ typedef enum { /* bitmask of allowed auth methods for connections to SOCKS5 proxies */ CINIT(SOCKS5_AUTH, LONG, 267), + /* Enable/disable SSH compression */ + CINIT(SSH_COMPRESSION, LONG, 268), + + /* Post MIME data. */ + CINIT(MIMEPOST, OBJECTPOINT, 269), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -1934,15 +1962,140 @@ typedef enum { CURL_TIMECOND_LAST } curl_TimeCond; +/* Special size_t value signaling a zero-terminated string. */ +#define CURL_ZERO_TERMINATED ((size_t) -1) /* curl_strequal() and curl_strnequal() are subject for removal in a future - libcurl, see lib/README.curlx for details + release */ +CURL_EXTERN int curl_strequal(const char *s1, const char *s2); +CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n); + +/* Mime/form handling support. */ +typedef struct curl_mime_s curl_mime; /* Mime context. */ +typedef struct curl_mimepart_s curl_mimepart; /* Mime part context. */ + +/* + * NAME curl_mime_init() + * + * DESCRIPTION + * + * Create a mime context and return its handle. The easy parameter is the + * target handle. + */ +CURL_EXTERN curl_mime *curl_mime_init(CURL *easy); + +/* + * NAME curl_mime_free() + * + * DESCRIPTION + * + * release a mime handle and its substructures. + */ +CURL_EXTERN void curl_mime_free(curl_mime *mime); + +/* + * NAME curl_mime_addpart() + * + * DESCRIPTION + * + * Append a new empty part to the given mime context and return a handle to + * the created part. + */ +CURL_EXTERN curl_mimepart *curl_mime_addpart(curl_mime *mime); + +/* + * NAME curl_mime_name() + * + * DESCRIPTION + * + * Set mime/form part name. + */ +CURL_EXTERN CURLcode curl_mime_name(curl_mimepart *part, const char *name); + +/* + * NAME curl_mime_filename() + * + * DESCRIPTION + * + * Set mime part remote file name. + */ +CURL_EXTERN CURLcode curl_mime_filename(curl_mimepart *part, + const char *filename); + +/* + * NAME curl_mime_type() + * + * DESCRIPTION + * + * Set mime part type. + */ +CURL_EXTERN CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype); + +/* + * NAME curl_mime_encoder() + * + * DESCRIPTION + * + * Set mime data transfer encoder. + */ +CURL_EXTERN CURLcode curl_mime_encoder(curl_mimepart *part, + const char *encoding); + +/* + * NAME curl_mime_data() + * + * DESCRIPTION + * + * Set mime part data source from memory data, + */ +CURL_EXTERN CURLcode curl_mime_data(curl_mimepart *part, + const char *data, size_t datasize); + +/* + * NAME curl_mime_filedata() + * + * DESCRIPTION + * + * Set mime part data source from named file. + */ +CURL_EXTERN CURLcode curl_mime_filedata(curl_mimepart *part, + const char *filename); + +/* + * NAME curl_mime_data_cb() + * + * DESCRIPTION + * + * Set mime part data source from callback function. + */ +CURL_EXTERN CURLcode curl_mime_data_cb(curl_mimepart *part, + curl_off_t datasize, + curl_read_callback readfunc, + curl_seek_callback seekfunc, + curl_free_callback freefunc, + void *arg); - !checksrc! disable SPACEBEFOREPAREN 2 -*/ -CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2); -CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n); +/* + * NAME curl_mime_subparts() + * + * DESCRIPTION + * + * Set mime part data source from subparts. + */ +CURL_EXTERN CURLcode curl_mime_subparts(curl_mimepart *part, + curl_mime *subparts); +/* + * NAME curl_mime_headers() + * + * DESCRIPTION + * + * Set mime part headers. + */ +CURL_EXTERN CURLcode curl_mime_headers(curl_mimepart *part, + struct curl_slist *headers, + int take_ownership); +/* Old form API. */ /* name is uppercase CURLFORM_ */ #ifdef CFINIT #undef CFINIT @@ -2184,6 +2337,47 @@ struct curl_slist { struct curl_slist *next; }; +/* + * NAME curl_global_sslset() + * + * DESCRIPTION + * + * When built with multiple SSL backends, curl_global_sslset() allows to + * choose one. This function can only be called once, and it must be called + * *before* curl_global_init(). + * + * The backend can be identified by the id (e.g. CURLSSLBACKEND_OPENSSL). The + * backend can also be specified via the name parameter (passing -1 as id). + * If both id and name are specified, the name will be ignored. If neither id + * nor name are specified, the function will fail with + * CURLSSLSET_UNKNOWN_BACKEND and set the "avail" pointer to the + * NULL-terminated list of available backends. + * + * Upon success, the function returns CURLSSLSET_OK. + * + * If the specified SSL backend is not available, the function returns + * CURLSSLSET_UNKNOWN_BACKEND and sets the "avail" pointer to a NULL-terminated + * list of available SSL backends. + * + * The SSL backend can be set only once. If it has already been set, a + * subsequent attempt to change it will result in a CURLSSLSET_TOO_LATE. + */ + +typedef struct { + curl_sslbackend id; + const char *name; +} curl_ssl_backend; + +typedef enum { + CURLSSLSET_OK = 0, + CURLSSLSET_UNKNOWN_BACKEND, + CURLSSLSET_TOO_LATE, + CURLSSLSET_NO_BACKENDS /* libcurl was built without any SSL support */ +} CURLsslset; + +CURL_EXTERN CURLsslset curl_global_sslset(curl_sslbackend id, const char *name, + const curl_ssl_backend ***avail); + /* * NAME curl_slist_append() * @@ -2224,27 +2418,6 @@ struct curl_certinfo { format "name: value" */ }; -/* enum for the different supported SSL backends */ -typedef enum { - CURLSSLBACKEND_NONE = 0, - CURLSSLBACKEND_OPENSSL = 1, - CURLSSLBACKEND_GNUTLS = 2, - CURLSSLBACKEND_NSS = 3, - CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */ - CURLSSLBACKEND_GSKIT = 5, - CURLSSLBACKEND_POLARSSL = 6, - CURLSSLBACKEND_CYASSL = 7, - CURLSSLBACKEND_SCHANNEL = 8, - CURLSSLBACKEND_DARWINSSL = 9, - CURLSSLBACKEND_AXTLS = 10, - CURLSSLBACKEND_MBEDTLS = 11 -} curl_sslbackend; - -/* aliases for library clones and renames */ -#define CURLSSLBACKEND_LIBRESSL 1 -#define CURLSSLBACKEND_BORINGSSL 1 -#define CURLSSLBACKEND_WOLFSSL 6 - /* Information about the SSL library used and the respective internal SSL handle, which can be used to obtain further information regarding the connection. Asked for with CURLINFO_TLS_SSL_PTR or CURLINFO_TLS_SESSION. */ @@ -2341,7 +2514,7 @@ typedef enum { CURLCLOSEPOLICY_LAST /* last, never use this */ } curl_closepolicy; -#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_SSL (1<<0) /* no purpose since since 7.57.0 */ #define CURL_GLOBAL_WIN32 (1<<1) #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) #define CURL_GLOBAL_NOTHING 0 @@ -2419,6 +2592,7 @@ typedef enum { CURLVERSION_SECOND, CURLVERSION_THIRD, CURLVERSION_FOURTH, + CURLVERSION_FIFTH, CURLVERSION_LAST /* never actually use this */ } CURLversion; @@ -2427,7 +2601,7 @@ typedef enum { meant to be a built-in version number for what kind of struct the caller expects. If the struct ever changes, we redefine the NOW to another enum from above. */ -#define CURLVERSION_NOW CURLVERSION_FOURTH +#define CURLVERSION_NOW CURLVERSION_FIFTH typedef struct { CURLversion age; /* age of the returned struct */ @@ -2455,6 +2629,12 @@ typedef struct { const char *libssh_version; /* human readable string */ + /* These fields were added in CURLVERSION_FIFTH */ + + unsigned int brotli_ver_num; /* Numeric Brotli version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + const char *brotli_version; /* human readable string. */ + } curl_version_info_data; #define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ @@ -2484,6 +2664,8 @@ typedef struct { #define CURL_VERSION_PSL (1<<20) /* Mozilla's Public Suffix List, used for cookie domain verification */ #define CURL_VERSION_HTTPS_PROXY (1<<21) /* HTTPS-proxy support built-in */ +#define CURL_VERSION_MULTI_SSL (1<<22) /* Multiple SSL backends available */ +#define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */ /* * NAME curl_version_info() diff --git a/CrowLeer/curl/curlver.h b/CrowLeer/curl/curlver.h index f3cc1ea..30b1463 100644 --- a/CrowLeer/curl/curlver.h +++ b/CrowLeer/curl/curlver.h @@ -30,13 +30,13 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.55.1" +#define LIBCURL_VERSION "7.57.0" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 -#define LIBCURL_VERSION_MINOR 55 -#define LIBCURL_VERSION_PATCH 1 +#define LIBCURL_VERSION_MINOR 57 +#define LIBCURL_VERSION_PATCH 0 /* This is the numeric version of the libcurl version number, meant for easier parsing and comparions by programs. The LIBCURL_VERSION_NUM define will @@ -57,7 +57,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x073701 +#define LIBCURL_VERSION_NUM 0x073900 /* * This is the date and time when the full source package was created. The @@ -68,7 +68,7 @@ * * "2007-11-23" */ -#define LIBCURL_TIMESTAMP "2017-08-14" +#define LIBCURL_TIMESTAMP "2017-11-29" #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) #define CURL_AT_LEAST_VERSION(x,y,z) \ diff --git a/CrowLeer/curl/libcurl_a.lib b/CrowLeer/curl/libcurl_a.lib index 617267d..8b93a4f 100644 Binary files a/CrowLeer/curl/libcurl_a.lib and b/CrowLeer/curl/libcurl_a.lib differ diff --git a/CrowLeer/curl/libcurl_a_debug.lib b/CrowLeer/curl/libcurl_a_debug.lib new file mode 100644 index 0000000..b39ded4 Binary files /dev/null and b/CrowLeer/curl/libcurl_a_debug.lib differ diff --git a/CrowLeer/curl/multi.h b/CrowLeer/curl/multi.h index f93e511..911c91d 100644 --- a/CrowLeer/curl/multi.h +++ b/CrowLeer/curl/multi.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms diff --git a/CrowLeer/curl/system.h b/CrowLeer/curl/system.h index 95c72d9..39dae75 100644 --- a/CrowLeer/curl/system.h +++ b/CrowLeer/curl/system.h @@ -52,226 +52,171 @@ #if defined(__DJGPP__) || defined(__GO32__) # if defined(__DJGPP__) && (__DJGPP__ > 1) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__SALFORDC__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__BORLANDC__) # if (__BORLANDC__ < 0x520) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # endif # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__TURBOC__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__WATCOMC__) # if defined(__386__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__POCC__) # if (__POCC__ < 280) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # elif defined(_MSC_VER) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__LCC__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__SYMBIAN32__) # if defined(__EABI__) /* Treat all ARM compilers equally */ -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__CW32__) # pragma longlong on -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__VC32__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__MWERKS__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(_WIN32_WCE) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__MINGW32__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_WS2TCPIP_H 1 #elif defined(__VMS) # if defined(__VAX) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__OS400__) # if defined(__ILEC400__) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 # endif @@ -279,34 +224,28 @@ #elif defined(__MVS__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 # elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 # endif # if defined(_LONG_LONG) # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(_LP64) # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 # endif @@ -314,56 +253,45 @@ #elif defined(__370__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 # elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 # endif # if defined(_LONG_LONG) # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(_LP64) # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 # endif #elif defined(TPF) -# define CURL_SIZEOF_LONG 8 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 #elif defined(__TINYC__) /* also known as tcc */ -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t @@ -373,25 +301,20 @@ #elif defined(__SUNPRO_C) /* Oracle Solaris Studio */ # if !defined(__LP64) && (defined(__ILP32) || \ defined(__i386) || defined(__sparcv8)) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__LP64) || \ defined(__amd64) || defined(__sparcv9) -# define CURL_SIZEOF_LONG 8 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 @@ -401,62 +324,51 @@ #elif defined(_MSC_VER) # if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T __int64 # define CURL_FORMAT_CURL_OFF_T "I64d" # define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # else -# define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 /* ===================================== */ /* KEEP GENERIC GCC THE LAST ENTRY */ /* ===================================== */ #elif defined(__GNUC__) -# if !defined(__LP64__) && (defined(__ILP32__) || \ - defined(__i386__) || defined(__powerpc__) || defined(__arm__) || \ - defined(__sparc__) || defined(__mips__) || defined(__sh__) || \ - defined(__XTENSA__) || (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4)) -# define CURL_SIZEOF_LONG 4 +# if !defined(__LP64__) && \ + (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \ + defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ + defined(__sparc__) || defined(__mips__) || defined(__sh__) || \ + defined(__XTENSA__) || \ + (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4)) # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__LP64__) || \ defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \ (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) -# define CURL_SIZEOF_LONG 8 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 #else /* generic "safe guess" on old 32 bit style */ -# define CURL_SIZEOF_LONG 4 -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" @@ -465,6 +377,12 @@ # define CURL_TYPEOF_CURL_SOCKLEN_T int #endif +#ifdef _AIX +/* AIX needs */ +#define CURL_PULL_SYS_POLL_H +#endif + + /* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */ /* ws2tcpip.h is required here to properly make type definitions below. */ #ifdef CURL_PULL_WS2TCPIP_H @@ -485,6 +403,12 @@ # include #endif +/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */ +/* sys/poll.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_POLL_H +# include +#endif + /* Data type definition of curl_socklen_t. */ #ifdef CURL_TYPEOF_CURL_SOCKLEN_T typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; diff --git a/CrowLeer/curl/typecheck-gcc.h b/CrowLeer/curl/typecheck-gcc.h index 7454824..10c74c7 100644 --- a/CrowLeer/curl/typecheck-gcc.h +++ b/CrowLeer/curl/typecheck-gcc.h @@ -96,6 +96,9 @@ __extension__ ({ \ if((_curl_opt) == CURLOPT_HTTPPOST) \ if(!_curl_is_arr((value), struct curl_httppost)) \ _curl_easy_setopt_err_curl_httpost(); \ + if((_curl_opt) == CURLOPT_MIMEPOST) \ + if(!_curl_is_ptr((value), curl_mime)) \ + _curl_easy_setopt_err_curl_mimepost(); \ if(_curl_is_slist_option(_curl_opt)) \ if(!_curl_is_arr((value), struct curl_slist)) \ _curl_easy_setopt_err_curl_slist(); \ @@ -200,6 +203,9 @@ _CURL_WARNING(_curl_easy_setopt_err_postfields, _CURL_WARNING(_curl_easy_setopt_err_curl_httpost, "curl_easy_setopt expects a 'struct curl_httppost *' " "argument for this option") +_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost, + "curl_easy_setopt expects a 'curl_mime *' " + "argument for this option") _CURL_WARNING(_curl_easy_setopt_err_curl_slist, "curl_easy_setopt expects a 'struct curl_slist *' argument for this option") _CURL_WARNING(_curl_easy_setopt_err_CURLSH, diff --git a/CrowLeer/main.cpp b/CrowLeer/main.cpp index 98c7b26..a3050f7 100644 --- a/CrowLeer/main.cpp +++ b/CrowLeer/main.cpp @@ -91,261 +91,266 @@ void doWork(unordered_set& urls, queue& todo, uri base) int main(int argc, char *argv[]) { - //Condition to use the -s flag - bool sameDomain = false; - - //Variable for the command line options management - char opt=0; - - //Default value of the saved files path - fs::path directory; - pathString = fs::current_path().string(); - - /* getopt_long stores the option index here. */ - static struct option long_options[] = - { - { "help", no_argument, 0, 'h' }, - { "url", required_argument, 0, 'u' }, - { "threads", required_argument, 0, 't' }, - { "depth", required_argument, 0, 'd' }, - { "same-domain", required_argument, 0, 'x' }, - { "save", required_argument, 0, 'S' }, - { "output", required_argument, 0, 'o' }, - { "f-global", required_argument, 0, 'f' }, - { "f-protocol", required_argument, 0, 'f' }, - { "f-domain", required_argument, 0, 'f' }, - { "f-path", required_argument, 0, 'f' }, - { "f-filename", required_argument, 0, 'f' }, - { "f-extension", required_argument, 0, 'f' }, - { "f-querystring", required_argument, 0, 'f' }, - { "f-anchor", required_argument, 0, 'f' }, - { "s-global", required_argument, 0, 's' }, - { "s-protocol", required_argument, 0, 's' }, - { "s-domain", required_argument, 0, 's' }, - { "s-path", required_argument, 0, 's' }, - { "s-filename", required_argument, 0, 's' }, - { "s-extension", required_argument, 0, 's' }, - { "s-querystring", required_argument, 0, 's' }, - { "s-anchor", required_argument, 0, 's' }, - { 0, 0, 0, 0 } - }; - - while (opt != -1) - { - int option_index = 0; - - opt = getopt_long(argc, argv, "hu:xSo:t:d:f:s:", long_options, &option_index); - - /* Detect the end of the options. */ - if (opt == -1) - break; - - switch (opt) - { - case 'h': - { - cout << HELP_MSG << endl; - return 0; - break; - } - case 'u': - { - cout << "Selected URL: " << optarg << endl; - url.append(optarg); - break; - } - case 't': - { - cout << "Threads number: " << optarg << endl; - thrnum = atoi(optarg); - break; - } - case 'd': - { - cout << "Maximum depth: " << optarg << endl; - maxdepth = atoi(optarg); - break; - } - case 'x': - { - sameDomain = true; - cout << "Same domain rule applied" << endl; - break; - } - case 'S': - { - save = true; - cout << "Activate Save rule applied" << endl; - break; - } - case 'o': - { - pathString.clear(); - pathString.append(optarg); - cout << "Output directory for saved files changed to " << optarg << endl; - break; - } - case 'f': - { - if (long_options[option_index].name == "f-global") - { - followCondition.global = optarg; - cout << "Global Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-protocol") - { - followCondition.protocol = optarg; - cout << "Protocol Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-domain") - { - followCondition.domain = optarg; - cout << "Domain Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-path") - { - followCondition.path = optarg; - cout << "Path Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-filename") - { - followCondition.filename = optarg; - cout << "Filename Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-extension") - { - followCondition.extension = optarg; - cout << "Extension Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-querystring") - { - followCondition.querystring = optarg; - cout << "Querystring Follow rule: " << optarg << endl; - } - else if (long_options[option_index].name == "f-anchor") - { - followCondition.anchor = optarg; - cout << "Anchor Follow rule: " << optarg << endl; - } - break; - } - case 's': - { - if (long_options[option_index].name == "s-global") - { - saveCondition.global = optarg; - cout << "Global Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-protocol") - { - saveCondition.protocol = optarg; - cout << "Protocol save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-domain") - { - saveCondition.domain = optarg; - cout << "Domain Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-path") - { - saveCondition.path = optarg; - cout << "Path Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-filename") - { - saveCondition.filename = optarg; - cout << "Filename Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-extension") - { - saveCondition.extension = optarg; - cout << "Extension Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-querystring") - { - saveCondition.querystring = optarg; - cout << "Querystring Save rule: " << optarg << endl; - } - else if (long_options[option_index].name == "s-anchor") - { - saveCondition.anchor = optarg; - cout << "Anchor Save rule: " << optarg << endl; - } - break; - } - case ':': - { - cout << "Missing value for option -" << (char)optopt << endl; - return 0; - break; - } - case '?': - default: - return 0; - } - } - if (optind < argc) - { - cout << "Illegal non-option arguments: "; - while (optind < argc) - cout << argv[optind++] << " "; - cout << "\n\n" << HELP_MSG << endl; - return 0; - } - - if (url.empty()) - { - cout << "URL: "; - cin >> url; - } - - cout << endl; - - url = validate(url); + ////Condition to use the -s flag + //bool sameDomain = false; + + ////Variable for the command line options management + //char opt=0; + + ////Default value of the saved files path + //fs::path directory; + //pathString = fs::current_path().string(); + + ///* getopt_long stores the option index here. */ + //static struct option long_options[] = + //{ + // { "help", no_argument, 0, 'h' }, + // { "url", required_argument, 0, 'u' }, + // { "threads", required_argument, 0, 't' }, + // { "depth", required_argument, 0, 'd' }, + // { "same-domain", required_argument, 0, 'x' }, + // { "save", required_argument, 0, 'S' }, + // { "output", required_argument, 0, 'o' }, + // { "f-global", required_argument, 0, 'f' }, + // { "f-protocol", required_argument, 0, 'f' }, + // { "f-domain", required_argument, 0, 'f' }, + // { "f-path", required_argument, 0, 'f' }, + // { "f-filename", required_argument, 0, 'f' }, + // { "f-extension", required_argument, 0, 'f' }, + // { "f-querystring", required_argument, 0, 'f' }, + // { "f-anchor", required_argument, 0, 'f' }, + // { "s-global", required_argument, 0, 's' }, + // { "s-protocol", required_argument, 0, 's' }, + // { "s-domain", required_argument, 0, 's' }, + // { "s-path", required_argument, 0, 's' }, + // { "s-filename", required_argument, 0, 's' }, + // { "s-extension", required_argument, 0, 's' }, + // { "s-querystring", required_argument, 0, 's' }, + // { "s-anchor", required_argument, 0, 's' }, + // { 0, 0, 0, 0 } + //}; + + //while (opt != -1) + //{ + // int option_index = 0; + + // opt = getopt_long(argc, argv, "hu:xSo:t:d:f:s:", long_options, &option_index); + + // /* Detect the end of the options. */ + // if (opt == -1) + // break; + + // switch (opt) + // { + // case 'h': + // { + // cout << HELP_MSG << endl; + // return 0; + // break; + // } + // case 'u': + // { + // cout << "Selected URL: " << optarg << endl; + // url.append(optarg); + // break; + // } + // case 't': + // { + // cout << "Threads number: " << optarg << endl; + // thrnum = atoi(optarg); + // break; + // } + // case 'd': + // { + // cout << "Maximum depth: " << optarg << endl; + // maxdepth = atoi(optarg); + // break; + // } + // case 'x': + // { + // sameDomain = true; + // cout << "Same domain rule applied" << endl; + // break; + // } + // case 'S': + // { + // save = true; + // cout << "Activate Save rule applied" << endl; + // break; + // } + // case 'o': + // { + // pathString.clear(); + // pathString.append(optarg); + // cout << "Output directory for saved files changed to " << optarg << endl; + // break; + // } + // case 'f': + // { + // if (long_options[option_index].name == "f-global") + // { + // followCondition.global = optarg; + // cout << "Global Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-protocol") + // { + // followCondition.protocol = optarg; + // cout << "Protocol Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-domain") + // { + // followCondition.domain = optarg; + // cout << "Domain Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-path") + // { + // followCondition.path = optarg; + // cout << "Path Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-filename") + // { + // followCondition.filename = optarg; + // cout << "Filename Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-extension") + // { + // followCondition.extension = optarg; + // cout << "Extension Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-querystring") + // { + // followCondition.querystring = optarg; + // cout << "Querystring Follow rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "f-anchor") + // { + // followCondition.anchor = optarg; + // cout << "Anchor Follow rule: " << optarg << endl; + // } + // break; + // } + // case 's': + // { + // if (long_options[option_index].name == "s-global") + // { + // saveCondition.global = optarg; + // cout << "Global Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-protocol") + // { + // saveCondition.protocol = optarg; + // cout << "Protocol save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-domain") + // { + // saveCondition.domain = optarg; + // cout << "Domain Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-path") + // { + // saveCondition.path = optarg; + // cout << "Path Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-filename") + // { + // saveCondition.filename = optarg; + // cout << "Filename Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-extension") + // { + // saveCondition.extension = optarg; + // cout << "Extension Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-querystring") + // { + // saveCondition.querystring = optarg; + // cout << "Querystring Save rule: " << optarg << endl; + // } + // else if (long_options[option_index].name == "s-anchor") + // { + // saveCondition.anchor = optarg; + // cout << "Anchor Save rule: " << optarg << endl; + // } + // break; + // } + // case ':': + // { + // cout << "Missing value for option -" << (char)optopt << endl; + // return 0; + // break; + // } + // case '?': + // default: + // return 0; + // } + //} + //if (optind < argc) + // { + // cout << "Illegal non-option arguments: "; + // while (optind < argc) + // cout << argv[optind++] << " "; + // cout << "\n\n" << HELP_MSG << endl; + // return 0; + // } + + //if (url.empty()) + //{ + // cout << "URL: "; + // cin >> url; + //} + + //cout << endl; + + //url = validate(url); + // + //string response; //Contains HTTP response + + //response = HTTPrequest(url); + + //uri base(url); + //if (sameDomain) + // followCondition.domain = std::regex_replace(base.domain, regex("\\."), "\\."); + + //unordered_set urls; //Hash table which contains the URLs found in the response + //queue todo; //Queue containing the urls left to crawl + + //cout << todo.size() << " >> " << url << " : " << base.depth << endl; + + ////Check if the starting url has to be saved + //if (save && base.check(saveCondition)) + //{ + // directory = pathString; + // directory /= base.domain; + // directory /= base.path; + // if (!fs::exists(directory)) + // fs::create_directories(directory); + // if (base.filename.empty()) + // directory /= "index.html"; + // else + // directory /= base.filename + "." + base.extension; + // writeToDisk(response, directory); + //} + + //crawl(response, urls, todo, save, &base); + + //thread *threads = new thread[thrnum]; + + //for (int i = 0; i < thrnum; i++) + //{ + // threads[i] = std::thread(doWork, std::ref(urls), std::ref(todo), base); + //} + + //for (int i = 0; i < thrnum; i++) + //{ + // threads[i].join(); + //} + + //cout << "\nCrawling completed\n"; + // - string response; //Contains HTTP response - - response = HTTPrequest(url); - - uri base(url); - if (sameDomain) - followCondition.domain = std::regex_replace(base.domain, regex("\\."), "\\."); - - unordered_set urls; //Hash table which contains the URLs found in the response - queue todo; //Queue containing the urls left to crawl - - cout << todo.size() << " >> " << url << " : " << base.depth << endl; - - //Check if the starting url has to be saved - if (save && base.check(saveCondition)) - { - directory = pathString; - directory /= base.domain; - directory /= base.path; - if (!fs::exists(directory)) - fs::create_directories(directory); - if (base.filename.empty()) - directory /= "index.html"; - else - directory /= base.filename + "." + base.extension; - writeToDisk(response, directory); - } - - crawl(response, urls, todo, save, &base); - - thread *threads = new thread[thrnum]; - - for (int i = 0; i < thrnum; i++) - { - threads[i] = std::thread(doWork, std::ref(urls), std::ref(todo), base); - } - - for (int i = 0; i < thrnum; i++) - { - threads[i].join(); - } + uri prova("//canibelli.it/patata/patatamon.jpg"); - cout << "\nCrawling completed\n"; + cin.ignore(); return 0; } \ No newline at end of file diff --git a/CrowLeer/uri.cpp b/CrowLeer/uri.cpp index 1519d1c..de02724 100644 --- a/CrowLeer/uri.cpp +++ b/CrowLeer/uri.cpp @@ -97,9 +97,10 @@ uri parse(string str, uri* const parent) int pos; int end; + /* str = trim(str); - string relative=""; //Holds relative paths informations + string relative = ""; //Holds relative paths informations if (parent != nullptr) { @@ -107,7 +108,7 @@ uri parse(string str, uri* const parent) } //Relative path - if (str[0] == '\\' || str[0] == '.' || (str[0]=='/' && str[1]!='/') ) + if (str[0] == '\\' || str[0] == '.' || (str[0] == '/' && str[1] != '/')) { relative = str[0]; str.erase(0, 1); @@ -124,7 +125,7 @@ uri parse(string str, uri* const parent) //Protocol pos = str.find(":"); - if (pos != string::npos && str[pos+1]=='/' && str[pos+2]=='/') + if (pos != string::npos && str[pos + 1] == '/' && str[pos + 2] == '/') { temp.protocol = str.substr(0, pos); str.erase(0, pos); @@ -157,7 +158,7 @@ uri parse(string str, uri* const parent) temp.domain = parent->domain; } } - else if(parent != nullptr) + else if (parent != nullptr) { temp.domain = parent->domain; if (relative == "." || relative == "/") @@ -173,7 +174,7 @@ uri parse(string str, uri* const parent) //Path pos = str.find_last_of("/"); - if(pos != string::npos) + if (pos != string::npos) { temp.path = str.substr(0, pos); str.erase(0, pos + 1); @@ -189,7 +190,7 @@ uri parse(string str, uri* const parent) else //Check back for missed Path { pos = str.find_first_of("?#"); - if(pos != string::npos) + if (pos != string::npos) { temp.path = str.substr(0, pos); str.erase(0, pos); @@ -212,7 +213,7 @@ uri parse(string str, uri* const parent) return temp; } } - else if(str.length() > 0) //Check back for missed Path + else if (str.length() > 0) //Check back for missed Path { if (!temp.path.empty()) temp.path += "/"; @@ -235,7 +236,7 @@ uri parse(string str, uri* const parent) pos = str.find("#"); if (pos != string::npos) { - temp.querystring = str.substr(1, pos-1); + temp.querystring = str.substr(1, pos - 1); str.erase(0, pos); } else @@ -252,6 +253,12 @@ uri parse(string str, uri* const parent) temp.anchor = str.substr(1); str.clear(); } + */ + + network::uri support(str); + cout << support.scheme() << endl; + cout << support.is_absolute() << endl; + cout << support.has_scheme() << endl; return temp; } diff --git a/CrowLeer/uri.h b/CrowLeer/uri.h index 18e7db5..6bb6a5c 100644 --- a/CrowLeer/uri.h +++ b/CrowLeer/uri.h @@ -2,6 +2,7 @@ #include "conditions.h" #include +#include using std::string; diff --git a/CrowLeer/utils.cpp b/CrowLeer/utils.cpp index 885a822..f99dfda 100644 --- a/CrowLeer/utils.cpp +++ b/CrowLeer/utils.cpp @@ -8,8 +8,6 @@ #define CURL_STATICLIB #include "curl.h" -#pragma comment(lib, "libcurl_a.lib") - using std::cout; using std::cin; using std::endl; using std::ofstream;