diff options
author | steve <steve@FreeBSD.org> | 1996-12-14 05:59:58 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1996-12-14 05:59:58 +0000 |
commit | 1dd75e9822783fc7d4286a38c101e10903d1fd11 (patch) | |
tree | e8209743dbc3d45345369caf50ae6399fbbda5a0 /bin/hostname/hostname.c | |
parent | 88dfe6ac44c03217ad1c86e9ce45937a36eda99d (diff) | |
download | FreeBSD-src-1dd75e9822783fc7d4286a38c101e10903d1fd11.zip FreeBSD-src-1dd75e9822783fc7d4286a38c101e10903d1fd11.tar.gz |
Merge Lite2 mods, -Wall cleaning, and show usage if
incorrectly called.
Incorrect usage mod obtained from: NetBSD
Diffstat (limited to 'bin/hostname/hostname.c')
-rw-r--r-- | bin/hostname/hostname.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/bin/hostname/hostname.c b/bin/hostname/hostname.c index 00408ec..50ad17e 100644 --- a/bin/hostname/hostname.c +++ b/bin/hostname/hostname.c @@ -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); +} |