int i, cnt;
size_t align, need;
+ *res = 0;
cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME);
if (cnt<0) switch (cnt) {
case EAI_NONAME:
*err = HOST_NOT_FOUND;
- return ENOENT;
+ return 0;
+ case EAI_NODATA:
+ *err = NO_DATA;
+ return 0;
case EAI_AGAIN:
*err = TRY_AGAIN;
return EAGAIN;
case EAI_FAIL:
*err = NO_RECOVERY;
return EBADMSG;
- case EAI_MEMORY:
case EAI_SYSTEM:
*err = NO_RECOVERY;
return errno;
- case 0:
- break;
}
h->h_addrtype = af;
h->h_addr_list = (void *)buf;
buf += (cnt+1)*sizeof(char *);
+ for (i=0; i<cnt; i++) {
+ h->h_addr_list[i] = (void *)buf;
+ buf += h->h_length;
+ memcpy(h->h_addr_list[i], addrs[i].addr, h->h_length);
+ }
+ h->h_addr_list[i] = 0;
+
h->h_name = h->h_aliases[0] = buf;
strcpy(h->h_name, canon);
buf += strlen(h->h_name)+1;
h->h_aliases[2] = 0;
- for (i=0; i<cnt; i++) {
- h->h_addr_list[i] = (void *)buf;
- buf += h->h_length;
- memcpy(h->h_addr_list[i], addrs[i].addr, h->h_length);
- }
- h->h_addr_list[i] = 0;
-
*res = h;
return 0;
}