.TITLE AUTOQ - AUTOMATIC .LST FILE QUEUER. .IDENT /Y01.00/ .ENABL LC .NLIST BEX ; This program will automatically request the QUEUE utility to ; print all .LST files on device DK: and delete them as they are ; listed. Before starting, the user must assign the device which ; contains the .LST files to DK: and ensure that QUEUE is running. ; Eg: .SRUN SY:QUEUE.REL ; .LOAD LP:=QUEUE ; .SRUN SY:AUTOQ.REL ; If there are no .LST files on DK: or a read error occurs ; or QUEUE cnnot handle the request, a timed wait is executed and ; a re-try is attempted later. ; Author: GA ; Edit History: ; ----- Macros and definitions ------------------------------------ .IIF NDF MMG$T, MMG$T=0 ;** Assume we're not mapped.** .MCALL .READW, .WRITW, .LOOKUP, .DELETE, .PURGE, .TWAIT .MCALL .DSTAT, .PRINT, .RCTRLO, .EXIT, .CLOSE, .RENAME .IF NE MMG$T .MCALL .CRRG, .CRAW, .RDBBK, .RDBDF, .WDBBK .RDBDF ;Define XM mnemonics. APR = 7 ;Use APR 7. WINOFF = 0 ;Offset into region to start window. BUFF = APR*4096.*2 ;Where the buffer is. .ENDC WDCT = 512. ;512. words per directory segment. FLG.DE = 1 ;QUEUE request flag for delete file. FLG.JR = 10 ;QUEUE request flag for initial request. .PAGE ; ----- Parameter and data area ----------------------------------- ; The USR is tricky so put sensitive data up here out of its way! .PSECT AUTOQ AREA:: .WORD 0,0,0,0,0 ;EMT request block. TIMBLK::.BYTE 0,24 ;.TWAIT code. .WORD TIME TIME:: .WORD 0,60.*5. ;Sleep for 5 seconds. DK:: .RAD50 /DK LST/ ;Specification for .LST file device. .RAD50 /DK LIS/ ;Specification for renaming to .LIS. MQ:: .RAD50 /MQ/ ;Specification for message queue. .ASCIZ /QUEUE/ .EVEN REPLY:: .WORD 0 .BLKW 6 REQST:: .WORD FLG.JR ;Initial request. .ASCIZ /AUTOQ/ ;We're AUTOQ. .WORD JOB,0 JOB:: .WORD ;Delete file when done. .WORD 0 JOBNAM::.RAD50 /LP / ;Job to LP, name = input file. .WORD 1 ;One file per request. FILBLK::.WORD 0,0 ;Use default flags. QFILE:: .RAD50 /DK LIS/ ;File to be queued. .IF NE MMG$T WADR:: .WDBBK APR,WDCT/32.,0,WINOFF,WDCT/32.,WS.MAP WNRID = WADR+W.NRID ;Address of region ID word. RGADR:: .RDBBK WDCT/32. .ENDC .PAGE ; ----- Entry point (and USR swap area) --------------------------- START:: .IF EQ MMG$T MOV #START,@#46 ;USR swap here in case its FB & not XM. .ENDC .RCTRLO ;Just in case we need to report an error. MOV #DK,R1 ;R1 => DK:FILNAM.LST block (always). MOV #AREA,R2 ;R2 => EMT request block (always). .IF NE MMG$T .CRRG R2,#RGADR ;Allocate a region in extended memory. BCC 1$ ;Did we get it? JSR PC,ABORT ;Nope then abort. .ASCIZ "Unable to get required extended memory!" ;.EXIT ;Done in subroutine abort. .EVEN 1$: MOV RGADR,WNRID ;Map the region to our window. .CRAW R2,#WADR ;Creat the window. BCC 2$ ;Did it map up? JSR PC,ABORT ;No, it figures - abort... .ASCIZ "Error mapping window to extended memory region!" .EVEN .ENDC 2$: BR FIND ;And now for something really different. .PAGE ; ----- Wait here on errors and when nothing to do ---------------- WAIT: MOV #TIMBLK,R0 ;** Wait until later! ** .TWAIT ; ----- Start looking for .LST files ------------------------------- FIND: .DSTAT R2,R1 ;Is DK: there and assigned? BCC 1$ JSR PC,WARNING ;Should never happen. .ASCIZ "DK: not assigned!" ;BR WAIT ;Done in subroutine warning. .EVEN 1$: TST 4(R2) ;Is DK: loaded? BNE 2$ ;No if entry point is 0 JSR PC,WARNING ;Report queueing will fail. .ASCIZ "DK: handler not loaded!" ;BR WAIT ;Done in subroutine warning. .EVEN 2$: .PURGE #0 ;Free channel 0 for use. CLR 2(R1) ;No file for non-file-structured .LOOKUP R2,#0,R1,#0 ; directory reads. MOV #BUFF,R4 ;R4 => buffer for directory reads. MOV #1,R3 ;Directory starts at blk 6. 3$: ASL R3 ;2 blocks per segment. ADD #4,R3 .READW R2,#0,R4,#WDCT,R3 ;CHAN,BUFF,WDCT,BLK BCS WAIT ;Directory read error (device off line). 4$: MOV R4,R5 ;Copy start of buffer pointer. ADD #12,R5 ;R5 -> file status word. 5$: BIT #4000,@R5 ;Is this the end of the segment? BEQ 6$ MOV 2(R4),R3 ;Yes so next segment pointer. BNE 3$ ;Was that the last segment? BR WAIT ;Yes, then no queueing is needed. 6$: BIT #2000,(R5)+ ;Is this file a permanent entry? BEQ 7$ ;No, then ignore it. CMP 4(R5),#^RLST ;Yes,then is extension .LST? BEQ 8$ ;Yes,whaddya know, one to queue. 7$: ADD #14,R5 ;Skip other file entry words. BR 5$ 8$: MOV (R5),2(R1) ;Put filename everywhere its needed. MOV (R5),12(R1) MOV (R5),JOBNAM+2 MOV (R5)+,QFILE+2 MOV (R5),4(R1) MOV (R5),14(R1) MOV (R5),JOBNAM+4 MOV (R5)+,QFILE+4 .PAGE ; ----- Start a QUEUE request --------------------------------------- STARTQ::.PURGE #1 ;Make channel 1 available. .LOOKUP R2,#1,#MQ ;Is QUEUE running? BCC 1$ ;Yes, all ok. JSR PC,ABORT ;No, tisk-tisk, abort him. .ASCIZ "QUEUE isn't running!" ;.EXIT ;Done in subroutine abort. .EVEN 1$: .PURGE #2 ;Make channel 2 available. .RENAME R2,#2,R1 ;Rename .LST file to .LIS file. BCC 2$ ;Did it rename ok? JSR PC,WARNING ;No, then tell him about it. .ASCIZ ".LIS file is protected, cannot rename!" ;BR WAIT ;Done in subroutine warning. .EVEN 2$: .WRITW R2,#1,#REQST,#6 ;Send request message to QUEUE. BCC 6$ ;All ok? 3$: .PURGE #2 ;No, then unrename the file. MOV #^RLIS,6(R1) ;Swap extensions around in the MOV #^RLST,16(R1) ;rename parameter block. .RENAME R2,#2,R1 ;Unrename them. BCC 4$ ;All ok? JSR PC,ABORT ;No, then we're really up to our .ASCIZ ".LIS file won't unrename!" ;ankles in it. ;.EXIT ;Done in subroutine abort. .EVEN 4$: MOV #^RLST,6(R1) ;Unswap extensions. MOV #^RLIS,16(R1) 5$: JSR PC,WARNING ;Here when QUEUE won't do the listing. .ASCIZ "QUEUE won't take the listing request!" ;BR WAIT ;Done is subroutine warning. .EVEN 6$: .READW R2,#1,#REPLY,#6 ;Does QUEUE acknowledge the request? BCS 3$ ;No, take not queued case. TST REPLY+2 ;Was the request successful? BNE 3$ ;No, take not queued case. JMP FIND ;Yes, go try for another file to list. .PAGE ; ----- Errors and Aborts ------------------------------------------- WARNING:.PRINT #INFORM ;Print standard informationr leader. MOV (SP)+,R5 ;R5 => error message text. .PRINT R5 ;Tell him he blew it. JMP WAIT ;.....Go wait..... INFORM: .ASCII "AUTOQ-I-"<200> .EVEN ABORT: .PRINT #FATAL ;Print standard fatal error header. MOV (SP)+,R5 ;R5 -> error message text. .PRINT R5 ;Tell him he blew it. .EXIT ;.....Going home..... FATAL: .ASCII "AUTOQ-F-"<200> .EVEN ; ----- Buffer area for non-mapped operation ------------------------ .IF EQ MMG$T BUFF:: .BLKB 4096.+START-. ;Room for USR & buffer area. .ENDC .END START