Patch: extend getent to print all IP addresses
Thorsten Kukuk
kukuk@suse.de
Fri Feb 14 14:31:00 GMT 2003
Hi,
here is a patch, which extends getent to print all IP addresses
for one host, not only the first one:
2003-02-14 Thorsten Kukuk <kukuk@suse.de>
* nss/getent.c (print_hosts): Print all IP addresses of one host.
--- nss/getent.c
+++ nss/getent.c 2003/02/14 12:45:28
@@ -232,21 +232,26 @@
static inline void
print_hosts (struct hostent *host)
{
- unsigned int i;
+ unsigned int i, cnt = 0;
char buf[INET6_ADDRSTRLEN];
- const char *ip = inet_ntop (host->h_addrtype, host->h_addr_list[0],
- buf, sizeof (buf));
-
- printf ("%-15s %s", ip, host->h_name);
- i = 0;
- while (host->h_aliases[i] != NULL)
+ while (host->h_addr_list[cnt] != NULL)
{
- putchar_unlocked (' ');
- fputs_unlocked (host->h_aliases[i], stdout);
- ++i;
+ const char *ip = inet_ntop (host->h_addrtype, host->h_addr_list[cnt],
+ buf, sizeof (buf));
+
+ printf ("%-15s %s", ip, host->h_name);
+
+ i = 0;
+ while (host->h_aliases[i] != NULL)
+ {
+ putchar_unlocked (' ');
+ fputs_unlocked (host->h_aliases[i], stdout);
+ ++i;
+ }
+ putchar_unlocked ('\n');
+ ++cnt;
}
- putchar_unlocked ('\n');
}
static int
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux AG Deutschherrnstr. 15-19 D-90429 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
More information about the Libc-hacker
mailing list