From 5dc5b8a2b643d906390fab1d1423208113079f00 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 15 Mar 2020 11:41:10 +1300 Subject: [PATCH] LibCore: Rename Udp classes to UDP The kernel was already using the UDP prefix, and the TCP LibCore classes are also uppercased. Let's rename for consistency. Also order the LibCore Makefile alphabetically, because everywhere else seems to be doing that :) --- Libraries/LibCore/Forward.h | 4 +- Libraries/LibCore/Makefile | 38 +++++++++---------- .../LibCore/{UdpServer.cpp => UDPServer.cpp} | 18 ++++----- .../LibCore/{UdpServer.h => UDPServer.h} | 10 ++--- .../LibCore/{UdpSocket.cpp => UDPSocket.cpp} | 10 ++--- .../LibCore/{UdpSocket.h => UDPSocket.h} | 10 ++--- Servers/LookupServer/LookupServer.cpp | 4 +- 7 files changed, 47 insertions(+), 47 deletions(-) rename Libraries/LibCore/{UdpServer.cpp => UDPServer.cpp} (88%) rename Libraries/LibCore/{UdpServer.h => UDPServer.h} (91%) rename Libraries/LibCore/{UdpSocket.cpp => UDPSocket.cpp} (90%) rename Libraries/LibCore/{UdpSocket.h => UDPSocket.h} (88%) diff --git a/Libraries/LibCore/Forward.h b/Libraries/LibCore/Forward.h index b857acafa1..9d15634050 100644 --- a/Libraries/LibCore/Forward.h +++ b/Libraries/LibCore/Forward.h @@ -54,8 +54,8 @@ class TCPServer; class TCPSocket; class Timer; class TimerEvent; -class UdpServer; -class UdpSocket; +class UDPServer; +class UDPSocket; enum class TimerShouldFireWhenNotVisible; diff --git a/Libraries/LibCore/Makefile b/Libraries/LibCore/Makefile index 10557fe393..10c243b503 100644 --- a/Libraries/LibCore/Makefile +++ b/Libraries/LibCore/Makefile @@ -1,33 +1,33 @@ OBJS = \ ArgsParser.o \ + ConfigFile.o \ DateTime.o \ - IODevice.o \ - File.o \ - SocketAddress.o \ - Socket.o \ - LocalSocket.o \ - LocalServer.o \ - TCPSocket.o \ - TCPServer.o \ - UdpSocket.o \ - UdpServer.o \ + DirIterator.o \ ElapsedTimer.o \ - MimeData.o \ - Notifier.o \ + Event.o \ + EventLoop.o \ + File.o \ + Gzip.o \ + HttpJob.o \ HttpRequest.o \ HttpResponse.o \ - HttpJob.o \ + IODevice.o \ + LocalServer.o \ + LocalSocket.o \ + MimeData.o \ NetworkJob.o \ NetworkResponse.o \ + Notifier.o \ Object.o \ - Timer.o \ - EventLoop.o \ - ConfigFile.o \ - Event.o \ ProcessStatisticsReader.o \ - DirIterator.o \ + Socket.o \ + SocketAddress.o \ + TCPServer.o \ + TCPSocket.o \ + Timer.o \ + UDPServer.o \ + UDPSocket.o \ UserInfo.o \ - Gzip.o \ puff.o LIBRARY = libcore.a diff --git a/Libraries/LibCore/UdpServer.cpp b/Libraries/LibCore/UDPServer.cpp similarity index 88% rename from Libraries/LibCore/UdpServer.cpp rename to Libraries/LibCore/UDPServer.cpp index a1b9bd8a8d..7b230d63e5 100644 --- a/Libraries/LibCore/UdpServer.cpp +++ b/Libraries/LibCore/UDPServer.cpp @@ -27,25 +27,25 @@ #include #include #include -#include -#include +#include +#include #include #include namespace Core { -UdpServer::UdpServer(Object* parent) +UDPServer::UDPServer(Object* parent) : Object(parent) { m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); ASSERT(m_fd >= 0); } -UdpServer::~UdpServer() +UDPServer::~UDPServer() { } -bool UdpServer::listen(const IPv4Address& address, u16 port) +bool UDPServer::listen(const IPv4Address& address, u16 port) { if (m_listening) return false; @@ -68,7 +68,7 @@ bool UdpServer::listen(const IPv4Address& address, u16 port) return true; } -RefPtr UdpServer::accept() +RefPtr UDPServer::accept() { ASSERT(m_listening); sockaddr_in in; @@ -79,10 +79,10 @@ RefPtr UdpServer::accept() return nullptr; } - return UdpSocket::construct(accepted_fd); + return UDPSocket::construct(accepted_fd); } -Optional UdpServer::local_address() const +Optional UDPServer::local_address() const { if (m_fd == -1) return {}; @@ -95,7 +95,7 @@ Optional UdpServer::local_address() const return IPv4Address(address.sin_addr.s_addr); } -Optional UdpServer::local_port() const +Optional UDPServer::local_port() const { if (m_fd == -1) return {}; diff --git a/Libraries/LibCore/UdpServer.h b/Libraries/LibCore/UDPServer.h similarity index 91% rename from Libraries/LibCore/UdpServer.h rename to Libraries/LibCore/UDPServer.h index a9a022459f..055a4cdb0d 100644 --- a/Libraries/LibCore/UdpServer.h +++ b/Libraries/LibCore/UDPServer.h @@ -33,15 +33,15 @@ namespace Core { -class UdpServer : public Object { - C_OBJECT(UdpServer) +class UDPServer : public Object { + C_OBJECT(UDPServer) public: - virtual ~UdpServer() override; + virtual ~UDPServer() override; bool is_listening() const { return m_listening; } bool listen(const IPv4Address& address, u16 port); - RefPtr accept(); + RefPtr accept(); Optional local_address() const; Optional local_port() const; @@ -49,7 +49,7 @@ public: Function on_ready_to_accept; private: - explicit UdpServer(Object* parent = nullptr); + explicit UDPServer(Object* parent = nullptr); int m_fd { -1 }; bool m_listening { false }; diff --git a/Libraries/LibCore/UdpSocket.cpp b/Libraries/LibCore/UDPSocket.cpp similarity index 90% rename from Libraries/LibCore/UdpSocket.cpp rename to Libraries/LibCore/UDPSocket.cpp index ae66eaf26e..39d73412e7 100644 --- a/Libraries/LibCore/UdpSocket.cpp +++ b/Libraries/LibCore/UDPSocket.cpp @@ -24,23 +24,23 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include namespace Core { -UdpSocket::UdpSocket(int fd, Object* parent) +UDPSocket::UDPSocket(int fd, Object* parent) : Socket(Socket::Type::UDP, parent) { - // NOTE: This constructor is used by UdpServer::accept(), so the socket is already connected. + // NOTE: This constructor is used by UDPServer::accept(), so the socket is already connected. m_connected = true; set_fd(fd); set_mode(IODevice::ReadWrite); set_error(0); } -UdpSocket::UdpSocket(Object* parent) +UDPSocket::UDPSocket(Object* parent) : Socket(Socket::Type::UDP, parent) { int fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0); @@ -53,7 +53,7 @@ UdpSocket::UdpSocket(Object* parent) } } -UdpSocket::~UdpSocket() +UDPSocket::~UDPSocket() { } diff --git a/Libraries/LibCore/UdpSocket.h b/Libraries/LibCore/UDPSocket.h similarity index 88% rename from Libraries/LibCore/UdpSocket.h rename to Libraries/LibCore/UDPSocket.h index e5a4223e0e..35c0d4ee75 100644 --- a/Libraries/LibCore/UdpSocket.h +++ b/Libraries/LibCore/UDPSocket.h @@ -30,14 +30,14 @@ namespace Core { -class UdpSocket final : public Socket { - C_OBJECT(UdpSocket) +class UDPSocket final : public Socket { + C_OBJECT(UDPSocket) public: - virtual ~UdpSocket() override; + virtual ~UDPSocket() override; private: - UdpSocket(int fd, Object* parent = nullptr); - explicit UdpSocket(Object* parent = nullptr); + UDPSocket(int fd, Object* parent = nullptr); + explicit UDPSocket(Object* parent = nullptr); }; } diff --git a/Servers/LookupServer/LookupServer.cpp b/Servers/LookupServer/LookupServer.cpp index 3d466cb231..ea92b11faf 100644 --- a/Servers/LookupServer/LookupServer.cpp +++ b/Servers/LookupServer/LookupServer.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -176,7 +176,7 @@ Vector LookupServer::lookup(const String& hostname, bool& did_timeout, u auto buffer = request.to_byte_buffer(); - auto udp_socket = Core::UdpSocket::construct(); + auto udp_socket = Core::UDPSocket::construct(); udp_socket->set_blocking(true); struct timeval timeout {