Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XML

XML.m

Go to the documentation of this file.
  1. XML ;(WASH ISC)/THM/GJL-MailMan Physical link ;06/04/2002 08:26
  1. ;;8.0;MailMan;;Jun 28, 2002
  1. ; Entry points (DBIA 1283):
  1. ; GET - Set up variables for communications protocol in file 3.4
  1. ;
  1. ; Entry points used by MailMan options (not covered by DBIA):
  1. ; C XMDXPROT
  1. OPEN ;
  1. N Y
  1. I $G(XMCHAN)="" S XMCHAN="SCP"
  1. D GET Q:ER
  1. D OP Q:ER
  1. S:'$D(XMESC) XMESC="~"
  1. S:'$D(XMFS) XMFS=255
  1. S:'$D(XM) XM=""
  1. Q
  1. GET ; Set up variables for communications protocol in file 3.4
  1. ; In:
  1. ; XMCHAN - Name of the communications protocol
  1. ; Out:
  1. ; XMCHAN - IEN of the communications protocol
  1. ; XMPROT - Name of the communications protocol
  1. ; XMSEN - Xecute this variable to send a line
  1. ; XMREC - Xecute this variable to receive a line
  1. ; XMOPEN - Xecute this variable to open the channel
  1. ; XMCLOSE - Xecute this variable to close the channel
  1. ; XMOS - Operating System, used in ^XMLTCP
  1. N DIC,X
  1. S X=XMCHAN,DIC="^DIC(3.4,",DIC(0)="FO"
  1. D ^DIC I Y<0 D Q
  1. . D ERTRAN^XMC1(42244,XMCHAN) ;Invalid Communications Protocol: '|1|'
  1. . S Y=XMTRAN
  1. S XMCHAN=+Y,XMPROT=$P(Y,U,2)
  1. S XMSEN=$G(^DIC(3.4,XMCHAN,1),"Q"),XMREC=$G(^(2),"Q"),XMOPEN=$G(^(3),"Q"),XMCLOSE=$G(^(4),"Q")
  1. S XMOS=^%ZOSF("OS")
  1. I XMOS["MSM" D
  1. . S XMOS("MSMVER")=$P($ZV," 4.0.",2)
  1. . S:+XMOS("MSMVER")=0 XMOS("MSMVER")=8
  1. Q
  1. OP ;
  1. I "Q"'[$G(XMOPEN) X XMOPEN
  1. I 'XMC("BATCH"),'$D(XMQUIET) S X=255 X ^%ZOSF("RM")
  1. Q
  1. C X ^%ZOSF("EON")
  1. I $D(XMCLOSE) X:$L(XMCLOSE) XMCLOSE
  1. Q
  1. ; The following has nothing to do with the above.
  1. ; These are used by the SCP Communications Protocol in file 3.4.
  1. SEND ; Sends XMSG, returns ER=0 or 1, and XMLER=number of "soft" errors
  1. I $L(XMSG)>255 S XMLER=0,ER=1 G SRQ
  1. I XMSG'?.ANP F %=1:1:$L(XMSG) I $E(XMSG,%)?1C,$A(XMSG,%)'=9 S XMSG=$E(XMSG,1,%-1)_$E(XMSG,%+1,999) Q:XMSG?.ANP S %=%-1
  1. D SRINIT S X=XMSG D SUM
  1. I $G(XMINST) D XMTSTAT^XMTDR(XMINST,"S",XMSG,0)
  1. SL S XMLER=XMLER+1 I (XMLER+1)>XMLMAXER D NEWSTRAT
  1. I ER W XMLERR,$C(13) G SRQ
  1. D BUFLUSH W XMSG,$C(13) W XMLINE,U,XMSUM,$C(13) R XMLX:XMLTIME G:XMLX=(XMLINE_U_XMLACK) SRQ
  1. S XMLY=XMLX=(XMLINE_U_XMLNAK),XMLZ=0 D:'XMLY ENQ G SL:XMLY,SRQ
  1. ENQ ; ACK/NAK garbled - try to re-establish contact
  1. S XMLZ=XMLZ+1 I XMLZ>XMLMAXER S (ER,XMLY)=1 Q
  1. D BUFLUSH W XMLENQ,$C(13) R XMLX:XMLTIME Q:XMLX=(XMLINE_U_XMLACK)
  1. I XMLX[XMLACK!(XMLX[XMLNAK),+XMLX=XMLINE!(+XMLX=XMLINE-1) S XMLY=1 Q
  1. H 1 G ENQ
  1. REC ; Receives XMRG, returns ER=0 or 1, and XMLER=number of "soft" errors
  1. D SRINIT S:'$D(XMLAN) XMLAN=XMLINE_U_XMLNAK
  1. I $D(XMRG),$G(XMINST) D XMTSTAT^XMTDR(XMINST,"R",XMRG,0)
  1. RL S XMLER=XMLER+1 I (XMLER+1)>XMLMAXER D NEWSTRAT I ER=1 G SRQ
  1. R XMRG#255:$S($D(XMSTIME):XMSTIME,1:XMLTIME)
  1. S XMLZ=$S('$T:-1,XMRG=XMLENQ:0,XMRG=XMLERR:2,1:1)
  1. S ER=XMLZ=2 G:XMLZ>1 SRQ I 'XMLZ D BUFLUSH W XMLAN,$C(13) G RL
  1. R XMLY:XMLTIME
  1. I +XMLY=XMLINE S X=XMRG D SUM S XMLZ=XMSUM=$P(XMLY,U,2) G RL2
  1. S XMLZ=0 I +XMLY=(XMLINE-1),XMLINE'=1 D BUFLUSH W +XMLY,U,XMLACK,$C(13) G RL
  1. RL2 S XMLAN=XMLINE_U_$S(XMLZ:XMLACK,1:XMLNAK) D BUFLUSH W XMLAN,$C(13)
  1. G SRQ:XMLZ,RL
  1. SRINIT ; Initialize variables for Send/Receive
  1. S XMLINE=$S('$D(XMLINE):1,1:XMLINE+1),XMLACK="ACK",XMLNAK="NAK"
  1. S XMLENQ=$C(9)_"ENQ"_$C(9),XMLERR=$C(9)_"ERROR"_$C(9)
  1. S XMLER=-1 ;soft error count
  1. S XMLMAXER=5 ;maximum allowable soft errors
  1. S XMLTIME=30 ;length of READ time
  1. S ER=0 ;non-recoverable error flag
  1. Q
  1. NEWSTRAT ; Select new strategy, one or both machines may be slow
  1. I XMLMAXER=5 S ER=1 Q ;already tried new strategy, give up.
  1. S XMTLER=$S('$D(XMTLER):XMLER,1:XMTLER+XMLER),XMLER=0 ;add to total
  1. S XMLMAXER=5 ;reduce allowable soft errors
  1. S XMLTIME=30 ;increase the READ time
  1. Q
  1. SRQ ; Exit from Send/Receive
  1. S XMTLER=$S('$D(XMTLER):XMLER,1:XMTLER+XMLER) ;Total errors
  1. K XMLACK,XMLNAK,XMLENQ,XMLERR,XMLMAXER,XMLTIME,XMLX,XMLY,XMLZ
  1. Q
  1. BUFLUSH ; Flush buffer
  1. Q:'$D(XMBFLUSH)
  1. X ^%ZOSF("TRMON") S X=$P($H,",",2) F %=1:1 R %:0 Q:'$T S %=$P($H,",",2) S:%<X %=%+86400 Q:%-X>15
  1. X ^%ZOSF("TRMOFF")
  1. Q
  1. SUM ; Calculate checksum, accounting also for the character's position
  1. S XMSUM=0 F %=1:1:$L(X) S XMSUM=XMSUM+($A(X,%)*%)
  1. Q