From da70596895d8135e08f8caac6978117697b4c021 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 18 Aug 2024 21:39:29 +0200 Subject: [REFACTOR] Improved project structure. Signed-off-by: Amlal El Mahrouss --- dev/Kernel/Sources/URL.cxx | 98 ---------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 dev/Kernel/Sources/URL.cxx (limited to 'dev/Kernel/Sources/URL.cxx') diff --git a/dev/Kernel/Sources/URL.cxx b/dev/Kernel/Sources/URL.cxx deleted file mode 100644 index 189aba8e..00000000 --- a/dev/Kernel/Sources/URL.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#include -#include -#include - -/// BUGS: 0 - -namespace Kernel -{ - URL::URL(StringView& strUrl) - : fUrlView(strUrl, false) - { - } - - URL::~URL() = default; - - /// @brief internal and reserved protocols by kernel. - constexpr const Char* kURLProtocols[] = { - "file", // Filesystem protocol - "zup", // ZKA update protocol - "oscc", // Open System Configuration Connectivity. - "odbc", // ODBC connectivity. - "https", // HTTPS layer driver (HTTPS.sys). - }; - - constexpr const int kUrlOutSz = 1; //! such as: :// - constexpr const int kProtosCount = 5; - constexpr const int kRangeSz = 4096; - - ErrorOr url_extract_location(const Char* url) - { - if (!url || *url == 0 || rt_string_len(url, kRangeSz) > kRangeSz) - return ErrorOr{-1}; - - StringView view(rt_string_len(url)); - - SizeT i = 0; - bool scheme_found = false; - - for (; i < rt_string_len(url); ++i) - { - if (!scheme_found) - { - for (int y = 0; kProtosCount; ++y) - { - if (rt_string_in_string(view.CData(), kURLProtocols[y])) - { - i += rt_string_len(kURLProtocols[y]) + kUrlOutSz; - scheme_found = true; - - break; - } - } - } - - view.Data()[i] = url[i]; - } - - return ErrorOr(view); - } - - ErrorOr url_extract_protocol(const Char* url) - { - if (!url || *url == 0 || rt_string_len(url, kRangeSz) > kRangeSz) - return ErrorOr{-1}; - - ErrorOr view{-1}; - - return view; - } - - Ref> URL::Location() noexcept - { - const Char* src = fUrlView.Leak().CData(); - auto loc = url_extract_location(src); - - if (!loc) - return {}; - - return Ref>(loc); - } - - Ref> URL::Protocol() noexcept - { - const Char* src = fUrlView.Leak().CData(); - auto loc = url_extract_protocol(src); - - if (!loc) - return {}; - - return Ref>(loc); - } -} // namespace Kernel -- cgit v1.2.3