xref: /f-stack/tools/libutil/realhostname.3 (revision 22ce4aff)
11eaf0ac3Slogwang.\" Copyright (c) 1999 Brian Somers <[email protected]>
21eaf0ac3Slogwang.\" All rights reserved.
31eaf0ac3Slogwang.\"
41eaf0ac3Slogwang.\" Redistribution and use in source and binary forms, with or without
51eaf0ac3Slogwang.\" modification, are permitted provided that the following conditions
61eaf0ac3Slogwang.\" are met:
71eaf0ac3Slogwang.\" 1. Redistributions of source code must retain the above copyright
81eaf0ac3Slogwang.\"    notice, this list of conditions and the following disclaimer.
91eaf0ac3Slogwang.\" 2. Redistributions in binary form must reproduce the above copyright
101eaf0ac3Slogwang.\"    notice, this list of conditions and the following disclaimer in the
111eaf0ac3Slogwang.\"    documentation and/or other materials provided with the distribution.
121eaf0ac3Slogwang.\"
131eaf0ac3Slogwang.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
141eaf0ac3Slogwang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
151eaf0ac3Slogwang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
161eaf0ac3Slogwang.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
171eaf0ac3Slogwang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
181eaf0ac3Slogwang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
191eaf0ac3Slogwang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
201eaf0ac3Slogwang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
211eaf0ac3Slogwang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
221eaf0ac3Slogwang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
231eaf0ac3Slogwang.\" SUCH DAMAGE.
241eaf0ac3Slogwang.\"
251eaf0ac3Slogwang.\" $FreeBSD$
261eaf0ac3Slogwang.\"
271eaf0ac3Slogwang.Dd April 6, 1999
281eaf0ac3Slogwang.Dt REALHOSTNAME 3
291eaf0ac3Slogwang.Os
301eaf0ac3Slogwang.Sh NAME
311eaf0ac3Slogwang.Nm realhostname
321eaf0ac3Slogwang.Nd "convert an IP number to the real host name"
331eaf0ac3Slogwang.Sh LIBRARY
341eaf0ac3Slogwang.Lb libutil
351eaf0ac3Slogwang.Sh SYNOPSIS
361eaf0ac3Slogwang.In libutil.h
371eaf0ac3Slogwang.Ft int
381eaf0ac3Slogwang.Fn realhostname "char *host" "size_t hsize" "const struct in_addr *ip"
391eaf0ac3Slogwang.Sh DESCRIPTION
401eaf0ac3SlogwangThe function
411eaf0ac3Slogwang.Fn realhostname
421eaf0ac3Slogwangconverts
431eaf0ac3Slogwang.Ar ip
441eaf0ac3Slogwangto the corresponding host name.
451eaf0ac3SlogwangThis is done by resolving
461eaf0ac3Slogwang.Ar ip
471eaf0ac3Slogwangto a host name and then ensuring that the host name resolves
481eaf0ac3Slogwangback to
491eaf0ac3Slogwang.Ar ip .
501eaf0ac3Slogwang.Pp
511eaf0ac3Slogwang.Ar host
521eaf0ac3Slogwangmust point to a buffer of at least
531eaf0ac3Slogwang.Ar hsize
541eaf0ac3Slogwangbytes, and will always be written to by this function.
551eaf0ac3Slogwang.Pp
561eaf0ac3SlogwangIf the name resolution does not work both ways or if the host name is longer
571eaf0ac3Slogwangthan
581eaf0ac3Slogwang.Ar hsize
591eaf0ac3Slogwangbytes,
601eaf0ac3Slogwang.Xr inet_ntoa 3
611eaf0ac3Slogwangis used to convert
621eaf0ac3Slogwang.Ar ip
631eaf0ac3Slogwangto an ASCII form.
641eaf0ac3Slogwang.Pp
651eaf0ac3SlogwangIf the string written to
661eaf0ac3Slogwang.Ar host
671eaf0ac3Slogwangis
681eaf0ac3Slogwang.Ar hsize
691eaf0ac3Slogwangbytes long,
701eaf0ac3Slogwang.Ar host
711eaf0ac3Slogwangwill not be NUL terminated.
721eaf0ac3Slogwang.Sh RETURN VALUES
731eaf0ac3SlogwangThe
741eaf0ac3Slogwang.Fn realhostname
751eaf0ac3Slogwangfunction will return one of the following constants which are defined in
761eaf0ac3Slogwang.In libutil.h :
771eaf0ac3Slogwang.Bl -tag -width XXX -offset XXX
781eaf0ac3Slogwang.It Li HOSTNAME_FOUND
791eaf0ac3SlogwangA valid host name was found.
801eaf0ac3Slogwang.It Li HOSTNAME_INCORRECTNAME
811eaf0ac3SlogwangA host name was found, but it did not resolve back to the passed
821eaf0ac3Slogwang.Ar ip .
831eaf0ac3Slogwang.Ar host
841eaf0ac3Slogwangnow contains the numeric value of
851eaf0ac3Slogwang.Ar ip .
861eaf0ac3Slogwang.It Li HOSTNAME_INVALIDADDR
871eaf0ac3Slogwang.Ar ip
881eaf0ac3Slogwangcould not be resolved.
891eaf0ac3Slogwang.Ar host
901eaf0ac3Slogwangnow contains the numeric value of
911eaf0ac3Slogwang.Ar ip .
921eaf0ac3Slogwang.It Li HOSTNAME_INVALIDNAME
931eaf0ac3SlogwangA host name was found, but it could not be resolved back to any ip number.
941eaf0ac3Slogwang.Ar host
951eaf0ac3Slogwangnow contains the numeric value of
961eaf0ac3Slogwang.Ar ip .
971eaf0ac3Slogwang.El
981eaf0ac3Slogwang.Sh SEE ALSO
991eaf0ac3Slogwang.Xr gethostbyaddr 3 ,
1001eaf0ac3Slogwang.Xr gethostbyname 3 ,
1011eaf0ac3Slogwang.Xr inet_ntoa 3 ,
1021eaf0ac3Slogwang.Xr realhostname_sa 3
103*22ce4affSfengbojiang.Sh HISTORY
104*22ce4affSfengbojiangThe
105*22ce4affSfengbojiang.Fn realhostname
106*22ce4affSfengbojiangfunction first appeared in
107*22ce4affSfengbojiang.Fx 3.2 .
108