source: FOIAVistA/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/ZISUTL.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 3.2 KB
Line 
1%ZISUTL ;Device Handler Utility routine ;01/08/2007
2 ;;8.0;KERNEL;**18,24,34,69,118,127,199,275,425**;JUL 10, 1995;Build 18
3 Q ;No entry from top
4GETDEV(X) ;Return IO variables
5 I '$D(^TMP("XUDEVICE",$J,X)) S POP=1 Q
6 ;Cleanup first
7 N % K IO("S")
8 D SYMBOL("K") ;Kill first
9 D SYMBOL(1,$NA(^TMP("XUDEVICE",$J,X)))
10 Q
11 ;
12SAVDEV(NM) ;Save IO variables
13 ;NM=Handle name
14 N %,Y,R
15 I $G(IO)="" Q
16 S Y=$$FINDEV(NM) I 'Y S Y=$$NEXTDEV(NM)
17 S R=$NA(^TMP("XUDEVICE",$J,Y)) K @R ;Clear
18 S @R@(0)=NM
19 D SYMBOL(0,R)
20 Q
21 ;
22SYMBOL(MODE,ROOT) ;0=Save, 1=Restore, K=Kill IO variables
23 N %
24 ;Handle IO as special case. Don't want to kill all of IO.
25 I MODE=0 S:$D(IO)#2 @ROOT@("IO")=IO
26 I MODE=1 S:$D(@ROOT@("IO")) IO=@ROOT@("IO")
27 F %="IO(""DOC"")","IO(""HFSIO"")","IO(""Q"")","IO(""S"")","IO(""SPOOL"")","IO(""ZIO"")","IOBS","IOCPU","IOF","IOHG","IOM","ION","IOPAR","IOUPAR","IOS","IOSL","IOST","IOST(0)","IOT","IOXY" D
28 . I MODE=0 S:$D(@%)#2 @ROOT@(%)=@% Q
29 . I MODE=1 S:$D(@ROOT@(%)) @%=@ROOT@(%) Q
30 . I MODE="K" K @%
31 . Q
32 Q
33 ;
34RMDEV(X) ;Remove saved IO variables.
35 N Y
36 S Y=$$FINDEV(X)
37 Q:'Y
38 K ^TMP("XUDEVICE",$J,"B",X),^TMP("XUDEVICE",$J,+Y)
39 Q
40 ;
41RMALLDEV() ;Remove saved IO variables for all devices saved in table.
42 K ^TMP("XUDEVICE",$J)
43 Q 1
44 ;
45FINDEV(NM) ;Find Device name and return IEN.
46 Q $O(^TMP("XUDEVICE",$J,"B",NM,0))
47 ;
48NEXTDEV(NM) ;Return next available device.
49 N Y
50 F Y=1:1 Q:'$D(^TMP("XUDEVICE",$J,Y))
51 S ^TMP("XUDEVICE",$J,"B",NM,Y)=""
52 Q Y
53 ;
54OPEN(HNDL,IOP,%ZIS) ;Open extrinsic function
55 ;Parameters
56 ;HNDL=Handle name
57 ;IOP string--optional
58 ;%ZIS string--optional
59 N %
60 I $G(IOP)="" K IOP ;Remove IOP if null.
61 D ^%ZIS,SAVDEV(HNDL):POP=0
62 Q
63 ;
64CLOSE(X1) ;Close extrinsic functionsl
65 ;X1=Handle
66 N %,Y
67 S Y=$$FINDEV(X1)
68 Q:'Y
69 D GETDEV(Y)
70 D ^%ZISC,RMDEV(X1)
71 Q
72 ;
73USE(X1) ;Restore IO* variables pertaining to the device.
74 ;X1=Handle name
75 N %,Y
76 S Y=$$FINDEV^%ZISUTL(X1)
77 Q:'Y
78 D GETDEV^%ZISUTL(Y)
79 I $G(IOT)'="RES" U $S($D(IO(1,IO)):IO,1:IO(0))
80 K IO("CLOSE")
81 Q
82 ;
83LINEPORT() ;Return device name for line port.
84 ;
85 N %,%1,Y
86 S Y=0
87 S %=$$LNPRTIEN^%ZISUTL($$LNPRTNAM^%ZISUTL)
88 S Y=+$P($G(^%ZIS(3.23,+%,0)),"^",3)
89 Q Y
90LNPRTSUB() ;Return line port subtype pointer.
91 N %
92 S %=$$LNPRTIEN^%ZISUTL($$LNPRTNAM^%ZISUTL)
93 Q +$P($G(^%ZIS(3.23,+%,0)),"^",4)
94 ;
95LNPRTNAM() ;Return Line port name
96 N Y,%
97 S Y="",%=$G(^%ZOSF("OS"))
98 I %["VAX DSM"!(%["OpenM-NT") D
99 .S Y=$ZIO
100 E I %["MSM" X "S Y=$ZDEV($I)"
101 Q Y
102LNPRTIEN(X) ;Return internal entry number of Line/port
103 Q:X'?1AN.29ANP 0
104 Q $O(^%ZIS(3.23,"B",X,0))
105LNPRTADR(X) ;Returns Line/Port name of a fixed device.
106 N %,Y
107 S Y=""
108 S %=$O(^%ZIS(1,"B",X,0))
109 S %=$O(^%ZIS(3.23,"C",+%,0))
110 I %,$G(^%ZIS(3.23,+%,0))]"" S Y=$P(^(0),"^")
111 Q Y
112 ;
113FIND(IOP) ;e.f. Get the IEN of a device
114 N %XX,%YY,%ZIS,%ZISV
115 S %ZISV=^%ZOSF("VOL"),%XX=$$UP^%ZIS1(IOP) D 1^%ZIS5
116 Q %YY
117NOQ(IOP) ;e.f. Return queueing status
118 ;Call with Device name, Return 1 if NO QUEUE, Else 0.
119 N %X,%Y S %X=$$FIND(IOP) Q:%X'>0 0
120 S %Y=$P($G(^%ZIS(1,%X,0)),U,12)
121 Q %Y=2
122 ;
123UNIQUE(ZISNA) ;Build a unque number to add to a device name
124 ;If passed a name put the number before the last dot.
125 N %,%1
126 S %=$H,%=$H_"-"_$J,%=$$CRC32^XLFCRC(%)
127 I '$L($G(ZISNA)) Q %
128 S %1=$L(ZISNA,"."),%="_"_%
129 S:%1=1 %=ZISNA_% S:%1>1 %=$P(ZISNA,".",1,%1-1)_%_"."_$P(ZISNA,".",%1)
130 Q %
Note: See TracBrowser for help on using the repository browser.