static int _gethostbyname(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, int *h_errnop) { struct asr_query *as; struct asr_result ar; int r; if (af == -1) as = gethostbyname_async(name, NULL); else as = gethostbyname2_async(name, af, NULL); if (as == NULL) return (errno); asr_run_sync(as, &ar); errno = ar.ar_errno; *h_errnop = ar.ar_h_errno; if (ar.ar_hostent == NULL) return (0); r = _fillhostent(ar.ar_hostent, ret, buf, buflen); free(ar.ar_hostent); return (r); }
static struct hostent * _gethostbyname(const char *name, int af) { struct async *as; struct async_res ar; if (af == -1) as = gethostbyname_async(name, NULL); else as = gethostbyname2_async(name, af, NULL); if (as == NULL) { h_errno = NETDB_INTERNAL; return (NULL); } async_run_sync(as, &ar); errno = ar.ar_errno; h_errno = ar.ar_h_errno; if (ar.ar_hostent == NULL) return (NULL); _fillhostent(ar.ar_hostent, &_hostent, _entbuf, sizeof(_entbuf)); free(ar.ar_hostent); return (&_hostent); }
struct async * gethostbyname_async(const char *name, struct asr *asr) { return gethostbyname2_async(name, AF_INET, asr); }
struct asr_query * gethostbyname_async(const char *name, void *asr) { return gethostbyname2_async(name, AF_INET, asr); }