%%s 7/3/765 %%d D 1.3 09-Apr-82 14:34:20 tools 3 2 %%c Modified sndmsg.w`sndmsg.r`pstmrk to look for the first blank in the %%c string returned by mailid. If one is found, it is overwritten by an %%c EOS. This is to ensure that the From: string which is generated is %%c understandable by msg when performing an answer function. %%s 2/3/766 %%d D 1.2 05-Apr-82 19:47:16 tools 2 1 %%c Eliminate definition of USERSIZE in sndmsg.r`defns. USERSIZE is now %%c defined in symbols. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:14:33 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 #-h- cpb 115 asc 25-mar-82 08:49:35 v1.1 (sw-tools v1.1) common / cpb / bp, bf(MAXLINE) integer bp # put back pointer for gadtok character bf # buffer used by gadtok #-h- csndm 412 asc 25-mar-82 08:49:35 v1.1 (sw-tools v1.1) common / csndm / tofile(FILENAMESIZE), ccfile(FILENAMESIZE), subjct(MAXLINE), msgfil(FILENAMESIZE), reply(MAXLINE) character tofile # file containing To addresses; init = EOS character ccfile # file containing Cc addresses; init = EOS character subjct # subject string for message; init = EOS character msgfil # file containing message; init = EOS character reply # in-reply-to string; init = EOS #-h- sndbuf 95 asc 25-mar-82 08:49:36 v1.1 (sw-tools v1.1) common / scrbuf / buf(MAXLINE) character buf # scratch buffer used for getlin's throughout #-h- sndscr 407 asc 25-mar-82 08:49:36 v1.1 (sw-tools v1.1) common / sndscr / nusers, temp0(FILENAMESIZE), temp1(FILENAMESIZE), temp2(FILENAMESIZE), temp3(FILENAMESIZE) integer nusers # running count of valid users character temp0 # temporary file for complete message character temp1 # temporary file to hold processed To addresses character temp2 # temporary file to hold processed Cc addresses character temp3 # temporary file to hold body of message %%D 2 #-h- sndmsg.r 14402 asc 25-mar-82 08:49:39 v1.1 (sw-tools v1.1) #-h- defns 296 asc 25-mar-82 08:48:58 v1.1 (sw-tools v1.1) define(USERSIZE,60) %%E 2 %%I 2 %%D 3 #-h- sndmsg.r 14386 asc 05-apr-82 19:46:18 tools (lblh csam sventek) %%E 3 %%I 3 #-h- sndmsg.r 14461 asc 09-apr-82 14:32:40 tools (lblh csam sventek) %%E 3 #-h- defns 275 asc 05-apr-82 19:45:49 tools (lblh csam sventek) %%E 2 define(DO_ALL,1) define(DO_FIRST,2) define(TIMEZONE,"PST") define(RIGHTMARGIN,80) define(TERMEOF,"^Z") define(USERWIDTH,15) ifdef(LARGE_ADDRESS_SPACE) define(MEM_SIZE,16000) elsedef define(MEM_SIZE,4000) # size of dynamic storage in integers (dpm 10-Jun-81) enddef #-h- main 734 asc 25-mar-82 08:49:00 v1.1 (sw-tools v1.1) DRIVER(sndmsg) include csndm include sndscr string tos "To: " string ccs "Cc: " string errmsg "No valid user names specified." call query("usage: sndmsg.") call sndcmd # process command arguments call sndint # initialize tblook table nusers = 0 # initialize number of users call sndadr(tofile, temp1, tos) # get To addresses call sndadr(ccfile, temp2, ccs) # get Cc addresses if (nusers == 0) call snderr(errmsg) # no valid users call getsbj(subjct) # get subject string call genmsg(msgfil, temp3) # get body of message call mmerge # merge pieces onto temp0 call sdmail(temp0, temp1) # send to To call sdmail(temp0, temp2) # send to Cc call cleanf # clean up temp files DRETURN end #-h- addusr 837 asc 25-mar-82 08:49:01 v1.1 (sw-tools v1.1) subroutine addusr(user, unit) integer unit, n integer tblook, isatty, prompt character user(USERSIZE), temp(FILENAMESIZE), utemp(USERSIZE), c character clower include sndscr string errmsg "Invalid user name: " string qpstr "Do you wish to f[orget it], r[eplace it] or l[ist valid users]? " string rpstr "Replacement address: " call scopy(user, 1, utemp, 1) repeat { if (tblook(utemp, temp) == YES) { nusers = nusers + 1 call putlin(utemp, unit) call putch('@n', unit) break } else { call putlin(errmsg, ERROUT) call remark(utemp) if (isatty(STDIN) == YES) { n = prompt(qpstr, utemp, STDIN) c = clower(utemp(1)) if (c == 'r') { n=prompt(rpstr,utemp,STDIN); utemp(n)=EOS } else if (c == 'l') { call usrlst; utemp(1) = EOS } else return } } } return end #-h- adhelp 752 asc 25-mar-82 08:49:02 v1.1 (sw-tools v1.1) subroutine adhelp call remark("Valid responses to the To and Cc prompts are sequences") call remark("of usernames separated by commas. If it is necessary") call remark("to continue the list of users on the next line, simply") call remark("type a comma before hitting the carriage return.") call putch('@n', ERROUT) call remark("If the username 'all' is specified, all known users on") call remark("the system will be included. A username preceded by a") call remark("less than symbol (<) is taken to be the name of a file") call remark("containing usernames separated by blanks and tabs (old") call remark("mail style mailing lists), and each user found therein") call remark("will be included.") call putch('@n', ERROUT) return end #-h- badarg 153 asc 25-mar-82 08:49:02 v1.1 (sw-tools v1.1) subroutine badarg(arg) character arg(ARB) string errmsg "Ignoring invalid argument: " call putlin(errmsg, ERROUT) call remark(arg) return end #-h- cleanf 170 asc 25-mar-82 08:49:03 v1.1 (sw-tools v1.1) subroutine cleanf integer junk integer remove include sndscr junk = remove(temp0) junk = remove(temp1) junk = remove(temp2) junk = remove(temp3) return end #-h- domlst 616 asc 25-mar-82 08:49:03 v1.1 (sw-tools v1.1) subroutine domlst(file, key, unit) integer key, unit, int, i integer open, getlin, index, getwrd character file(ARB), token(USERSIZE) include sndbuf string errmsg "Error opening mailing list file: " int = open(file, READ) if (int != ERR) { while (getlin(buf, int) != EOF) { i = index(buf, '#') if (i > 0) buf(i) = EOS i = 1 if (getwrd(buf, i, token) > 0) call addusr(token, unit) if (key == DO_ALL) while (getwrd(buf, i, token) > 0) call addusr(token, unit) } call close(int) } else { call putlin(errmsg, ERROUT) call remark(file) } return end #-h- dotcst 642 asc 25-mar-82 08:49:04 v1.1 (sw-tools v1.1) subroutine dotcst(file, pstr, out, user) integer out, in, i, j, n integer open, length, getlin character user(MAXLINE), file(ARB), pstr(ARB) string bls " " in = open(file, READ) if (in == ERR) return call putlin(pstr, out) j = 9 for (i=getlin(user,in); i != EOF; i=getlin(user,in)) { user(i) = EOS n = j + length(user) + 1 if (n > RIGHTMARGIN) { call putch(',', out) call putch('@n', out) call putlin(bls, out) j = 9 } if (j > 9) call putch(',', out) call putch(' ', out) call putlin(user, out) j = j + length(user) + 2 } call putch('@n', out) call close(in) return end #-h- editit 472 asc 25-mar-82 08:49:04 v1.1 (sw-tools v1.1) subroutine editit(file, buf) character file(FILENAMESIZE), buf(ARB), proc(FILENAMESIZE), pid(PIDSIZE) integer i, spawn, loccom string suffix IMAGE_SUFFIX string ed "ed" call impath(buf) if (loccom(ed, buf, suffix, proc) != BINARY) call error("Cannot locate ed image file.") i = 1 call stcopy(ed, 1, buf, i) call chcopy(' ', buf, i) call scopy(file, 1, buf, i) if (spawn(proc, buf, pid, WAIT) != OK) call error("Error in spawning ed!") return end #-h- gadtok 693 asc 25-mar-82 08:49:06 v1.1 (sw-tools v1.1) integer function gadtok(pstr, token, int) integer i, int integer prompt, length, equal character pstr(ARB), token(USERSIZE) include cpb string help "?@n" repeat { while (bp == 0) { if (prompt(pstr, bf, int) == EOF) return(EOF) if (equal(bf, help) == YES) { call adhelp bp = 0 } else bp = 1 } if (bf(bp) == '@n') return(EOF) call skipbl(bf, bp) for (i=1; ; i=i+1) { if (bf(bp) == ',' | bf(bp) == '@n') break token(i) = bf(bp) bp = bp + 1 } token(i) = EOS if (bf(bp) == ',') { bp = bp + 1 if (bf(bp) == '@n') bp = 0 } call sqzblk(token) i = length(token) if (i > 0) return(i) } end #-h- genmsg 1462 asc 25-mar-82 08:49:07 v1.1 (sw-tools v1.1) subroutine genmsg(infile, outfil) character infile(ARB), outfil(ARB), file(FILENAMESIZE) character clower integer out, edit, int, junk integer create, open, isatty, prompt, getlin, fsize, remove include sndbuf string errmsg "Error generating message to send." string pstr "Do you want to use ed to create your mail? [y/n] " string sde "sde" string inps "Input message: (type q to quit or " string eofs TERMEOF out = create(outfil, WRITE) if (out == ERR) call snderr(errmsg) edit = NO if (infile(1) != EOS) int = open(infile, READ) else int = STDIN if (int == STDIN & isatty(int) == YES) { junk = prompt(pstr, buf, STDIN) if (clower(buf(1)) == 'y') { edit = YES call scratf(sde, file) call remark("You are now entering ed to create your mail.") call remark("Please wait for ed to prompt for a command.") call editit(file, buf) int = open(file, READ) } else { call putlin(inps, ERROUT) call putlin(eofs, ERROUT) call remark(" to send).") } } if (int == ERR) { call close(out) call snderr(errmsg) } while (getlin(buf,int) != EOF) if (clower(buf(1)) == 'q' & buf(2) == '@n' & edit == NO & int == STDIN) { call close(out) junk = remove(outfil) out = create(outfil, WRITE) break } else call putlin(buf, out) call close(out) if (fsize(outfil) == 0) call snderr(errmsg) if (int != STDIN) call close(int) if (edit == YES) junk = remove(file) return end #-h- getsbj 283 asc 25-mar-82 08:49:09 v1.1 (sw-tools v1.1) subroutine getsbj(subjct) character subjct(MAXLINE) integer n integer prompt, isatty string pstr "Subject: " if (subjct(1) == EOS & isatty(STDIN) == YES) { n = prompt(pstr, subjct, STDIN) if (n > 0) subjct(n) = EOS else subjct(1) = EOS } return end #-h- mmerge 334 asc 25-mar-82 08:49:10 v1.1 (sw-tools v1.1) subroutine mmerge integer out, int integer create, open include sndscr string errmsg "Error opening temp0." out = create(temp0, WRITE) if (out == ERR) call snderr(errmsg) call pstmrk(out) int = open(temp3, READ) if (int != ERR) { call fcopy(int, out) call close(int) } call close(out) return end #-h- notify 354 asc 25-mar-82 08:49:10 v1.1 (sw-tools v1.1) ### Notify Send message to all terminals user is logged in on. subroutine notify( user, msg) character msg(ARB), user(ARB), term(FILENAMESIZE), tlist(MAXLINE) integer i integer getwrd, trmlst # function(s) if( trmlst( user, tlist) == 0 ) return # not logged in. for( i = 1 ; getwrd( tlist, i, term) != 0 ; ) call brdcst( msg, term) return end #-h- pbinit 56 asc 25-mar-82 08:49:10 v1.1 (sw-tools v1.1) subroutine pbinit include cpb bp = 0 return end %%D 3 #-h- pstmrk 1033 asc 25-mar-82 08:49:11 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- pstmrk 1103 asc 09-apr-82 14:32:21 tools (lblh csam sventek) %%E 3 subroutine pstmrk(int) %%D 3 integer int, now(7) %%E 3 %%I 3 integer int, now(7), i integer index %%E 3 character idate(10), itime(10), user(USERSIZE), hdrpat(4) include csndm include sndscr include sndbuf string dates "Date: " string dashst " - " string timzon TIMEZONE string froms "From: " string subjs "Subject: " string repls "In-reply-to: " string tos "To: " string ccs "Cc: " data hdrpat/1, 1, '@n', EOS/ call mailid(user) %%I 3 i = index(user, ' ') if (i > 0) user(i) = EOS %%E 3 call getnow(now) call fmtdat(idate, itime, now, LETTER) call putlin(hdrpat, int) call putlin(dates, int) call putlin(idate, int) call putch(' ', int) call putlin(itime, int) call putlin(dashst, int) call putlin(timzon, int) call putch('@n', int) call putlin(froms, int) call putlin(user, int) call putch('@n', int) call putlin(subjs, int) call putlin(subjct, int) call putch('@n', int) if (reply(1) != EOS) { call putlin(repls, int) call putlin(reply, int) call putch('@n', int) } call dotcst(temp1, tos, int, buf) call dotcst(temp2, ccs, int, buf) call putch('@n', int) return end #-h- sdmail 937 asc 25-mar-82 08:49:12 v1.1 (sw-tools v1.1) subroutine sdmail(msg, mlist) integer inp, int, n, junk, out, topfil(2) integer open, getlin, tblook, create, note character msg(ARB), mlist(ARB), file(FILENAMESIZE) include sndbuf string mymail "mymail" string posted "Mail posted to " string errmsg "Cannot send mail to " string uhave "[You have new mail]@007" inp = open(msg, READ) if (inp != ERR) { junk = note(topfil, inp) int = open(mlist, READ) if (int != ERR) { for (n=getlin(buf,int); n != EOF; n=getlin(buf,int)) { buf(n) = EOS junk = tblook(buf, file) call concat(file, mymail, file) call seek(topfil, inp) out = create(file, APPEND) if (out == ERR) { call putlin(errmsg, ERROUT) call remark(buf) } else { call fcopy(inp, out) call close(out) call putlin(posted, ERROUT) call remark(buf) call notify( buf, uhave) } } call close(int) } call close(inp) } return end #-h- sndadr 810 asc 25-mar-82 08:49:12 v1.1 (sw-tools v1.1) subroutine sndadr(infile, outfil, pstr) character infile(ARB), outfil(ARB), pstr(ARB), token(USERSIZE) integer int, out integer open, create, gadtok, equal, isatty string all "all" if (infile(1) == EOS) if (isatty(STDIN) == YES) int = STDIN else int = ERR else int = open(infile, READ) if (int == ERR) return out = create(outfil, WRITE) if (out != ERR) { call pbinit while (gadtok(pstr, token, int) != EOF) { call fold(token) if (token(1) == '<') { call scopy(token, 2, token, 1) call domlst(token, DO_ALL, out) } else if (equal(token, all) == YES) { call adrfil(token) call domlst(token, DO_FIRST, out) } else call addusr(token, out) } call close(out) } if (int != STDIN) call close(int) return end #-h- sndcmd 626 asc 25-mar-82 08:49:13 v1.1 (sw-tools v1.1) subroutine sndcmd integer i integer getarg, equal character clower include csndm include sndbuf tofile(1) = EOS ccfile(1) = EOS msgfil(1) = EOS reply(1) = EOS subjct(1) = EOS for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) if (buf(1) == '-') { c = clower(buf(2)) if (c == 't') call scopy(buf, 3, tofile, 1) else if (c == 'c') call scopy(buf, 3, ccfile, 1) else if (c == 's') call scopy(buf, 3, subjct, 1) else if (c == 'm') call scopy(buf, 3, msgfil, 1) else if (c == 'r') call scopy(buf, 3, reply, 1) else call badarg(buf) } else call badarg(buf) return end #-h- snderr 90 asc 25-mar-82 08:49:14 v1.1 (sw-tools v1.1) subroutine snderr(buf) character buf(ARB) call cleanf call error(buf) return end #-h- sndint 707 asc 25-mar-82 08:49:14 v1.1 (sw-tools v1.1) subroutine sndint character user(USERSIZE), file(FILENAMESIZE) integer int, i, junk integer open, getlin, getwrd include sndscr include sndbuf DS_DECL(Mem,MEM_SIZE) # declare dynamic storage for symbol table string sm0 "sm0" string sm1 "sm1" string sm2 "sm2" string sm3 "sm3" call tbinit(MEM_SIZE) call adrfil(file) int = open(file, READ) if (int != ERR) { while (getlin(buf, int) != EOF) { i = 1 junk = getwrd(buf, i, user) junk = getwrd(buf, i, file) call tbinst(user, file) } call close(int) } else call error("Cannot open local user file.") call scratf(sm0, temp0) call scratf(sm1, temp1) call scratf(sm2, temp2) call scratf(sm3, temp3) return end #-h- sqzblk 218 asc 25-mar-82 08:49:14 v1.1 (sw-tools v1.1) subroutine sqzblk(token) character token(ARB) integer i, j j = 1 for (i=1; token(i) != EOS; i=i+1) if (token(i) != ' ' & token(i) != '@t') { token(j) = token(i) j = j + 1 } token(j) = EOS return end #-h- usrlst 448 asc 25-mar-82 08:49:15 v1.1 (sw-tools v1.1) subroutine usrlst character buf(MAXLINE), obuf(MAXLINE) integer int, i, nxtcol integer getlin, open call adrfil(buf) int = open(buf, READ) call inpack(nxtcol, RIGHTMARGIN, obuf, ERROUT) while (getlin(buf, int) != EOF) { for (i=1; buf(i) != ' ' & buf(i) != '@t'; i=i+1) ; buf(i) = EOS call dopack(buf, nxtcol, RIGHTMARGIN, obuf, ERROUT) } call flpack(nxtcol, RIGHTMARGIN, obuf, ERROUT) call close(int) return end #-h- sndmsg.fmt 1903 asc 25-mar-82 08:49:45 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Sndmsg (1) 11-Nov-81 utility for sending mail to other users .sy sndmsg .ds `sndmsg' is the utility used to send mail to other users of the mail system. The user is prompted for all of the necessary input in the following manner: .sp .in +5 .ti -3 1. The list of To addresses. .ti -3 2. The list of Cc (carbon copy) addresses .ti -3 3. The subject of the message .ti -3 4. The body of the message .sp .in -5 The responses to the To and Cc prompts consist of user-names separated by commas. If it is necessary to continue the list of addresses onto another line, a comma typed at the end of the line causes `sndmsg' to prompt for another line of addresses. If the string `all' is typed as an address, all users of the mail system will receive a copy of the message. If the address consists of `