Skip to content

Commit 32e05f9

Browse files
committed
WebContent: Port to LibMain :^)
1 parent 69a7ffa commit 32e05f9

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

Userland/Services/WebContent/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ set(SOURCES
1717
)
1818

1919
serenity_bin(WebContent)
20-
target_link_libraries(WebContent LibCore LibIPC LibGfx LibWeb)
20+
target_link_libraries(WebContent LibCore LibIPC LibGfx LibWeb LibMain)

Userland/Services/WebContent/main.cpp

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
11
/*
2-
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
2+
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
33
*
44
* SPDX-License-Identifier: BSD-2-Clause
55
*/
66

77
#include <LibCore/EventLoop.h>
88
#include <LibCore/LocalServer.h>
99
#include <LibIPC/ClientConnection.h>
10+
#include <LibMain/Main.h>
11+
#include <LibSystem/Wrappers.h>
1012
#include <WebContent/ClientConnection.h>
1113

12-
int main(int, char**)
14+
ErrorOr<int> serenity_main(Main::Arguments)
1315
{
1416
Core::EventLoop event_loop;
15-
if (pledge("stdio recvfd sendfd accept unix rpath", nullptr) < 0) {
16-
perror("pledge");
17-
return 1;
18-
}
19-
if (unveil("/res", "r") < 0) {
20-
perror("unveil");
21-
return 1;
22-
}
23-
if (unveil("/tmp/portal/request", "rw") < 0) {
24-
perror("unveil");
25-
return 1;
26-
}
27-
if (unveil("/tmp/portal/image", "rw") < 0) {
28-
perror("unveil");
29-
return 1;
30-
}
31-
if (unveil("/tmp/portal/websocket", "rw") < 0) {
32-
perror("unveil");
33-
return 1;
34-
}
35-
if (unveil(nullptr, nullptr) < 0) {
36-
perror("unveil");
37-
return 1;
38-
}
17+
TRY(System::pledge("stdio recvfd sendfd accept unix rpath", nullptr));
18+
TRY(System::unveil("/res", "r"));
19+
TRY(System::unveil("/tmp/portal/request", "rw"));
20+
TRY(System::unveil("/tmp/portal/image", "rw"));
21+
TRY(System::unveil("/tmp/portal/websocket", "rw"));
22+
TRY(System::unveil(nullptr, nullptr));
3923

4024
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
4125
VERIFY(socket);

0 commit comments

Comments
 (0)