mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
host: Port to LibMain
This commit is contained in:
parent
dbcccde062
commit
63466d385c
2 changed files with 6 additions and 8 deletions
|
@ -107,6 +107,7 @@ target_link_libraries(gunzip LibCompress LibMain)
|
||||||
target_link_libraries(gzip LibCompress LibMain)
|
target_link_libraries(gzip LibCompress LibMain)
|
||||||
target_link_libraries(head LibMain)
|
target_link_libraries(head LibMain)
|
||||||
target_link_libraries(hexdump LibMain)
|
target_link_libraries(hexdump LibMain)
|
||||||
|
target_link_libraries(host LibMain)
|
||||||
target_link_libraries(id LibMain)
|
target_link_libraries(id LibMain)
|
||||||
target_link_libraries(ini LibMain)
|
target_link_libraries(ini LibMain)
|
||||||
target_link_libraries(jp LibMain)
|
target_link_libraries(jp LibMain)
|
||||||
|
|
|
@ -5,25 +5,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments args)
|
||||||
{
|
{
|
||||||
if (pledge("stdio unix", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio unix", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* name_or_ip = nullptr;
|
const char* name_or_ip = nullptr;
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("Convert between domain name and IPv4 address.");
|
args_parser.set_general_help("Convert between domain name and IPv4 address.");
|
||||||
args_parser.add_positional_argument(name_or_ip, "Domain name or IPv4 address", "name");
|
args_parser.add_positional_argument(name_or_ip, "Domain name or IPv4 address", "name");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(args);
|
||||||
|
|
||||||
// If input looks like an IPv4 address, we should do a reverse lookup.
|
// If input looks like an IPv4 address, we should do a reverse lookup.
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue