mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 04:43:32 +00:00
Merge Lite2 mods, -Wall cleaning, and show usage if
incorrectly called. Incorrect usage mod obtained from: NetBSD
This commit is contained in:
parent
8a166df9c3
commit
113b529fc5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20415
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)hostname.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $Id: hostname.1,v 1.2 1994/09/24 02:55:40 davidg Exp $
|
||||
.\" @(#)hostname.1 8.2 (Berkeley) 4/28/95
|
||||
.\" $Id: hostname.1,v 1.3 1996/02/11 22:33:13 mpp Exp $
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dd April 28, 1995
|
||||
.Dt HOSTNAME 1
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
@ -41,9 +41,9 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm hostname
|
||||
.Op Fl s
|
||||
.Op Ar nameofhost
|
||||
.Op Ar name-of-host
|
||||
.Sh DESCRIPTION
|
||||
.Nm Hostname
|
||||
.Nm
|
||||
prints the name of the current host. The super-user can
|
||||
set the hostname by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
|
@ -30,17 +30,17 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: hostname.c,v 1.2 1994/09/24 02:55:40 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
static char const copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
|
||||
static char const sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -51,12 +51,13 @@ static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
extern int optind;
|
||||
int ch, sflag;
|
||||
char *p, hostname[MAXHOSTNAMELEN];
|
||||
|
||||
@ -68,13 +69,14 @@ main(argc,argv)
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
(void)fprintf(stderr,
|
||||
"usage: hostname [-s] [hostname]\n");
|
||||
exit(1);
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc > 1)
|
||||
usage();
|
||||
|
||||
if (*argv) {
|
||||
if (sethostname(*argv, strlen(*argv)))
|
||||
err(1, "sethostname");
|
||||
@ -87,3 +89,11 @@ main(argc,argv)
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: hostname [-s] [hostname]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user