Include appropriate header files to bring prototypes into scope.
Cleaned up man page.
This commit is contained in:
parent
d229d39c12
commit
0eee1ab6c0
|
@ -30,35 +30,29 @@
|
|||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)domainname.1 6.8 (Berkeley) 7/27/91
|
||||
.\" $Id: domainname.1,v 1.2 1993/08/01 07:48:46 mycroft Exp $
|
||||
.\" $Id: domainname.1,v 1.3 1993/09/10 01:24:45 jtc Exp $
|
||||
.\"
|
||||
.Dd July 27, 1991
|
||||
.Dt DOMAINNAME 1
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
.Nm domainname
|
||||
.Nd set or print name of current host system
|
||||
.Nd set or print the name of the current domain
|
||||
.Sh SYNOPSIS
|
||||
.Nm domainname
|
||||
.Op Fl s
|
||||
.Op Ar nameofhost
|
||||
.Op Ar name-of-domain
|
||||
.Sh DESCRIPTION
|
||||
.Nm Hostname
|
||||
prints the name of the current host. The super-user can
|
||||
set the domainname by supplying an argument; this is usually done in the
|
||||
.Nm Domainname
|
||||
prints the domain name of the current host. The super-user can
|
||||
set the domain name by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
.Pa /etc/netstart ,
|
||||
normally run at boot
|
||||
time.
|
||||
.Pp
|
||||
Options:
|
||||
.Bl -tag -width flag
|
||||
.It Fl s
|
||||
Trims off any domain information from the printed
|
||||
name.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr getdomainname 2
|
||||
.Xr hostname 1 ,
|
||||
.Xr getdomainname 2 ,
|
||||
.Xr setdomainname 2
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm domainname
|
||||
|
|
|
@ -1,34 +1,45 @@
|
|||
#ifndef lint
|
||||
static char rcsid[] = "$Id: domainname.c,v 1.2 1993/08/02 17:15:10 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: domainname.c,v 1.3 1993/09/10 01:24:46 jtc Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static void usage __P((void));
|
||||
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char dom[MAXHOSTNAMELEN];
|
||||
|
||||
if( argc>2 ) {
|
||||
fprintf(stderr, "usage: domainname [name]\n");
|
||||
exit(1);
|
||||
usage ();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
if( argc==2 ) {
|
||||
if( setdomainname(argv[1], strlen(argv[1])+1) == -1) {
|
||||
perror("setdomainname");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
} else {
|
||||
if( getdomainname(dom, sizeof(dom)) == -1) {
|
||||
perror("getdomainname");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s\n", dom);
|
||||
}
|
||||
if( getdomainname(dom, sizeof dom) == -1) {
|
||||
perror("getdomainname");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s\n", dom);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage ()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: domainname [name-of-domain]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)hostname.1 6.8 (Berkeley) 7/27/91
|
||||
.\" $Id: hostname.1,v 1.4 1993/08/01 07:48:39 mycroft Exp $
|
||||
.\" $Id: hostname.1,v 1.5 1993/09/10 01:24:51 jtc Exp $
|
||||
.\"
|
||||
.Dd July 27, 1991
|
||||
.Dt HOSTNAME 1
|
||||
|
@ -41,7 +41,7 @@
|
|||
.Sh SYNOPSIS
|
||||
.Nm hostname
|
||||
.Op Fl s
|
||||
.Op Ar nameofhost
|
||||
.Op Ar name-of-host
|
||||
.Sh DESCRIPTION
|
||||
.Nm Hostname
|
||||
prints the name of the current host. The super-user can
|
||||
|
@ -58,7 +58,9 @@ Trims off any domain information from the printed
|
|||
name.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr gethostname 2
|
||||
.Xr domainname 1 ,
|
||||
.Xr gethostname 2 ,
|
||||
.Xr sethostname 2
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm hostname
|
||||
|
|
|
@ -39,30 +39,34 @@ char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)hostname.c 5.4 (Berkeley) 5/31/90";*/
|
||||
static char rcsid[] = "$Id: hostname.c,v 1.4 1993/08/01 18:59:40 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: hostname.c,v 1.5 1993/09/10 01:24:53 jtc Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static void usage __P((void));
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
extern int optind;
|
||||
int ch, sflag;
|
||||
char hostname[MAXHOSTNAMELEN], *p, *index();
|
||||
char hostname[MAXHOSTNAMELEN], *p;
|
||||
|
||||
sflag = 0;
|
||||
while ((ch = getopt(argc, argv, "s")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "s")) != -1)
|
||||
switch((char)ch) {
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
fputs("hostname [-s] [hostname]\n", stderr);
|
||||
exit(1);
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
argv += optind;
|
||||
|
||||
|
@ -82,3 +86,10 @@ main(argc,argv)
|
|||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage ()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: hostname [-s] [hostname]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue