From b7c15c31519dc44c1f691e0466badd556ffe9423 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 18:18:56 +0200 Subject: Adding upstream version 3.7.10. Signed-off-by: Daniel Baumann --- auxiliary/name-addr-test/gethostbyaddr.c | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 auxiliary/name-addr-test/gethostbyaddr.c (limited to 'auxiliary/name-addr-test/gethostbyaddr.c') diff --git a/auxiliary/name-addr-test/gethostbyaddr.c b/auxiliary/name-addr-test/gethostbyaddr.c new file mode 100644 index 0000000..b973901 --- /dev/null +++ b/auxiliary/name-addr-test/gethostbyaddr.c @@ -0,0 +1,46 @@ + /* + * gethostbyaddr tester. compile with: + * + * cc -o gethostbyaddr gethostbyaddr.c (SunOS 4.x) + * + * cc -o gethostbyaddr gethostbyaddr.c -lnsl (SunOS 5.x) + * + * run as: gethostbyaddr address + * + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + +#include +#include +#include +#include +#include +#include + +main(argc, argv) +int argc; +char **argv; +{ + struct hostent *hp; + long addr; + + if (argc != 2) { + fprintf(stderr, "usage: %s i.p.address\n", argv[0]); + exit(1); + } + addr = inet_addr(argv[1]); + if (hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) { + printf("Hostname:\t%s\n", hp->h_name); + printf("Aliases:\t"); + while (hp->h_aliases[0]) + printf("%s ", *hp->h_aliases++); + printf("\n"); + printf("Addresses:\t"); + while (hp->h_addr_list[0]) + printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++)); + printf("\n"); + exit(0); + } + fprintf(stderr, "host %s not found\n", argv[1]); + exit(1); +} -- cgit v1.2.3