--- /dev/null
+#include <stdio.h>
+#include <netdb.h>
+
+static char *a2c(char *ap,int af) {
+ static char data[1000];
+ char *dp = data;
+ int n;
+ unsigned char *bp = (unsigned char*) ap;
+ unsigned short *sp = (unsigned short *)ap;
+ if ( af == AF_INET ) {
+ for ( n = 0; n < 4; n++ ) {
+ sprintf( dp, ".%d", bp[n] );
+ while ( *(++dp) );
+ }
+ } else {
+ int pack = 0;
+ for ( n = 0; n < 8; n++ ) {
+ if ( pack < 2 && sp[n] == 0 ) {
+ if ( pack == 0 ) {
+ *(dp++) = ':';
+ pack = 1;
+ }
+ } else {
+ sprintf( dp, ":%x", ntohs( sp[n] ) );
+ while ( *(++dp) );
+ }
+ }
+ }
+ return data + 1;
+}
+
+static void checkname(char *name,int af) {
+ struct hostent *hp = gethostbyname2( name, af );
+ int i;
+ if ( hp && hp->h_addr_list ) {
+ for ( i = 0; hp->h_addr_list[i]; i++ ) {
+ fprintf( stdout, "%s\n", a2c( hp->h_addr_list[i], af ) );
+ }
+ }
+}
+
+int main(int argc,char *argv[]) {
+ int i;
+ for ( i = 1; i < argc; i++ ) {
+ checkname( argv[i], AF_INET );
+ checkname( argv[i], AF_INET6 );
+ }
+ return 0;
+}