%%s 239/24/103 %%d D 1.1.3 07-Dec-83 16:51:30 eccmnk 4 3 %%c Added the following new features: (1) appended "hh:mm:ss" to the "[message %%c from on ]" message and appended "from %%c hh:mm:ss" to the eot message; (2) added -user option to send %%c each line to all of the terminals that a user is logged in on; (3) added %%c "[] " header to lines sent to the other user's terminal; (4) %%c added a routine to remove unwanted (possibly malicious) non-printable %%c characters from the line sent; (5) removed the extra new-line character %%c from each line sent to the other user's terminal; (6) made "send" report %%c that the user you are sending your message to has logged out and to %%c terminate "send" if "user" is no longer logged in on the terminal(s) you %%c were sending to. %%c %%c Required modifications to send.w`send.r`send, send.w`send.fmt, and the %%c addition of send.w`send.r`getdvi, send.w`send.r`lsttrm, send.w`send.r`nocc, %%c send.w`send.r`sndmsg and send.w`sndsym. %%s 3/3/124 %%d D 1.1.2 30-Jul-83 09:09:57 tools 3 2 %%c Removed trailing periods from quoted strings. %%s 3/3/124 %%d D 1.1.1 25-Jun-82 12:50:02 dpm 2 1 %%c Changed incorrect reference to "tt" to "ttstr" in trnlog call in %%c module send.w`send.r`send. Sending user's terminal is now correctly %%c identified instead of being shown as "dra0:[tools.msg]". %%s 0/0/0 %%d D 1.1 27-Mar-82 15:03:36 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- send.r 1834 asc 25-mar-82 09:40:40 v1.1 (sw-tools v1.1) #-h- send 1456 asc 25-mar-82 09:40:34 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- send.r 1834 asc 25-jun-82 12:48:12 dpm (martin,d.p.) %%E 3 %%I 3 %%D 4 #-h- send.r 1838 asc 30-jul-83 09:09:20 tools (lblh csam sventek) %%E 4 %%E 3 %%D 4 #-h- send 1459 asc 25-jun-82 12:44:34 dpm (martin,d.p.) %%E 4 %%E 2 %%I 4 #-h- send.r 7153 asc 30-nov-83 17:48:31 eccmnk (michael n. kimura) #-h- send 2834 asc 30-nov-83 17:42:36 eccmnk (michael n. kimura) %%E 4 ### Send Send a message to another terminal. DRIVER(send) %%D 4 integer i, len, tcnt integer brdcst, getarg, getlin, length, prompt, trmlst # function(s) %%E 4 %%I 4 integer i, len, tcnt, alltrm, offset, j, junk integer getarg, getlin, prompt, lsttrm # function(s) integer now( 7), day %%E 4 %%I 4 character date( 10), time( 9) %%E 4 character pbuf(MAXLINE) character toname(FILENAMESIZE) character msg(MAXLINE) character myname(USERSIZE) character myterm(FILENAMESIZE) character tlist(MAXLINE) %%I 4 character pidlst(MAXLINE) character arg(FILENAMESIZE) character uname(USERSIZE) character user(USERSIZE) %%E 4 string intro "[message from " string gomsg "[terminate message with ^Z]" %%D 4 string eot "[end of message]" %%E 4 %%I 4 string eot "[end of message from " %%E 4 string onstr " on " string picstr "Pick one: " string blkqmk " ? " string ttstr "TT" %%D 4 string usage "? Usage: send {user | term}" %%E 4 %%I 4 string usage "? Usage: send {user | -user | term}" string gomsg1 "[Sending message to " string gomsg2 " on " %%E 4 call query(usage) %%D 4 if( getarg( 1, toname, FILENAMESIZE) == EOF ) %%E 4 %%I 4 if( getarg( 1, arg, FILENAMESIZE) == EOF ) %%E 4 call error(usage) %%D 4 tcnt = trmlst( toname, tlist) %%E 4 %%I 4 alltrm = NO if( arg(1) == '-' ) if ( arg(2) == EOS ) call error(usage) else { call strcpy( arg(2), user) # send message to all of the terminals alltrm = YES # that ``user'' is logged in on } else call strcpy( arg, user) tcnt = lsttrm( user, tlist, pidlst) %%E 4 if( tcnt != 0 ) { %%D 4 if( tcnt == 1 ) %%E 4 %%I 4 if( tcnt == 1 | alltrm == YES ) { %%E 4 call strcpy( tlist, toname) %%I 4 call putlin( gomsg1, STDOUT) call putlin( user, STDOUT) call putlin( gomsg2, STDOUT) call putlin( toname, STDOUT) call putch( ']', STDOUT) call putch( '@n', STDOUT) } %%E 4 else { i = 1 %%I 4 tcnt = 0 %%E 4 call stcopy( picstr, 1, pbuf, i) call stcopy( tlist, 1, pbuf, i) call stcopy( blkqmk, 1, pbuf, i) len = prompt( pbuf, toname, STDIN) if( toname(len) == '@n' ) toname(len) = EOS } } %%I 4 else call strcpy( user, toname) %%E 4 i = 1 call stcopy( intro, 1, msg, i) call mailid(myname) call stcopy( myname, 1, msg, i) call stcopy( onstr, 1, msg, i) %%D 2 call trnlog( tt, myterm) %%E 2 %%I 2 call trnlog( ttstr, myterm) %%E 2 call fold(myterm) call stcopy( myterm, 1, msg, i) %%I 4 call chcopy( ' ', msg, i) call getnow( now) call fmtdat( date, time, now, LETTER) call stcopy( time, 1, msg, i) %%E 4 call chcopy( ']', msg, i) call chcopy( BELL, msg, i) %%D 4 if( brdcst( msg, toname) != OK ) call snderr(toname) %%E 4 %%I 4 call sndmsg( msg, user, tcnt, toname, pidlst) %%E 4 call remark(gomsg) %%D 4 while( getlin( msg, STDIN) != EOF ) if( brdcst( msg, toname) != OK ) call snderr(toname) %%E 4 %%I 4 offset = 1 call strcpy( myname, uname) uname(index( uname, ' ')) = NULL call chcopy( '[', msg, offset) call stcopy( uname, 1, msg, offset) call chcopy( ']', msg, offset) call chcopy( ' ', msg, offset) %%E 4 %%D 4 if( brdcst( eot, toname) != OK ) call snderr(toname) %%E 4 %%I 4 for (len=getlin(msg(offset),STDIN); len != EOF; len=getlin(msg(offset),STDIN) ) { msg(offset+len-1) = EOS call nocc(msg) # remove unwanted (malicious) control characters call sndmsg( msg, user, tcnt, toname, pidlst) } %%E 4 %%I 4 i = 1 call stcopy( eot, 1, msg, i) call stcopy( myname, 1, msg, i) call chcopy( ' ', msg, i) call getnow( now) call fmtdat( date, time, now, LETTER) call stcopy( time, 1, msg, i) call chcopy( ']', msg, i) call sndmsg( msg, user, tcnt, toname, pidlst) %%E 4 DRETURN end %%D 3 #-h- snderr 232 asc 25-mar-82 09:40:35 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- snderr 231 asc 30-jul-83 09:06:43 tools (lblh csam sventek) %%E 3 ### SndErr Output error message for "send" subroutine snderr(term) character term(ARB) string errmsg "? Can't write to ``@007" call fold(term) call putlin( errmsg, ERROUT) call putlin( term, ERROUT) %%D 3 call error("''.") %%E 3 %%I 3 call error("''") %%E 3 return end %%D 4 #-h- send.fmt 1074 asc 25-mar-82 09:40:41 v1.1 (sw-tools v1.1) %%E 4 %%I 4 #-h- getdvi 479 asc 30-nov-83 17:42:37 eccmnk (michael n. kimura) ### GetDvI Get the pid of terminal subroutine getdvi( term, pidtrm) include sndsym character term(ARB), pidtrm(ARB) integer*2 itmlst(8) integer pidb, pid, trmdsc(2) equivalence ( pidb, itmlst(3) ) data itmlst / 4, DVI_PID, 4*0, 2*0/ pidb = %loc(pid) trmdsc(1) = length(term) trmdsc(2) = %loc(term) call sys$clref(%val(DVI_EVENT_FLAG)) call sys$getdvi(%val(DVI_EVENT_FLAG),,trmdsc,itmlst,,,,) call sys$waitfr(%val(DVI_EVENT_FLAG)) call puthex( pid, pidtrm) return end #-h- lsttrm 1842 asc 30-nov-83 17:42:37 eccmnk (michael n. kimura) ### LstTrm List terminals user is logged in on and PID's of user. integer function lsttrm( user, tlist, pidlst) character user(ARB), tlist(ARB), pidlst(ARB) character image(FILENAMESIZE) character cmd(MAXLINE), pid(PIDSIZE), scrfil(FILENAMESIZE) character lin(MAXLINE), name(FILENAMESIZE), term(FILENAMESIZE) filedes fd filedes open # function(s) integer i, junk, tcnt, tndx, pndx integer equal, getlin, getwrd, loccom, spawn, remove # function(s) string path STD_PATH string suffix IMAGE_SUFFIX string blkgtr " >" string whostr "who" string minusv "-v" call scratf( whostr, scrfil) junk = loccom( whostr, path, suffix, image) i = 1 call stcopy( whostr, 1, cmd, i) call chcopy( ' ', cmd, i) call stcopy( minusv, 1, cmd, i) call chcopy( ' ', cmd, i) call stcopy( user, 1, cmd, i) call stcopy( blkgtr, 1, cmd, i) call stcopy( scrfil, 1, cmd, i) if( spawn( image, cmd, pid, WAIT) == ERR ) call error("? Can't spawn ``who''") else { fd = open( scrfil, READ) if( fd == ERR ) call error("? Can't read scratch file") tcnt = 0 tndx = 1 pndx = 1 call fold(user) while( getlin( lin, fd) != EOF ) { i = 1 call fold(lin) junk = getwrd( lin, i, term) # terminal name junk = getwrd( lin, i, name) # user name junk = getwrd( lin, i, pid) # process name junk = getwrd( lin, i, pid) # image name junk = getwrd( lin, i, pid) # day part of login time junk = getwrd( lin, i, pid) # hh:mm:ss part of login time junk = getwrd( lin, i, pid) # PID if( equal( user, name) == YES ) { if( tndx > 1 ) call chcopy( ' ', tlist, tndx) call stcopy( term, 1, tlist, tndx) tcnt = tcnt + 1 if( pndx > 1 ) call chcopy( ' ', pidlst, pndx) call stcopy( pid, 1, pidlst, pndx) } } call close(fd) junk = remove(scrfil) } return(tcnt) end #-h- nocc 242 asc 30-nov-83 17:42:37 eccmnk (michael n. kimura) ## nocc - this routine removes some unwanted characters subroutine nocc(token) integer i character token(ARB) for (i=1; token(i) != EOS; i=i+1) if ( (token(i) >= DEL) | (token(i) < ' ' & token(i) != TAB) ) token(i) = '.' return end #-h- sndmsg 1052 asc 30-nov-83 17:42:38 eccmnk (michael n. kimura) ### SndMsg Send message to terminal(s) subroutine sndmsg( msg, user, tcnt, toname, pidlst) character msg(ARB), user(ARB), toname(ARB), pidlst(ARB) integer tcnt integer brdcst, getwrd, strcmp integer i, j, k character pidtrm(PIDSIZE), pidusr(PIDSIZE), term(FILENAMESIZE) string ermsg1 "? User " string ermsg2 " logged out of terminal @007" if( tcnt == 0 ) { if( brdcst( msg, toname) != OK ) call snderr(toname) } else for( i = 1, j = 1; getwrd( toname, i, term) != 0 ; ) { junk = getwrd( pidlst, j, pidusr) call getdvi( term, pidtrm) if( strcmp( pidusr, pidtrm) != 0) { tcnt = tcnt - 1 for ( k=i-1; k>=i-length(term); k=k-1) toname(k) = ' ' for ( k=j-1; k>=j-length(pidusr); k=k-1) pidlst(k) = ' ' call putlin( ermsg1, ERROUT) call putlin( user, ERROUT) call putlin( ermsg2, ERROUT) call putlin( term, ERROUT) if (tcnt == 0) call error("") else call putch( '@n', ERROUT) } else if( brdcst( msg, term) != OK ) call snderr(term) } return end #-h- send.fmt 1191 asc 07-dec-83 16:41:43 dpm (dave martin) %%E 4 .so ~bin/manhdr .hd Send (1) 10-Nov-81 send a message to another user's terminal .sy %%D 4 send {user | term} %%E 4 %%I 4 send {user | -user | term} %%E 4 .ds Send copies lines from your terminal to that of another user. When first called, it sends the message .sp .ti +5 %%D 4 [message from on ] %%E 4 %%I 4 [message from on hh:mm:ss] %%E 4 .sp All lines you type will then be transmitted to the other user's terminal until you enter a ^Z. The message .sp .ti +5 %%D 4 [end of message] %%E 4 %%I 4 [end of message from hh:mm:ss] %%E 4 .sp is then sent. You may specify either a username or a particular terminal (i.e. tta0) to receive the message. If you specify a username and that user is logged in on more than one terminal, you are asked to pick one of the terminals to receive the %%D 4 message. %%E 4 %%I 4 message. If -username is specified then all of the terminals that the user is logged in on will receive the message. %%E 4 .fl A scratch file generated with seed ``who''. .im Send spawns ``who'' to map users to their terminals, and then calls the VMS SYS$BRDCST system service to send the messages. .sa The UNIX command "write" .di ? Can't write to ``username''. .sp ? Can't spawn ``who''. .sp ? Can't read scratch file. .au %%D 4 Dave Martin (Hughes Aircraft) %%E 4 %%I 4 Dave Martin (Hughes Aircraft) with modifications by Mike Kimura. %%E 4 .bu %%D 4 The VMS SYS$BRDCST system service wraps NEWLINEs around each message. %%E 4 %%I 4 #-h- sndsym 107 asc 30-nov-83 17:48:47 eccmnk (michael n. kimura) # definitions used by the send tool define(DVI_EVENT_FLAG,1) # DEC defined symbols define(DVI_PID,16%e) %%E 4 %%E 1