int save_errno;
sm_gethostbyname(name, family)	char *name;	int family;{	struct hostent *h = NULL;#if (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4))# if SOLARIS == 20300 || SOLARIS == 203	static struct hostent hp;	static char buf[1000];	extern struct hostent *_switch_gethostbyname_r();	if (tTd(61, 10))		dprintf("_switch_gethostbyname_r(%s)... ", name);	h = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno);# else /* SOLARIS == 20300 || SOLARIS == 203 */	extern struct hostent *__switch_gethostbyname();	if (tTd(61, 10))		dprintf("__switch_gethostbyname(%s)... ", name);	h = __switch_gethostbyname(name);# endif /* SOLARIS == 20300 || SOLARIS == 203 */#else /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */	int nmaps;# if NETINET6	int flags = AI_DEFAULT|AI_ALL;	int err;# endif /* NETINET6 */	int save_errno;	char *maptype[MAXMAPSTACK];	short mapreturn[MAXMAPACTIONS];	char hbuf[MAXNAME];	if (tTd(61, 10))		dprintf("sm_gethostbyname(%s, %d)... ", name, family);# if NETINET6#  if ADDRCONFIG_IS_BROKEN	flags &= ~AI_ADDRCONFIG;#  endif /* ADDRCONFIG_IS_BROKEN */	h = getipnodebyname(name, family, flags, &err);	h_errno = err;# else /* NETINET6 */	h = gethostbyname(name);# endif /* NETINET6 */	save_errno = errno;	if (h == NULL)	{		if (tTd(61, 10))			dprintf("failure\n");		nmaps = switch_map_find("hosts", maptype, mapreturn);		while (--nmaps >= 0)		{			if (strcmp(maptype[nmaps], "nis") == 0 ||			    strcmp(maptype[nmaps], "files") == 0)				break;		}		if (nmaps >= 0)		{			/* try short name */			if (strlen(name) > (SIZE_T) sizeof hbuf - 1)			{				errno = save_errno;				return NULL;			}			(void) strlcpy(hbuf, name, sizeof hbuf);			shorten_hostname(hbuf);			/* if it hasn't been shortened, there's no point */			if (strcmp(hbuf, name) != 0)			{				if (tTd(61, 10))					dprintf("sm_gethostbyname(%s, %d)... ",					       hbuf, family);# if NETINET6				h = getipnodebyname(hbuf, family,						    AI_V4MAPPED|AI_ALL,						    &err);				h_errno = err;				save_errno = errno;# else /* NETINET6 */				h = gethostbyname(hbuf);				save_errno = errno;# endif /* NETINET6 */			}		}	}#endif /* (SOLARIS > 10000 && SOLARIS < 20400) || (defined(SOLARIS) && SOLARIS < 204) || (defined(sony_news) && defined(__svr4)) */	if (tTd(61, 10))	{		if (h == NULL)			dprintf("failure\n");		else		{			dprintf("%s\n", h->h_name);			if (tTd(61, 11))			{#if NETINET6				struct in6_addr ia6;				char buf6[INET6_ADDRSTRLEN];#else /* NETINET6 */				struct in_addr ia;#endif /* NETINET6 */				int i;				if (h->h_aliases != NULL)					for (i = 0; h->h_aliases[i] != NULL;					     i++)						dprintf("\talias: %s\n",							h->h_aliases[i]);				for (i = 0; h->h_addr_list[i] != NULL; i++)				{					char *addr;#if NETINET6					memmove(&ia6, h->h_addr_list[i],						IN6ADDRSZ);					addr = anynet_ntop(&ia6,							   buf6, sizeof buf6);#else /* NETINET6 */					memmove(&ia, h->h_addr_list[i],						INADDRSZ);					addr = (char *) inet_ntoa(ia);#endif /* NETINET6 */					if (addr != NULL)						dprintf("\taddr: %s\n", addr);				}			}		}	}	errno = save_errno;	return h;}