make exit codes match manpage

use <sys/cdefs.h> __COPYRIGHT and __RCSID macros, prototype main()
This commit is contained in:
mikel 1997-08-01 04:32:44 +00:00
parent fdf1615bca
commit 2c00d4fdb3
1 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mesg.c,v 1.4 1994/12/23 07:16:32 jtc Exp $ */
/* $NetBSD: mesg.c,v 1.5 1997/08/01 04:32:44 mikel Exp $ */
/*
* Copyright (c) 1987, 1993
@ -38,17 +38,18 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1987, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mesg.c 8.2 (Berkeley) 1/21/94";
#endif
static char rcsid[] = "$NetBSD: mesg.c,v 1.4 1994/12/23 07:16:32 jtc Exp $";
__RCSID("$NetBSD: mesg.c,v 1.5 1997/08/01 04:32:44 mikel Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -61,6 +62,8 @@ static char rcsid[] = "$NetBSD: mesg.c,v 1.4 1994/12/23 07:16:32 jtc Exp $";
#include <string.h>
#include <unistd.h>
int main __P((int, char **));
int
main(argc, argv)
int argc;
@ -70,7 +73,7 @@ main(argc, argv)
char *tty;
int ch;
while ((ch = getopt(argc, argv, "")) != EOF)
while ((ch = getopt(argc, argv, "")) != -1)
switch (ch) {
case '?':
default:
@ -80,9 +83,9 @@ main(argc, argv)
argv += optind;
if ((tty = ttyname(STDERR_FILENO)) == NULL)
err(1, "ttyname");
err(2, "ttyname");
if (stat(tty, &sb) < 0)
err(1, "%s", tty);
err(2, "%s", tty);
if (*argv == NULL) {
if (sb.st_mode & S_IWGRP) {
@ -96,11 +99,11 @@ main(argc, argv)
switch (*argv[0]) {
case 'y':
if (chmod(tty, sb.st_mode | S_IWGRP) < 0)
err(1, "%s", tty);
err(2, "%s", tty);
exit(0);
case 'n':
if (chmod(tty, sb.st_mode & ~S_IWGRP) < 0)
err(1, "%s", tty);
err(2, "%s", tty);
exit(1);
}