.TITLE PRTQ Spooler daemon .NLIST BEX .ENABL LC ; ; Spooler daemon ; ; This program searches for control files produced by the PRINT spooler ; program, the SPQSRV network spool server program or the autospool facility. ; Spool queue entries are extracted from the control files, which are placed ; on the SY: device. The queue entries point to data files which are sent to ; the specified output device or remote host. Finally, the control file and ; data file (if specified) are deleted. Note the DK: device is assigned ; according to the LOGIN sequence for the user specified in the control file. ; ; External symbols ; .GLOBL FNDQUE ;build spool queue .GLOBL CONECT ;user routine .GLOBL GTHOST ;get local host .GLOBL PRTSEQ,PRTVCG,PRTFAX,PRTNET ;spoolers ; ; Entry symbols ; .GLOBL RDBYT,PRBYT ;char i/o routines .GLOBL QUELST,FILBUF,FILBLK,HOST,PRTPTR,DEVBLK ;sharp pointers .GLOBL PRIDNT ;display ident ; ; System definitions ; .ASECT .MCALL .MSG,.COM,.CHR,.TRDEF,.TRAP,.PRT,.LGD ;dcnlib macroni .MCALL .DSTAT,.ENTER,.LOOKU,.FPROT,.DELET,.CLOSE,.PURGE ;rt-11 macros .MCALL .EXIT,.TTYIN,.TTYOU,.QSET .MCALL CALL,FORMAT ;netlib macros .COM ;define common data .CHR ;define ascii character codes .TRDEF ;define trap codes .PRT ;define queue file entry format .LGD ;define login file entry ; ; Module definitions ; ; Assembly parameters ; MAXSIZ = 4 ;max blocks input buffer QUESIZ = 20. ;max elements on completion queue SPQSIZ = 20. ;max elements on special queue TP.TT = 4 ;terminal/line printer device TP.FX = 117 ;facsimile device TP.VG = 31 ;bitmap device ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; Output daemon ; START: BIS #40000,@#44 ;disable folding .QSET #QUEUE,#QUESIZ ;allocate space for completion queue CLR PRTPTR ;switch to log .MSG <#^RLOG> CLR FLAGS MOV #DEVEXT,R0 ;build queue list MOV #QUELST,R1 JSR PC,FNDQUE TST QUELST ;is queue empty BNE PRT1 ;branch if no FORMAT #COM20 ;no output files queued JMP EXIT ; PRT1: CALL GTHOST,#HOST,#0,#0 ;get local host string CMP #<^RDK >,QUELST+SQ.FIL ;is file on DK: BNE 1$ ;branch if no CALL CONECT,#QUELST+SQ.USR,#0,0 ;yes. connect to user directory TST R0 BEQ 1$ ;branch if no error FORMAT #COM60,#QUELST ;unknown userid JMP DONE4 ; 1$: CLR FILBLK ;is this autospool file TST QUELST+SQ.QUE BNE 2$ ;branch if no INC FILBLK ;yes. start read at block one DEC QUELST+SQ.SIZ BR 3$ ; 2$: .FPROT #ARGBLK,#0,#QUELST+SQ.QUE,#1 ;protect control file BCS 4$ ;branch if error 3$: .FPROT #ARGBLK,#0,#QUELST+SQ.FIL,#1 ;protect data file BCS 4$ ;branch if error .LOOKU #ARGBLK,#3,#QUELST+SQ.FIL ;open data file BCC 5$ ;branch if ok 4$: FORMAT #COM14,#QUELST ;data file not found BR DONE1 ; 5$: TST QUELST+SQ.DST ;is destination local BNE TCP10 ;branch if no TST QUELST+SQ.DST+2 BEQ PRT10 ;branch if yes ; ; Output to remote host ; TCP10: FORMAT #COM10A,#QUELST ;transfer begins .MSG <#^RLOG> ;flush buffer JSR PC,PRTNET ;network spooler BCC DONE ;branch if ok .PURGE #3 ;problem. come back another time .FPROT #ARGBLK,#0,#QUELST+SQ.FIL,#0 ;unprotect data file TST QUELST+SQ.QUE ;is this autospool file BEQ 1$ ;branch if yes .FPROT #ARGBLK,#0,#QUELST+SQ.QUE,#0 ;no. unprotect control file 1$: JMP DONE6 ; ; Output to sequential device ; PRT10: .DSTAT #DEVBLK,#QUELST+SQ.DEV ;is this sequential device BCS 1$ ;branch if no TST DEVBLK BMI 1$ ;branch if no .ENTER #ARGBLK,#0,#QUELST+SQ.DEV ;yes. open output filespec BCC 2$ ;branch if ok 1$: FORMAT #COM12,#QUELST ;invalid output device BR DONE1 ; 2$: FORMAT #COM10,#QUELST ;transfer begins .MSG <#^RLOG> ;flush buffer CMPB DEVBLK,#TP.VG ;is this vcg BNE 3$ ;branch if no JSR PC,PRTVCG ;yes. light display BR 5$ ; 3$: CMPB DEVBLK,#TP.FX ;is this fax BNE 4$ ;branch if no JSR PC,PRTFAX ;yes. stroke fax BR 5$ ; 4$: JSR PC,PRTSEQ ;tickle printer 5$: .CLOSE #0 ;keep what there is BR DONE ; ; Transfer complete ; DONE: FORMAT #COM13,#QUELST ;transfer complete CALL CONECT,#QUELST+SQ.USR,#0,#AF.PRT ;tattle tickletoe DONE1: .PURGE #3 ;clean house .FPROT #ARGBLK,#0,#QUELST+SQ.FIL,#0 ;unprotect data file TST QUELST+SQ.QUE ;is this autospool file BEQ 1$ ;branch if yes BIT #SX.DEL,QUELST+SQ.FLG ;no. is delete specified BEQ DONE4 ;branch if no 1$: .DELET #ARGBLK,#0,#QUELST+SQ.FIL ;yes. delete data file DONE4: TST QUELST+SQ.QUE ;is this autospool file BEQ 1$ ;branch if yes .FPROT #ARGBLK,#0,#QUELST+SQ.QUE,#0 ;no. unprotect control file .DELET #ARGBLK,#0,#QUELST+SQ.QUE ;delete control file 1$: TST QUELST+SQ.LEN ;is there another file BEQ EXIT ;branch if no DONE6: BIS #1,FLAGS EXIT: BIS #2,FLAGS ;acknowledge .MSG <#^RLOG> ;flush buffer .TRAP #TR.SMP,#<^RPRT>,FLAGS ;spool service request .EXIT ; ; Subroutine to read byte ; R0 = byte ; RDBYT: .TTYIN ;fetch byte CMPB R0,#LF ;set cc RTS PC ; ; Subroutine to write byte ; R0 = byte ; PRBYT: TST PRTPTR ;is output to log BEQ 1$ ;branch if yes MOVB R0,@PRTPTR ;no. stash where told BEQ 2$ INC PRTPTR 2$: RTS PC ; 1$: .TTYOU ;put byte RTS PC ; ; Subroutine to display program ident ; PRIDNT: MOV R0,-(SP) ;appear transparent MOV #COM00,R0 ;display program ident JSR PC,FORMAT MOV (SP)+,R0 RTS PC ; ; Data segment ; .PSECT $BOSD,RO,D ;read-only data ; DEVEXT: .RAD50 'SY SPQ' ;control file name prototype COM00: .ASCIZ '?PRTQ-^+' COM20: .ASCIZ '?PRTQ-I-No output files queued' COM60: .ASCIZ '?PRTQ-F-Unknown userid ^A' COM14: .ASCIZ '?PRTQ-F-Data file not found ^F' COM12: .ASCIZ '?PRTQ-F-Invalid output device ^F' COM10: .ASCII '?PRTQ-I-Transfer begins ^A' .ASCIZ ' ^F''[^I''] to ^F' COM10A: .ASCII '?PRTQ-I-Transfer begins ^A' .ASCIZ ' ^F''[^I''] to ^C' COM13: .ASCIZ '?PRTQ-I-Transfer complete' .EVEN ; .PSECT $ERAS,RW,I ;read/write data ; ARGBLK: .BLKW 5 ;rt-11 argument block DEVBLK: .BLKW 4 ;device status block FLAGS: .BLKW 1 ;things that wave FILBLK: .BLKW 1 ;input file block PRTPTR: .BLKW 1 ;format output pointer/switch HOST: .BLKB 64. ;source host name .EVEN QUELST: .BLKW SPQSIZ*SQ.LEN/2+1 ;spool queue QUEUE: .BLKW QUESIZ.*7. ;completion queue FILBUF: .BLKW MAXSIZ*256. ;input buffer ; .END START