1 /* mesg - enable or disable communications. Author: John J. Ribera */
4 * mesg - enable or disable communications.
6 * Usage: mesg [ y | n ]
8 * 'mesg n' will turn off group and world permissions of the
10 * 'mesg y' will enable group and world to write to the user's
12 * mesg with no parameters will put the writeable status
15 * Author: John J. Ribera, Jr. 09/09/90
17 #include <sys/types.h>
23 int main(int argc
, char *argv
[]);
32 if ((tty_name
= ttyname(0)) == NULL
) exit(2);
33 if (stat(tty_name
, &statb
) == -1) exit(2);
35 if (*argv
[1] == 'n') statb
.st_mode
= 0600;
36 else if (*argv
[1] == 'y') statb
.st_mode
= 0620;
38 fprintf(stderr
, "mesg: usage: mesg [n|y]\n");
41 if (chmod(tty_name
, statb
.st_mode
) == -1) exit(2);
42 } else printf((statb
.st_mode
& 020) ? "is y\n" : "is n\n");
44 if (statb
.st_mode
& 020) exit(0);