From 70c1eb30fe7139cb9e924012633ddc01c04e7c84 Mon Sep 17 00:00:00 2001 From: Gammasoft Date: Mon, 4 Nov 2024 17:50:29 +0100 Subject: [PATCH] Fix build --- .../src/manual_tests.cpp | 161 +----------------- 1 file changed, 1 insertion(+), 160 deletions(-) diff --git a/tests/xtd.core.manual_tests/src/manual_tests.cpp b/tests/xtd.core.manual_tests/src/manual_tests.cpp index a1970271ee6..378151521a9 100644 --- a/tests/xtd.core.manual_tests/src/manual_tests.cpp +++ b/tests/xtd.core.manual_tests/src/manual_tests.cpp @@ -2,168 +2,9 @@ using namespace xtd; -/* -errno_t socket_error_to_errno(xtd::net::sockets::socket_error error) noexcept { - using namespace xtd::net::sockets; - switch (error) { - case socket_error::sock_error : return -1; - case socket_error::success : return 0; - case socket_error::operation_aborted : return ECONNABORTED; - case socket_error::io_pending : return static_cast(error); - case socket_error::interrupted : return EINTR; - case socket_error::access_denied : return EACCES; - case socket_error::fault : return EFAULT; - case socket_error::invalid_argument : return EINVAL; - case socket_error::too_many_open_sockets : return EMFILE; - case socket_error::would_block : return EAGAIN; - case socket_error::in_progress : return EINPROGRESS; - case socket_error::already_in_progress : return EALREADY; - case socket_error::not_socket : return ENOTSOCK; - case socket_error::destination_address_required : return EDESTADDRREQ; - case socket_error::message_size : return EMSGSIZE; - case socket_error::protocol_type : return EPROTOTYPE; - case socket_error::protocol_option : return ENOPROTOOPT; - case socket_error::protocol_not_supported : return EPROTONOSUPPORT; - case socket_error::socket_not_supported : return ENOTSUP; // ESOCKTNOSUPPORT; - case socket_error::operation_not_supported : return ENOTSUP; - case socket_error::protocol_family_not_supported : return ENOTSUP; // EPFNOSUPPORT; - case socket_error::address_family_not_supported : return EAFNOSUPPORT; - case socket_error::address_already_in_use : return EADDRINUSE; - case socket_error::address_not_available : return EADDRNOTAVAIL; - case socket_error::network_down : return ENETDOWN; - case socket_error::network_unreachable : return ENETUNREACH; - case socket_error::network_reset : return ENETRESET; - case socket_error::connection_aborted : return ECONNABORTED; - case socket_error::connection_reset : return ECONNRESET; - case socket_error::no_buffer_space_available : return ENOBUFS; - case socket_error::is_connected : return EISCONN; - case socket_error::not_connected : return ENOTCONN; - case socket_error::shutdown : return static_cast(error); // ESHUTDOWN; - case socket_error::timed_out : return ETIMEDOUT; - case socket_error::connection_refused : return ECONNREFUSED; - case socket_error::host_down : return static_cast(error); // EHOSTDOWN; - case socket_error::host_unreachable : return EHOSTUNREACH; - case socket_error::process_limit : return static_cast(error); // EPROCLIM; - case socket_error::system_not_ready : return static_cast(error); - case socket_error::version_not_supported : return static_cast(error); // ERPCMISMATCH; - case socket_error::not_initialized : return static_cast(error); - case socket_error::disconnecting : return static_cast(error); - case socket_error::type_not_found : return static_cast(error); - case socket_error::host_not_found : return static_cast(error); - case socket_error::try_again : return static_cast(error); - case socket_error::no_recovery : return static_cast(error); - case socket_error::no_data : return static_cast(error); - default: return static_cast(error); - } -} - -string errno_to_string(errno_t error) noexcept { - if (error == 0) return "The operation completed successfully"; - auto previous_locale = std::locale::global(std::locale("en_US.UTF-8")); - auto result = string {std::strerror(error)}; - std::locale::global(previous_locale); - return result; -} - */ - -string socket_error_to_string(xtd::net::sockets::socket_error error) noexcept { - using namespace xtd::net::sockets; - - auto socket_error_to_errno = [](socket_error error) { - switch (error) { - case socket_error::sock_error : return -1; - case socket_error::success : return 0; - case socket_error::operation_aborted : return ECONNABORTED; - case socket_error::io_pending : return static_cast(error); - case socket_error::interrupted : return EINTR; - case socket_error::access_denied : return EACCES; - case socket_error::fault : return EFAULT; - case socket_error::invalid_argument : return EINVAL; - case socket_error::too_many_open_sockets : return EMFILE; - case socket_error::would_block : return EAGAIN; - case socket_error::in_progress : return EINPROGRESS; - case socket_error::already_in_progress : return EALREADY; - case socket_error::not_socket : return ENOTSOCK; - case socket_error::destination_address_required : return EDESTADDRREQ; - case socket_error::message_size : return EMSGSIZE; - case socket_error::protocol_type : return EPROTOTYPE; - case socket_error::protocol_option : return ENOPROTOOPT; - case socket_error::protocol_not_supported : return EPROTONOSUPPORT; - case socket_error::socket_not_supported : return ENOTSUP; // ESOCKTNOSUPPORT; - case socket_error::operation_not_supported : return ENOTSUP; - case socket_error::protocol_family_not_supported : return ENOTSUP; // EPFNOSUPPORT; - case socket_error::address_family_not_supported : return EAFNOSUPPORT; - case socket_error::address_already_in_use : return EADDRINUSE; - case socket_error::address_not_available : return EADDRNOTAVAIL; - case socket_error::network_down : return ENETDOWN; - case socket_error::network_unreachable : return ENETUNREACH; - case socket_error::network_reset : return ENETRESET; - case socket_error::connection_aborted : return ECONNABORTED; - case socket_error::connection_reset : return ECONNRESET; - case socket_error::no_buffer_space_available : return ENOBUFS; - case socket_error::is_connected : return EISCONN; - case socket_error::not_connected : return ENOTCONN; - case socket_error::shutdown : return static_cast(error); // ESHUTDOWN; - case socket_error::timed_out : return ETIMEDOUT; - case socket_error::connection_refused : return ECONNREFUSED; - case socket_error::host_down : return static_cast(error); // EHOSTDOWN; - case socket_error::host_unreachable : return EHOSTUNREACH; - case socket_error::process_limit : return static_cast(error); // EPROCLIM; - case socket_error::system_not_ready : return static_cast(error); - case socket_error::version_not_supported : return static_cast(error); // ERPCMISMATCH; - case socket_error::not_initialized : return static_cast(error); - case socket_error::disconnecting : return static_cast(error); - case socket_error::type_not_found : return static_cast(error); - case socket_error::host_not_found : return static_cast(error); - case socket_error::try_again : return static_cast(error); - case socket_error::no_recovery : return static_cast(error); - case socket_error::no_data : return static_cast(error); - default: return static_cast(error); - } - }; - - auto errno_to_string = [](errno_t error) { - if (error == 0) return string {"The operation completed successfully"}; - auto previous_locale = std::locale::global(std::locale("en_US.UTF-8")); - auto result = string {std::strerror(error)}; - std::locale::global(previous_locale); - return result; - }; - - return errno_to_string(socket_error_to_errno(error)); -} - -string errno_to_string(errno_t error) noexcept { - if (error == 0) return "The operation completed successfully"; - auto previous_locale = std::locale::global(std::locale("en_US.UTF-8")); - auto result = string {std::strerror(error)}; - std::locale::global(previous_locale); - return result; -} - -/* -string error_to_string(int errnum) { - auto result = string {}; - auto messageBuffer = LPSTR {nullptr}; - auto size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, null, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&messageBuffer), 0, null); - if (messageBuffer == null) result = string::format("Unknown error (0x{:x})", errnum); - else { - result = string {messageBuffer, size}.replace("\n", ""); - LocalFree(messageBuffer); - } - - return result; -} - */ - auto main(int argc, char* argv[]) -> int { - //console::write_line("Hello, World!"); + console::write_line("Hello, World!"); - //for (auto errnum = 0; errnum <= 110; ++errnum) - // console::write_line("{:d3} - {}", errnum, errno_to_string(errnum)); - for (auto error : enum_object<>::get_values()) - console::write_line("{} - {}", error, socket_error_to_string(error)); - console::write_line("{} - {}", ESOCKTNOSUPPORT, errno_to_string(ESOCKTNOSUPPORT)); /* try { throw exception {};