summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-12-25 14:31:45 +0000
committerAndreas Kling <kling@serenityos.org>2021-12-27 22:00:01 +0100
commit98c8eca70c5b5a48de4e55b3ed864c93f6c831c4 (patch)
tree72b532bbb42973745c7bd81a79067f3be411304d
parent289cf8d7ef0e8289471b8cec038f2c10e9247467 (diff)
downloadserenity-98c8eca70c5b5a48de4e55b3ed864c93f6c831c4.zip
EchoServer: Port to LibMain
-rw-r--r--Userland/Services/EchoServer/CMakeLists.txt2
-rw-r--r--Userland/Services/EchoServer/main.cpp20
2 files changed, 7 insertions, 15 deletions
diff --git a/Userland/Services/EchoServer/CMakeLists.txt b/Userland/Services/EchoServer/CMakeLists.txt
index 498be2d59f..4c02e9d1b0 100644
--- a/Userland/Services/EchoServer/CMakeLists.txt
+++ b/Userland/Services/EchoServer/CMakeLists.txt
@@ -9,4 +9,4 @@ set(SOURCES
)
serenity_bin(EchoServer)
-target_link_libraries(EchoServer LibCore)
+target_link_libraries(EchoServer LibCore LibMain)
diff --git a/Userland/Services/EchoServer/main.cpp b/Userland/Services/EchoServer/main.cpp
index 5bd35adf59..5a7db00aa5 100644
--- a/Userland/Services/EchoServer/main.cpp
+++ b/Userland/Services/EchoServer/main.cpp
@@ -9,28 +9,20 @@
#include <AK/IPv4Address.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
+#include <LibCore/System.h>
#include <LibCore/TCPServer.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <LibMain/Main.h>
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio unix inet id accept", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
+ TRY(Core::System::pledge("stdio unix inet id accept", nullptr));
+ TRY(Core::System::unveil(nullptr, nullptr));
int port = 7;
Core::ArgsParser args_parser;
args_parser.add_option(port, "Port to listen on", "port", 'p', "port");
- args_parser.parse(argc, argv);
+ args_parser.parse(arguments);
if ((u16)port != port) {
warnln("Invalid port number: {}", port);