static char *sccsid
= "@(#)wall.c 4.1 (Berkeley) %G%";
* 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".
if((f
= fopen("/etc/utmp", "r")) == NULL
) {
fprintf(stderr
, "Cannot open /etc/utmp\n");
localclock
= localtime( &clock
);
fread((char *)utmp
, sizeof(struct utmp
), USERS
, f
);
/* take message from unix file instead of standard input */
if((f
= fopen(argv
[1], "r")) == NULL
) {
fprintf(stderr
,"Cannot open %s\n", argv
[1]);
while((i
= getc(f
)) != EOF
) mesg
[msize
++] = i
;
sline
= ttyslot(2); /* 'utmp' slot no. of sender */
for (i
=0;(c
=utmp
[sline
].ut_name
[i
]) && i
<sizeof(utmp
[0].ut_name
);i
++)
who
[i
] = '\0'; /* sender initials */
fprintf(stderr
, "Try again\n");
if((f
= fopen(t
, "w")) == NULL
) {
fprintf(stderr
,"cannot open %s\n", t
);
fprintf(f
, "\n\a\a\aBroadcast Message from %s (%s) at %d:%02d ...\r\n\n"
,who
, utmp
[sline
].ut_line
, localclock
-> tm_hour
, localclock
-> tm_min
);
/* fwrite(mesg, msize, 1, f); */
for (cp
= mesg
, c
= msize
; c
-- > 0; cp
++) {