;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Copyright 2006 Fidelity Information Services, Inc ; ; ; ; This source code contains the intellectual property ; ; of its copyright holder(s), and is made available ; ; under a license. If you do not know the terms of ; ; the license, please stop and do not read further. ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gdeget: ;read in an existing GD or create a default CONVERT n accmeth,hdrlab,MAXSEGLN,MAXREGLN,SIZEOF,RMS,csegs,cregs,contents d gdeinit ;s label=$e(rec,1,12) s (v23,v24,v25)=0 ; to allow autoconvert i label="GTCGBLDIR001" s label=hdrlab,(v23,v24)=1,update=1 ; to allow autoconvert i label="GTCGBLDIR002" s label=hdrlab,v24=1,update=1 ; to allow autoconvert i label="GTCGBLDIR003" s label=hdrlab,v25=1,update=1 ; to allow autoconvert i label'=hdrlab zm gdeerr("GDUNKNFMT"):file,gdeerr("INPINTEG") s filesize=$$bin2num($ze(rec,13,16)) s header=$ze(rec,17,SIZEOF("gd_header")),abs=abs+SIZEOF("gd_header") ; contents i $ze(rec,abs,abs+3)'=$c(0,0,0,0) zm gdeerr("INPINTEG") ; filler s abs=abs+4 s contents("maxrecsize")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("mapcnt")=$$bin2num($ze(rec,abs,abs+1)),abs=abs+2 s contents("maps")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("regioncnt")=$$bin2num($ze(rec,abs,abs+1)),abs=abs+2 s contents("regions")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("segmentcnt")=$$bin2num($ze(rec,abs,abs+1)),abs=abs+2 s contents("segments")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("gdscnt")=$$bin2num($ze(rec,abs,abs+1)),abs=abs+2 s contents("gdsfiledata")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("rmscnt")=$$bin2num($ze(rec,abs,abs+1)),abs=abs+2 s contents("rmsfiledata")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s contents("end")=$$bin2num($ze(rec,abs,abs+3)),abs=abs+4 s abs=abs+22 i contents("regioncnt")'=contents("segmentcnt") zm gdeerr("INPINTEG") i contents("regioncnt")-1>contents("mapcnt") zm gdeerr("INPINTEG") ; verify offsets i abs'=(SIZEOF("gd_header")+SIZEOF("gd_contents")+1) zm gdeerr("INPINTEG") s x=contents("maps") i x+1'=(abs-SIZEOF("gd_header")) zm gdeerr("INPINTEG") s x=x+(contents("mapcnt")*SIZEOF("gd_map")) i x'=contents("regions") zm gdeerr("INPINTEG") s x=x+(contents("regioncnt")*SIZEOF("gd_region")) i x'=contents("segments") zm gdeerr("INPINTEG") s x=x+(contents("segmentcnt")*SIZEOF("gd_segment")) i x'=contents("gdsfiledata") zm gdeerr("INPINTEG") s x=x+(contents("gdscnt")*SIZEOF("gds_filedata")) i x'=contents("rmsfiledata") zm gdeerr("INPINTEG") s x=x+(contents("rmscnt")*SIZEOF("rms_filedata")) i x'=contents("end") zm gdeerr("INPINTEG") s rel=abs ; maps - verify that mapped regions and regions are 1-to-1 k reglist f i=1:1:contents("mapcnt") d map s s="" f i=1:1:contents("regioncnt") s s=$o(reglist(s)) i $l($o(reglist(s))) zm gdeerr("INPINTEG") ; regions k cregs,xregs s cregs=0 f i=1:1:contents("regioncnt") d region i cregs'=contents("regioncnt") zm gdeerr("INPINTEG") ; segments k csegs,xsegs s csegs=0 f i=1:1:contents("segmentcnt") d segment i csegs'=contents("segmentcnt") zm gdeerr("INPINTEG") ; gdsfiledata f i=1:1:contents("gdscnt") d fabdata(SIZEOF("gds_filedata"),0) ; rmsfiledata f i=1:1:contents("rmscnt") d fabdata(SIZEOF("rms_filedata"),SIZEOF("struct RAB")) ; names k nams s nams=0 i $zl(rec)-(rel-1)<3 d nextrec s nams=$ze(rec,rel,rel+2),rel=rel+3,abs=abs+3 f i=1:1:nams d name ; regions k regs s regs=0 i $zl(rec)-(rel-1)<3 d nextrec s regs=$ze(rec,rel,rel+2),rel=rel+3,abs=abs+3 i regsmaxreg(x)) regs(s,x)=maxreg(x) f s s=$o(segs(s)) q:'$l(s) s am=segs(s,"ACCESS_METHOD"),x="" s:am="RMS" am="BG" d . d segres f s x=$o(segs(s,am,x)) q:x="" s segs(s,x)=segs(s,am,x) k segs(s,am,x) d . . s:$d(minseg(am,x))&(segs(s,x)maxseg(am,x)) segs(s,x)=maxseg(am,x) . f i=1:1:$l(accmeth,"\") s x=$p(accmeth,"\",i) i am'=x k segs(s,x) k minseg("RMS"),maxseg("RMS"),tmpseg("RMS") i tmpacc="RMS" s tmpacc="BG" q tmpres: k tmpreg("LOCK_WRITE") s x="" s x=$o(tmpreg(x)) q:x="" d . s:$d(minreg(x))&(tmpreg(x)maxreg(x)) tmpreg(x)=maxreg(x) s am="" f s am=$o(tmpseq(am)) q:am="" s x="" f s x=$o(tmpseq(am,x)) q:x="" d . s:$d(minseg(am,x))&(tmpseg(am,x)maxseg(am,x)) tmpseg(am,x)=maxseg(am,x) q regres: s x="" f s x=$o(tmpreg(x)) q:x="" s:'$d(regs(s,x)) regs(s,x)=tmpreg(x) q segres: s x="" f s x=$o(tmpseg(am,x)) q:x="" s:'$d(segs(s,am,x)) segs(s,am,x)=tmpseg(am,x) q ; verify s x=$$ALL^GDEVERIF i 'x zm gdeerr("INPINTEG") q ;---------------------------------------------------------------------------------------------------------------------------------- badfile ;file access failed s:'debug $et="" s abortzs=$zs zm gdeerr("GDREADERR"):file,+abortzs h ; bin2num:(bin) ; binary number -> number n num,i s num=0 f i=1:1:$zl(bin) s num=$za(bin,i)*HEX(i-1*2)+num q num ; str2hex:(in) n i,j,out s out="" f i=1:1 s j=$a(in,i) q:j=-1 f k=j\16,j#16 s out=out_$s(k<10:k,1:$c(k+55)) q out ; num2long:(num) i num<0 zm gdeerr("INPINTEG") i num'SIZEOF("mident") zm gdeerr("INPINTEG") i $zl(rec)-(rel-1)MAXREGLN zm gdeerr("INPINTEG") i $zl(rec)-(rel-1)max zm gdeerr("INPINTEG") i $zl(rec)-(rel-1)