.TITLE VTLHDR - Display File Header .IDENT /1.0/ .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: VTLHDR.MAC ; Author: Robin Miller ; Date: August 3, 1983 ; ; Description: ; ; This module contains the routines to display the file header. ; ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL DIR$, QIOW$ .MCALL FCSBT$, FDOFF$, FHDOF$, NBOFF$ FCSBT$ ; Define the FCS bits. FDOFF$ DEF$L ; Define the FDB offsets. FHDOF$ DEF$L ; Define the file header offsets. NBOFF$ DEF$L ; Define the FNB offsets. ; ACP function codes to read the file attributes: RFHBLK: .BYTE -1,5 ; Read UIC/protection/characteristics. .WORD HDRBUF+V.UIC ; Address where to store them. .BYTE -4,40 ; Read the record I/O area. .WORD HDRBUF+V.UFAT ; Address where to store them. .BYTE -15,43 ; Read the dates and times .WORD HDRBUF+V.REVN ; and store them here. .WORD 0 ; End of ACP QIO list. ; Directive parameter block to read the file attributes. RFHDR: QIOW$ IO.RAT,,,,DSKSB,,<,RFHBLK,,,,> DSKSB:: .BLKW 2 ; Disk I/O status block. ; Define the header record offsets: ; Size Description: V.UIC == 0 ; ( 2) The binary file owner UIC. V.PROT == V.UIC+2 ; ( 2) The binary protection code. V.FCHA == V.PROT+2 ; ( 2) The file characteristics. V.UCHA == V.FCHA ; ( 1) The user file characteristics. V.SCHA == V.UCHA+1 ; ( 1) The system file characteristics. V.UFAT == V.FCHA+2 ; (32) The user file attributes. ; FCS uses the 1st 14 bytes. V.RTYP == V.UFAT ; ( 1) The record type. V.FORG == V.RTYP ; RMS format and organization. V.RATT == V.RTYP+1 ; ( 1) The record attributes. ; Same offset for RMS. V.RSIZ == V.RATT+1 ; ( 2) The maximum record size. ; Same offset for RMS. V.HIBK == V.RSIZ+2 ; ( 4) The highest block number. V.HVBN == V.HIBK ; RMS high virtual block number. V.EFBK == V.HIBK+4 ; ( 4) The end of file block number. V.HEOF == V.EFBK ; RMS end of file block number. V.FFBY == V.EFBK+4 ; ( 2) The 1st free byte in last block. ; Same offset for RMS. ; Start of RMS specific offsets: V.BKSZ == V.FFBY+2 ; ( 1) Bucket size (relative/indexed). V.HDSZ == V.BKSZ+1 ; ( 1) The fixed header size. V.MRS == V.HDSZ+1 ; ( 2) The maximum record size limit. V.DEQ == V.MRS+2 ; ( 2) The default extend quantity. V.REVN == V.UFAT+32. ; ( 2) The revision number (binary). V.RDAT == V.REVN+2 ; ( 7) The revision date (ddmmmyy). V.RTIM == V.RDAT+7 ; ( 6) The revision time (hhmmss). V.CDAT == V.RTIM+6 ; ( 7) The creation date (ddmmmyy). V.CTIM == V.CDAT+7 ; ( 6) The creation time (hhmmss). V.EDAT == V.CTIM+6 ; ( 7) The expiration date (ddmmmyy). HDRSIZ = V.EDAT+7 ; Size of the header buffer. HDRBUF::.BLKB HDRSIZ ; Buffer for file header information. .EVEN ; Messages: MHDRM: .ASCIZ "FILE HEADER" FILEM: .ASCIZ "File name: " FIDM: .ASCIZ "File ID: (" OWNERM: .ASCIZ "Owner UIC: " PROTM: .ASCIZ "Protection: " SYSM: .ASCIZ " System: " OWNM: .ASCIZ ", Owner: " GRPM: .ASCIZ ", Group: " WRLDM: .ASCIZ ", World: " CDATM: .ASCIZ "Creation Date: " RDATM: .ASCIZ "Revision Date: " EDATM: .ASCIZ "Expiration Date: " REVNM: .ASCIZ ", Number: " NDATM: .ASCIZ "none specified" COPTM: .ASCIZ "Contiguity Options: " CNONM: .ASCIZ "none" CONTM: .ASCIZ "contiguous" CBTRYM: .ASCIZ "contiguous-best-try" FHDRM: .ASCIZ "FCS/RMS FILE ATTRIBUTES:" FORGM: .ASCIZ "File Organization: " RFORM: .ASCIZ "Record Format: " RATTM: .ASCIZ "Record Attributes: " MRSM: .ASCIZ "Maximum Record Size: " RSIZM: .ASCIZ "Longest Record: " BKSZM: .ASCIZ "Bucket size: " HDSZM: .ASCIZ "Fixed Control Size: " HIBKM: .ASCIZ "Blocks Allocated: " DEQM: .ASCIZ ", Default Extend Size: " EFBKM: .ASCIZ "End-of-file VBN: " FFBYM: .ASCIZ ", Offset: " .EVEN ; More messages: ; File organizations: ORGTBL: .WORD SEQM ; (0) Sequential. .WORD RELM ; (1) Relative. .WORD IDXM ; (2) Indexed. .WORD HSHM ; (3) Hashed. MAXORG = <<.-ORGTBL>/2> ; Maximum file organization. SEQM: .ASCIZ "sequential" RELM: .ASCIZ "relative" IDXM: .ASCIZ "indexed" HSHM: .ASCIZ "hashed" .EVEN ; Record format table: RTYPE: .WORD UNDM ; (0) Undefined record format. .WORD FIXM ; (1) Fixed length records. .WORD VARM ; (2) Variable length record. .WORD VFCM ; (3) Variable with fixed control. .WORD STMM ; (4) ASCII Stream records. MAXTYP = <<.-RTYPE>/2> ; Maximum record type. UNDM: .ASCIZ "undefined" FIXM: .ASCIZ "fixed" VARM: .ASCIZ "variable" VFCM: .ASCIZ "variable-with-fixed-control" STMM: .ASCIZ "stream" .EVEN ; Record attributes messages. RATBL: .WORD NOM ; (0) No record attributes. .WORD FTNM ; (1) Fortran carriage control. .WORD CRM ; (2) Implied carriage control. .WORD UNKM ; (3) Unknown record attributes. .WORD PRNM ; (4) Print carriage control. MAXRAT = <<.-RATBL>/2> ; Maximum record attribute. NOM: .ASCIZ "none" UNKM: .ASCIZ "unknown" FTNM: .ASCIZ "fortran" CRM: .ASCIZ "carriage-return" PRNM: .ASCIZ "print" BLKM: .ASCIZ "no-span" .EVEN .SBTTL SHOHDR - Show the file header. ;+ ; ; SHOHDR - Read, format and display the file header. ; ; Inputs: ; None. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- SHOHDR::CALL $SAVAL ; Save all registers. MOV IENTRY,R5 ; Copy the file entry address. CALL RDHDR ; Read file header information. BCC 10$ ; If CC, success (continue ...) RETURN 10$: BIC #B.DOPR,STATUS ; Disable reprompting the user. MOV #HDRBUF,R2 ; Set the header buffer address. ; FILE HEADER: MOV #FMTBUF,R0 ; The output buffer address. CALL NARROW ; Set the screen narrow. MOV #MHDRM,R1 ; Address of the header message. CALL MOVEC ; Copy it. CALL CPYBLA ; Append blank line to buffer. CALL VTYPE ; Write it to the terminal. ; Format and write the original file name. MOV #FILEM,R1 ; Address of the file name message. CALL MOVEC ; Copy it. MOV O.FNAM(R5),R1 ; Copy the file name buffer address. CALL MOVEC ; And copy it. CALL VTYPE ; Write it to the terminal. ; Format and write the file identication (FID). MOV #FIDM,R1 ; Address of the file ID message. CALL MOVEC ; Copy it. CALL DOFID ; Do the file ID. MOVB #'),(R0)+ ; Finish the FID formatting. CALL VTYPE ; Write it to the terminal. ; Format and write the file owner UIC. MOV #OWNERM,R1 ; Address of the owner message. CALL MOVEC ; Copy it. MOV R2,-(SP) ; Save R2. MOV V.UIC(R2),R3 ; Copy the binary owner UIC. MOV R0,R2 ; Copy the output buffer address. MOV #1,R4 ; Setup the control code. CALL .PPASC ; Convert the UIC to [ggg,mmm]. MOV R2,R0 ; Copy the output buffer address. MOV (SP)+,R2 ; Restore R2. CALL VTYPE ; Write it to the terminal. ; Format and write the protection. MOV #PROTM,R1 ; Address of the protection message. CALL MOVEC ; Copy it. CALL ADDPRO ; Add the protection fields. CALL VTYPE ; Write it to the terminal. ; Format and write the creation date and time. MOV #CDATM,R1 ; Address of creation date message. CALL MOVEC ; Copy it. CALL DOCDAT ; Do the creation date. CALL VTYPE ; Write it to the terminal. ; Format and write the revision date, time, and revision number. MOV #RDATM,R1 ; Address of revision date message. CALL MOVEC ; Copy it. CALL DORDAT ; Do the revision date. CALL VTYPE ; Write it to the terminal. ; Format and write the expiration date. MOV #EDATM,R1 ; Address of expiration date message. CALL MOVEC ; Copy it. CALL DOEDAT ; Do the expiration date. CALL VTYPE ; Write it to the terminal. ; Format and write the contiguity options. MOV #COPTM,R1 ; Address of the contiguity message. CALL MOVEC ; Copy it. MOV #CNONM,R1 ; Presume no options. BITB #UC.CON,V.UCHA(R2) ; Is the file contiguous ? BEQ 20$ ; If EQ, no MOV #CONTM,R1 ; Address of the contiguous message. BR 30$ ; And continue ... 20$: BITB #UC.CNB,V.UCHA(R2) ; Is this contiguous-best-try ? BEQ 30$ ; If EQ, no MOV #CBTRYM,R1 ; Address of best-try message. 30$: CALL MOVEC ; Copy it. CALL CPYBLA ; Append blank line to buffer. CALL VTYPE ; Write it to the terminal. ; FCS/RMS FILE ATTRIBUTES: MOV #FHDRM,R1 ; Address of the header message. CALL MOVEC ; Copy it. CALL CPYBLA ; Append blank line to buffer. CALL VTYPE ; Write it to the terminal. ; Format and write the file organization (bits 4-7 of V.RTYP). MOV #FORGM,R1 ; Address of file organization message. CALL MOVEC ; Copy it. MOVB V.FORG(R2),R1 ; Copy the file organization byte. ASH #-4,R1 ; Shift into bits 0-4. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDORG ; Add the file organization. CALL VTYPE ; Write it to the terminal. ; Format and write the record format (bits 0-3 of V.RTYP). MOV #RFORM,R1 ; Address of record format message. CALL MOVEC ; Copy it. MOVB V.RTYP(R2),R1 ; Copy the binary file type. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDTYP ; Add the record format message. CALL VTYPE ; Write it to the terminal. ; Format and write the record attributes. MOV #RATTM,R1 ; Address of record attributes message. CALL MOVEC ; Copy it. MOVB V.RATT(R2),R1 ; Copy the binary file attributes. BIC #^C17,R1 ; Clear unwanted bits. CALL ADDRAT ; Add the record attributes message. CALL VTYPE ; Write it to the terminal. ; Format and write the maximum record size. MOV #MRSM,R1 ; Address of maximum size message. CALL MOVEC ; Copy it. MOV V.MRS(R2),R1 ; Copy the maximum record size. CALL CVTDEC ; Convert it to decimal ASCII. CALL VTYPE ; Write it to the terminal. ; Format and write the longest record size. MOV #RSIZM,R1 ; Address of longest size message. CALL MOVEC ; Copy it. MOV V.RSIZ(R2),R1 ; Copy the longest record size. CALL CVTDEC ; Convert it to decimal ASCII. CALL VTYPE ; Write it to the terminal. ; Format and output the bucket size (if there is one). TSTB V.BKSZ(R2) ; Is there a bucket size ? BEQ 40$ ; If EQ, no (skip this then). MOV #BKSZM,R1 ; Address of bucket size message. CALL MOVEC ; Copy it. MOVB V.BKSZ(R2),R1 ; Copy the bucket size. CALL CVTDEC ; Convert it to decimal ASCII. CALL VTYPE ; Write it to the terminal. ; Format and output the fixed control size (if there is one). 40$: TSTB V.HDSZ(R2) ; Is there a fixed control size ? BEQ 50$ ; If EQ, no (skip it then). MOV #HDSZM,R1 ; Address of fixed control message. CALL MOVEC ; Copy it. MOVB V.HDSZ(R2),R1 ; Copy the fixed control size. CALL CVTDEC ; Convert it to decimal ASCII. CALL VTYPE ; Write it to the terminal. ; Format the number of blocks to allocate. 50$: MOV #HIBKM,R1 ; Address of the blocks message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ADD #V.HIBK,R1 ; Point to the high block number. CALL CVTDTD ; Convert double to decimal ASCII. ; Format and write the default extend size. MOV #DEQM,R1 ; Address of default extend message. CALL MOVEC ; Copy it. MOV V.DEQ(R2),R1 ; Copy the default extend size. CALL CVTDEC ; Convert it to decimal ASCII. CALL VTYPE ; Write it to the terminal. ; Format the end-of-file block number. MOV #EFBKM,R1 ; Address of end-of-file message. CALL MOVEC ; Copy it. MOV R2,R1 ; Copy the header record address. ADD #V.EFBK,R1 ; Point to the end-of-file address. CALL CVTDTD ; Convert double to decimal ASCII. ; Format and write the first free byte in the last block. MOV #FFBYM,R1 ; Address of the free message. CALL MOVEC ; Copy it. MOV V.FFBY(R2),R1 ; Copy the first free byte. CALL CVTDEC ; Convert it to decimal ASCII. CALL CPYBLA ; Append blank line to buffer. CALL VTYPE ; Write it to the terminal. CALL PRSPEC ; Prompt user before continuing. JMP REFCMD ; Now, refresh the screen. .SBTTL RDHDR - Read the file header. ;+ ; ; RDHDR - Read the file header information. ; ; Inputs: ; R5 = The file entry address. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- RDHDR:: CALL $SAVAL ; Save all registers. ; Setup the LUN, EFN, and FNB for the QIO. MOV #RFHDR,R2 ; Set the QIO DPB address. MOV O.FDB(R5),R3 ; Copy the FDB address. MOVB F.LUN(R3),Q.IOLU(R2) ; Setup the logical unit number. MOVB F.EFN(R3),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$ #RFHDR ; Read the file header information. MOV DSKSB,TIOSB ; Copy the disk I/O status code. CALL CHKERR ; And go check for errors. RETURN .SBTTL ADDPRO - Add The Protection Message ;+ ; ; ADDPRO - Add the file protection message. ; ; Inputs: ; R0 = the output buffer address. ; R2 = address of the header record. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDPRO: JSR R5,.SAVR1 ; Save R1 - R5 MOV V.PROT(R2),R3 ; Copy the protection code. ; Setup the system protection. MOV #SYSM,R1 ; Address of system message. CALL MOVEC ; Copy it. CALL SETPRO ; Move in the protection. ; Setup the owner protection. MOV #OWNM,R1 ; Address of owner message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. ; Setup the group protection. MOV #GRPM,R1 ; Address of group message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. ; Setup the world protection. MOV #WRLDM,R1 ; Address of world message. CALL MOVEC ; Copy it. ASH #-4,R3 ; Shift bits into place. CALL SETPRO ; Move in the protection. RETURN ; Move in the protection codes: RWED SETPRO: BIT #FP.RDV,R3 ; Allowed read access ? BNE 10$ ; If NE, no. MOVB #'R,(R0)+ ; Yes, show it. 10$: BIT #FP.WRV,R3 ; Allowed write access ? BNE 20$ ; If NE, no. MOVB #'W,(R0)+ ; Yes, show it. 20$: BIT #FP.EXT,R3 ; Allowed execute access ? BNE 30$ ; If NE, no. MOVB #'E,(R0)+ ; Yes, show it. 30$: BIT #FP.DEL,R3 ; Allowed delete access ? BNE 40$ ; If NE, no. MOVB #'D,(R0)+ ; Yes, show it. 40$: RETURN .SBTTL ADDRAT - Add The Record Attributes Message ;+ ; ; ADDRAT - Add the record attributes message. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary record attributes byte. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDRAT: JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXRAT ; Is the attribute too large ? BLO 10$ ; If LO, no (it's in range). MOV R1,R2 ; Copy the record attributes. MOV #BLKM,R1 ; Presume no-span attribute. BITB #FD.BLK,R2 ; Is it no-span attribute ? BNE 20$ ; If NE, yes. MOV #UNKM,R1 ; Nope, tellem "unknown" BR 20$ ; And continue ... 10$: ASL R1 ; Make a word offset. MOV RATBL(R1),R1 ; Get the message address. 20$: CALL MOVEC ; And copy it. RETURN .SBTTL ADDORG - Add The File Organization ;+ ; ; ADDORG - Add the file organization. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary organization value. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDORG: JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXORG ; Is it too large ? BLO 10$ ; If LO, no. MOV #UNDM,R1 ; Tellem "undefined". BR 20$ ; And copy it. 10$: ASL R1 ; Make a word offset. MOV ORGTBL(R1),R1 ; Get the message address. 20$: CALL MOVEC ; And copy it. RETURN .SBTTL ADDTYP - Add The Record Type Message ;+ ; ; ADDTYP - Add the record type message. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary record type. ; ; Outputs: ; R0 = the updated buffer address. ; ; All other registers are preserved. ; ;- ADDTYP: JSR R5,.SAVR1 ; Save R1 - R5 CMP R1,#MAXTYP ; Is the type too large ? BLO 10$ ; If LO, no. CLR R1 ; Yes, force "undefined". 10$: ASL R1 ; Make a word offset. MOV RTYPE(R1),R1 ; Get the message address. CALL MOVEC ; And copy it. RETURN .SBTTL DOCDAT - Do the creation date. ;+ ; ; DOCDAT - Do the creation date. ; ; Inputs: ; R0 = The output buffer address. ; R2 = The header buffer address. ; ; Outputs: ; R0 = The updated buffer address. ; ; All other registers are preserved. ; ;- DOCDAT::JSR R5,.SAVR1 ; Save R1 - R5 MOV R2,R1 ; Copy the header buffer address. ADD #V.CDAT,R1 ; Point to the creation date. CALL MAKDAT ; Format the creation date. MOV R2,R1 ; Copy the header buffer address. ADD #V.CTIM,R1 ; Point to the creation time. CALL MAKTIM ; Format the creation time. RETURN .SBTTL DORDAT - Do the revision date. ;+ ; ; DORDAT - Do the revision date. ; ; Inputs: ; R0 = The output buffer address. ; R2 = The header buffer address. ; ; Outputs: ; R0 = The updated buffer address. ; ; All other registers are preserved. ; ;- DORDAT::JSR R5,.SAVR1 ; Save R1 - R5 MOV R2,R1 ; Copy the header buffer address. ADD #V.RDAT,R1 ; Point to the revision date. CALL MAKDAT ; Format the revision date. MOV R2,R1 ; Copy the header buffer address. ADD #V.RTIM,R1 ; Point to the revision time. CALL MAKTIM ; Format the revision time. MOV #REVNM,R1 ; Address of revision number message. CALL MOVEC ; Copy it. MOV V.REVN(R2),R1 ; Copy the revision number. CALL CVTDEC ; Convert it to decimal ASCII. RETURN .SBTTL DOEDAT - Do the expiration date. ;+ ; ; DOEDAT - Do the expiration date. ; ; Inputs: ; R0 = The output buffer address. ; R2 = The header buffer address. ; ; Outputs: ; R0 = The updated buffer address. ; ; All other registers are preserved. ; ;- DOEDAT::JSR R5,.SAVR1 ; Save R1 - R5 MOV R2,R1 ; Copy the header buffer address. ADD #V.EDAT,R1 ; Point to the expiration date. CMPB 5(R1),#'5 ; Date = 17NOV58 for VAX/VMS ? BEQ 5$ ; If EQ, yes (No expiration date). TSTB (R1) ; Is there an expiration date ? BNE 10$ ; If NE, yes. 5$: MOV #NDATM,R1 ; Else, show none specified. CALL MOVEC ; Copy it. BR 20$ ; And continue ... 10$: CALL MAKDAT ; Format the expiration date. 20$: RETURN .SBTTL DOFID - Do the file identification. ;+ ; ; DOFID - Do the file identification. ; ; Inputs: ; R0 = The output buffer address. ; R5 = The file entry address. ; ; Outputs: ; R0 = The updated buffer address. ; ; All other registers are preserved. ; ;- DOFID: JSR R5,.SAVR1 ; Save R1 - R5 MOV O.FNB(R5),R4 ; Copy the file name block address. MOV (R4)+,R1 ; Copy the first FID word. CALL 10$ ; Convert it to ASCII. MOVB #',,(R0)+ ; Put in the delimiter. MOV (R4)+,R1 ; Copy the second FID word. CALL 10$ ; Convert it to ASCII. MOVB #',,(R0)+ ; Put in the delimiter. MOV (R4)+,R1 ; Copy the third FID word. CALL 10$ ; Convert it to ASCII. CLRB (R0) ; Terminate with a null. RETURN 10$: TST VAXFLG ; Are we running on VAX/VMS ? BEQ 20$ ; If EQ, no (presume RSX-11M). CALL CVTDEC ; Convert it to decimal ASCII. RETURN 20$: CALL CVTOCT ; Convert it to octal ASCII. RETURN .END