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

XMKPRD.m

Go to the documentation of this file.
  1. XMKPRD ;ISC-SF/GMB-DNS Interface ;07/11/2002 08:09
  1. ;;8.0;MailMan;;Jun 28, 2002
  1. NEXTIPF(XMSITE,XMIPT,XMIPLIST) ; Function returns next IP address to try.
  1. ; IN:
  1. ; XMSITE - .01 field of domain in file 4.2 (not a synonym)
  1. ; XMIPT - List of IP addresses, separated by ",", already tried
  1. ; XMIPLIST - (optional) List of IP addresses, separated by ",", to try
  1. I '$D(XMIPLIST) D
  1. . D SHOW(42260) ;Call DNS for IP Address list ...
  1. . S XMIPLIST=$$IPADDR(XMSITE)
  1. . D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
  1. I XMIPLIST="" Q ""
  1. I $G(XMIPT)="" Q $P(XMIPLIST,",")
  1. N XMJ,XMIP
  1. F XMJ=1:1:$L(XMIPT,",") D Q:XMIP=""!(","_XMIPT_","'[(","_XMIP_","))
  1. . S XMIP=$P(XMIPT,",",XMJ)
  1. . D NEXTIP(.XMIP,.XMIPLIST)
  1. Q XMIP
  1. IPADDR(XMSITE) ;
  1. N XMIPARY,XMIP,XMIPSITE,XMI,XMIPREC,XMIPLIST
  1. D MAIL^XLFNSLK(.XMIPARY,XMSITE)
  1. S XMI=0
  1. F S XMI=$O(XMIPARY(XMI)) Q:'XMI D
  1. . S XMIPREC=XMIPARY(XMI)
  1. . S XMIP=$P(XMIPREC,U,2)
  1. . ;I XMIP'?1.N1"."1.N1"."1.N1".".E D Q
  1. . I XMIP="" D Q
  1. . . D SHOW(42260.1,XMIPREC) ;Ignore '|1|' - no IP address
  1. . S XMIPSITE=$$UP^XLFSTR($P(XMIPREC,U,1))
  1. . ; Accept whatever DNS returns, except for FORUM. We accept FORUM if
  1. . ; we're trying to get to FORUM, but we don't want messages destined
  1. . ; for another site to be routed through FORUM. If this is a non-VA
  1. . ; site, then it's OK to route through FORUM.
  1. . I ^XMB("NETNAME")[".DOMAIN.EXT",XMSITE'["DOMAIN.EXT",XMIPSITE["DOMAIN.EXT" D Q
  1. . . D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
  1. . ;I '$$SAMESITE(XMIPSITE,XMSITE) D Q
  1. . ;. D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
  1. . I ","_$G(XMIPLIST)_","[(","_XMIP_",") D Q
  1. . . D SHOW(42260.3,XMIPREC) ;Ignore '|1|' - already have that IP address
  1. . D SHOW(42260.4,XMIPREC) ;Accept '|1|'
  1. . I $G(XMIPLIST)="" S XMIPLIST=XMIP Q
  1. . S XMIPLIST=XMIPLIST_","_XMIP
  1. Q $G(XMIPLIST)
  1. SAMESITE(X,XMSITE) ;
  1. N DIC,Y,D
  1. I $E(X,$L(X))="." S X=$E(X,1,$L(X)-1)
  1. S DIC="^DIC(4.2,",DIC(0)="FMXZ",D="B^C"
  1. F D MIX^DIC1 Q:Y>0!(X'[".") S X=$P(X,".",2,99)
  1. I Y,Y(0,0)=XMSITE Q 1
  1. Q 0
  1. SHOW(XMDIALOG,XM1) ;
  1. I $D(ZTQUEUED)!'$G(XMC("PLAY")) Q
  1. I +XMDIALOG=XMDIALOG W !,$$EZBLD^DIALOG(XMDIALOG,$G(XM1)) Q
  1. W !,XMDIALOG
  1. Q
  1. NEXTIP(XMIP,XMIPLIST) ;
  1. N XMI
  1. F XMI=1:1:$L(XMIPLIST,",") Q:$P(XMIPLIST,",",XMI)=XMIP
  1. I XMIP'=$P(XMIPLIST,",",XMI) S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
  1. I XMI=1 S XMIPLIST=$P(XMIPLIST,",",2,99)
  1. E I XMI=$L(XMIPLIST,",") S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)
  1. E S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)_","_$P(XMIPLIST,",",XMI+1,99)
  1. S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99)
  1. Q
  1. ; *** The following is not used ***
  1. CONNECT(XMSITE,XMIP,XMPORT) ; Function tries to connect to site.
  1. ; Returns the IP address if success; 0 if failure
  1. ; XMSITE - Site name to connect to
  1. ; XMIP - Site IP address to try first (optional). If none given,
  1. ; or if attempt fails, DNS is called to retrieve address(es).
  1. ; XMPORT - Port number to use (optional, default=25)
  1. N XMIPLIST,XMOK
  1. I '$G(XMPORT) S XMPORT=25
  1. D SHOW("Connect to "_XMSITE_" on port "_XMPORT_$S($G(XMIP):", IP Address "_XMIP,1:""))
  1. I $G(XMIP)="" D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP="" 0
  1. S XMOK=0
  1. F D TRYIP(XMIP,.XMOK) Q:XMOK D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP=""
  1. Q:XMOK XMIP
  1. D SHOW("Connect failed. Try again later.")
  1. Q 0
  1. NEXTIPR(XMSITE,XMIP,XMIPLIST) ; Routine returns next IP address to try
  1. ; IN/OUT:
  1. ; XMIP - in: Last IP address tried
  1. ; out: Next IP address to try
  1. ; XMIPLIST - in: (optional) List of IP addresses, separated by ",",
  1. ; we haven't yet tried
  1. ; out: Same, but with XMIP (out) removed
  1. I '$D(XMIPLIST) D
  1. . D SHOW(42260) ;Call DNS for IP Address list ...
  1. . S XMIPLIST=$$IPADDR(XMSITE)
  1. . D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
  1. I XMIPLIST="" S XMIP="" Q
  1. I $G(XMIP)="" S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
  1. D NEXTIP(.XMIP,.XMIPLIST)
  1. Q
  1. TRYIP(XMIP,XMOK) ; Try the IP address, if it works, set XMOK=1
  1. D SHOW("Trying "_XMIP)
  1. D CALL^%ZISTCP(XMIP,XMPORT)
  1. S XMOK='POP
  1. I 'XMOK D SHOW("Attempt failed.")
  1. Q