Blame ares_gethostbyname_file.3

Packit 514978
.\"
Packit 514978
.\" Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
.\"
Packit 514978
.\" Permission to use, copy, modify, and distribute this
Packit 514978
.\" software and its documentation for any purpose and without
Packit 514978
.\" fee is hereby granted, provided that the above copyright
Packit 514978
.\" notice appear in all copies and that both that copyright
Packit 514978
.\" notice and this permission notice appear in supporting
Packit 514978
.\" documentation, and that the name of M.I.T. not be used in
Packit 514978
.\" advertising or publicity pertaining to distribution of the
Packit 514978
.\" software without specific, written prior permission.
Packit 514978
.\" M.I.T. makes no representations about the suitability of
Packit 514978
.\" this software for any purpose.  It is provided "as is"
Packit 514978
.\" without express or implied warranty.
Packit 514978
.\"
Packit 514978
.TH ARES_GETHOSTBYNAME 3 "25 July 1998"
Packit 514978
.SH NAME
Packit 514978
ares_gethostbyname_file \- Lookup a name in the system's hosts file
Packit 514978
.SH SYNOPSIS
Packit 514978
.nf
Packit 514978
.B #include <ares.h>
Packit 514978
.PP
Packit 514978
.B int ares_gethostbyname_file(ares_channel \fIchannel\fP, const char *\fIname\fP,
Packit 514978
.B 	int \fIfamily\fP, struct hostent **host)
Packit 514978
.fi
Packit 514978
.SH DESCRIPTION
Packit 514978
The
Packit 514978
.B ares_gethostbyname_file
Packit 514978
function performs a host lookup by name against the system's hosts file (or equivalent local hostname database).  
Packit 514978
The
Packit 514978
.IR channel
Packit 514978
parameter is required, but no asynchronous queries are performed.  Instead, the
Packit 514978
lookup is done via the same mechanism used to perform 'f' lookups
Packit 514978
(see the
Packit 514978
.I lookups
Packit 514978
options field in \fIares_init_options(3)\fP).
Packit 514978
The parameter
Packit 514978
.I name
Packit 514978
gives the hostname as a NUL-terminated C string, and
Packit 514978
.I family
Packit 514978
gives the desired type of address for the resulting host entry.  
Packit 514978
.PP
Packit 514978
The return value indicates whether the query succeeded and, if not, how it
Packit 514978
failed.  It may have any of the following values:
Packit 514978
.TP 19
Packit 514978
.B ARES_SUCCESS
Packit 514978
The host lookup completed successfully and 
Packit 514978
.I host
Packit 514978
now points to the result (and must be freed with \fIares_free_hostent(3)\fP).
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOTFOUND
Packit 514978
The hostname
Packit 514978
.I name
Packit 514978
was not found.
Packit 514978
.TP 19
Packit 514978
.B ARES_EFILE
Packit 514978
There was a file I/O error while performing the lookup.
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOMEM
Packit 514978
Memory was exhausted.
Packit 514978
.PP
Packit 514978
On successful completion of the query, the pointer pointed to by
Packit 514978
.I host
Packit 514978
points to a
Packit 514978
.B struct hostent
Packit 514978
containing the address of the host returned by the lookup.  The user must
Packit 514978
free the memory pointed to by
Packit 514978
.IR host
Packit 514978
when finished with it by calling \fIares_free_hostent(3)\fP.  If the lookup did
Packit 514978
not complete successfully, 
Packit 514978
.I host
Packit 514978
will be
Packit 514978
.BR NULL .
Packit 514978
.SH AVAILABILITY
Packit 514978
Added in c-ares 1.5.4
Packit 514978
.SH SEE ALSO
Packit 514978
.BR ares_gethostbyname (3),
Packit 514978
.BR ares_free_hostent (3),
Packit 514978
.BR ares_init_options (3)
Packit 514978
.SH AUTHOR
Packit 514978
Brad Spencer
Packit 514978
.br
Packit 514978
Copyright 1998 by the Massachusetts Institute of Technology.