diff --git a/usr.bin/mesg/Makefile b/usr.bin/mesg/Makefile index bf1979c3ca17..2a673985f66d 100644 --- a/usr.bin/mesg/Makefile +++ b/usr.bin/mesg/Makefile @@ -1,5 +1,5 @@ -# from: @(#)Makefile 5.2 (Berkeley) 5/11/90 -# $Id: Makefile,v 1.2 1993/07/31 15:19:13 mycroft Exp $ +# $NetBSD: Makefile,v 1.3 1994/12/23 07:16:29 jtc Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= mesg diff --git a/usr.bin/mesg/mesg.1 b/usr.bin/mesg/mesg.1 index 985b4cf9f689..24eb70202dc2 100644 --- a/usr.bin/mesg/mesg.1 +++ b/usr.bin/mesg/mesg.1 @@ -1,5 +1,7 @@ -.\" Copyright (c) 1987, 1990 The Regents of the University of California. -.\" All rights reserved. +.\" $NetBSD: mesg.1,v 1.3 1994/12/23 07:16:31 jtc Exp $ +.\" +.\" Copyright (c) 1987, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -29,43 +31,40 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)mesg.1 6.7 (Berkeley) 7/26/91 -.\" $Id: mesg.1,v 1.2 1993/08/01 07:30:48 mycroft Exp $ +.\" @(#)mesg.1 8.1 (Berkeley) 6/6/93 .\" -.Dd July 26, 1991 +.Dd June 6, 1993 .Dt MESG 1 .Os .Sh NAME .Nm mesg -.Nd Display (do not display) messages from other users +.Nd display (do not display) messages from other users .Sh SYNOPSIS .Nm mesg .Op Cm n | Cm y .Sh DESCRIPTION The .Nm mesg -utility is invoked by a user to control write access others have to -her or his terminal. By default, write access is allowed, and -programs such as -.Xr talk 1 , -.Xr write 1 +utility is invoked by a users to control write access others +have to the terminal device associated with the standard error +output. +Write access is allowed by default, and programs such as +.Xr talk 1 and -.Xr echo 1 -may display messages on the target user's terminal. +.Xr write 1 +may display messages on the terminal. .Pp Options available: .Bl -tag -width flag .It Cm n -Disallows messages and informs the -sender -that `Your party is refusing messages'. +Disallows messages. .It Cm y -Allows messages to be displayed. +Permits messages to be displayed. .El .Pp If no arguments are given, .Nm mesg -displays the present message status. +displays the present message status to the standard error output. .Pp The .Nm mesg @@ -76,7 +75,7 @@ utility exits with one of the following values: Messages are allowed. .It Li "\ 1" Messages are not allowed. -.It Li "\-1" +.It Li "\>1" An error has occurred. .El .Sh FILES @@ -84,10 +83,9 @@ An error has occurred. .It Pa /dev/[pt]ty[pq]? .El .Sh SEE ALSO -.Xr write 1 , +.Xr biff 1 , .Xr talk 1 , -.Xr echo 1 , -.Xr biff 1 +.Xr write 1 .Sh HISTORY A .Nm mesg diff --git a/usr.bin/mesg/mesg.c b/usr.bin/mesg/mesg.c index af7c24e1d7d4..1abcc0dc366c 100644 --- a/usr.bin/mesg/mesg.c +++ b/usr.bin/mesg/mesg.c @@ -1,6 +1,8 @@ +/* $NetBSD: mesg.c,v 1.4 1994/12/23 07:16:32 jtc Exp $ */ + /* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph @@ -37,74 +39,71 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1987 Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1987, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/*static char sccsid[] = "from: @(#)mesg.c 4.7 (Berkeley) 3/1/91";*/ -static char rcsid[] = "$Id: mesg.c,v 1.3 1994/05/17 04:15:59 cgd Exp $"; +#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 $"; #endif /* not lint */ -/* - * mesg -- set current tty to accept or - * forbid write permission. - * - * mesg [y] [n] - * y allow messages - * n forbid messages - */ - #include #include + +#include +#include #include +#include +#include +#include -static char *tty; - +int main(argc, argv) int argc; - char **argv; + char *argv[]; { - struct stat sbuf; - char *ttyname(); + struct stat sb; + char *tty; + int ch; - if (!(tty = ttyname(2))) { - fputs("mesg: not a device in /dev.\n", stderr); - exit(-1); - } - if (stat(tty, &sbuf) < 0) { - perror("mesg"); - exit(-1); - } - if (argc < 2) { - if (sbuf.st_mode & 020) { - fputs("is y\n", stderr); + while ((ch = getopt(argc, argv, "")) != EOF) + switch (ch) { + case '?': + default: + goto usage; + } + argc -= optind; + argv += optind; + + if ((tty = ttyname(STDERR_FILENO)) == NULL) + err(1, "ttyname"); + if (stat(tty, &sb) < 0) + err(1, "%s", tty); + + if (*argv == NULL) { + if (sb.st_mode & S_IWGRP) { + (void)fprintf(stderr, "is y\n"); exit(0); } - fputs("is n\n", stderr); + (void)fprintf(stderr, "is n\n"); exit(1); } -#define OTHER_WRITE 020 - switch(*argv[1]) { + + switch (*argv[0]) { case 'y': - newmode(sbuf.st_mode | OTHER_WRITE); + if (chmod(tty, sb.st_mode | S_IWGRP) < 0) + err(1, "%s", tty); exit(0); case 'n': - newmode(sbuf.st_mode &~ OTHER_WRITE); + if (chmod(tty, sb.st_mode & ~S_IWGRP) < 0) + err(1, "%s", tty); exit(1); - default: - fputs("usage: mesg [y] [n]\n", stderr); - exit(-1); } - /*NOTREACHED*/ -} -newmode(m) - u_short m; -{ - if (chmod(tty, m) < 0) { - perror("mesg"); - exit(-1); - } +usage: (void)fprintf(stderr, "usage: mesg [y | n]\n"); + exit(2); } diff --git a/usr.bin/mkfifo/Makefile b/usr.bin/mkfifo/Makefile index 853be6ab2167..463d91a3a7f4 100644 --- a/usr.bin/mkfifo/Makefile +++ b/usr.bin/mkfifo/Makefile @@ -1,5 +1,5 @@ -# from: @(#)Makefile 5.2 (Berkeley) 5/11/90 -# $Id: Makefile,v 1.2 1993/07/31 15:19:01 mycroft Exp $ +# $NetBSD: Makefile,v 1.3 1994/12/23 07:16:52 jtc Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= mkfifo diff --git a/usr.bin/mkfifo/mkfifo.1 b/usr.bin/mkfifo/mkfifo.1 index 02cc63858987..56071b3ba32c 100644 --- a/usr.bin/mkfifo/mkfifo.1 +++ b/usr.bin/mkfifo/mkfifo.1 @@ -1,5 +1,7 @@ -.\" Copyright (c) 1990 The Regents of the University of California. -.\" All rights reserved. +.\" $NetBSD: mkfifo.1,v 1.4 1994/12/23 07:16:54 jtc Exp $ +.\" +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. @@ -32,12 +34,11 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)mkfifo.1 5.6 (Berkeley) 7/1/91 -.\" $Id: mkfifo.1,v 1.3 1993/08/01 07:30:41 mycroft Exp $ +.\" @(#)mkfifo.1 8.2 (Berkeley) 1/5/94 .\" -.Dd July 1, 1991 +.Dd January 5, 1994 .Dt MKFIFO 1 -.Os +.Os BSD 4.4 .Sh NAME .Nm mkfifo .Nd make fifos @@ -73,17 +74,18 @@ requires write permission in the parent directory. .Pp .Nm Mkfifo exits 0 if successful, and >0 if an error occurred. -.Sh STANDARDS -The -.Nm Mkfifo -command is expected to be -.St -p1003.2 -compatible. .Sh SEE ALSO .Xr mkdir 1 , -.Xr rm 1 -.Sh HISTORY +.Xr mknod 1 , +.Xr rm 1 , +.Xr mkfifo 2 +.Sh STANDARDS The .Nm mkfifo -command is -.Ud +utility is expected to be +.St -p1003.2-92 +compliant. +.Sh HISTORY +.Nm +command appears in +.Bx 4.4 . diff --git a/usr.bin/mkfifo/mkfifo.c b/usr.bin/mkfifo/mkfifo.c index 32b69cf4300d..8818ca8f4600 100644 --- a/usr.bin/mkfifo/mkfifo.c +++ b/usr.bin/mkfifo/mkfifo.c @@ -1,6 +1,8 @@ +/* $NetBSD: mkfifo.c,v 1.7 1994/12/23 07:16:56 jtc Exp $ */ + /* - * Copyright (c) 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,14 +34,16 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1990 Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/*static char sccsid[] = "from: @(#)mkfifo.c 5.3 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: mkfifo.c,v 1.6 1993/12/31 19:35:37 jtc Exp $"; +#if 0 +static char sccsid[] = "@(#)mkfifo.c 8.2 (Berkeley) 1/5/94"; +#endif +static char rcsid[] = "$NetBSD: mkfifo.c,v 1.7 1994/12/23 07:16:56 jtc Exp $"; #endif /* not lint */ #include @@ -57,7 +61,7 @@ static void usage(); int main(argc, argv) int argc; - char **argv; + char *argv[]; { int ch, exitval; void * set; @@ -86,8 +90,9 @@ main(argc, argv) default: usage(); } - - if (!*(argv += optind)) + argc -= optind; + argv += optind; + if (argv[0] == NULL) usage(); for (exitval = 0; *argv; ++argv) { @@ -99,7 +104,7 @@ main(argc, argv) exit(exitval); } -static void +void usage() { (void)fprintf(stderr, "usage: mkfifo [-m mode] fifoname ...\n");