diff options
author | alexmajor <5017286+alexmajor@users.noreply.github.com> | 2022-01-24 21:02:39 -0500 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-02-01 04:58:24 +0000 |
commit | 61f2b7434f720fa26a883b534d658ad70b95ee1c (patch) | |
tree | b700e4a139ef633d5da1e23e3ca93a82def93165 /Userland | |
parent | 6deb03233542f97e630087ba1f73ad09fee54faa (diff) | |
download | serenity-61f2b7434f720fa26a883b534d658ad70b95ee1c.zip |
syscall: Port to LibMain
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Utilities/syscall.cpp | 16 |
2 files changed, 10 insertions, 7 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index d7833e6060..aa0e6f8066 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -166,6 +166,7 @@ target_link_libraries(stat LibMain) target_link_libraries(strace LibMain) target_link_libraries(su LibCrypt LibMain) target_link_libraries(sync LibMain) +target_link_libraries(syscall LibMain) target_link_libraries(tac LibMain) target_link_libraries(tail LibMain) target_link_libraries(tar LibArchive LibCompress) 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); } |