e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/utils/dnsInfo/dnsInfo.c src/utils/dnsInfo/dnsInfo.c index 015d392..34949f9 100644 --- src/utils/dnsInfo/dnsInfo.c +++ src/utils/dnsInfo/dnsInfo.c @@ -1,73 +1,76 @@ /* dnsInfo - Get info from DNS about a machine. */ + +/* Copyright (C) 2011 The Regents of the University of California + * See README in this or parent directory for licensing information. */ #include "common.h" #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/utsname.h> #include "linefile.h" #include "hash.h" #include "options.h" void usage() /* Explain usage and exit. */ { errAbort( "dnsInfo - Get info from DNS about a machine\n" "usage:\n" " dnsInfo machine\n" ); } void dnsInfo(char *machine) /* dnsInfo - Get info from DNS about a machine. */ { struct hostent *h; char **aliases, **addresses; char str[INET6_ADDRSTRLEN]; if (sameString(machine, "localhost")) { struct utsname myname; if (uname(&myname) < 0) errnoAbort("Couldn't uname."); printf("localhost: %s\n", myname.nodename); machine = myname.nodename; { char buf[256]; if (getdomainname(buf, sizeof(buf)) < 0) errnoAbort("getdomainname error"); printf("domain name: %s\n", buf); } } if ((h = gethostbyname(machine)) == NULL) errAbort("Couldn't gethostbyname: %s", hstrerror(h_errno)); printf("official hostname: %s\n", h->h_name); for (aliases = h->h_aliases; *aliases != NULL; ++aliases) printf("\talias: %s\n", *aliases); switch (h->h_addrtype) { case AF_INET: case AF_INET6: addresses = h->h_addr_list; for (addresses = h->h_addr_list; *addresses != NULL; ++addresses) { printf("\taddress: %s\n", inet_ntop(h->h_addrtype, *addresses, str, sizeof(str))); } break; default: errAbort("unknown address type %d", (int)h->h_addrtype); break; } } int main(int argc, char *argv[]) /* Process command line. */ { optionHash(&argc, argv); if (argc != 2) usage(); dnsInfo(argv[1]); return 0; }