0N/A - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 0N/A - Copyright (C) 2001 Internet Software Consortium. 0N/A - Permission to use, copy, modify, and distribute this software for any 0N/A - purpose with or without fee is hereby granted, provided that the above 0N/A - copyright notice and this permission notice appear in all copies. 0N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 0N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 0N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 0N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 0N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 0N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 0N/A - PERFORMANCE OF THIS SOFTWARE. 0N/A>lwres_gethostent</
TITLE 0N/ACONTENT="Modular DocBook HTML Stylesheet Version 1.73 0N/A>lwres_gethostbyname, lwres_gethostbyname2, lwres_gethostbyaddr, lwres_gethostent, lwres_sethostent, lwres_endhostent, lwres_gethostbyname_r, lwres_gethostbyaddr_r, lwres_gethostent_r, lwres_sethostent_r, lwres_endhostent_r -- lightweight resolver get network host entry</
DIV 0N/ACLASS="REFSYNOPSISDIV" lwres_gethostbyname</
CODE>(const char *name);</
CODElwres_gethostbyname2</
CODE>(const char *name, int af);</
CODElwres_gethostbyaddr</
CODE>(const char *addr, int len, int type);</
CODElwres_gethostbyname_r</
CODE>(const char *name, struct hostent *resbuf, char *buf, int buflen, int *error);</
CODElwres_gethostbyaddr_r</
CODE>(const char *addr, int len, int type, struct hostent *resbuf, char *buf, int buflen, int *error);</
CODE>(struct hostent *resbuf, char *buf, int buflen, int *error);</
CODE>These functions provide hostname-to-address and
address-to-hostname lookups by means of the lightweight resolver.
They are similar to the standard
functions provided by most operating systems.
which is usually defined in
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatibility */</
PRE>The members of this structure are:
>The official (canonical) name of the host.</
P>A NULL-terminated array of alternate names (nicknames) for the host.</
P>The type of address being returned —
>The length of the address in bytes.</
Pterminated array of network addresses for the host.
Host addresses are returned in network byte order.</
P>For backward compatibility with very old software,
>lwres_gethostent_r()</
TT>lwres_sethostent_r()</
TT>lwres_endhostent_r()</
TTprovide iteration over the known host entries on systems that
provide such functionality through facilities like
or NIS. The lightweight resolver does not currently implement
these functions; it only provides them as stub functions that always
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyname()</
TT> always looks for an IPv4
>lwres_gethostbyname2()</
TTaddress of protocol family <
TTaddresses respectively. Successful calls of the functions return a
>for the name that was looked up.
> is returned if the lookups by
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>Reverse lookups of addresses are performed by
>lwres_gethostbyaddr()</
TT> is an address of length
> bytes and protocol family
>lwres_gethostbyname_r()</
TT> is a thread-safe function
for forward lookups. If an error occurs, an error code is returned in
> is a pointer to a <
SPAN> which is initialised by a successful call to
>lwres_gethostbyname_r()</
TT> bytes which is used to store the
>lwres_gethostbyname_r()</
TTwhich is a pointer to the <
SPAN>lwres_gethostbyaddr_r()</
TT> is a thread-safe function
that performs a reverse lookup of address <
TT> bytes long and is of protocol
>. If an error occurs, the error code is returned
>. The other function parameters are
identical to those in <
TT>lwres_gethostbyname_r()</
TT> is a pointer to a <
SPAN> which is initialised by a successful call to
>lwres_gethostbyaddr_r()</
TT> bytes which is used to store the
>lwres_gethostbyaddr_r()</
TT>, which is a pointer to the
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyaddr()</
TTreturn NULL to indicate an error. In this case the global variable
will contain one of the following error codes defined in
>The host or address was not found.</
P>A recoverable error occurred,
e.g., a timeout.
Retrying the lookup may succeed.</
P>A non-recoverable error occurred.</
P>The name exists, but has no address information
associated with it (or vice versa in the case
of a reverse lookup). The code NO_ADDRESS
is accepted as a synonym for NO_DATA for backwards
translates these error codes to suitable error messages.</
P>lwres_gethostent_r()</
TT>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TT>, a pointer to the <
SPAN> that was initialised by these functions. They return
> if the lookups fail or if <
TTwas too small to hold the list of addresses and names referenced by
>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TT> set the global variable
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyaddr()</
TTare not thread safe; they return pointers to static data and
provide error codes through a global variable.
Thread-safe versions for name and address lookup are provided by
>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TT>The resolver daemon does not currently support any non-DNS
consequently the above functions don't, either.</
P