70 lines
1.7 KiB
Groff
70 lines
1.7 KiB
Groff
'\"macro stdmacro
|
|
.\" Copyright (c) 1983 Regents of the University of California.
|
|
.\" All rights reserved. The Berkeley software License Agreement
|
|
.\" specifies the terms and conditions for redistribution.
|
|
.\"
|
|
.\" @(#)gethostname.2 6.4 (Berkeley) 5/22/86
|
|
.\"
|
|
.TH gethostname 2
|
|
.SH NAME
|
|
gethostname, sethostname \- get/set name of current host
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
\f3#include <unistd.h>\f1
|
|
\f3int gethostname (char \(**name, size_t namelen);\f1
|
|
\f3int sethostname (char \(**name, int namelen);\f1
|
|
.fi
|
|
.Op
|
|
.Op f
|
|
.SH FORTRAN SYNOPSIS
|
|
.nf
|
|
\f3integer function gethostname (name, namelen)\f1
|
|
\f3character *1 name (namelen)\f1
|
|
\f3integer namelen\f1
|
|
.fi
|
|
.Op
|
|
.SH DESCRIPTION
|
|
.I Gethostname
|
|
returns the standard hostname for the current processor, as
|
|
previously set by
|
|
.IR sethostname .
|
|
The parameter
|
|
.I namelen
|
|
specifies the size of the
|
|
.I name
|
|
array.
|
|
The returned name is null-terminated and truncated if insufficient
|
|
space is provided.
|
|
.PP
|
|
.I Sethostname
|
|
sets the name of the host machine to be
|
|
.IR name ,
|
|
which has length
|
|
.IR namelen .
|
|
This call is restricted to the superuser and
|
|
is normally used only when the system is bootstrapped.
|
|
.SH "RETURN VALUE"
|
|
If the call succeeds a value of 0 is returned.
|
|
If the call
|
|
fails, then a value of \-1 is returned and an error code is
|
|
placed in the global location \f2errno\fP.
|
|
.SH "ERRORS"
|
|
The following errors may be returned by these calls:
|
|
.TP 15
|
|
[EFAULT]
|
|
The \f2name\fP or \f2namelen\fP parameter gave an
|
|
invalid address.
|
|
.TP 15
|
|
[EPERM]
|
|
The caller tried to set the hostname and was not the superuser.
|
|
.TP 15
|
|
[EINVAL]
|
|
The \f2namelen\fP parameter was too large.
|
|
.SH SEE ALSO
|
|
gethostid(2)
|
|
.SH BUGS
|
|
Hostnames are limited to MAXHOSTNAMELEN (from
|
|
.IR <sys/param.h> )
|
|
characters, currently 256.
|