summaryrefslogtreecommitdiff
path: root/Userland/Utilities/base64.cpp
diff options
context:
space:
mode:
authorfaxe1008 <fabianblatz@gmail.com>2021-11-23 17:15:35 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-23 22:54:25 +0100
commitb918e798e6458a16fffffb43843983c0f6c9677e (patch)
tree52a29355899d1203735f308e92cd667a5bcc689b /Userland/Utilities/base64.cpp
parentf47d92af7248fc866122da9ebc76dff3f778a921 (diff)
downloadserenity-b918e798e6458a16fffffb43843983c0f6c9677e.zip
base64: Port to LibMain
Diffstat (limited to 'Userland/Utilities/base64.cpp')
-rw-r--r--Userland/Utilities/base64.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp
index e08e025509..190eb6558e 100644
--- a/Userland/Utilities/base64.cpp
+++ b/Userland/Utilities/base64.cpp
@@ -9,16 +9,15 @@
#include <AK/ByteBuffer.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
+#include <LibCore/System.h>
+#include <LibMain/Main.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio rpath", nullptr));
bool decode = false;
const char* filepath = nullptr;
@@ -26,7 +25,7 @@ int main(int argc, char** argv)
Core::ArgsParser args_parser;
args_parser.add_option(decode, "Decode data", "decode", 'd');
args_parser.add_positional_argument(filepath, "", "file", Core::ArgsParser::Required::No);
- args_parser.parse(argc, argv);
+ args_parser.parse(arguments);
ByteBuffer buffer;
if (filepath == nullptr || strcmp(filepath, "-") == 0) {
@@ -44,10 +43,7 @@ int main(int argc, char** argv)
buffer = file->read_all();
}
- if (pledge("stdio", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio", nullptr));
if (decode) {
auto decoded = decode_base64(StringView(buffer));
@@ -61,4 +57,5 @@ int main(int argc, char** argv)
auto encoded = encode_base64(buffer);
outln("{}", encoded);
+ return 0;
}