blob: 0324988dc481ea820adcd80a7cef722c1331b070 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Format.h>
#include <AK/StringView.h>
#include <AK/Vector.h>
#include <LibMain/Main.h>
#include <string.h>
int main(int argc, char** argv)
{
Vector<StringView> arguments;
arguments.ensure_capacity(argc);
for (int i = 0; i < argc; ++i)
arguments.unchecked_append(argv[i]);
auto result = serenity_main({
.argc = argc,
.argv = argv,
.strings = arguments.span(),
});
if (result.is_error()) {
auto error = result.release_error();
if (error.is_syscall())
warnln("Runtime error: {}: {} (errno={})", error.string_literal(), strerror(error.code()), error.code());
else if (error.is_errno())
warnln("Runtime error: {} (errno={})", strerror(error.code()), error.code());
else
warnln("Runtime error: {}", error.string_literal());
return 1;
}
return result.value();
}
|