DHCPClient: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-29 21:35:04 +01:00
parent 6e7ff8cf1c
commit 74a6fb64b2
Notes: sideshowbarker 2024-07-17 23:16:59 +09:00
2 changed files with 9 additions and 24 deletions

View file

@ -11,4 +11,4 @@ set(SOURCES
)
serenity_bin(DHCPClient)
target_link_libraries(DHCPClient LibCore)
target_link_libraries(DHCPClient LibCore LibMain)

View file

@ -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;
}
TRY(Core::System::unveil("/proc/net/", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
unveil(nullptr, nullptr);
auto client = DHCPv4Client::construct();
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();
}