      SUBROUTINE MAIN
      COMMON / CSNDM / TOFILE(40), CCFILE(40), SUBJCT(512), MSGFIL(40), 
     *REPLY(512)
      LOGICAL*1 TOFILE
      LOGICAL*1 CCFILE
      LOGICAL*1 SUBJCT
      LOGICAL*1 MSGFIL
      LOGICAL*1 REPLY
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      LOGICAL*1 TOS(5)
      LOGICAL*1 CCS(5)
      LOGICAL*1 ERRMSG(31)
      DATA TOS(1)/84/,TOS(2)/111/,TOS(3)/58/,TOS(4)/32/,TOS(5)/0/
      DATA CCS(1)/67/,CCS(2)/99/,CCS(3)/58/,CCS(4)/32/,CCS(5)/0/
      DATA ERRMSG(1)/78/,ERRMSG(2)/111/,ERRMSG(3)/32/,ERRMSG(4)/118/,ERR
     *MSG(5)/97/,ERRMSG(6)/108/,ERRMSG(7)/105/,ERRMSG(8)/100/,ERRMSG(9)/
     *32/,ERRMSG(10)/117/,ERRMSG(11)/115/,ERRMSG(12)/101/,ERRMSG(13)/114
     */,ERRMSG(14)/32/,ERRMSG(15)/110/,ERRMSG(16)/97/,ERRMSG(17)/109/,ER
     *RMSG(18)/101/,ERRMSG(19)/115/,ERRMSG(20)/32/,ERRMSG(21)/115/,ERRMS
     *G(22)/112/,ERRMSG(23)/101/,ERRMSG(24)/99/,ERRMSG(25)/105/,ERRMSG(2
     *6)/102/,ERRMSG(27)/105/,ERRMSG(28)/101/,ERRMSG(29)/100/,ERRMSG(30)
     */46/,ERRMSG(31)/0/
      CALL QUERY(15Husage:  sndmsg.)
      CALL SNDCMD
      CALL SNDINT
      NUSERS = 0
      CALL SNDADR(TOFILE, TEMP1, TOS)
      CALL SNDADR(CCFILE, TEMP2, CCS)
      IF (.NOT.(NUSERS .EQ. 0))GOTO 23000
      CALL SNDERR(ERRMSG)
23000 CONTINUE
      CALL GETSBJ(SUBJCT)
      CALL GENMSG(MSGFIL, TEMP3)
      CALL MMERGE
      CALL SDMAIL(TEMP0, TEMP1)
      CALL SDMAIL(TEMP0, TEMP2)
      CALL CLEANF
      RETURN
      END
      SUBROUTINE ADDUSR(USER, UNIT)
      INTEGER UNIT, N
      INTEGER TBLOOK, ISATTY, PROMPT
      LOGICAL*1 USER(40), TEMP(40), UTEMP(40), C
      LOGICAL*1 CLOWER
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      LOGICAL*1 ERRMSG(20)
      LOGICAL*1 QPSTR(65)
      LOGICAL*1 RPSTR(22)
      DATA ERRMSG(1)/73/,ERRMSG(2)/110/,ERRMSG(3)/118/,ERRMSG(4)/97/,ERR
     *MSG(5)/108/,ERRMSG(6)/105/,ERRMSG(7)/100/,ERRMSG(8)/32/,ERRMSG(9)/
     *117/,ERRMSG(10)/115/,ERRMSG(11)/101/,ERRMSG(12)/114/,ERRMSG(13)/32
     */,ERRMSG(14)/110/,ERRMSG(15)/97/,ERRMSG(16)/109/,ERRMSG(17)/101/,E
     *RRMSG(18)/58/,ERRMSG(19)/32/,ERRMSG(20)/0/
      DATA QPSTR(1)/68/,QPSTR(2)/111/,QPSTR(3)/32/,QPSTR(4)/121/,QPSTR(5
     *)/111/,QPSTR(6)/117/,QPSTR(7)/32/,QPSTR(8)/119/,QPSTR(9)/105/,QPST
     *R(10)/115/,QPSTR(11)/104/,QPSTR(12)/32/,QPSTR(13)/116/,QPSTR(14)/1
     *11/,QPSTR(15)/32/,QPSTR(16)/102/,QPSTR(17)/91/,QPSTR(18)/111/,QPST
     *R(19)/114/,QPSTR(20)/103/,QPSTR(21)/101/,QPSTR(22)/116/,QPSTR(23)/
     *32/,QPSTR(24)/105/,QPSTR(25)/116/,QPSTR(26)/93/,QPSTR(27)/44/,QPST
     *R(28)/32/,QPSTR(29)/114/,QPSTR(30)/91/,QPSTR(31)/101/,QPSTR(32)/11
     *2/,QPSTR(33)/108/,QPSTR(34)/97/,QPSTR(35)/99/,QPSTR(36)/101/,QPSTR
     *(37)/32/,QPSTR(38)/105/,QPSTR(39)/116/,QPSTR(40)/93/,QPSTR(41)/32/
     *,QPSTR(42)/111/,QPSTR(43)/114/,QPSTR(44)/32/,QPSTR(45)/108/,QPSTR(
     *46)/91/,QPSTR(47)/105/,QPSTR(48)/115/,QPSTR(49)/116/,QPSTR(50)/32/
     *,QPSTR(51)/118/,QPSTR(52)/97/,QPSTR(53)/108/,QPSTR(54)/105/,QPSTR(
     *55)/100/,QPSTR(56)/32/,QPSTR(57)/117/,QPSTR(58)/115/,QPSTR(59)/101
     */,QPSTR(60)/114/,QPSTR(61)/115/,QPSTR(62)/93/,QPSTR(63)/63/,QPSTR(
     *64)/32/,QPSTR(65)/0/
      DATA RPSTR(1)/82/,RPSTR(2)/101/,RPSTR(3)/112/,RPSTR(4)/108/,RPSTR(
     *5)/97/,RPSTR(6)/99/,RPSTR(7)/101/,RPSTR(8)/109/,RPSTR(9)/101/,RPST
     *R(10)/110/,RPSTR(11)/116/,RPSTR(12)/32/,RPSTR(13)/97/,RPSTR(14)/10
     *0/,RPSTR(15)/100/,RPSTR(16)/114/,RPSTR(17)/101/,RPSTR(18)/115/,RPS
     *TR(19)/115/,RPSTR(20)/58/,RPSTR(21)/32/,RPSTR(22)/0/
      CALL SCOPY(USER, 1, UTEMP, 1)
23002 CONTINUE
      IF (.NOT.(TBLOOK(UTEMP, TEMP) .EQ. 1))GOTO 23005
      NUSERS = NUSERS + 1
      CALL PUTLIN(UTEMP, UNIT)
      CALL PUTCH(10, UNIT)
      GOTO 23004
23005 CONTINUE
      CALL PUTLIN(ERRMSG, 3)
      CALL REMARK(UTEMP)
      IF (.NOT.(ISATTY(1) .EQ. 1))GOTO 23007
      N = PROMPT(QPSTR, UTEMP, 1)
      C = CLOWER(UTEMP(1))
      IF (.NOT.(C .EQ. 114))GOTO 23009
      N=PROMPT(RPSTR,UTEMP,1)
      UTEMP(N)=0 
      GOTO 23010
23009 CONTINUE
      IF (.NOT.(C .EQ. 108))GOTO 23011
      CALL USRLST
      UTEMP(1) = 0 
      GOTO 23012
23011 CONTINUE
      RETURN
23012 CONTINUE
23010 CONTINUE
23007 CONTINUE
23006 CONTINUE
23003 GOTO 23002
23004 CONTINUE
      RETURN
      END
      SUBROUTINE ADHELP
      CALL REMARK(54HValid responses to the To and Cc prompts are sequen
     *ces)
      CALL REMARK(53Hof usernames separated by commas.  If it is necessa
     *ry)
      CALL REMARK(54Hto continue the list of users on the next line, sim
     *ply)
      CALL REMARK(48Htype a comma before hitting the carriage return.)
      CALL PUTCH(10, 3)
      CALL REMARK(54HIf the username 'all' is specified, all known users
     * on)
      CALL REMARK(54Hthe system will be included.  A username preceded b
     *y a)
      CALL REMARK(54Hless than symbol (<) is taken to be the name of a f
     *ile)
      CALL REMARK(54Hcontaining usernames separated by blanks and tabs (
     *old)
      CALL REMARK(54Hmail style mailing lists), and each user found ther
     *ein)
      CALL REMARK(17Hwill be included.)
      CALL PUTCH(10, 3)
      RETURN
      END
      SUBROUTINE BADARG(ARG)
      LOGICAL*1 ARG(100)
      LOGICAL*1 ERRMSG(28)
      DATA ERRMSG(1)/73/,ERRMSG(2)/103/,ERRMSG(3)/110/,ERRMSG(4)/111/,ER
     *RMSG(5)/114/,ERRMSG(6)/105/,ERRMSG(7)/110/,ERRMSG(8)/103/,ERRMSG(9
     *)/32/,ERRMSG(10)/105/,ERRMSG(11)/110/,ERRMSG(12)/118/,ERRMSG(13)/9
     *7/,ERRMSG(14)/108/,ERRMSG(15)/105/,ERRMSG(16)/100/,ERRMSG(17)/32/,
     *ERRMSG(18)/97/,ERRMSG(19)/114/,ERRMSG(20)/103/,ERRMSG(21)/117/,ERR
     *MSG(22)/109/,ERRMSG(23)/101/,ERRMSG(24)/110/,ERRMSG(25)/116/,ERRMS
     *G(26)/58/,ERRMSG(27)/32/,ERRMSG(28)/0/
      CALL PUTLIN(ERRMSG, 3)
      CALL REMARK(ARG)
      RETURN
      END
      SUBROUTINE CLEANF
      INTEGER JUNK
      INTEGER REMOVE
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      JUNK = REMOVE(TEMP0)
      JUNK = REMOVE(TEMP1)
      JUNK = REMOVE(TEMP2)
      JUNK = REMOVE(TEMP3)
      RETURN
      END
      SUBROUTINE DOMLST(FILE, KEY, UNIT)
      INTEGER KEY, UNIT, INT, I
      INTEGER OPEN, GETLIN, INDEXC, GETWRD
      LOGICAL*1 FILE(100), TOKEN(40)
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      LOGICAL*1 ERRMSG(34)
      DATA ERRMSG(1)/69/,ERRMSG(2)/114/,ERRMSG(3)/114/,ERRMSG(4)/111/,ER
     *RMSG(5)/114/,ERRMSG(6)/32/,ERRMSG(7)/111/,ERRMSG(8)/112/,ERRMSG(9)
     */101/,ERRMSG(10)/110/,ERRMSG(11)/105/,ERRMSG(12)/110/,ERRMSG(13)/1
     *03/,ERRMSG(14)/32/,ERRMSG(15)/109/,ERRMSG(16)/97/,ERRMSG(17)/105/,
     *ERRMSG(18)/108/,ERRMSG(19)/105/,ERRMSG(20)/110/,ERRMSG(21)/103/,ER
     *RMSG(22)/32/,ERRMSG(23)/108/,ERRMSG(24)/105/,ERRMSG(25)/115/,ERRMS
     *G(26)/116/,ERRMSG(27)/32/,ERRMSG(28)/102/,ERRMSG(29)/105/,ERRMSG(3
     *0)/108/,ERRMSG(31)/101/,ERRMSG(32)/58/,ERRMSG(33)/32/,ERRMSG(34)/0
     */
      INT = OPEN(FILE, 1)
      IF (.NOT.(INT .NE. -3))GOTO 23013
23015 IF (.NOT.(GETLIN(BUF, INT) .NE. -1))GOTO 23016
      I = INDEXC(BUF, 35)
      IF (.NOT.(I .GT. 0))GOTO 23017
      BUF(I) = 0
23017 CONTINUE
      I = 1
      IF (.NOT.(GETWRD(BUF, I, TOKEN) .GT. 0))GOTO 23019
      CALL ADDUSR(TOKEN, UNIT)
23019 CONTINUE
      IF (.NOT.(KEY .EQ. 1))GOTO 23021
23023 IF (.NOT.(GETWRD(BUF, I, TOKEN) .GT. 0))GOTO 23024
      CALL ADDUSR(TOKEN, UNIT)
      GOTO 23023
23024 CONTINUE
23021 CONTINUE
      GOTO 23015
23016 CONTINUE
      CALL CLOSE(INT)
      GOTO 23014
23013 CONTINUE
      CALL PUTLIN(ERRMSG, 3)
      CALL REMARK(FILE)
23014 CONTINUE
      RETURN
      END
      SUBROUTINE DOTCST(FILE, PSTR, OUT, USER)
      INTEGER OUT, IN, I, J, N
      INTEGER OPEN, LENGTH, GETLIN
      LOGICAL*1 USER(512), FILE(100), PSTR(100)
      LOGICAL*1 BLS(9)
      DATA BLS(1)/32/,BLS(2)/32/,BLS(3)/32/,BLS(4)/32/,BLS(5)/32/,BLS(6)
     */32/,BLS(7)/32/,BLS(8)/32/,BLS(9)/0/
      IN = OPEN(FILE, 1)
      IF (.NOT.(IN .EQ. -3))GOTO 23025
      RETURN
23025 CONTINUE
      CALL PUTLIN(PSTR, OUT)
      J = 9
      I=GETLIN(USER,IN)
23027 IF (.NOT.(I .NE. -1))GOTO 23029
      USER(I) = 0
      N = J + LENGTH(USER) + 1
      IF (.NOT.(N .GT. 80))GOTO 23030
      CALL PUTCH(44, OUT)
      CALL PUTCH(10, OUT)
      CALL PUTLIN(BLS, OUT)
      J = 9
23030 CONTINUE
      IF (.NOT.(J .GT. 9))GOTO 23032
      CALL PUTCH(44, OUT)
23032 CONTINUE
      CALL PUTCH(32, OUT)
      CALL PUTLIN(USER, OUT)
      J = J + LENGTH(USER) + 2
23028 I=GETLIN(USER,IN)
      GOTO 23027
23029 CONTINUE
      CALL PUTCH(10, OUT)
      CALL CLOSE(IN)
      RETURN
      END
      SUBROUTINE EDITIT(FILE, BUF)
      LOGICAL*1 FILE(40), BUF(100), PROC(40), PID(7)
      INTEGER I, SSPAWN, LOCCOM
      LOGICAL*1 SUFFIX(7)
      LOGICAL*1 ED(3)
      DATA SUFFIX(1)/46/,SUFFIX(2)/116/,SUFFIX(3)/115/,SUFFIX(4)/107/,SU
     *FFIX(5)/0/,SUFFIX(6)/10/,SUFFIX(7)/0/
      DATA ED(1)/101/,ED(2)/100/,ED(3)/0/
      CALL IMPATH(BUF)
      IF (.NOT.(LOCCOM(ED, BUF, SUFFIX, PROC) .NE. 60))GOTO 23034
      CALL ERROR(28HCannot locate ed image file.)
23034 CONTINUE
      I = 1
      CALL STCOPY(ED, 1, BUF, I)
      CALL CHCOPY(32, BUF, I)
      CALL SCOPY(FILE, 1, BUF, I)
      IF (.NOT.(SSPAWN(PROC, BUF, PID, 119) .NE. 0))GOTO 23036
      CALL ERROR(21HError in spawning ed!)
23036 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GADTOK(PSTR, TOKEN, INT)
      INTEGER I, INT
      INTEGER PROMPT, LENGTH, EQUAL
      LOGICAL*1 PSTR(100), TOKEN(40)
      COMMON / CPB / BP, BF(512)
      INTEGER BP
      LOGICAL*1 BF
      LOGICAL*1 HELP(3)
      DATA HELP(1)/63/,HELP(2)/10/,HELP(3)/0/
23038 CONTINUE
23041 IF (.NOT.(BP .EQ. 0))GOTO 23042
      IF (.NOT.(PROMPT(PSTR, BF, INT) .EQ. -1))GOTO 23043
      GADTOK=(-1)
      RETURN
23043 CONTINUE
      IF (.NOT.(EQUAL(BF, HELP) .EQ. 1))GOTO 23045
      CALL ADHELP
      BP = 0
      GOTO 23046
23045 CONTINUE
      BP = 1
23046 CONTINUE
      GOTO 23041
23042 CONTINUE
      IF (.NOT.(BF(BP) .EQ. 10))GOTO 23047
      GADTOK=(-1)
      RETURN
23047 CONTINUE
      CALL SKIPBL(BF, BP)
      I=1
23049 CONTINUE
      IF (.NOT.(BF(BP) .EQ. 44 .OR. BF(BP) .EQ. 10))GOTO 23052
      GOTO 23051
23052 CONTINUE
      TOKEN(I) = BF(BP)
      BP = BP + 1
23050 I=I+1
      GOTO 23049
23051 CONTINUE
      TOKEN(I) = 0
      IF (.NOT.(BF(BP) .EQ. 44))GOTO 23054
      BP = BP + 1
      IF (.NOT.(BF(BP) .EQ. 10))GOTO 23056
      BP = 0
23056 CONTINUE
23054 CONTINUE
      CALL SQZBLK(TOKEN)
      I = LENGTH(TOKEN)
      IF (.NOT.(I .GT. 0))GOTO 23058
      GADTOK=(I)
      RETURN
23058 CONTINUE
23039 GOTO 23038
23040 CONTINUE
      END
      SUBROUTINE GENMSG(INFILE, OUTFIL)
      LOGICAL*1 INFILE(100), OUTFIL(100), FILE(40)
      LOGICAL*1 CLOWER
      INTEGER OUT, EDIT, INT, JUNK
      INTEGER CREATE, OPEN, ISATTY, PROMPT, GETLIN, FSIZE, REMOVE
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      LOGICAL*1 ERRMSG(34)
      LOGICAL*1 PSTR(50)
      LOGICAL*1 SDE(4)
      LOGICAL*1 INPS(35)
      LOGICAL*1 EOFS(3)
      DATA ERRMSG(1)/69/,ERRMSG(2)/114/,ERRMSG(3)/114/,ERRMSG(4)/111/,ER
     *RMSG(5)/114/,ERRMSG(6)/32/,ERRMSG(7)/103/,ERRMSG(8)/101/,ERRMSG(9)
     */110/,ERRMSG(10)/101/,ERRMSG(11)/114/,ERRMSG(12)/97/,ERRMSG(13)/11
     *6/,ERRMSG(14)/105/,ERRMSG(15)/110/,ERRMSG(16)/103/,ERRMSG(17)/32/,
     *ERRMSG(18)/109/,ERRMSG(19)/101/,ERRMSG(20)/115/,ERRMSG(21)/115/,ER
     *RMSG(22)/97/,ERRMSG(23)/103/,ERRMSG(24)/101/,ERRMSG(25)/32/,ERRMSG
     *(26)/116/,ERRMSG(27)/111/,ERRMSG(28)/32/,ERRMSG(29)/115/,ERRMSG(30
     *)/101/,ERRMSG(31)/110/,ERRMSG(32)/100/,ERRMSG(33)/46/,ERRMSG(34)/0
     */
      DATA PSTR(1)/68/,PSTR(2)/111/,PSTR(3)/32/,PSTR(4)/121/,PSTR(5)/111
     */,PSTR(6)/117/,PSTR(7)/32/,PSTR(8)/119/,PSTR(9)/97/,PSTR(10)/110/,
     *PSTR(11)/116/,PSTR(12)/32/,PSTR(13)/116/,PSTR(14)/111/,PSTR(15)/32
     */,PSTR(16)/117/,PSTR(17)/115/,PSTR(18)/101/,PSTR(19)/32/,PSTR(20)/
     *101/,PSTR(21)/100/,PSTR(22)/32/,PSTR(23)/116/,PSTR(24)/111/,PSTR(2
     *5)/32/,PSTR(26)/99/,PSTR(27)/114/,PSTR(28)/101/,PSTR(29)/97/,PSTR(
     *30)/116/,PSTR(31)/101/,PSTR(32)/32/,PSTR(33)/121/,PSTR(34)/111/,PS
     *TR(35)/117/,PSTR(36)/114/,PSTR(37)/32/,PSTR(38)/109/,PSTR(39)/97/,
     *PSTR(40)/105/,PSTR(41)/108/,PSTR(42)/63/,PSTR(43)/32/,PSTR(44)/91/
     *,PSTR(45)/121/,PSTR(46)/47/,PSTR(47)/110/,PSTR(48)/93/,PSTR(49)/32
     */,PSTR(50)/0/
      DATA SDE(1)/115/,SDE(2)/100/,SDE(3)/101/,SDE(4)/0/
      DATA INPS(1)/73/,INPS(2)/110/,INPS(3)/112/,INPS(4)/117/,INPS(5)/11
     *6/,INPS(6)/32/,INPS(7)/109/,INPS(8)/101/,INPS(9)/115/,INPS(10)/115
     */,INPS(11)/97/,INPS(12)/103/,INPS(13)/101/,INPS(14)/58/,INPS(15)/3
     *2/,INPS(16)/40/,INPS(17)/116/,INPS(18)/121/,INPS(19)/112/,INPS(20)
     */101/,INPS(21)/32/,INPS(22)/113/,INPS(23)/32/,INPS(24)/116/,INPS(2
     *5)/111/,INPS(26)/32/,INPS(27)/113/,INPS(28)/117/,INPS(29)/105/,INP
     *S(30)/116/,INPS(31)/32/,INPS(32)/111/,INPS(33)/114/,INPS(34)/32/,I
     *NPS(35)/0/
      DATA EOFS(1)/94/,EOFS(2)/90/,EOFS(3)/0/
      OUT = CREATE(OUTFIL, 2)
      IF (.NOT.(OUT .EQ. -3))GOTO 23060
      CALL SNDERR(ERRMSG)
23060 CONTINUE
      EDIT = 0
      IF (.NOT.(INFILE(1) .NE. 0))GOTO 23062
      INT = OPEN(INFILE, 1)
      GOTO 23063
23062 CONTINUE
      INT = 1
23063 CONTINUE
      IF (.NOT.(INT .EQ. 1 .AND. ISATTY(INT) .EQ. 1))GOTO 23064
      JUNK = PROMPT(PSTR, BUF, 1)
      IF (.NOT.(CLOWER(BUF(1)) .EQ. 121))GOTO 23066
      EDIT = 1
      CALL SCRATF(SDE, FILE)
      CALL REMARK(44HYou are now entering ed to create your mail.)
      CALL REMARK(43HPlease wait for ed to prompt for a command.)
      CALL EDITIT(FILE, BUF)
      INT = OPEN(FILE, 1)
      GOTO 23067
23066 CONTINUE
      CALL PUTLIN(INPS, 3)
      CALL PUTLIN(EOFS, 3)
      CALL REMARK(10H to send).)
23067 CONTINUE
23064 CONTINUE
      IF (.NOT.(INT .EQ. -3))GOTO 23068
      CALL CLOSE(OUT)
      CALL SNDERR(ERRMSG)
23068 CONTINUE
23070 IF (.NOT.(GETLIN(BUF,INT) .NE. -1))GOTO 23071
      IF (.NOT.(CLOWER(BUF(1)) .EQ. 113 .AND. BUF(2) .EQ. 10 .AND. EDIT 
     *.EQ. 0 .AND. INT .EQ. 1))GOTO 23072
      CALL CLOSE(OUT)
      JUNK = REMOVE(OUTFIL)
      OUT = CREATE(OUTFIL, 2)
      GOTO 23071
23072 CONTINUE
      CALL PUTLIN(BUF, OUT)
23073 CONTINUE
      GOTO 23070
23071 CONTINUE
      CALL CLOSE(OUT)
      IF (.NOT.(FSIZE(OUTFIL) .EQ. 0))GOTO 23074
      CALL SNDERR(ERRMSG)
23074 CONTINUE
      IF (.NOT.(INT .NE. 1))GOTO 23076
      CALL CLOSE(INT)
23076 CONTINUE
      IF (.NOT.(EDIT .EQ. 1))GOTO 23078
      JUNK = REMOVE(FILE)
23078 CONTINUE
      RETURN
      END
      SUBROUTINE GETSBJ(SUBJCT)
      LOGICAL*1 SUBJCT(512)
      INTEGER N
      INTEGER PROMPT, ISATTY
      LOGICAL*1 PSTR(10)
      DATA PSTR(1)/83/,PSTR(2)/117/,PSTR(3)/98/,PSTR(4)/106/,PSTR(5)/101
     */,PSTR(6)/99/,PSTR(7)/116/,PSTR(8)/58/,PSTR(9)/32/,PSTR(10)/0/
      IF (.NOT.(SUBJCT(1) .EQ. 0 .AND. ISATTY(1) .EQ. 1))GOTO 23080
      N = PROMPT(PSTR, SUBJCT, 1)
      IF (.NOT.(N .GT. 0))GOTO 23082
      SUBJCT(N) = 0
      GOTO 23083
23082 CONTINUE
      SUBJCT(1) = 0
23083 CONTINUE
23080 CONTINUE
      RETURN
      END
      SUBROUTINE MMERGE
      INTEGER OUT, INT
      INTEGER CREATE, OPEN
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      LOGICAL*1 ERRMSG(21)
      DATA ERRMSG(1)/69/,ERRMSG(2)/114/,ERRMSG(3)/114/,ERRMSG(4)/111/,ER
     *RMSG(5)/114/,ERRMSG(6)/32/,ERRMSG(7)/111/,ERRMSG(8)/112/,ERRMSG(9)
     */101/,ERRMSG(10)/110/,ERRMSG(11)/105/,ERRMSG(12)/110/,ERRMSG(13)/1
     *03/,ERRMSG(14)/32/,ERRMSG(15)/116/,ERRMSG(16)/101/,ERRMSG(17)/109/
     *,ERRMSG(18)/112/,ERRMSG(19)/48/,ERRMSG(20)/46/,ERRMSG(21)/0/
      OUT = CREATE(TEMP0, 2)
      IF (.NOT.(OUT .EQ. -3))GOTO 23084
      CALL SNDERR(ERRMSG)
23084 CONTINUE
      CALL PSTMRK(OUT)
      INT = OPEN(TEMP3, 1)
      IF (.NOT.(INT .NE. -3))GOTO 23086
      CALL FCOPY(INT, OUT)
      CALL CLOSE(INT)
23086 CONTINUE
      CALL CLOSE(OUT)
      RETURN
      END
      SUBROUTINE NOTIFY( USER, MSG)
      LOGICAL*1 MSG(100), USER(100), TERM(40), TLIST(512)
      INTEGER I
      INTEGER GETWRD, TRMLST
      IF (.NOT.( TRMLST( USER, TLIST) .EQ. 0 ))GOTO 23088
      RETURN
23088 CONTINUE
      I = 1 
23090 IF (.NOT.(GETWRD( TLIST, I, TERM) .NE. 0 ))GOTO 23092
      CALL BRDCST( MSG, TERM)
23091 GOTO 23090
23092 CONTINUE
      RETURN
      END
      SUBROUTINE PBINIT
      COMMON / CPB / BP, BF(512)
      INTEGER BP
      LOGICAL*1 BF
      BP = 0
      RETURN
      END
      SUBROUTINE PSTMRK(INT)
      INTEGER INT, NOW(7), I
      INTEGER INDEXC
      LOGICAL*1 IDATE(10), ITIME(10), USER(40), HDRPAT(4)
      COMMON / CSNDM / TOFILE(40), CCFILE(40), SUBJCT(512), MSGFIL(40), 
     *REPLY(512)
      LOGICAL*1 TOFILE
      LOGICAL*1 CCFILE
      LOGICAL*1 SUBJCT
      LOGICAL*1 MSGFIL
      LOGICAL*1 REPLY
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      LOGICAL*1 DATES(10)
      LOGICAL*1 DASHST(4)
      LOGICAL*1 TIMZON(4)
      LOGICAL*1 FROMS(10)
      LOGICAL*1 SUBJS(10)
      LOGICAL*1 REPLS(14)
      LOGICAL*1 TOS(9)
      LOGICAL*1 CCS(9)
      DATA DATES(1)/68/,DATES(2)/97/,DATES(3)/116/,DATES(4)/101/,DATES(5
     *)/58/,DATES(6)/32/,DATES(7)/32/,DATES(8)/32/,DATES(9)/32/,DATES(10
     *)/0/
      DATA DASHST(1)/32/,DASHST(2)/45/,DASHST(3)/32/,DASHST(4)/0/
      DATA TIMZON(1)/80/,TIMZON(2)/83/,TIMZON(3)/84/,TIMZON(4)/0/
      DATA FROMS(1)/70/,FROMS(2)/114/,FROMS(3)/111/,FROMS(4)/109/,FROMS(
     *5)/58/,FROMS(6)/32/,FROMS(7)/32/,FROMS(8)/32/,FROMS(9)/32/,FROMS(1
     *0)/0/
      DATA SUBJS(1)/83/,SUBJS(2)/117/,SUBJS(3)/98/,SUBJS(4)/106/,SUBJS(5
     *)/101/,SUBJS(6)/99/,SUBJS(7)/116/,SUBJS(8)/58/,SUBJS(9)/32/,SUBJS(
     *10)/0/
      DATA REPLS(1)/73/,REPLS(2)/110/,REPLS(3)/45/,REPLS(4)/114/,REPLS(5
     *)/101/,REPLS(6)/112/,REPLS(7)/108/,REPLS(8)/121/,REPLS(9)/45/,REPL
     *S(10)/116/,REPLS(11)/111/,REPLS(12)/58/,REPLS(13)/32/,REPLS(14)/0/
      DATA TOS(1)/84/,TOS(2)/111/,TOS(3)/58/,TOS(4)/32/,TOS(5)/32/,TOS(6
     *)/32/,TOS(7)/32/,TOS(8)/32/,TOS(9)/0/
      DATA CCS(1)/67/,CCS(2)/99/,CCS(3)/58/,CCS(4)/32/,CCS(5)/32/,CCS(6)
     */32/,CCS(7)/32/,CCS(8)/32/,CCS(9)/0/
      DATA HDRPAT/1, 1, 10, 0/
      CALL MAILID(USER)
      I = INDEXC(USER, 32)
      IF (.NOT.(I .GT. 0))GOTO 23093
      USER(I) = 0
23093 CONTINUE
      CALL GETNOW(NOW)
      CALL FMTDAT(IDATE, ITIME, NOW, 1)
      CALL PUTLIN(HDRPAT, INT)
      CALL PUTLIN(DATES, INT)
      CALL PUTLIN(IDATE, INT)
      CALL PUTCH(32, INT)
      CALL PUTLIN(ITIME, INT)
      CALL PUTLIN(DASHST, INT)
      CALL PUTLIN(TIMZON, INT)
      CALL PUTCH(10, INT)
      CALL PUTLIN(FROMS, INT)
      CALL PUTLIN(USER, INT)
      CALL PUTCH(10, INT)
      CALL PUTLIN(SUBJS, INT)
      CALL PUTLIN(SUBJCT, INT)
      CALL PUTCH(10, INT)
      IF (.NOT.(REPLY(1) .NE. 0))GOTO 23095
      CALL PUTLIN(REPLS, INT)
      CALL PUTLIN(REPLY, INT)
      CALL PUTCH(10, INT)
23095 CONTINUE
      CALL DOTCST(TEMP1, TOS, INT, BUF)
      CALL DOTCST(TEMP2, CCS, INT, BUF)
      CALL PUTCH(10, INT)
      RETURN
      END
      SUBROUTINE SDMAIL(MSG, MLIST)
      INTEGER INP, INT, N, JUNK, OUT, TOPFIL(2)
      INTEGER OPEN, GETLIN, TBLOOK, CREATE, NOTE
      LOGICAL*1 MSG(100), MLIST(100), FILE(40)
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      LOGICAL*1 MYMAIL(7)
      LOGICAL*1 POSTED(16)
      LOGICAL*1 ERRMSG(21)
      LOGICAL*1 UHAVE(21)
      DATA MYMAIL(1)/109/,MYMAIL(2)/121/,MYMAIL(3)/109/,MYMAIL(4)/97/,MY
     *MAIL(5)/105/,MYMAIL(6)/108/,MYMAIL(7)/0/
      DATA POSTED(1)/77/,POSTED(2)/97/,POSTED(3)/105/,POSTED(4)/108/,POS
     *TED(5)/32/,POSTED(6)/112/,POSTED(7)/111/,POSTED(8)/115/,POSTED(9)/
     *116/,POSTED(10)/101/,POSTED(11)/100/,POSTED(12)/32/,POSTED(13)/116
     */,POSTED(14)/111/,POSTED(15)/32/,POSTED(16)/0/
      DATA ERRMSG(1)/67/,ERRMSG(2)/97/,ERRMSG(3)/110/,ERRMSG(4)/110/,ERR
     *MSG(5)/111/,ERRMSG(6)/116/,ERRMSG(7)/32/,ERRMSG(8)/115/,ERRMSG(9)/
     *101/,ERRMSG(10)/110/,ERRMSG(11)/100/,ERRMSG(12)/32/,ERRMSG(13)/109
     */,ERRMSG(14)/97/,ERRMSG(15)/105/,ERRMSG(16)/108/,ERRMSG(17)/32/,ER
     *RMSG(18)/116/,ERRMSG(19)/111/,ERRMSG(20)/32/,ERRMSG(21)/0/
      DATA UHAVE(1)/91/,UHAVE(2)/89/,UHAVE(3)/111/,UHAVE(4)/117/,UHAVE(5
     *)/32/,UHAVE(6)/104/,UHAVE(7)/97/,UHAVE(8)/118/,UHAVE(9)/101/,UHAVE
     *(10)/32/,UHAVE(11)/110/,UHAVE(12)/101/,UHAVE(13)/119/,UHAVE(14)/32
     */,UHAVE(15)/109/,UHAVE(16)/97/,UHAVE(17)/105/,UHAVE(18)/108/,UHAVE
     *(19)/93/,UHAVE(20)/7/,UHAVE(21)/0/
      INP = OPEN(MSG, 1)
      IF (.NOT.(INP .NE. -3))GOTO 23097
      JUNK = NOTE(TOPFIL, INP)
      INT = OPEN(MLIST, 1)
      IF (.NOT.(INT .NE. -3))GOTO 23099
      N=GETLIN(BUF,INT)
23101 IF (.NOT.(N .NE. -1))GOTO 23103
      BUF(N) = 0
      JUNK = TBLOOK(BUF, FILE)
      CALL CONCAT(FILE, MYMAIL, FILE)
      CALL SEEK(TOPFIL, INP)
      OUT = CREATE(FILE, 4)
      IF (.NOT.(OUT .EQ. -3))GOTO 23104
      CALL PUTLIN(ERRMSG, 3)
      CALL REMARK(BUF)
      GOTO 23105
23104 CONTINUE
      CALL FCOPY(INP, OUT)
      CALL CLOSE(OUT)
      CALL PUTLIN(POSTED, 3)
      CALL REMARK(BUF)
      CALL NOTIFY( BUF, UHAVE)
23105 CONTINUE
23102 N=GETLIN(BUF,INT)
      GOTO 23101
23103 CONTINUE
      CALL CLOSE(INT)
23099 CONTINUE
      CALL CLOSE(INP)
23097 CONTINUE
      RETURN
      END
      SUBROUTINE SNDADR(INFILE, OUTFIL, PSTR)
      LOGICAL*1 INFILE(100), OUTFIL(100), PSTR(100), TOKEN(40)
      INTEGER INT, OUT
      INTEGER OPEN, CREATE, GADTOK, EQUAL, ISATTY
      LOGICAL*1 ALL(4)
      DATA ALL(1)/97/,ALL(2)/108/,ALL(3)/108/,ALL(4)/0/
      IF (.NOT.(INFILE(1) .EQ. 0))GOTO 23106
      IF (.NOT.(ISATTY(1) .EQ. 1))GOTO 23108
      INT = 1
      GOTO 23109
23108 CONTINUE
      INT = -3
23109 CONTINUE
      GOTO 23107
23106 CONTINUE
      INT = OPEN(INFILE, 1)
23107 CONTINUE
      IF (.NOT.(INT .EQ. -3))GOTO 23110
      RETURN
23110 CONTINUE
      OUT = CREATE(OUTFIL, 2)
      IF (.NOT.(OUT .NE. -3))GOTO 23112
      CALL PBINIT
23114 IF (.NOT.(GADTOK(PSTR, TOKEN, INT) .NE. -1))GOTO 23115
      CALL FOLD(TOKEN)
      IF (.NOT.(TOKEN(1) .EQ. 60))GOTO 23116
      CALL SCOPY(TOKEN, 2, TOKEN, 1)
      CALL DOMLST(TOKEN, 1, OUT)
      GOTO 23117
23116 CONTINUE
      IF (.NOT.(EQUAL(TOKEN, ALL) .EQ. 1))GOTO 23118
      CALL ADRFIL(TOKEN)
      CALL DOMLST(TOKEN, 2, OUT)
      GOTO 23119
23118 CONTINUE
      CALL ADDUSR(TOKEN, OUT)
23119 CONTINUE
23117 CONTINUE
      GOTO 23114
23115 CONTINUE
      CALL CLOSE(OUT)
23112 CONTINUE
      IF (.NOT.(INT .NE. 1))GOTO 23120
      CALL CLOSE(INT)
23120 CONTINUE
      RETURN
      END
      SUBROUTINE SNDCMD
      INTEGER I
      INTEGER GETARG, EQUAL
      LOGICAL*1 CLOWER
      COMMON / CSNDM / TOFILE(40), CCFILE(40), SUBJCT(512), MSGFIL(40), 
     *REPLY(512)
      LOGICAL*1 TOFILE
      LOGICAL*1 CCFILE
      LOGICAL*1 SUBJCT
      LOGICAL*1 MSGFIL
      LOGICAL*1 REPLY
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      TOFILE(1) = 0
      CCFILE(1) = 0
      MSGFIL(1) = 0
      REPLY(1) = 0
      SUBJCT(1) = 0
      I=1
23122 IF (.NOT.(GETARG(I, BUF, 512) .NE. -1))GOTO 23124
      IF (.NOT.(BUF(1) .EQ. 45))GOTO 23125
      C = CLOWER(BUF(2))
      IF (.NOT.(C .EQ. 116))GOTO 23127
      CALL SCOPY(BUF, 3, TOFILE, 1)
      GOTO 23128
23127 CONTINUE
      IF (.NOT.(C .EQ. 99))GOTO 23129
      CALL SCOPY(BUF, 3, CCFILE, 1)
      GOTO 23130
23129 CONTINUE
      IF (.NOT.(C .EQ. 115))GOTO 23131
      CALL SCOPY(BUF, 3, SUBJCT, 1)
      GOTO 23132
23131 CONTINUE
      IF (.NOT.(C .EQ. 109))GOTO 23133
      CALL SCOPY(BUF, 3, MSGFIL, 1)
      GOTO 23134
23133 CONTINUE
      IF (.NOT.(C .EQ. 114))GOTO 23135
      CALL SCOPY(BUF, 3, REPLY, 1)
      GOTO 23136
23135 CONTINUE
      CALL BADARG(BUF)
23136 CONTINUE
23134 CONTINUE
23132 CONTINUE
23130 CONTINUE
23128 CONTINUE
      GOTO 23126
23125 CONTINUE
      CALL BADARG(BUF)
23126 CONTINUE
23123 I=I+1
      GOTO 23122
23124 CONTINUE
      RETURN
      END
      SUBROUTINE SNDERR(BUF)
      LOGICAL*1 BUF(100)
      CALL CLEANF
      CALL ERROR(BUF)
      RETURN
      END
      SUBROUTINE SNDINT
      LOGICAL*1 USER(40), FILE(40)
      INTEGER INT, I, JUNK
      INTEGER OPEN, GETLIN, GETWRD
      COMMON / SNDSCR / NUSERS, TEMP0(40), TEMP1(40), TEMP2(40), TEMP3(4
     *0)
      INTEGER NUSERS
      LOGICAL*1 TEMP0
      LOGICAL*1 TEMP1
      LOGICAL*1 TEMP2
      LOGICAL*1 TEMP3
      COMMON / SCRBUF / BUF(512)
      LOGICAL*1 BUF
      INTEGER MEM(4000)
      LOGICAL*1 CMEM(8000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      LOGICAL*1 SM0(4)
      LOGICAL*1 SM1(4)
      LOGICAL*1 SM2(4)
      LOGICAL*1 SM3(4)
      DATA SM0(1)/115/,SM0(2)/109/,SM0(3)/48/,SM0(4)/0/
      DATA SM1(1)/115/,SM1(2)/109/,SM1(3)/49/,SM1(4)/0/
      DATA SM2(1)/115/,SM2(2)/109/,SM2(3)/50/,SM2(4)/0/
      DATA SM3(1)/115/,SM3(2)/109/,SM3(3)/51/,SM3(4)/0/
      CALL TBINIT(4000)
      CALL ADRFIL(FILE)
      INT = OPEN(FILE, 1)
      IF (.NOT.(INT .NE. -3))GOTO 23137
23139 IF (.NOT.(GETLIN(BUF, INT) .NE. -1))GOTO 23140
      I = 1
      JUNK = GETWRD(BUF, I, USER)
      JUNK = GETWRD(BUF, I, FILE)
      CALL TBINST(USER, FILE)
      GOTO 23139
23140 CONTINUE
      CALL CLOSE(INT)
      GOTO 23138
23137 CONTINUE
      CALL ERROR(28HCannot open local user file.)
23138 CONTINUE
      CALL SCRATF(SM0, TEMP0)
      CALL SCRATF(SM1, TEMP1)
      CALL SCRATF(SM2, TEMP2)
      CALL SCRATF(SM3, TEMP3)
      RETURN
      END
      SUBROUTINE SQZBLK(TOKEN)
      LOGICAL*1 TOKEN(100)
      INTEGER I, J
      J = 1
      I=1
23141 IF (.NOT.(TOKEN(I) .NE. 0))GOTO 23143
      IF (.NOT.(TOKEN(I) .NE. 32 .AND. TOKEN(I) .NE. 9))GOTO 23144
      TOKEN(J) = TOKEN(I)
      J = J + 1
23144 CONTINUE
23142 I=I+1
      GOTO 23141
23143 CONTINUE
      TOKEN(J) = 0
      RETURN
      END
      SUBROUTINE USRLST
      LOGICAL*1 BUF(512), OBUF(512)
      INTEGER INT, I, NXTCOL
      INTEGER GETLIN, OPEN
      CALL ADRFIL(BUF)
      INT = OPEN(BUF, 1)
      CALL INPACK(NXTCOL, 80, OBUF, 3)
23146 IF (.NOT.(GETLIN(BUF, INT) .NE. -1))GOTO 23147
      I=1
23148 IF (.NOT.(BUF(I) .NE. 32 .AND. BUF(I) .NE. 9))GOTO 23150
23149 I=I+1
      GOTO 23148
23150 CONTINUE
      BUF(I) = 0
      CALL DOPACK(BUF, NXTCOL, 80, OBUF, 3)
      GOTO 23146
23147 CONTINUE
      CALL FLPACK(NXTCOL, 80, OBUF, 3)
      CALL CLOSE(INT)
      RETURN
      END
