Open System Services System Calls Reference Manual (G06.28+)

gethostbyname_r(2) OSS System Calls Reference Manual
NAME
gethostbyname_r - Gets a host entry by name (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <netdb.h>]
#include <spthread.h>
[extern h_errno;]
struct hostent *gethostbyname_r (
const char *name,
struct hostent *host,
char *buffer,
int buen,
int *h_errnop
);
PARAMETERS
name Species the network name or alias.
host Points to a struct hostent structure allocated by the caller.
buffer Points to the buffer supplied by the caller and used as a storage space for host
data.
buflen Species the size of the buffer passed in bytes.
h_errnop Points to the global integer h_errno to indicate the error code if an error occurs.
See the ERRORS subsection of this reference page for possible values that
might be returned.
DESCRIPTION
The gethostbyname_r() function is the reentrant version of the gethostbyname() function.
The gethostbyname_r() function searches host entries sequentially until a match with the name
parameter occurs. This function returns a pointer to a structure of type hostent whose members
specify data obtained from a name server specied in the /etc/resolv.conf le or from elds of a
record line in the /etc/hosts network hostname database le. When the name server is not run-
ning and /etc/resolv.conf cannot be searched, this function searches the /etc/hosts name le.
The gethostbyname_r() function updates the hostent structure pointed to by the host parameter.
Storage referenced by the hostent structure is allocated from the memory provided with the
buffer parameter, which is buen characters in size. The h_errnop paremeter is updated with the
h_errno value if an error occurs.
NOTES
The netdb.h header le denes the hostent structure.
A return value points to static data, which is overwritten by any subsequent calls to gethost-
byaddr( ), gethostbyaddr_r(), gethostbyname(), gethostbyname_r(), gethostent(),or
gethostent_r().
356 Hewlett-Packard Company 527186-005