static char *sccsid
= "@(#)wall.c 4.5 (Berkeley) 81/06/12";
* wall.c - Broadcast a message to all users.
* This program is not related to David Wall, whose Stanford Ph.D. thesis
* is entitled "Mechanisms for Broadcast and Selective Broadcast".
#define IGNOREUSER "sleeper"
if((f
= fopen("/etc/utmp", "r")) == NULL
) {
fprintf(stderr
, "Cannot open /etc/utmp\n");
localclock
= localtime( &clock
);
/* take message from unix file instead of standard input */
if((mf
= fopen(argv
[1], "r")) == NULL
) {
fprintf(stderr
,"Cannot open %s\n", argv
[1]);
while((i
= getc(mf
)) != EOF
) {
if (msize
>= sizeof mesg
) {
fprintf(stderr
, "Message too long\n");
sline
= ttyslot(2); /* 'utmp' slot no. of sender */
fread((char *)utmp
, sizeof(struct utmp
), USERS
, f
);
strncpy(who
, utmp
[sline
].ut_name
, sizeof(utmp
[sline
].ut_name
));
if ((p
->ut_name
[0] == 0) ||
(strncmp (p
->ut_name
, IGNOREUSER
, sizeof(p
->ut_name
)) == 0))
/*** this might be nice, but utmp gets so out of date !!
/*** you can't do this with lots of users & MAXUPROC
fprintf(stderr, "Try again\n");
while ((i
= fork()) == -1)
if (wait((int *)0) == -1) {
fprintf(stderr
, "Try again\n");
signal(SIGALRM
, SIG_DFL
); /* blow away if open hangs */
if((f
= fopen(t
, "w")) == NULL
) {
fprintf(stderr
,"cannot open %s\n", t
);
"\n\a\a\aBroadcast Message from %s!%s (%.*s) at %d:%02d ...\r\n\n"
, sizeof(utmp
[sline
].ut_line
)
/* fwrite(mesg, msize, 1, f); */
for (cp
= mesg
, c
= msize
; c
-- > 0; cp
++) {