1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:37:36 +00:00

DHCPClient: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-29 21:35:04 +01:00
parent 6e7ff8cf1c
commit 74a6fb64b2
2 changed files with 9 additions and 24 deletions

View file

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

View file

@ -5,35 +5,20 @@
*/ */
#include "DHCPv4Client.h" #include "DHCPv4Client.h"
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h> #include <LibCore/System.h>
#include <stdio.h> #include <LibMain/Main.h>
#include <unistd.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) { TRY(Core::System::pledge("stdio unix inet cpath rpath"));
perror("pledge");
return 1;
}
Core::EventLoop event_loop; Core::EventLoop event_loop;
if (unveil("/proc/net/", "r") < 0) { TRY(Core::System::unveil("/proc/net/", "r"));
perror("unveil"); TRY(Core::System::unveil(nullptr, nullptr));
return 1;
}
unveil(nullptr, nullptr); auto client = TRY(DHCPv4Client::try_create());
auto client = DHCPv4Client::construct();
if (pledge("stdio inet cpath rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio inet cpath rpath"));
return event_loop.exec(); return event_loop.exec();
} }