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