From 61f2b7434f720fa26a883b534d658ad70b95ee1c Mon Sep 17 00:00:00 2001 From: alexmajor <5017286+alexmajor@users.noreply.github.com> Date: Mon, 24 Jan 2022 21:02:39 -0500 Subject: syscall: Port to LibMain --- Userland/Utilities/CMakeLists.txt | 1 + Userland/Utilities/syscall.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Userland') 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 + * Copyright (c) 2022, Alex Major * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -34,11 +36,11 @@ struct AK::Formatter : Formatter { } }; -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { bool output_buffer = false; bool list_syscalls = false; - Vector arguments; + Vector 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); } -- cgit v1.2.3