diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 18:17:47 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 18:18:59 +0100 |
| commit | 65254486efff0fd1bb78a48ff90b7713a5ce539f (patch) | |
| tree | 20ce02c12a74ba9e6cd382bf9c1f09a0c611cb4d /Private/Source/Network/IP.cpp | |
| parent | f03986937db0b927da4b10554801e18e4dc7c43f (diff) | |
Kernel: Update TODO.
Src: Refactorings according to clang-format.
Meta: Update specification.
Public: Remove useless UIKit.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/Network/IP.cpp')
| -rw-r--r-- | Private/Source/Network/IP.cpp | 158 |
1 files changed, 63 insertions, 95 deletions
diff --git a/Private/Source/Network/IP.cpp b/Private/Source/Network/IP.cpp index ba6fd71f..4e8f602a 100644 --- a/Private/Source/Network/IP.cpp +++ b/Private/Source/Network/IP.cpp @@ -10,118 +10,86 @@ #include <NetworkKit/IP.hpp> #include <NewKit/Utils.hpp> -namespace hCore -{ - char* RawIPAddress::Address() - { - return m_Addr; - } +namespace hCore { +char* RawIPAddress::Address() { return m_Addr; } - RawIPAddress::RawIPAddress(char bytes[4]) - { - rt_copy_memory(bytes, m_Addr, 4); - } +RawIPAddress::RawIPAddress(char bytes[4]) { rt_copy_memory(bytes, m_Addr, 4); } - bool RawIPAddress::operator==(const RawIPAddress& ipv4) - { - for (Size index = 0; index < 4; ++index) - { - if (ipv4.m_Addr[index] != m_Addr[index]) - return false; - } +bool RawIPAddress::operator==(const RawIPAddress& ipv4) { + for (Size index = 0; index < 4; ++index) { + if (ipv4.m_Addr[index] != m_Addr[index]) return false; + } - return true; - } + return true; +} - bool RawIPAddress::operator!=(const RawIPAddress& ipv4) - { - for (Size index = 0; index < 4; ++index) - { - if (ipv4.m_Addr[index] == m_Addr[index]) - return false; - } +bool RawIPAddress::operator!=(const RawIPAddress& ipv4) { + for (Size index = 0; index < 4; ++index) { + if (ipv4.m_Addr[index] == m_Addr[index]) return false; + } - return true; - } + return true; +} - char& RawIPAddress::operator[](const Size& index) - { - kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n"; +char& RawIPAddress::operator[](const Size& index) { + kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n"; - if (index > 4) - panic(RUNTIME_CHECK_EXPRESSION); + if (index > 4) panic(RUNTIME_CHECK_EXPRESSION); - return m_Addr[index]; - } + return m_Addr[index]; +} - RawIPAddress6::RawIPAddress6(char bytes[8]) - { - rt_copy_memory(bytes, m_Addr, 8); - } +RawIPAddress6::RawIPAddress6(char bytes[8]) { + rt_copy_memory(bytes, m_Addr, 8); +} - char &RawIPAddress6::operator[](const Size &index) - { - kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n"; +char& RawIPAddress6::operator[](const Size& index) { + kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n"; - if (index > 8) - panic(RUNTIME_CHECK_EXPRESSION); + if (index > 8) panic(RUNTIME_CHECK_EXPRESSION); - return m_Addr[index]; - } + return m_Addr[index]; +} - bool RawIPAddress6::operator==(const RawIPAddress6& ipv6) - { - for (SizeT index = 0; index < 8; ++index) - { - if (ipv6.m_Addr[index] != m_Addr[index]) - return false; - } +bool RawIPAddress6::operator==(const RawIPAddress6& ipv6) { + for (SizeT index = 0; index < 8; ++index) { + if (ipv6.m_Addr[index] != m_Addr[index]) return false; + } - return true; - } + return true; +} - bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) - { - for (SizeT index = 0; index < 8; ++index) - { - if (ipv6.m_Addr[index] == m_Addr[index]) - return false; - } +bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) { + for (SizeT index = 0; index < 8; ++index) { + if (ipv6.m_Addr[index] == m_Addr[index]) return false; + } - return true; - } + return true; +} - ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6> ipv6) - { - auto str = StringBuilder::Construct(ipv6.Leak().Address()); - return str; - } +ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6> ipv6) { + auto str = StringBuilder::Construct(ipv6.Leak().Address()); + return str; +} - ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress> ipv4) - { - auto str = StringBuilder::Construct(ipv4.Leak().Address()); - return str; - } +ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress> ipv4) { + auto str = StringBuilder::Construct(ipv4.Leak().Address()); + return str; +} - bool IPFactory::IpCheckVersion4(const char *ip) - { - int cnter = 0; - - for (Size base = 0; base < string_length(ip); ++base) - { - if (ip[base] == '.') - { - cnter = 0; - } - else - { - if (cnter == 3) - return false; - - ++cnter; - } - } - - return true; +bool IPFactory::IpCheckVersion4(const char* ip) { + int cnter = 0; + + for (Size base = 0; base < string_length(ip); ++base) { + if (ip[base] == '.') { + cnter = 0; + } else { + if (cnter == 3) return false; + + ++cnter; } -} // namespace NewKit + } + + return true; +} +} // namespace hCore |
