.TITLE VTLFCS - Various FCS Routines. .IDENT /1.2/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: VTLFCS.MAC ; Author: Robin Miller ; Date: July 21, 1983 ; ; Description: ; ; This module contains routines which do FCS functions. ; ; Modification History: ; ; June 5, 1984 by Robin Miller. Edit (01), Version 1.2 ; Call native mode spawn routine to print a file on VMS. The ; normal .PRINT directive doesn't work with RA81/RA60 disks. ; ;- .ENABL AMA .NLIST BEX .MCALL DIR$, QIOW$ .MCALL CLOSE$, FCSBT$, NBOFF$ FCSBT$ DEF$L ; Define the FCS bits locally. NBOFF$ DEF$L ; Define the FNB offsets locally. ; Local messages: DELMSG: .ASCIZ "Really DELETE this file ? " PRIM1: .ASCIZ "File " PRIM2: .ASCIZ " submitted to queue " PRIRSX: .ASCIZ "LP0:" PRIVMS: .ASCIZ "SYS$PRINT:" .EVEN ; ACP function codes to read the file attributes: WPRBLK: .BYTE 2,2 ; Write the file protection. .WORD ALLPRO ; Address of protection mask. .WORD 0 ; End of ACP QIO list. ALLPRO: .WORD 0 ; Give RWED access to everyone. ; Directive parameter block to write the file protection. WPROT: QIOW$ IO.WAT,,,,DSKSB,,<,WPRBLK,,,,> .SBTTL DELCMD - Delete the current file. ;+ ; ; DELCMD - Delete the current file. ; ; This routine is called to delete the current file being displayed. ; The .DLFNB routine automatically closes the input file before trying ; to delete the file. The contents of N.STAT and N.NEXT in the FNB ; must be saved and cleared before calling .DLFNB. Failure to do so ; results in the next file being deleted (if wildcards are active) ; instead of the current file (ouch !!!). After the call to .DLFNB ; whether successful or not, N.STAT and N.NEXT must be restored so we ; can continue displaying the next file (if any). ; ; On VAX/VMS, we must also adjust N.NEXT (next directory record). This ; must be done because VMS automatically sorts the directory after a ; file is deleted. Thus, we must adjust the directory record by one ; or else the file which should be displayed next is skipped. ; ; Although the next directory record adjustment is not necessary for ; RSX-11M, it doesn't bother the wildcard lookup since the directory ; record is marked as empty. ; ; Implicit inputs: ; IENTRY = The active file entry address. ; ; Outputs: ; All registers are preserved except R3 - R5. ; ;- DELCMD::JSR R5,$SAVRG ; Save R3 - R5. MOV IENTRY,R5 ; Set the file entry address. MOV #DELMSG,R1 ; Set the prompt string address. CALL WRTPRL ; Write the prompt to the terminal. MOV #FMTBUF,R0 ; Set address of the input buffer. MOV #CMDSIZ,R1 ; Set the maximum input byte count. CALL GETCMD ; Get the response from the user. BCS 90$ ; If CS, error or time to exit. CMPB (R0),#'Y ; Does user really want to delete ? BNE 90$ ; If NE, no (decided not to after all). ; The user wants to delete the current file. CALL MRKSAV ; Save the current record position. MOV O.FDB(R5),R0 ; Copy the FDB address. ; Save and clear N.STAT and N.NEXT for the delete. MOV O.FNB(R5),R1 ; Copy the FNB address. MOV N.FID(R1),O.FID(R5) ; Save the first word of the FID. CALL CHAPRO ; Change the file protection. MOV N.STAT(R1),-(SP) ; Save N.STAT and MOV N.NEXT(R1),-(SP) ; N.NEXT on the stack. CLR N.STAT(R1) ; Now clear CLR N.NEXT(R1) ; both of them. CALL .DLFNB ; Now, try to delete the file. MOV (SP)+,N.NEXT(R1) ; Restore N.NEXT MOV (SP)+,N.STAT(R1) ; and N.STAT. BCS 10$ ; If CS, we had an error. ; For VAX/VMS, we must adjust the N.NEXT record number. BIS #B.NEXT,STATUS ; Show we should go to next file. TST N.NEXT(R1) ; Are we doing wildcard .FINDs ? BEQ 100$ ; If EQ, no (don't need to adjust). DEC N.NEXT(R1) ; Else, adjust so next file is found. BR 100$ ; And use common return ... ; We had an error trying to delete the file. 10$: CALL FCSERR ; Report the FCS error message. CALL REOPEN ; Reopen and reposition the file. 90$: BIS #B.DOPR,STATUS ; Show we should prompt again. 100$: RETURN .SBTTL PRICMD - Print the current file. ;+ ; ; PRICMD - Print the current file. ; ; This routine is called to print the current file being displayed. The ; file is automatically closed before being spooled to the line printer. ; After to file is spooled, the file is reopened so the user can decide ; whether to go on to the next file or not. ; ; Implicit inputs: ; IENTRY = The active file entry address. ; ; Outputs: ; All registers are preserved except R0 - R2. ; ;- PRICMD::JSR R5,$SAVRG ; Save R3 - R5. MOV IENTRY,R5 ; Set the file entry address. .IFNDF RSX11M MOV #FMTBUF,R0 ; Set the output buffer address.(01) CALL SETMSG ; Set to write to message line. (01) CALL VTYPE ; Set position/reverse video. (01) CALL VMSPRI ; Check for VMS print command. (01) BCC 110$ ; If CC, spawn was successful. (01) .ENDC ; RSX11M CALL MRKSAV ; Save the current record position. MOV O.FDB(R5),R0 ; Copy the FDB address. MOV O.FNB(R5),R1 ; Copy the FNB address. MOV N.FID(R1),O.FID(R5) ; Save the first word of the FID. CALL .PRINT ; Send the file to the line printer. BCC 10$ ; If CC, success. CALL FCSERR ; Else, report the error message. BR 100$ ; And use common code ... ; Tell the user the file has been submitted. 10$: MOV #FMTBUF,R0 ; Set the output buffer address. CALL SETMSG ; Setup to write to the message line. MOV #PRIM1,R1 ; Set address of "File " message. CALL MOVEC ; Append it to the output buffer. CALL BOLD ; Turn on the bold video attribute. MOV O.FNAM(R5),R1 ; Copy the address of the file name. CALL MOVEC ; Append it to the output buffer. CALL ATTOFF ; Turn off all video attributes. CALL REVERSE ; Now turn reverse video back on. MOV #PRIM2,R1 ; Set address of "submitted to" msg. CALL MOVEC ; Append it to the output buffer. MOV #PRIRSX,R1 ; Presume we're on RSX-11M. TST VAXFLG ; Are we running on VAX/VMS ? BEQ 20$ ; If EQ, no (running on RSX-11M). MOV #PRIVMS,R1 ; Set address of "SYS$PRINT" message. 20$: CALL MOVEC ; Append it to the output buffer. CALL TYPMSG ; Now write it to the terminal. 100$: CALL REOPEN ; Reopen and reposition the file. 110$: RETURN .SBTTL REOPEN - Reopen a file by FID. ;+ ; ; REOPEN - Reopen a file by file ID. ; ; This routine is used to reopen a file by FID. Since the open routine ; clears the first word of the FID in the FNB, it is restored from the ; file entry table before reopening the file. If the file is reopened, ; it is also repositioned to where it was before it was closed. ; ; Inputs: ; R5 = The file entry address: ; O.FID = The 1st word of the FID. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- REOPEN: CALL $SAVAL ; Save all registers. MOV O.FDB(R5),R0 ; Copy the FDB address. MOV O.FNB(R5),R1 ; Copy the FNB address. MOV O.FID(R5),N.FID(R1) ; Restore the FID to reopen file. CALL .OPFID ; Reopen the file by file ID. BCC 10$ ; If CC, the file is open. CALL FCSERR ; Else, report the FCS error. BR 20$ ; And use common return ... 10$: CALL PNTSAV ; Restore the previous record position. CLC ; Show file was successfully reopened. 20$: RETURN .SBTTL NXDCMD - Next directory command. ;+ ; ; NXDCMD - Next directory command. ; ; This routine set the next directory bit in the status word of the file ; name block. This forces us to the next directory when doing wildcard ; directory lookup. ; ; Inputs: ; None. ; ; Outputs: ; All registers except R0-R2 are preserved. ; ;- NXDCMD::MOV IENTRY,R2 ; Copy the file entry address. MOV O.FNB(R2),R1 ; Copy the FNB address. BIS #NB.NXD,N.STAT(R1) ; Set the next directory bit. RETURN .SBTTL CHAPRO - Change the file protection. ;+ ; ; CHAPRO - Write the file protection. ; ; This routine is used to change the file protection to RWED for system, ; owner, group, and world so the file can be deleted. The file which ; is open for read must be closed before the new file attributes can ; be written. ; ; Inputs: ; R5 = The file entry address. ; ; Implicit inputs: ; Protection changed if B.PROT in SWMASK is cleared. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- CHAPRO: CALL $SAVAL ; Save all registers. BIT #B.PROT,SWMASK ; Allowed to change protection ? BNE 100$ ; If NE, no (leave it alone). ; Setup the LUN, EFN, and FNB for the QIO. MOV #WPROT,R2 ; Set the QIO DPB address. MOV O.FDB(R5),R0 ; Copy the FDB address. CLOSE$ ; Close the file first. MOV O.FNB(R5),R1 ; Copy the FNB address. MOV O.FID(R5),N.FID(R1) ; Restore the file ID. MOVB F.LUN(R0),Q.IOLU(R2) ; Setup the logical unit number. MOVB F.EFN(R0),Q.IOEF(R2) ; Setup the event flag number. MOV O.FNB(R5),Q.IOPL(R2) ; Setup the FNB address. ; Issue the QIO to read the file header information. DIR$ #WPROT ; Write the file protection. ;*** MOV DSKSB,TIOSB ; Copy the disk I/O status code. ;*** CALL CHKERR ; And go check for errors. 100$: RETURN .END