19 #ifdef HAVE_NETINET_IN_H
20 # include <netinet/in.h>
25 #ifdef HAVE_ARPA_INET_H
26 # include <arpa/inet.h>
36 char *
line = NULL, *
p, *q, **alias;
37 char *txtaddr, *txthost, *txtalias;
39 size_t addrlen, linesize, naliases;
41 struct hostent *hostent = NULL;
60 while (*
p && (*
p !=
'#'))
137 addr.family = AF_UNSPEC;
139 if ((family == AF_INET) || (family == AF_UNSPEC))
144 addr.family = AF_INET;
145 addrlen =
sizeof(
addr.addrV4);
148 if ((family ==
AF_INET6) || ((family == AF_UNSPEC) && (!addrlen)))
154 addrlen =
sizeof(
addr.addrV6);
171 hostent->h_aliases = NULL;
172 hostent->h_addr_list = NULL;
176 if (!hostent->h_name)
180 hostent->h_addr_list =
ares_malloc(2 *
sizeof(
char *));
181 if (!hostent->h_addr_list)
183 hostent->h_addr_list[1] = NULL;
185 if (!hostent->h_addr_list[0])
187 if (
addr.family == AF_INET)
188 memcpy(hostent->h_addr_list[0], &
addr.addrV4,
sizeof(
addr.addrV4));
190 memcpy(hostent->h_addr_list[0], &
addr.addrV6,
sizeof(
addr.addrV6));
193 hostent->h_aliases =
ares_malloc((naliases + 1) *
sizeof(
char *));
194 if (!hostent->h_aliases)
196 alias = hostent->h_aliases;
198 *(alias + naliases--) = NULL;
212 txtalias = *q ? q : NULL;
242 if (hostent->h_aliases)
244 for (alias = hostent->h_aliases; *alias; alias++)
248 if (hostent->h_addr_list)
250 if (hostent->h_addr_list[0])