projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4 release
[unix-history]
/
usr
/
src
/
cmd
/
write.c
diff --git
a/usr/src/cmd/write.c
b/usr/src/cmd/write.c
index
b896a7c
..
626a98f
100644
(file)
--- a/
usr/src/cmd/write.c
+++ b/
usr/src/cmd/write.c
@@
-1,3
+1,4
@@
+static char *sccsid = "@(#)write.c 4.2 (Berkeley) 11/10/80";
/*
* write to another user
*/
/*
* write to another user
*/
@@
-7,6
+8,10
@@
#include <sys/stat.h>
#include <signal.h>
#include <utmp.h>
#include <sys/stat.h>
#include <signal.h>
#include <utmp.h>
+#include <time.h>
+
+#define NMAX sizeof(ubuf.ut_name)
+#define LMAX sizeof(ubuf.ut_line)
char *strcat();
char *strcpy();
char *strcat();
char *strcpy();
@@
-23,6
+28,7
@@
int logcnt;
int eof();
int timout();
FILE *tf;
int eof();
int timout();
FILE *tf;
+char *getenv();
main(argc, argv)
char *argv[];
main(argc, argv)
char *argv[];
@@
-31,6
+37,9
@@
char *argv[];
register i;
register FILE *uf;
int c1, c2;
register i;
register FILE *uf;
int c1, c2;
+ long clock = time( 0 );
+ struct tm *localtime();
+ struct tm *localclock = localtime( &clock );
if(argc < 2) {
printf("usage: write user [ttyname]\n");
if(argc < 2) {
printf("usage: write user [ttyname]\n");
@@
-54,8
+63,10
@@
char *argv[];
strcat(histty, histtya);
}
while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) {
strcat(histty, histtya);
}
while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) {
+ if (ubuf.ut_name[0] == '\0')
+ continue;
if (strcmp(ubuf.ut_line, mytty)==0) {
if (strcmp(ubuf.ut_line, mytty)==0) {
- for(i=0; i<
8
; i++) {
+ for(i=0; i<
NMAX
; i++) {
c1 = ubuf.ut_name[i];
if(c1 == ' ')
c1 = 0;
c1 = ubuf.ut_name[i];
if(c1 == ' ')
c1 = 0;
@@
-65,7
+76,7
@@
char *argv[];
}
}
if(him[0] != '-' || him[1] != 0)
}
}
if(him[0] != '-' || him[1] != 0)
- for(i=0; i<
8
; i++) {
+ for(i=0; i<
NMAX
; i++) {
c1 = him[i];
c2 = ubuf.ut_name[i];
if(c1 == 0)
c1 = him[i];
c2 = ubuf.ut_name[i];
if(c1 == 0)
@@
-112,11
+123,12
@@
cont:
if ((stbuf.st_mode&02) == 0)
goto perm;
sigs(eof);
if ((stbuf.st_mode&02) == 0)
goto perm;
sigs(eof);
- fprintf(tf, "Message from ");
+ fprintf(tf, "
\r\n
Message from ");
#ifdef interdata
fprintf(tf, "(Interdata) " );
#endif
#ifdef interdata
fprintf(tf, "(Interdata) " );
#endif
- fprintf(tf, "%s %s...\n
\a
\a
\a
", me, mytty);
+ fprintf(tf, "%s on %s at %d:%02d ...\r\n
\a
\a
\a
"
+ , me, mytty , localclock -> tm_hour , localclock -> tm_min );
fflush(tf);
for(;;) {
char buf[128];
fflush(tf);
for(;;) {
char buf[128];
@@
-129,6
+141,8
@@
cont:
continue;
}
write(fileno(tf), buf, i);
continue;
}
write(fileno(tf), buf, i);
+ if ( buf[ i - 1 ] == '\n' )
+ write( fileno( tf ) , "\r" , 1 );
}
perm:
}
perm:
@@
-139,14
+153,14
@@
perm:
timout()
{
timout()
{
- printf("Timeout opening
his
tty\n");
+ printf("Timeout opening
their
tty\n");
exit(1);
}
eof()
{
exit(1);
}
eof()
{
- fprintf(tf, "EOF\n");
+ fprintf(tf, "EOF\
r\
n");
exit(0);
}
exit(0);
}
@@
-163,7
+177,7
@@
char *bp;
}
if(i == 0) {
sigs((int (*)())0);
}
if(i == 0) {
sigs((int (*)())0);
- execl("/bin/sh", "sh", "-c", bp+1, 0);
+ execl(
getenv("SHELL") ? getenv("SHELL") :
"/bin/sh", "sh", "-c", bp+1, 0);
exit(0);
}
while(wait((int *)NULL) != i)
exit(0);
}
while(wait((int *)NULL) != i)