mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
uniq: Port to LibMain
This commit is contained in:
parent
28ea412251
commit
35cd7c9a91
2 changed files with 5 additions and 6 deletions
|
@ -149,6 +149,7 @@ target_link_libraries(top LibMain)
|
||||||
target_link_libraries(touch LibMain)
|
target_link_libraries(touch LibMain)
|
||||||
target_link_libraries(truncate LibMain)
|
target_link_libraries(truncate LibMain)
|
||||||
target_link_libraries(tt LibPthread)
|
target_link_libraries(tt LibPthread)
|
||||||
|
target_link_libraries(uniq LibMain)
|
||||||
target_link_libraries(unzip LibArchive LibCompress)
|
target_link_libraries(unzip LibArchive LibCompress)
|
||||||
target_link_libraries(uptime LibMain)
|
target_link_libraries(uptime LibMain)
|
||||||
target_link_libraries(userdel LibMain)
|
target_link_libraries(userdel LibMain)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -36,19 +37,16 @@ static FILE* get_stream(const char* filepath, const char* perms)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath wpath cpath", nullptr) > 0) {
|
TRY(Core::System::pledge("stdio rpath wpath cpath"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* inpath = nullptr;
|
const char* inpath = nullptr;
|
||||||
const char* outpath = nullptr;
|
const char* outpath = nullptr;
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_positional_argument(inpath, "Input file", "input", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(inpath, "Input file", "input", Core::ArgsParser::Required::No);
|
||||||
args_parser.add_positional_argument(outpath, "Output file", "output", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(outpath, "Output file", "output", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
FILE* infile = get_stream(inpath, "r");
|
FILE* infile = get_stream(inpath, "r");
|
||||||
FILE* outfile = get_stream(outpath, "w");
|
FILE* outfile = get_stream(outpath, "w");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue