.TITLE BAPEOJ .IDENT /V3.03/ .ENABL LC .NLIST BEX ;************************************************************************** ; ; BAPEOJ.MAC ; ; This routine performs all End-of-Job processing. ; ; ;-------------------------------------------------------------------------- ; ; Version: V3.03 April 1983 ; ; Modification History ; ==================== ; ; SMT301 31-MAY-83 Steve Thompson ; Set correct file ownership when job ends. ; ; SMT305 27-JUL-83 Steve Thompson ; Make sure console messages appear even if ; /NOCOTERM has been specified. ; ; SMT308 25-SEP-83 Steve Thompson ; Clear U.BPRI UCB field before logging off the ; job, so that all tasks run by the logout ; command file execute at their installed ; priorities. ; ;-------------------------------------------------------------------------- ; ; Steve Thompson ; School of Chemical Engineering ; Olin Hall ; Cornell University ; Ithaca ; NY 14850 ; (607) 256 4616 (office) ; (607) 256 3895 (computer room) ; ;************************************************************************** .MCALL GET$, PRINT$, ENAR$S, DSAR$S .MCALL DIR$ .MCALL CLOSE$ ; ; Text messages. ; COEOJ: .ASCII /End of Job / COEOJJ: .ASCII /JOBJOBJOB/ COEOJS=.-COEOJ .BYTE 0 .IF DF,B3$ACC RESOUR: .ASCIZ /Resources Used by this Job:/ ; **Should go in BYE really** .ENDC ; DF,B3$ACC ; ; MCR commands. ; BYE: .ASCIZ /BYE/ ; For logging off the job PRI: .ASCII "PRI " ; For printing logfiles PRIQ: .ASCII / / ; Print queue name .ASCII ":/-FL=" ; No flag page PRIF: .ASCIZ "DDNN:[GGG,MMM]FILENAME.TYPE;VERSION/DE" .EVEN .PAGE .SBTTL MAIN LINE CODE ;+ ; **-$EOJEP-End of Job Processor ; ; This routine is called to perform end of job processing ; either when a job has normally terminated, or when an ; error occurred during job startup. ; ;- $EOJEP::TSTB LOGOPN ; Any logfile? BEQ 1$ ; If EQ no DIR$ #SAVOFF ; Yes, terminate flushing cycle 1$: ; Ref. label .IF DF,B3$TIM DIR$ #TIMOFF ; Cancel the job timer if on .ENDC ; DF,B3$TIM .IF DF,B3$PAG CLRB PAGFLG ; Switch off output limiting .ENDC ; DF,B3$PAG ; ; Construct "end of job" message. ; MOV #COEOJJ,R0 ; Get place for jobname MOV #JOBNAM,R1 ; Get jobname string address MOV #9.,R2 ; and its length 10$: MOVB (R1)+,(R0)+ ; Copy a byte DEC R2 ; Done yet? BGT 10$ ; If GT no, loop ; ; Don't try to log off a job that didn't start. ; TSTB ERRFLG ; Job Initialization failure? BNE 20$ ; If NE yes ; ; Write EOJ messages to history file. ; TSTB LOGOPN ; Any logfile? BEQ 18$ ; If EQ no DSAR$S ; Disable AST recognition MOV #^RSYS,ORIGIN ; Set SYS origin code MOV #COEOJ,R1 ; Send EOJ message... CALL WRHIST ; ...to history file .IF DF,B3$ACC MOV #RESOUR,R1 ; Send "resources used" message... CALL WRHIST ; ...to history file .ENDC ; DF,B3$ACC CLRB CPUFLG ; Now switch off CPU time messages ; ; Now log off the job. The use of BYE makes sure that we abort anything ; that somehow slipped by. ; ENAR$S ; Make sure we get BYE output 18$: CLRB U.BPRI(R0) ; Make tasks run at installed prio. MOV #BYE,R0 ; Get BYE command address CALL GIVMCR ; Log off the job. 20$: DIR$ #VTKILL ; Kill read to driver MOV VTUCB,R0 ; Get stream UCB address CLR U.BTCB(R0) ; Make driver think we've gone away DSAR$S ; ; ; Copy history file to end of logfile. ; TSTB HSTOPN ; Any history file? BEQ 60$ ; If EQ no TSTB LOGOPN ; Any logfile? BEQ 60$ ; If EQ no MOV #HSTFDB,R0 ; Get history file FDB address CLR R1 ; Set registers for rewind MOV #1,R2 ; CLR R3 ; CALL .POINT ; Rewind history file MOVB #'1,LOGBUF+1 ; Force a new page 30$: GET$ #HSTFDB,#,# ; Read line from history file BCS 40$ ; If CS, assume end of file MOV F.NRBD(R0),R1 ; Get size of record ADD #2,R1 ; Allow for carr. control & dest. byte MOV R1,VTSTAT+2 ; Fake it as from the driver CALL WRLOGF ; Write to logfile MOVB #SPA,LOGBUF+1 ; Reset carriage control BR 30$ ; Loop for more 40$: ; Ref. label ; ; Delete the History File, and print the logfile. ; MOV #HSTFDB,R0 ; Get history file FDB address CALL .DLFNB ; Delete the history file CLRB HSTOPN ; Show no history file open CALL DSPLOG ; Dispose of the logfile CLRB LOGOPN ; Show no logfile open ; ; Write EOJ message to console terminal. ; 60$: MOV #COEOJ,COWRIT+Q.IOPL ; Set up DPB MOV #COEOJS,COWRIT+Q.IOPL+2 ; DIR$ #COWRIT ; ; ; Send the message to the user if logged on. ; .IF DF,B3$MSG MOV #COEOJ,R0 ; Set message address MOV #COEOJS,R1 ; Set message size CALL MESSAG ; Do it .ENDC ; DF,B3$MSG ; ; Perform cleanup operations. ; ENAR$S ; Enable AST recognition CLRB JOBFLG ; Show job over CALL QMGEOJ ; Send end-of-job to QMG... RETURN ; That's it .PAGE .SBTTL LOGFILE DISPOSITION ROUTINE ;+ ; **-DSPLOG-Logfile disposition routine. ; ; This routine is called to construct an MCR PRINT command and ; to dispatch it for execution to cause the logfile to be ; printed on the print queue specified by the user. Since the ; batch stream is now logged off, we must fake a logon so that ; MCR will not reject the command. Also, any errors (such as ; a non-existant print queue) will give no messages, and the ; logfile will not appear (although it will remain on disk). ; If the /NOPRINTER qualifier was used, the logfile is closed ; but not printed. ; ; Inputs: ; Logfile is still open. ; ;- DSPLOG: BITB #QJ$SPL,SOJBUF+Q$JATT ; Print logfile? BEQ 10$ ; If EQ no MOV #PRIQ,R0 ; Get place to stick print queue MOV SOJBUF+Q$PRIN,R1 ; Get 1st word of print queue name CALL $C5TA ; Stick it in MOV SOJBUF+Q$PRIN+2,R1 ; Repeat for second word CALL $C5TA ; MOV #PRIF,R0 ; Get place to stick filespec MOV #LOGFDB,R1 ; Get FDB address MOV BINUFD,R3 ; Get UFD where file sits CALL EXPFNM ; Fill in filename MOVB #'/,(R0)+ ; Add "/DE" MOVB #'D,(R0)+ ; MOVB #'E,(R0)+ ; MOVB #ESC,(R0)+ ; Finish with an escape CLRB (R0) ; Make it ASCIZ ; ; Close the logfile. ; 10$: MOV JOBUIC,R1 ; Get owner UIC ;*SMT301* CALL .WFOWN ; ;*SMT301* CLOSE$ #LOGFDB ; Close logfile BITB #QJ$SPL,SOJBUF+Q$JATT ; Attempt to print? BEQ 20$ ; If EQ no ; ; Fake a logon for the purposes of PRINT. ; MOV VTUCB,R0 ; Get batch stream UCB address MOV JOBUIC,U.LUIC(R0) ; Set logon UIC MOV JOBUIC,U.UIC(R0) ; Set default UIC BIC #U2.LOG,U.CW2(R0) ; Log it on ; ; Issue the PRINT command (the output indicating the jobname, number, etc ; will be lost) ; MOV #PRI,R0 ; Get ASCIZ command address CALL GIVMCR ; Pass to MCR and wait ; ; Now cancel the fake logoff. ; MOV VTUCB,R0 ; Get batch stream UCB address CLR U.LUIC(R0) ; Zero logon UIC word CLR U.UIC(R0) ; Zero default UIC word BIS #U2.LOG,U.CW2(R0) ; Log it off 20$: RETURN ; That's it .END