This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |