diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-29 21:35:04 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-30 23:34:40 +0100 |
commit | 74a6fb64b2cd3bcfe98d9e31642385baea70bff7 (patch) | |
tree | 013fd9f1958535c62f2a5b040e76f71b51b74d6b | |
parent | 6e7ff8cf1c5498f4448e631dba3793a522a84d95 (diff) | |
download | serenity-74a6fb64b2cd3bcfe98d9e31642385baea70bff7.zip |
DHCPClient: Port to LibMain :^)
-rw-r--r-- | Userland/Services/DHCPClient/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Services/DHCPClient/main.cpp | 31 |
2 files changed, 9 insertions, 24 deletions
diff --git a/Userland/Services/DHCPClient/CMakeLists.txt b/Userland/Services/DHCPClient/CMakeLists.txt index 30d3dd70d2..c6f8b729f0 100644 --- a/Userland/Services/DHCPClient/CMakeLists.txt +++ b/Userland/Services/DHCPClient/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES ) serenity_bin(DHCPClient) -target_link_libraries(DHCPClient LibCore) +target_link_libraries(DHCPClient LibCore LibMain) diff --git a/Userland/Services/DHCPClient/main.cpp b/Userland/Services/DHCPClient/main.cpp index 70055f8c14..812ab78275 100644 --- a/Userland/Services/DHCPClient/main.cpp +++ b/Userland/Services/DHCPClient/main.cpp @@ -5,35 +5,20 @@ */ #include "DHCPv4Client.h" -#include <AK/JsonArray.h> -#include <AK/JsonObject.h> #include <LibCore/EventLoop.h> -#include <LibCore/LocalServer.h> -#include <stdio.h> -#include <unistd.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> -int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) +ErrorOr<int> serenity_main(Main::Arguments) { - if (pledge("stdio unix inet cpath rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } - + TRY(Core::System::pledge("stdio unix inet cpath rpath")); Core::EventLoop event_loop; - if (unveil("/proc/net/", "r") < 0) { - perror("unveil"); - return 1; - } - - unveil(nullptr, nullptr); - - auto client = DHCPv4Client::construct(); + TRY(Core::System::unveil("/proc/net/", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); - if (pledge("stdio inet cpath rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + auto client = TRY(DHCPv4Client::try_create()); + TRY(Core::System::pledge("stdio inet cpath rpath")); return event_loop.exec(); } |