edits, mainly to make the generated html output nicer
[platform/upstream/c-ares.git] / ares_gethostbyname.3
1 .\" $Id$
2 .\"
3 .\" Copyright 1998 by the Massachusetts Institute of Technology.
4 .\"
5 .\" Permission to use, copy, modify, and distribute this
6 .\" software and its documentation for any purpose and without
7 .\" fee is hereby granted, provided that the above copyright
8 .\" notice appear in all copies and that both that copyright
9 .\" notice and this permission notice appear in supporting
10 .\" documentation, and that the name of M.I.T. not be used in
11 .\" advertising or publicity pertaining to distribution of the
12 .\" software without specific, written prior permission.
13 .\" M.I.T. makes no representations about the suitability of
14 .\" this software for any purpose.  It is provided "as is"
15 .\" without express or implied warranty.
16 .\"
17 .TH ARES_GETHOSTBYNAME 3 "25 July 1998"
18 .SH NAME
19 ares_gethostbyname \- Initiate a host query by name
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
25 .B      struct hostent *\fIhostent\fP)
26 .PP
27 .B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP,
28 .B      int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP)
29 .fi
30 .SH DESCRIPTION
31 The
32 .B ares_gethostbyname
33 function initiates a host query by name on the name service channel
34 identified by
35 .IR channel .
36 The parameter
37 .I name
38 gives the hostname as a NUL-terminated C string, and
39 .I family
40 gives the desired type of address for the resulting host entry.  When the
41 query is complete or has failed, the ares library will invoke \fIcallback\fP.
42 Completion or failure of the query may happen immediately, or may happen
43 during a later call to \fIares_process(3)\fP, \fIares_destroy(3)\fP or
44 \fIares_cancel(3)\fP.
45 .PP
46 The callback argument
47 .I arg
48 is copied from the
49 .B ares_gethostbyname
50 argument
51 .IR arg .
52 The callback argument
53 .I status
54 indicates whether the query succeeded and, if not, how it failed.  It
55 may have any of the following values:
56 .TP 19
57 .B ARES_SUCCESS
58 The host lookup completed successfully.
59 .TP 19
60 .B ARES_ENOTIMP
61 The ares library does not know how to find addresses of type
62 .IR family .
63 .TP 19
64 .B ARES_EBADNAME
65 The hostname
66 .B name
67 is composed entirely of numbers and periods, but is not a valid
68 representation of an Internet address.
69 .TP 19
70 .B ARES_ENOTFOUND
71 The address
72 .I addr
73 was not found.
74 .TP 19
75 .B ARES_ENOMEM
76 Memory was exhausted.
77 .TP 19
78 .B ARES_EDESTRUCTION
79 The name service channel
80 .I channel
81 is being destroyed; the query will not be completed.
82 .PP
83 On successful completion of the query, the callback argument
84 .I hostent
85 points to a
86 .B struct hostent
87 containing the name of the host returned by the query.  The callback
88 need not and should not attempt to free the memory pointed to by
89 .IR hostent ;
90 the ares library will free it when the callback returns.  If the query
91 did not complete successfully,
92 .I hostent
93 will be
94 .BR NULL .
95 .SH SEE ALSO
96 .BR ares_process (3),
97 .BR ares_gethostbyaddr (3)
98 .SH AUTHOR
99 Greg Hudson, MIT Information Systems
100 .br
101 Copyright 1998 by the Massachusetts Institute of Technology.