.TITLE FNDQUE Build queue subroutine .NLIST BEX .ENABL LC ; ; Build queue subroutine ; ; This subroutine scans the directory of device SY: looking for files with ; specified extension. It reads the first block of each such file and appends ; the spool queue information from it to the region specified. ; ; External symbols ; ; Entry symbols ; .GLOBL FNDQUE ; ; System definitions ; .ASECT .MCALL .PRT ;dcnlib macroni .MCALL .LOOKU,.READW,.PURGE ;rt-11 macroni .PRT ;define queue file entry format ; ; Module definitions ; DIROFS = 6 ;beginning of rt-11 directory (block) SPQSIZ = 20. ;max elements on special queue ; ; Directory entry format ; . = 0 E.CTRL: .BLKW 1 ;control word PROTEK = 100000 ;protected file ENDBLK = 004000 ;end of segment marker PERM = 002000 ;permanent file EMPTY = 001000 ;empty entry TENT = 000400 ;tentative file E.NAME: .BLKW 3 ;file name and extension E.BLOK: .BLKW 1 ;size of hole allocated (blocks) E.CHAN: .BLKB 1 ;channel number of tentative file E.JNUM: .BLKB 1 ;process id of tentative file E.DATE: .BLKW 1 ;creation date E.LENG = . ;end of directory entry (extra words follow) ; ; Directory segment header format ; . = 0 D.SMAX: .BLKW 1 ;maximum segments D.LINK: .BLKW 1 ;link to next segment D.USED: .BLKW 1 ;last segment used (first segment only) D.XTRA: .BLKW 1 ;extra bytes in directory entry D.STRT: .BLKW 1 ;start block this segment D.LENG = . ;end of directory segment header ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; FNDQUE (que) build spool queue ; R0 = prototype file name pointer, r1 = region pointer, returns r0 = count ; FNDQUE: MOV R1,-(SP) ;preserve environment MOV R2,-(SP) MOV @R0,FILKEY ;save queue device CLR FILKEY+2 CLR FILKEY+4 CLR FILKEY+6 MOV 6(R0),FILEXT ;save queue file extension CLR QUECNT ;initialize MOV R1,R2 .LOOKU #ARGBLK,#0,#FILKEY ;open device BCS 6$ ;branch if not found MOV #DIROFS,DIRBLK 1$: .READW #ARGBLK,#0,#DIRBUF,#2*256.,DIRBLK ;read next segment BCS 6$ ;branch if error MOV DIRBUF+D.STRT,QUEBLK MOV #DIRBUF+D.LENG,R1 2$: BIT #ENDBLK,@R1 ;is it end of segment BNE 5$ ;branch if yes BIT #PERM,@R1 ;no. is it permanent BEQ 4$ ;branch if no CMP E.NAME+4(R1),FILEXT ;yes. does extension match BNE 4$ ;branch if no CMP QUECNT,#SPQSIZ ;is queue full BHIS 6$ ;branch if yes INC QUECNT ;no. read queue block .READW #ARGBLK,#0,R2,#SQ.LEN/2,QUEBLK BCS 6$ ;branch if error TST SQ.SIZ(R2) ;is size missing BNE 3$ ;branch if no MOV E.BLOK(R1),SQ.SIZ(R2) ;yes. use size of this file 3$: ADD #SQ.LEN,R2 4$: ADD E.BLOK(R1),QUEBLK ;keep book on position ADD #E.LENG,R1 ;advance to next entry ADD DIRBUF+D.XTRA,R1 BR 2$ ; 5$: MOV DIRBUF+D.LINK,R1 ;end of segment. link to next segment BEQ 6$ ;branch if none ASL R1 ADD #DIROFS-2,R1 MOV R1,DIRBLK BR 1$ ; 6$: CLR (R2)+ ;mark end of list .PURGE #0 ;leave nothing lying about MOV (SP)+,R2 ;restore environment MOV (SP)+,R1 JSR PC,SORT ;sort list MOV QUECNT,R0 ;return r0 = queue count RTS PC ; ; SORT (que) sort spool queue by date and time ; R1 = region pointer ; SORT: MOV R1,-(SP) ;make some yummy MOV R2,-(SP) MOV R3,-(SP) MOV R4,-(SP) 1$: TST @R1 ;is this end of list BEQ 7$ ;branch if yes MOV R1,R2 ;no. simple exchange sort 2$: TST @R2 ;is this end of list BEQ 6$ ;branch if yes CMP SQ.DAT(R1),SQ.DAT(R2) ;no. compare entries BLO 5$ BHI 3$ CMP SQ.TIM(R1),SQ.TIM(R2) BLO 5$ BHI 3$ CMP SQ.TIM+2(R1),SQ.TIM+2(R2) BLOS 5$ 3$: MOV R1,R0 ;exchange entries MOV R2,R3 MOV #SQ.LEN/2,R4 4$: MOV @R0,-(SP) MOV @R3,(R0)+ MOV (SP)+,(R3)+ SOB R4,4$ 5$: ADD #SQ.LEN,R2 ;advance to next entry BR 2$ ; 6$: ADD #SQ.LEN,R1 ;advance to next entry BR 1$ ; 7$: MOV (SP)+,R4 MOV (SP)+,R3 MOV (SP)+,R2 MOV (SP)+,R1 RTS PC ; ; Data segment ; .PSECT $ERAS,RW,I ;read/write data ; ; Variables ; ARGBLK: .BLKW 5 ;rt-11 argument block FILKEY: .BLKW 4 ;queue device FILEXT: .BLKW 1 ;queue file extension QUEBLK: .BLKW 1 ;queue block number DIRBLK: .BLKW 1 ;directory block number QUECNT: .BLKW 1 ;count of queue elements DIRBUF: .BLKW 2*256. ;directory segment buffer ; .END