GETHOSTNAME(2)
NAME
ghostname, shostname − get/set name of current host
SYNOPSIS
ghostname(name, namelen)
char *name;
int namelen;
shostname(name, namelen)
char *name;
int namelen;
DESCRIPTION
Ghostname returns the standard host name for the current processor, as previously set by shostname. The parameter namelen specifies the size of the name array. The returned name is null-terminated unless insufficient space is provided.
Shostname sets the name of the host machine to be name, which has length namelen. This call is restricted to the superuser and is normally used only when the system is bootstrapped.
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 int the global location errno.
ERRORS
The following errors may be returned by these calls:
[EFAULT] The name or namelen parameter gave an invalid address.
[EPERM] The caller was not the superuser.
RESTRICTIONS
Host names are limited to 32 characters.
These system calls are the same as the gethostname and sethostname system calls in ULTRIX-32. Due to the current constraint that function names must be significant in the first seven characters, the names were shortend to keep them from clashing with the (not yet implemented) gethostid and sethostid system calls.
For compatibility reasons, you can use gethostname and sethostname in your program, provided that either the top of the program contains the line
#define gethostname ghostname
or the module is compiled with
-Dgethostname=ghostname
as an argument to cc. This works because cpp recognizes eight characters of significance.