diff options
Diffstat (limited to 'Userland/Utilities/syscall.cpp')
-rw-r--r-- | Userland/Utilities/syscall.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Userland/Utilities/syscall.cpp b/Userland/Utilities/syscall.cpp index c59d121283..ab6ba4fd7e 100644 --- a/Userland/Utilities/syscall.cpp +++ b/Userland/Utilities/syscall.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, Alex Major * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,6 +10,7 @@ #include <AK/Iterator.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibMain/Main.h> #include <errno_codes.h> #include <stdio.h> #include <stdlib.h> @@ -34,11 +36,11 @@ struct AK::Formatter<Syscall::Function> : Formatter<StringView> { } }; -int main(int argc, char** argv) +ErrorOr<int> serenity_main(Main::Arguments arguments) { bool output_buffer = false; bool list_syscalls = false; - Vector<const char*> arguments; + Vector<const char*> syscall_arguments; Core::ArgsParser args_parser; args_parser.set_general_help( @@ -54,8 +56,8 @@ int main(int argc, char** argv) "Full example: syscall -o realpath [ /usr/share/man/man2/getgid.md 1024 buf 1024 ]"); args_parser.add_option(list_syscalls, "List all existing syscalls, and exit", "list-syscalls", 'l'); args_parser.add_option(output_buffer, "Output the contents of the buffer (beware of stray zero bytes!)", "output-buffer", 'o'); - args_parser.add_positional_argument(arguments, "Syscall arguments; see general help.", "syscall-arguments", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.add_positional_argument(syscall_arguments, "Syscall arguments; see general help.", "syscall-arguments", Core::ArgsParser::Required::No); + args_parser.parse(arguments); if (list_syscalls) { outln("syscall list:"); @@ -65,12 +67,12 @@ int main(int argc, char** argv) exit(0); } - if (arguments.is_empty()) { - args_parser.print_usage(stderr, argv[0]); + if (syscall_arguments.is_empty()) { + args_parser.print_usage(stderr, arguments.argv[0]); exit(1); } - ArgIter iter = arguments.begin(); + ArgIter iter = syscall_arguments.begin(); for (size_t i = 0; i < SC_NARG && !iter.is_end(); i++) { arg[i] = parse_from(iter); } |