source: WorldVistAEHR/trunk/r/MAILMAN-XM/XML1CRC.m@ 975

Last change on this file since 975 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.2 KB
Line 
1XML1CRC ;(WASH ISC)/RJ-OS Check Sum ;04/17/2002 10:58
2 ;;8.0;MailMan;;Jun 28, 2002
3OPEN D GET,OP
4 S:'$D(XMESC) XMESC="~" S:'$D(XMFS) XMFS=255 S:'$D(XM) XM="" S (XMSSQ,XMRSQ)=1 Q
5GET S X=XMCHAN,DIC="^DIC(3.4,",DIC(0)="Z" D ^DIC S XMCHAN=+Y
6 I '$D(^DIC(3.4,XMCHAN,0)) S ER=1,Y="Invalid channel" Q
7G2 S XMPROT=$P(^DIC(3.4,XMCHAN,0),U)
8 F X=1:1:4 S @($P("XMSEN^XMREC^XMOPEN^XMCLOSE",U,X))=$S($D(^(X)):^(X),1:"Q")
9 Q
10OP I $D(XMOPEN) X:$L(XMOPEN) XMOPEN
11 I '$D(XMQUIET) S X=255 X ^%ZOSF("RM")
12 Q
13C X ^%ZOSF("EON")
14 I $D(XMCLOSE) X:$L(XMCLOSE) XMCLOSE
15 Q
16SEND ;returns ER(0 OR 1), XMLER=number of "soft" errors
17 I $L(XMSG)>255 S XMLER=0,ER=1 G SRQ
18 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
19 D SRINIT S X=XMSG D SUM
20 I $G(XMINST) D XMTSTAT^XMTDR(XMINST,"S",XMSG,0) ; 1SCP
21SL S XMLER=XMLER+1 I (XMLER+1)>XMLMAXER D NEWSTRAT
22 I ER W XMLERR,$C(13) G SRQ
23 D BUFLUSH W XMSG,$C(13),XMLINE,U,XMSUM,$C(13) R XMLX:XMLTIME G:XMLX=(XMLINE_U_XMLACK) SRQ
24 S XMLY=XMLX=(XMLINE_U_XMLNAK),XMLZ=0 D:'XMLY ENQ G SL:XMLY,SRQ
25ENQ ;ACK/NAK garbled / re-establish contact
26 S XMLZ=XMLZ+1 I XMLZ>XMLMAXER S (ER,XMLY)=1 Q
27 D BUFLUSH W XMLENQ,$C(13) R XMLX:XMLTIME Q:XMLX=(XMLINE_U_XMLACK)
28 I XMLX[XMLACK!(XMLX[XMLNAK),+XMLX=XMLINE!(+XMLX=XMLINE-1) S XMLY=1 Q
29 H 1 G ENQ
30REC ;SEE SEND
31 D SRINIT S:'$D(XMLAN) XMLAN=XMLINE_U_XMLNAK
32 I $D(XMRG),$G(XMINST) D XMTSTAT^XMTDR(XMINST,"R",XMRG,0) ; 1SCP
33RL S XMLER=XMLER+1 I (XMLER+1)>XMLMAXER D NEWSTRAT I ER=1 G SRQ
34 R XMRG#255:$S($D(XMSTIME):XMSTIME,1:XMLTIME)
35 S XMLZ=$S('$T:-1,XMRG=XMLENQ:0,XMRG=XMLERR:2,1:1)
36 S ER=XMLZ=2 G:XMLZ>1 SRQ I 'XMLZ D BUFLUSH W XMLAN,$C(13) G RL
37 R XMLY:XMLTIME I +XMLY=XMLINE S X=XMRG D SUM S XMLZ=XMSUM=$P(XMLY,U,2) G RL2
38 S XMLZ=0 I +XMLY=(XMLINE-1),XMLINE'=1 D BUFLUSH W +XMLY,U,XMLACK,$C(13) G RL
39RL2 S XMLAN=XMLINE_U_$S(XMLZ:XMLACK,1:XMLNAK) D BUFLUSH W XMLAN,$C(13)
40 G SRQ:XMLZ,RL
41SRINIT ;
42 S XMLINE=$S('$D(XMLINE):1,1:XMLINE+1),XMLACK="ACK",XMLNAK="NAK"
43 S XMLENQ=$C(9)_"ENQ"_$C(9),XMLERR=$C(9)_"ERROR"_$C(9)
44 S XMLER=-1 ;soft error count
45 S XMLMAXER=5 ;maximum allowable soft errors
46 S XMLTIME=30 ;length of READ time
47 S ER=0 ;non-recoverable error flag
48 Q
49NEWSTRAT ;machines have various loads
50 I XMLMAXER=5 S ER=1 Q ;already tried new strategy, give up.
51 S XMTLER=$S('$D(XMTLER):XMLER,1:XMTLER+XMLER),XMLER=0 ;add to total
52 S XMLMAXER=5 ;reduce allowable soft errors
53 S XMLTIME=30 ;increase the READ time
54 Q
55SRQ ;Exit from Send/Receive
56 S XMTLER=$S('$D(XMTLER):XMLER,1:XMTLER+XMLER) ;Total errors
57 K XMLACK,XMLNAK,XMLENQ,XMLERR,XMLMAXER,XMLTIME,XMLX,XMLY,XMLZ
58 Q
59BUFLUSH ;Flush any characters out of the buffer
60 Q:'$D(XMBFLUSH)
61 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
62 X ^%ZOSF("TRMOFF") Q
63SUM ;Calculate checksum
64 I '$D(XMOS) D LPC^XMLSWP0
65 I $D(XMOS(0)) X XMOS(0) S XMSUM=Y Q
66 I XMOS["VAX DSM" S XMSUM=$ZC(%LPC,X) Q
67 I XMOS["DSM" S XMSUM=$ZC(LPC,X) Q
68 I XMOS["M/11"!(XMOS["M/VX") S XMSUM=$ZC(X) Q
69 S XMSUM=$A(X) Q:$L(X)=1 S I=1
70A S I=I+1 I $L(X)<I K %,%0,%1 S XMSUM=XMSUM+$L(X)*$L(X) Q
71 S Y=$A(X,I) F %=256:0 Q:%\4<Y S %=%\2
72B S %0=XMSUM#%,%=%\2 G A:%=0 S %0=%0\%,%1=Y\% I %1=1 S Y=Y-%
73 G B:%1+%0=0 I %1'=%0 S:%0=0 XMSUM=XMSUM+% G B
74 G B:%0=0 S XMSUM=XMSUM-%
75 G B
Note: See TracBrowser for help on using the repository browser.