h_errno = 0;
gethinfo(name, numeric)	char   *name;	u_short  numeric;{	struct hostent *hostent;	struct in_addr iaddr;	struct host_info *hinfo = NULL;	int x;	errno = 0;	h_errno = 0;	if (name)		hinfo = (struct host_info *) calloc(1, sizeof(struct host_info));	if (!hinfo)		nlog(1, "error obtaining host information");	strlcpy(hinfo->name, "(UNKNOWN)", sizeof(hinfo->name));	if (inet_aton(name, &iaddr) == 0) {		if (numeric)			nlog(1, "Can't parse %s as an IP address", name);		/*		 * failure to look up a name is fatal, 		 * since we can't do anything with it.		 */		hostent = gethostbyname(name);		if (!hostent)			nlog(1, "%s: forward host lookup failed: ", name);		strlcpy(hinfo->name, hostent->h_name, MAXHOSTNAMELEN);		for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {			memcpy(&hinfo->iaddrs[x], hostent->h_addr_list[x],			    sizeof(struct in_addr));			strlcpy(hinfo->addrs[x], inet_ntoa(hinfo->iaddrs[x]),			    sizeof(hinfo->addrs[0]));		}		/* Go ahead and return if we don't want to view more */		if (!o_verbose)				return (hinfo);		/*		 * Do inverse lookups in separate loop based on our collected 	   	 * forward addrs, since gethostby* tends to crap into the same		 * buffer over and over.		 */		for (x = 0; hinfo->iaddrs[x].s_addr && (x < 8); x++) {			hostent = gethostbyaddr((char *) &hinfo->iaddrs[x],			    sizeof(struct in_addr), AF_INET);			if ((!hostent) || (!hostent->h_name))				nlog(0, "Warning: inverse host lookup failed for %s: ",				    hinfo->addrs[x]);			else				(void) comparehosts(hinfo, hostent);		}	} else {		/* not INADDR_NONE: numeric addresses... */		memcpy(hinfo->iaddrs, &iaddr, sizeof(struct in_addr));		strlcpy(hinfo->addrs[0], inet_ntoa(iaddr), sizeof(hinfo->addrs));		/* If all that's wanted is numeric IP, go ahead and leave */		if (numeric)				return (hinfo);		/* Go ahead and return if we don't want to view more */		if (!o_verbose)				return (hinfo);		hostent = gethostbyaddr((char *) &iaddr, 					sizeof(struct in_addr), AF_INET);		/* 		 * numeric or not, failure to look up a PTR is 		 * *not* considered fatal 		 */		if (!hostent)			nlog(0, "%s: inverse host lookup failed: ", name);		else {			strlcpy(hinfo->name, hostent->h_name, MAXHOSTNAMELEN);			hostent = gethostbyname(hinfo->name);			if ((!hostent) || (!hostent->h_addr_list[0]))				nlog(0, "Warning: forward host lookup failed for %s: ",				    hinfo->name);			else				(void) comparehosts(hinfo, hostent);		}	}	/*	 * Whatever-all went down previously, we should now have a host_info 	 * struct with at least one IP address in it.	 */	h_errno = 0;	return (hinfo);}