Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
struct async *
gethostbyname_async(const char *name, struct asr *asr)
{
	return gethostbyname2_async(name, AF_INET, asr);
}
Ejemplo n.º 4
0
struct asr_query *
gethostbyname_async(const char *name, void *asr)
{
	return gethostbyname2_async(name, AF_INET, asr);
}