allocate: Port to LibMain :^)

This commit is contained in:
Kenneth Myhra 2021-11-25 22:04:13 +01:00 committed by Andreas Kling
parent 67f349be46
commit 494f177d22
Notes: sideshowbarker 2024-07-18 00:38:21 +09:00
2 changed files with 9 additions and 8 deletions

View file

@ -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)

View file

@ -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();