XU8P585 ;ISF/CJM- Patch XU-585 Post init ;09/11/2012
;;8.0;KERNEL;**585**;;Build 22
;
ENVIR ;Environment check for XU*8.0*585
I '$$CHECKDIR D
.S XPDQUIT=2
.W !,"The directory for the print files does not exist or the permissions were",!,"not correctly established"
Q
POST ;
N ERROR,OS
D PATCH^ZTMGRSET(585)
S OS=$$OS^%ZOSV()
I OS'["VMS",OS'["UNIX" Q
I $G(ERROR)<0 D BMES^XPDUTL("Failed to schedule the 'XU PURGE PRINT QUEUE HFS FILES' option! Please do so manually.")
N IEN,DATA,OPTION
S OPTION=$O(^DIC(19,"B","XU PURGE PRINT QUEUE HFS FILES",0))
I 'OPTION D BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
I OPTION D
.S IEN=$O(^DIC(19.2,"B",OPTION,0))
.S DATA(.01)=OPTION
.S DATA(2)=$$FMADD^XLFDT($$NOW^XLFDT,,1)
.S DATA(6)="1H"
.I IEN D
..I '$$UPD^HLOASUB1(19.2,IEN,.DATA) D BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
.E D
..I '$$ADD^HLOASUB1(19.2,,.DATA) D BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
Q
;
CNVRT ;convert HFS type devices that call NVSPRTU to PQ type devices
N DEVICE,NOW
S NOW=$$DT^XLFDT()
S DEVICE=0
;
;K ^XTMP("%ZIS HFS TO PQ") ;overlay old list if it exists
;
S ^XTMP("%ZIS HFS TO PQ",0)=$$FMADD^XLFDT(NOW,180)_"^"_NOW
F S DEVICE=$O(^%ZIS(1,DEVICE)) Q:'DEVICE D
.I $P($G(^%ZIS(1,DEVICE,"TYPE")),"^")="HFS" D
..N SUBTYPE
..S SUBTYPE=$P($G(^%ZIS(1,DEVICE,"SUBTYPE")),"^")
..Q:'SUBTYPE
..I $G(^%ZIS(2,SUBTYPE,3))["CLOSE^NVSPRTU" D
...N DATA
...S DATA(2)="PQ"
...S ^XTMP("%ZIS HFS TO PQ",DEVICE)=""
...D UPD^ZISFM(3.5,DEVICE,.DATA)
Q
;
UNDO ;undo the changes made by CNVRT conversion routine
N DEVICE
S DEVICE=0
F S DEVICE=$O(^XTMP("%ZIS HFS TO PQ",DEVICE)) Q:'DEVICE D
.N DATA
.S DATA(2)="HFS"
.D UPD^ZISFM(3.5,DEVICE,.DATA)
Q
;
;
CHECKDIR() ;tests if the print_queues directory has been created properly
;
;if production and VMS or Linux the test is not needed
N OS
Q:'$$PROD^XUPROD() 1
S OS=$$OS^%ZOSV()
I OS'["VMS",OS'["UNIX" Q 1
;
N DIR,FILE,IO,POP,HANDLE
S DIR=$$DIR
S FILE="TEST_"_$J
S HANDLE="ZUHANDLE"
;
I $$FEXIST(DIR_FILE) Q 1
D OPEN^%ZISH(HANDLE,DIR,FILE,"W")
Q:POP 0
D CLOSE^%ZISH(HANDLE)
D FDELETE(DIR_FILE)
Q 1
;
;
DIR() ;get directory for printer queues, a subdirectory of host file directory
N DIR,CODE
S CODE=$$PRI^%ZOSV
S DIR=$$CHKNM^%ZISF($P($G(^XTV(8989.3,1,"DEV")),"^",CODE))
I $$OS^%ZOSV()["VMS" D
.S DIR=$P(DIR,"]")_".print_queues]"
E D
.S DIR=DIR_"print_queues/"
Q DIR
;
FEXIST(FILE) ;
;returns 1 if the file exists, 0 otherwise
;
N OS S OS=$$OS^%ZOSV()
I OS["UNIX" Q $$LFEXIST(FILE)
E I OS["VMS" Q $$VFEXIST(FILE)
Q 0
;
VFEXIST(FILE) ;
;checks file's existance - VMS
N CMD,RET
S CMD="PIPE F = F$SEARCH("""_FILE_""")"
S CMD=CMD_" ; IF F$LENGTH(F) .EQ. 0 THEN DEFINE/JOB ZIS$VAL 0 ; IF F$LENGTH(F) .GT. 0 THEN DEFINE/JOB ZIS$VAL 1 "
I $ZF(-1,CMD)
S RET=$ZF("TRNLNM","ZIS$VAL","LNM$JOB")
I $ZF(-1,"DEASSIGN/JOB ZIS$VAL")
Q +$G(RET)
;
LFEXIST(FILE) ;
;checks file's existance - Linux,Unix
N CMD
S CMD="[ -f "_$$REPLACE(FILE,"$","'$'")_" ]"
Q '$ZF(-1,CMD)
;
FDELETE(FILE) ;
;delete file
N OS S OS=$$OS^%ZOSV()
I OS["UNIX" D LFDELETE(FILE)
E I OS["VMS" D VFDELETE(FILE)
Q
;
VFDELETE(FILE) ;
;delete file - VMS
N CMD
I FILE'[";" S FILE=FILE_";*"
S CMD="DELETE "_FILE
I $ZF(-1,CMD)
;
LFDELETE(FILE) ;
;delete file - Linux,Unix
N CMD
S CMD="rm -f "_$$REPLACE(FILE,"$","'$'")
I $ZF(-1,CMD)
;
REPLACE(STRING,SUB1,SUB2) ;
;
N REPLACE
S REPLACE(SUB1)=SUB2
Q $$REPLACE^XLFSTR(STRING,.REPLACE)
;
;
;
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXU8P585 3705 printed Dec 13, 2024@02:08:17 Page 2
XU8P585 ;ISF/CJM- Patch XU-585 Post init ;09/11/2012
+1 ;;8.0;KERNEL;**585**;;Build 22
+2 ;
ENVIR ;Environment check for XU*8.0*585
+1 IF '$$CHECKDIR
Begin DoDot:1
+2 SET XPDQUIT=2
+3 WRITE !,"The directory for the print files does not exist or the permissions were",!,"not correctly established"
End DoDot:1
+4 QUIT
POST ;
+1 NEW ERROR,OS
+2 DO PATCH^ZTMGRSET(585)
+3 SET OS=$$OS^%ZOSV()
+4 IF OS'["VMS"
IF OS'["UNIX"
QUIT
+5 IF $GET(ERROR)<0
DO BMES^XPDUTL("Failed to schedule the 'XU PURGE PRINT QUEUE HFS FILES' option! Please do so manually.")
+6 NEW IEN,DATA,OPTION
+7 SET OPTION=$ORDER(^DIC(19,"B","XU PURGE PRINT QUEUE HFS FILES",0))
+8 IF 'OPTION
DO BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
+9 IF OPTION
Begin DoDot:1
+10 SET IEN=$ORDER(^DIC(19.2,"B",OPTION,0))
+11 SET DATA(.01)=OPTION
+12 SET DATA(2)=$$FMADD^XLFDT($$NOW^XLFDT,,1)
+13 SET DATA(6)="1H"
+14 IF IEN
Begin DoDot:2
+15 IF '$$UPD^HLOASUB1(19.2,IEN,.DATA)
DO BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
End DoDot:2
+16 IF '$TEST
Begin DoDot:2
+17 IF '$$ADD^HLOASUB1(19.2,,.DATA)
DO BMES^XPDUTL("Failed to schedule the XU PURGE PRINT QUEUE HFS FILES option!")
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
CNVRT ;convert HFS type devices that call NVSPRTU to PQ type devices
+1 NEW DEVICE,NOW
+2 SET NOW=$$DT^XLFDT()
+3 SET DEVICE=0
+4 ;
+5 ;K ^XTMP("%ZIS HFS TO PQ") ;overlay old list if it exists
+6 ;
+7 SET ^XTMP("%ZIS HFS TO PQ",0)=$$FMADD^XLFDT(NOW,180)_"^"_NOW
+8 FOR
SET DEVICE=$ORDER(^%ZIS(1,DEVICE))
if 'DEVICE
QUIT
Begin DoDot:1
+9 IF $PIECE($GET(^%ZIS(1,DEVICE,"TYPE")),"^")="HFS"
Begin DoDot:2
+10 NEW SUBTYPE
+11 SET SUBTYPE=$PIECE($GET(^%ZIS(1,DEVICE,"SUBTYPE")),"^")
+12 if 'SUBTYPE
QUIT
+13 IF $GET(^%ZIS(2,SUBTYPE,3))["CLOSE^NVSPRTU"
Begin DoDot:3
+14 NEW DATA
+15 SET DATA(2)="PQ"
+16 SET ^XTMP("%ZIS HFS TO PQ",DEVICE)=""
+17 DO UPD^ZISFM(3.5,DEVICE,.DATA)
End DoDot:3
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
UNDO ;undo the changes made by CNVRT conversion routine
+1 NEW DEVICE
+2 SET DEVICE=0
+3 FOR
SET DEVICE=$ORDER(^XTMP("%ZIS HFS TO PQ",DEVICE))
if 'DEVICE
QUIT
Begin DoDot:1
+4 NEW DATA
+5 SET DATA(2)="HFS"
+6 DO UPD^ZISFM(3.5,DEVICE,.DATA)
End DoDot:1
+7 QUIT
+8 ;
+9 ;
CHECKDIR() ;tests if the print_queues directory has been created properly
+1 ;
+2 ;if production and VMS or Linux the test is not needed
+3 NEW OS
+4 if '$$PROD^XUPROD()
QUIT 1
+5 SET OS=$$OS^%ZOSV()
+6 IF OS'["VMS"
IF OS'["UNIX"
QUIT 1
+7 ;
+8 NEW DIR,FILE,IO,POP,HANDLE
+9 SET DIR=$$DIR
+10 SET FILE="TEST_"_$JOB
+11 SET HANDLE="ZUHANDLE"
+12 ;
+13 IF $$FEXIST(DIR_FILE)
QUIT 1
+14 DO OPEN^%ZISH(HANDLE,DIR,FILE,"W")
+15 if POP
QUIT 0
+16 DO CLOSE^%ZISH(HANDLE)
+17 DO FDELETE(DIR_FILE)
+18 QUIT 1
+19 ;
+20 ;
DIR() ;get directory for printer queues, a subdirectory of host file directory
+1 NEW DIR,CODE
+2 SET CODE=$$PRI^%ZOSV
+3 SET DIR=$$CHKNM^%ZISF($PIECE($GET(^XTV(8989.3,1,"DEV")),"^",CODE))
+4 IF $$OS^%ZOSV()["VMS"
Begin DoDot:1
+5 SET DIR=$PIECE(DIR,"]")_".print_queues]"
End DoDot:1
+6 IF '$TEST
Begin DoDot:1
+7 SET DIR=DIR_"print_queues/"
End DoDot:1
+8 QUIT DIR
+9 ;
FEXIST(FILE) ;
+1 ;returns 1 if the file exists, 0 otherwise
+2 ;
+3 NEW OS
SET OS=$$OS^%ZOSV()
+4 IF OS["UNIX"
QUIT $$LFEXIST(FILE)
+5 IF '$TEST
IF OS["VMS"
QUIT $$VFEXIST(FILE)
+6 QUIT 0
+7 ;
VFEXIST(FILE) ;
+1 ;checks file's existance - VMS
+2 NEW CMD,RET
+3 SET CMD="PIPE F = F$SEARCH("""_FILE_""")"
+4 SET CMD=CMD_" ; IF F$LENGTH(F) .EQ. 0 THEN DEFINE/JOB ZIS$VAL 0 ; IF F$LENGTH(F) .GT. 0 THEN DEFINE/JOB ZIS$VAL 1 "
+5 IF $ZF(-1,CMD)
+6 SET RET=$ZF("TRNLNM","ZIS$VAL","LNM$JOB")
+7 IF $ZF(-1,"DEASSIGN/JOB ZIS$VAL")
+8 QUIT +$GET(RET)
+9 ;
LFEXIST(FILE) ;
+1 ;checks file's existance - Linux,Unix
+2 NEW CMD
+3 SET CMD="[ -f "_$$REPLACE(FILE,"$","'$'")_" ]"
+4 QUIT '$ZF(-1,CMD)
+5 ;
FDELETE(FILE) ;
+1 ;delete file
+2 NEW OS
SET OS=$$OS^%ZOSV()
+3 IF OS["UNIX"
DO LFDELETE(FILE)
+4 IF '$TEST
IF OS["VMS"
DO VFDELETE(FILE)
+5 QUIT
+6 ;
VFDELETE(FILE) ;
+1 ;delete file - VMS
+2 NEW CMD
+3 IF FILE'[";"
SET FILE=FILE_";*"
+4 SET CMD="DELETE "_FILE
+5 IF $ZF(-1,CMD)
+6 ;
LFDELETE(FILE) ;
+1 ;delete file - Linux,Unix
+2 NEW CMD
+3 SET CMD="rm -f "_$$REPLACE(FILE,"$","'$'")
+4 IF $ZF(-1,CMD)
+5 ;
REPLACE(STRING,SUB1,SUB2) ;
+1 ;
+2 NEW REPLACE
+3 SET REPLACE(SUB1)=SUB2
+4 QUIT $$REPLACE^XLFSTR(STRING,.REPLACE)
+5 ;
+6 ;
+7 ;
+8 ;