2
- Copyright (C) 2000, 2001 Internet Software Consortium.
4
- Permission to use, copy, modify, and distribute this software for any
5
- purpose with or without fee is hereby granted, provided that the above
6
- copyright notice and this permission notice appear in all copies.
8
- THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9
- DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11
- INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13
- FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14
- NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15
- WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20
>lwres_gethostent</TITLE
23
CONTENT="Modular DocBook HTML Stylesheet Version 1.61
44
>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
46
CLASS="REFSYNOPSISDIV"
60
CLASS="FUNCSYNOPSISINFO"
61
>#include <lwres/netdb.h></PRE
67
lwres_gethostbyname</CODE
68
>(const char *name);</CODE
75
lwres_gethostbyname2</CODE
76
>(const char *name, int af);</CODE
83
lwres_gethostbyaddr</CODE
84
>(const char *addr, int len, int type);</CODE
91
lwres_gethostent</CODE
99
lwres_sethostent</CODE
100
>(int stayopen);</CODE
107
lwres_endhostent</CODE
115
lwres_gethostbyname_r</CODE
116
>(const char *name, struct hostent *resbuf, char *buf, int buflen, int *error);</CODE
123
lwres_gethostbyaddr_r</CODE
124
>(const char *addr, int len, int type, struct hostent *resbuf, char *buf, int buflen, int *error);</CODE
131
lwres_gethostent_r</CODE
132
>(struct hostent *resbuf, char *buf, int buflen, int *error);</CODE
139
lwres_sethostent_r</CODE
140
>(int stayopen);</CODE
147
lwres_endhostent_r</CODE
162
>These functions provide hostname-to-address and
163
address-to-hostname lookups by means of the lightweight resolver.
164
They are similar to the standard
168
CLASS="REFENTRYTITLE"
172
functions provided by most operating systems.
176
>struct hostent</SPAN
178
which is usually defined in
181
><namedb.h></TT
185
CLASS="PROGRAMLISTING"
187
char *h_name; /* official name of host */
188
char **h_aliases; /* alias list */
189
int h_addrtype; /* host address type */
190
int h_length; /* length of address */
191
char **h_addr_list; /* list of addresses from name server */
193
#define h_addr h_addr_list[0] /* address, for backward compatibility */</PRE
196
>The members of this structure are:
209
>The official (canonical) name of the host.</P
218
>A NULL-terminated array of alternate names (nicknames) for the host.</P
227
>The type of address being returned —
245
>The length of the address in bytes.</P
258
terminated array of network addresses for the host.
259
Host addresses are returned in network byte order.</P
265
>For backward compatibility with very old software,
270
is the first address in
278
>lwres_gethostent()</TT
282
>lwres_sethostent()</TT
286
>lwres_endhostent()</TT
290
>lwres_gethostent_r()</TT
294
>lwres_sethostent_r()</TT
299
>lwres_endhostent_r()</TT
301
provide iteration over the known host entries on systems that
302
provide such functionality through facilities like
307
or NIS. The lightweight resolver does not currently implement
308
these functions; it only provides them as stub functions that always
313
>lwres_gethostbyname()</TT
317
>lwres_gethostbyname2()</TT
318
> look up the hostname
327
>lwres_gethostbyname()</TT
328
> always looks for an IPv4
331
>lwres_gethostbyname2()</TT
333
address of protocol family <TT
345
> — IPv4 or IPV6
346
addresses respectively. Successful calls of the functions return a
349
>struct hostent</SPAN
350
>for the name that was looked up.
354
> is returned if the lookups by
357
>lwres_gethostbyname()</TT
361
>lwres_gethostbyname2()</TT
364
>Reverse lookups of addresses are performed by
367
>lwres_gethostbyaddr()</TT
374
> is an address of length
380
> bytes and protocol family
396
>lwres_gethostbyname_r()</TT
397
> is a thread-safe function
398
for forward lookups. If an error occurs, an error code is returned in
410
> is a pointer to a <SPAN
414
> which is initialised by a successful call to
417
>lwres_gethostbyname_r()</TT
424
> is a buffer of length
430
> bytes which is used to store the
441
> elements of the <SPAN
451
Successful calls to <TT
453
>lwres_gethostbyname_r()</TT
461
which is a pointer to the <SPAN
463
>struct hostent</SPAN
468
>lwres_gethostbyaddr_r()</TT
469
> is a thread-safe function
470
that performs a reverse lookup of address <TT
481
> bytes long and is of protocol
494
>. If an error occurs, the error code is returned
500
>. The other function parameters are
501
identical to those in <TT
503
>lwres_gethostbyname_r()</TT
510
> is a pointer to a <SPAN
514
> which is initialised by a successful call to
517
>lwres_gethostbyaddr_r()</TT
524
> is a buffer of length
530
> bytes which is used to store the
541
> elements of the <SPAN
553
>lwres_gethostbyaddr_r()</TT
560
>, which is a pointer to the
563
>struct hostent()</TT
577
>lwres_gethostbyname()</TT
581
>lwres_gethostbyname2()</TT
585
>lwres_gethostbyaddr()</TT
590
>lwres_gethostent()</TT
592
return NULL to indicate an error. In this case the global variable
597
will contain one of the following error codes defined in
600
><lwres/netdb.h></TT
615
>The host or address was not found.</P
624
>A recoverable error occurred, e.g., a timeout.
625
Retrying the lookup may succeed.</P
634
>A non-recoverable error occurred.</P
643
>The name exists, but has no address information
644
associated with it (or vice versa in the case
645
of a reverse lookup). The code NO_ADDRESS
646
is accepted as a synonym for NO_DATA for backwards
656
CLASS="REFENTRYTITLE"
657
>lwres_hstrerror</SPAN
660
translates these error codes to suitable error messages.</P
664
>lwres_gethostent()</TT
669
>lwres_gethostent_r()</TT
677
>Successful calls to <TT
679
>lwres_gethostbyname_r()</TT
683
>lwres_gethostbyaddr_r()</TT
690
>, a pointer to the <SPAN
694
> that was initialised by these functions. They return
698
> if the lookups fail or if <TT
704
was too small to hold the list of addresses and names referenced by
715
> elements of the <SPAN
724
> was too small, both
727
>lwres_gethostbyname_r()</TT
731
>lwres_gethostbyaddr_r()</TT
732
> set the global variable
752
CLASS="REFENTRYTITLE"
760
CLASS="REFENTRYTITLE"
761
>lwres_getipnode</SPAN
768
CLASS="REFENTRYTITLE"
769
>lwres_hstrerror</SPAN
783
>lwres_gethostbyname()</TT
787
>lwres_gethostbyname2()</TT
791
>lwres_gethostbyaddr()</TT
796
>lwres_endhostent()</TT
798
are not thread safe; they return pointers to static data and
799
provide error codes through a global variable.
800
Thread-safe versions for name and address lookup are provided by
803
>lwres_gethostbyname_r()</TT
808
>lwres_gethostbyaddr_r()</TT
812
>The resolver daemon does not currently support any non-DNS
813
name services such as
823
consequently the above functions don't, either.</P
b'\\ No newline at end of file'