xref: /freebsd/lib/libutil/trimdomain.3 (revision 7f3dea244c40159a41ab22da77a434d7c5b5e85a)
1.\" Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd April 7, 1999
28.Os
29.Dt TRIMDOMAIN 3
30.Sh NAME
31.Nm trimdomain
32.Nd "trim the current domain name from a host name"
33.Sh SYNOPSIS
34.Fd #include <sys/types.h>
35.Fd #include <libutil.h>
36.Ft void
37.Fn trimdomain "char *fullhost" "int hostsize"
38.Pp
39Link with
40.Va -lutil
41on the
42.Xr cc 1
43command line.
44.Sh DESCRIPTION
45The function
46.Fn trimdomain
47removes the current domain name from the passed
48.Ar fullhost
49name by writing a
50.Dv NUL
51character over the first period of the passed name.  The current domain
52name is determined by calling
53.Xr gethostname 3
54and removing everything up to the first period.  The name is determined
55the first time this function is called and is cached for future use.
56.Pp
57.Fn trimdomain
58will only trim the domain name if the passed
59.Ar fullname
60ends with the current domain name and if the length of the resulting host
61name does not exceed
62.Ar hostsize .
63.Pp
64If the passed
65.Ar fullname
66is actually a
67.Dv DISPLAY
68specification of the form
69.Sm off
70.Ar host No . Ar domain No : Ns
71.Sm on
72.Ar \&nn Oo
73.No . Ns Ar \&nn
74.Oc
75and the domain name is the same as the local domain name,
76.Fn trimdomain
77will remove the embedded domain name, copying the screen and display
78numbers to the end of the base host name and resulting in
79.Ar host No : Ns Ar \&nn Oo
80.No . Ns Ar \&nn
81.Oc .
82.Sh RETURN VALUES
83.Fn trimdomain
84does not return a value.
85.Sh SEE ALSO
86.Xr gethostname 3
87