XMLTCP3 ;(WASH ISC)/CAP - TCP/IP TO MAILMAN ;11/30/89 10:09 ; [ 02/15/95 2:45 PM ]
;;7.1;Mailman;**1003**;OCT 27, 1998
;;7.1;MailMan;;May 23, 1994
;IHS/REP;2/15/94; Changed for testing on port 3602
SEND ;returns ER(0 OR 1), XMLER=number of "soft" errors
S X="ITRAP^XMCTRAP",@^%ZOSF("TRAP")
S %=XMSG I $L(%)>255 S ER=1,XMTRAN="Line too long" G TRAN
I %'?.ANP F %1=1:1:$L(%) I $E(%,%1)?1C,$A(%,%1)'=9 S %=$E(%,1,%1-1)_$E(%,%1+1,999) Q:%?.ANP S %1=%1-1
S XMSG=% I $G(XMINST) S Y=$$STAT^XMLSTAT(XMINST,1,XMSG,"TCP/IP-MailMan",1)
W XMSG,$C(10),! I XMSG="." W $C(13)
Q
;Receive a line (must keep buffer / lines divided by LF)
REC I $D(XMRG),$G(XMINST) S Y=$$STAT^XMLSTAT(XMINST,2,XMRG,"TCP/IP-MailMan",1)
RE S %MORE="" G R:XMLTCP[$C(10) S %=255-$L(XMLTCP)
S X="ITRAP^XMCTRAP",@^%ZOSF("TRAP")
R X#$S(%:%,1:1):$S($G(XMSTIME):XMSTIME,1:299)
I '$T,XMLTCP'=("."_$C(10)) S ER=1,XMRG="",XMTRAN="Receiver timed out" G TRAN
E I X="" S ER=ER+.1 Q:ER=1 H 1 G RE
I $L(XMLTCP)=255 S %MORE=X
E S XMLTCP=$G(XMLTCP)_X
I (XMLTCP_%MORE)'[$C(10) G RE:%MORE=""
R S %=$F(XMLTCP_%MORE,$C(10))
I % S XMRG=$E(XMLTCP_%MORE,1,%-3+($A(XMLTCP,%-2)'=13)),XMLTCP=$E(XMLTCP_%MORE,%,999),%MORE="" G RQ
S XMRG=XMLTCP,XMLTCP="" K %MORE
RQ I $L(XMRG),$C(13,10)[$E(XMRG) S XMRG=$E(XMRG,2,$L(XMRG)) G RQ
Q
TRAN Q:XM'["D" D TRAN^XMC1 Q
XMLTCP3 ;(WASH ISC)/CAP - TCP/IP TO MAILMAN ;11/30/89 10:09 ; [ 02/15/95 2:45 PM ]
+1 ;;7.1;Mailman;**1003**;OCT 27, 1998
+2 ;;7.1;MailMan;;May 23, 1994
+3 ;IHS/REP;2/15/94; Changed for testing on port 3602
SEND ;returns ER(0 OR 1), XMLER=number of "soft" errors
+1 SET X="ITRAP^XMCTRAP"
SET @^%ZOSF("TRAP")
+2 SET %=XMSG
IF $LENGTH(%)>255
SET ER=1
SET XMTRAN="Line too long"
GOTO TRAN
+3 IF %'?.ANP
FOR %1=1:1:$LENGTH(%)
IF $EXTRACT(%,%1)?1C
IF $ASCII(%,%1)'=9
SET %=$EXTRACT(%,1,%1-1)_$EXTRACT(%,%1+1,999)
IF %?.ANP
QUIT
SET %1=%1-1
+4 SET XMSG=%
IF $GET(XMINST)
SET Y=$$STAT^XMLSTAT(XMINST,1,XMSG,"TCP/IP-MailMan",1)
+5 WRITE XMSG,$CHAR(10),!
IF XMSG="."
WRITE $CHAR(13)
+6 QUIT
+7 ;Receive a line (must keep buffer / lines divided by LF)
REC IF $DATA(XMRG)
IF $GET(XMINST)
SET Y=$$STAT^XMLSTAT(XMINST,2,XMRG,"TCP/IP-MailMan",1)
RE SET %MORE=""
IF XMLTCP[$CHAR(10)
GOTO R
SET %=255-$LENGTH(XMLTCP)
+1 SET X="ITRAP^XMCTRAP"
SET @^%ZOSF("TRAP")
+2 READ X#$SELECT(%:%,1:1):$SELECT($GET(XMSTIME):XMSTIME,1:299)
+3 IF '$TEST
IF XMLTCP'=("."_$CHAR(10))
SET ER=1
SET XMRG=""
SET XMTRAN="Receiver timed out"
GOTO TRAN
+4 IF '$TEST
IF X=""
SET ER=ER+.1
IF ER=1
QUIT
HANG 1
GOTO RE
+5 IF $LENGTH(XMLTCP)=255
SET %MORE=X
+6 IF '$TEST
SET XMLTCP=$GET(XMLTCP)_X
+7 IF (XMLTCP_%MORE)'[$CHAR(10)
IF %MORE=""
GOTO RE
R SET %=$FIND(XMLTCP_%MORE,$CHAR(10))
+1 IF %
SET XMRG=$EXTRACT(XMLTCP_%MORE,1,%-3+($ASCII(XMLTCP,%-2)'=13))
SET XMLTCP=$EXTRACT(XMLTCP_%MORE,%,999)
SET %MORE=""
GOTO RQ
+2 SET XMRG=XMLTCP
SET XMLTCP=""
KILL %MORE
RQ IF $LENGTH(XMRG)
IF $CHAR(13,10)[$EXTRACT(XMRG)
SET XMRG=$EXTRACT(XMRG,2,$LENGTH(XMRG))
GOTO RQ
+1 QUIT
TRAN IF XM'["D"
QUIT
DO TRAN^XMC1
QUIT