From e399835466fb364572ab27ef6947f1a11c674549 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 29 Nov 2021 19:35:51 +0100 Subject: [PATCH] ChessEngine: Port to LibMain :^) --- Userland/Services/ChessEngine/CMakeLists.txt | 2 +- Userland/Services/ChessEngine/main.cpp | 22 +++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Userland/Services/ChessEngine/CMakeLists.txt b/Userland/Services/ChessEngine/CMakeLists.txt index d5b61aab8c..1af7be2aef 100644 --- a/Userland/Services/ChessEngine/CMakeLists.txt +++ b/Userland/Services/ChessEngine/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_bin(ChessEngine) -target_link_libraries(ChessEngine LibChess LibCore) +target_link_libraries(ChessEngine LibChess LibCore LibMain) diff --git a/Userland/Services/ChessEngine/main.cpp b/Userland/Services/ChessEngine/main.cpp index d07e5ce173..8060b79ccd 100644 --- a/Userland/Services/ChessEngine/main.cpp +++ b/Userland/Services/ChessEngine/main.cpp @@ -7,24 +7,16 @@ #include "ChessEngine.h" #include #include -#include +#include +#include -int main() +ErrorOr serenity_main(Main::Arguments) { - if (pledge("stdio recvfd sendfd unix rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd unix rpath")); Core::EventLoop loop; - if (pledge("stdio recvfd sendfd unix", nullptr) < 0) { - perror("pledge"); - return 1; - } - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd unix")); + TRY(Core::System::unveil(nullptr, nullptr)); - auto engine = ChessEngine::construct(Core::File::standard_input(), Core::File::standard_output()); + auto engine = TRY(ChessEngine::try_create(Core::File::standard_input(), Core::File::standard_output())); return loop.exec(); }