allocate: Port to LibMain :^)
This commit is contained in:
parent
67f349be46
commit
494f177d22
Notes:
sideshowbarker
2024-07-18 00:38:21 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/494f177d226 Pull-request: https://github.com/SerenityOS/serenity/pull/11096
2 changed files with 9 additions and 8 deletions
|
@ -51,6 +51,7 @@ foreach(CMD_SRC ${CMD_SOURCES})
|
|||
endif()
|
||||
endforeach()
|
||||
|
||||
target_link_libraries(allocate LibMain)
|
||||
target_link_libraries(aplay LibAudio)
|
||||
target_link_libraries(arp LibMain)
|
||||
target_link_libraries(asctl LibAudio)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <string.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void usage()
|
||||
|
@ -22,25 +22,25 @@ enum class Unit {
|
|||
MiB,
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
int count = 50;
|
||||
auto unit = Unit::MiB;
|
||||
|
||||
if (argc >= 2) {
|
||||
auto number = String(argv[1]).to_uint();
|
||||
if (arguments.argc >= 2) {
|
||||
auto number = arguments.strings[1].to_uint();
|
||||
if (!number.has_value()) {
|
||||
usage();
|
||||
}
|
||||
count = number.value();
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
if (strcmp(argv[2], "B") == 0)
|
||||
if (arguments.argc >= 3) {
|
||||
if (arguments.strings[2] == "B")
|
||||
unit = Unit::Bytes;
|
||||
else if (strcmp(argv[2], "KiB") == 0)
|
||||
else if (arguments.strings[2] == "KiB")
|
||||
unit = Unit::KiB;
|
||||
else if (strcmp(argv[2], "MiB") == 0)
|
||||
else if (arguments.strings[2] == "MiB")
|
||||
unit = Unit::MiB;
|
||||
else
|
||||
usage();
|
||||
|
|
Loading…
Add table
Reference in a new issue