lwres_gethostent.docbook revision dafcb997e390efa4423883dafd100c975c4095d6
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<!--
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
d4ef65050feac78554addf6e16a06c6e2e0bd331Brian Wellington - Copyright (C) 2001 Internet Software Consortium.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson -
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - Permission to use, copy, modify, and distribute this software for any
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - purpose with or without fee is hereby granted, provided that the above
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - copyright notice and this permission notice appear in all copies.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson -
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - PERFORMANCE OF THIS SOFTWARE.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson-->
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews<!-- $Id: lwres_gethostent.docbook,v 1.6 2004/03/05 05:12:56 marka Exp $ -->
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<refentryinfo>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<date>Jun 30, 2000</date>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refentryinfo>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refmeta>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>lwres_gethostent</refentrytitle>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<manvolnum>3</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refmiscinfo>BIND9</refmiscinfo>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refmeta>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refnamediv>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostbyname</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostbyname2</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostbyaddr</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostent</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_sethostent</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_endhostent</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostbyname_r</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostbyaddr_r</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_gethostent_r</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_sethostent_r</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refname>lwres_endhostent_r</refname>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refpurpose>lightweight resolver get network host entry</refpurpose>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refnamediv>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refsynopsisdiv>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcsynopsis>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcsynopsisinfo>#include &lt;lwres/netdb.h&gt;</funcsynopsisinfo>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>const char *name</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname2</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>const char *name</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int af</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>const char *addr</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int len</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int type</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>void</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonvoid
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_sethostent</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int stayopen</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonvoid
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_endhostent</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>void</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname_r</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>const char *name</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>struct hostent *resbuf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>char *buf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int buflen</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int *error</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr_r</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>const char *addr</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int len</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int type</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>struct hostent *resbuf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>char *buf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int buflen</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int *error</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstruct hostent *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent_r</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>struct hostent *resbuf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>char *buf</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int buflen</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int *error</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonvoid
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_sethostent_r</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>int stayopen</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonvoid
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_endhostent_r</function></funcdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<paramdef>void</paramdef>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcprototype>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</funcsynopsis>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refsynopsisdiv>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<title>DESCRIPTION</title>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThese functions provide hostname-to-address and
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonaddress-to-hostname lookups by means of the lightweight resolver.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThey are similar to the standard
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>gethostent</refentrytitle><manvolnum>3
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonfunctions provided by most operating systems.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThey use a
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>struct hostent</type>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonwhich is usually defined in
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<filename>&lt;namedb.h&gt;</filename>.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<programlisting>
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafssonstruct hostent {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char *h_name; /* official name of host */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char **h_aliases; /* alias list */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson int h_addrtype; /* host address type */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson int h_length; /* length of address */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char **h_addr_list; /* list of addresses from name server */
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson};
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson#define h_addr h_addr_list[0] /* address, for backward compatibility */
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</programlisting>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe members of this structure are:
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<variablelist>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>h_name</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe official (canonical) name of the host.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>h_aliases</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonA NULL-terminated array of alternate names (nicknames) for the host.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>h_addrtype</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe type of address being returned &mdash;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>PF_INET</type>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonor
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>PF_INET6</type>.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>h_length</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe length of the address in bytes.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>h_addr_list</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonA <type>NULL</type>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonterminated array of network addresses for the host.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonHost addresses are returned in network byte order.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</variablelist>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonFor backward compatibility with very old software,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<constant>h_addr</constant>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis the first address in
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<constant>h_addr_list.</constant>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_sethostent()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_endhostent()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent_r()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_sethostent_r()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonand
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_endhostent_r()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonprovide iteration over the known host entries on systems that
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonprovide such functionality through facilities like
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<filename>/etc/hosts</filename>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonor NIS. The lightweight resolver does not currently implement
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonthese functions; it only provides them as stub functions that always
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonreturn failure.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname()</function> and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname2()</function> look up the hostname
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<parameter>name</parameter>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname()</function> always looks for an IPv4
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonaddress while <function>lwres_gethostbyname2()</function> looks for an
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonaddress of protocol family <parameter>af</parameter>: either
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>PF_INET</type> or <type>PF_INET6</type> &mdash; IPv4 or IPV6
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonaddresses respectively. Successful calls of the functions return a
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>struct hostent</type>for the name that was looked up.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>NULL</type> is returned if the lookups by
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname()</function> or
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname2()</function> fail.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonReverse lookups of addresses are performed by
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr()</function>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>addr</parameter> is an address of length
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>len</parameter> bytes and protocol family
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>type</parameter> &mdash; <type>PF_INET</type> or
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>PF_INET6</type>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname_r()</function> is a thread-safe function
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonfor forward lookups. If an error occurs, an error code is returned in
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<parameter>*error</parameter>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>resbuf</parameter> is a pointer to a <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type> which is initialised by a successful call to
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname_r()</function> .
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>buf</parameter> is a buffer of length
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>len</parameter> bytes which is used to store the
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<constant>h_name</constant>, <constant>h_aliases</constant>, and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<constant>h_addr_list</constant> elements of the <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type> returned in <parameter>resbuf</parameter>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas GustafssonSuccessful calls to <function>lwres_gethostbyname_r()</function>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonreturn <parameter>resbuf</parameter>,
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonwhich is a pointer to the <type>struct hostent</type> it created.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyaddr_r()</function> is a thread-safe function
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonthat performs a reverse lookup of address <parameter>addr</parameter>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonwhich is <parameter>len</parameter> bytes long and is of protocol
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonfamily <parameter>type</parameter> &mdash; <type>PF_INET</type> or
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>PF_INET6</type>. If an error occurs, the error code is returned
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonin <parameter>*error</parameter>. The other function parameters are
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonidentical to those in <function>lwres_gethostbyname_r()</function>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>resbuf</parameter> is a pointer to a <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type> which is initialised by a successful call to
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr_r()</function>.
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>buf</parameter> is a buffer of length
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>len</parameter> bytes which is used to store the
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<constant>h_name</constant>, <constant>h_aliases</constant>, and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<constant>h_addr_list</constant> elements of the <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type> returned in <parameter>resbuf</parameter>. Successful
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssoncalls to <function>lwres_gethostbyaddr_r()</function> return
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>resbuf</parameter>, which is a pointer to the
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>struct hostent()</function> it created.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refsect1>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<title>RETURN VALUES</title>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe functions
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname2()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonand
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonreturn NULL to indicate an error. In this case the global variable
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>lwres_h_errno</type>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonwill contain one of the following error codes defined in
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<filename>&lt;lwres/netdb.h&gt;</filename>:
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<variablelist>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>HOST_NOT_FOUND</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe host or address was not found.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>TRY_AGAIN</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonA recoverable error occurred, e.g., a timeout.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonRetrying the lookup may succeed.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>NO_RECOVERY</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonA non-recoverable error occurred.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<varlistentry><term><constant>NO_DATA</constant></term>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<listitem>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe name exists, but has no address information
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonassociated with it (or vice versa in the case
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonof a reverse lookup). The code NO_ADDRESS
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis accepted as a synonym for NO_DATA for backwards
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssoncompatibility.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson</listitem></varlistentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</variablelist>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontranslates these error codes to suitable error messages.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonand
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostent_r()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonalways return
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>NULL</type>.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas GustafssonSuccessful calls to <function>lwres_gethostbyname_r()</function> and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyaddr_r()</function> return
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<parameter>resbuf</parameter>, a pointer to the <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type> that was initialised by these functions. They return
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>NULL</type> if the lookups fail or if <parameter>buf</parameter>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonwas too small to hold the list of addresses and names referenced by
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonthe <constant>h_name</constant>, <constant>h_aliases</constant>, and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<constant>h_addr_list</constant> elements of the <type>struct
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafssonhostent</type>. If <parameter>buf</parameter> was too small, both
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyname_r()</function> and
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<function>lwres_gethostbyaddr_r()</function> set the global variable
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<type>errno</type> to <errorcode>ERANGE</errorcode>.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<title>SEE ALSO</title>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</citerefentry>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</citerefentry>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</manvolnum>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</citerefentry>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<title>BUGS</title>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname2()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonand
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_endhostent()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonare not thread safe; they return pointers to static data and
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonprovide error codes through a global variable.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThread-safe versions for name and address lookup are provided by
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyname_r()</function>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonand
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<function>lwres_gethostbyaddr_r()</function>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonrespectively.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe resolver daemon does not currently support any non-DNS
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonname services such as
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<filename>/etc/hosts</filename>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonor
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<type>NIS</type>,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonconsequently the above functions don't, either.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</para>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refsect1>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</refentry>