; This file updates SRDLST.MAC;1 from SRD V6.3. SRDLST.MAC;2/AU=SRDLST.MAC;1 \ -/.IDENT/,. .IDENT -6.4- ; NOV-83 -/CEF001/+1 ; ; ; VERSION 6.4 - 07-Nov-83 (;BT003) ; ; Bob Turkelson ; SRD Working Group ; ; Allow specification of major and minor sort keys in any order ; in the /SR:x:x:x switch, also allowing the sort to be either ; ascending or descending for any key (file name, type, version ; date). Ascending and descending capability adopted from ; changes by Dave Sides (Sachs/Freeman Assoc., Inc., c/o ; JHU/Applied Physics Laboratory)(;DJS001). Ideas for ; specifying sort keys came from the version of SRD in the ; U. S. Forest Service collection of programs appearing on the ; Spring 1982 SIG tape. The implementation here is quite ; different. ; Search forward in the sorted directory to determine the number ; of versions when highest or obsolete version selection is ; required, and remember where a new file name and type is ; found. Necessary to take care of ascending version ; numbers. (Replaces code which compared each entry with ; both the previous and the next entries.) A check for end ; of directory is performed. (Previously possible to get a ; memory protection violation error when checking last entry ; of a dense directory which exactly filled the last block.) ; Added the command file generation switch /CM, taken from the ; version of SRD submitted to the Spring 1982 SIG tape in the ; U. S. Forest Service collection of programs. ; Added the /PA switch to pack the file names (remove any blanks). ; Added the /TB switch to include in the summary the number of ; blocks used/allocated even if it would not otherwise appear. ; Added the /GT:n switch to select files with allocated sizes of ; at least n. blocks. ; Added the /FI:n switch to select by file ID. ; Added the /FO:[g,m] switch to select files by file owner, with ; /FO defaulting to files owned by the directory being listed; ; may be negated to select files with different file owners. ; Added the /ER switch to display files which produce errors ; when attempting to read their headers. ; Reference double word (rather than single word) values in the ; file headers to report a file's used and allocated blocks. ; For files with multiple headers, calculate the number of ; allocated blocks from the retrieval pointers (as has been ; done for any file when the header attributes show zero blocks ; allocated). Read each extension header into a buffer which ; starts at the beginning of the retrieval pointer area of the ; buffer for the first header. Only 51. additional words are ; needed for the buffer since the overlap is 205. words. ; Temporarily do not report errors when reading extension ; headers - treat the file as if it had a single header - unless ; the temporary switch /H2 is specified. A bug in RSX-11M V4.0 ; and RSX-11M-PLUS V2.0 causes a privilege violation reading an ; extension header unless you are in a privileged UIC or in the ; file owner's UIC. We recently determined that this does not ; occur in RSX-11M V3.2, and this problem has been corrected in ; V4.1 and RSX-11M-PLUS V2.1. ; When the date stored in the file header is corrupt, issue a ; non-fatal diagnostic message. (Previously the same fatal ; message was issued for this situation as was given for when ; an invalid date was specified in the command line.) ; Eliminate the extra zero byte appearing at the end of the UIC ; line. ; In diagnostic messages which refer to specific files include ; the UIC and file name in the message. ; Never "select" a file with a header read error. No further ; selection checks are performed for such a file. ; Do not "select" a file when a corrupt date is detected in ; the file header if file selection by date is requested. ; Make sure the UIC line for the directory appears when issuing ; a diagnostic for a header read error or for a corrupt date ; in the header. ; Set a flag bit in FLAGS$ at the beginning of SRDLST if the ; switches require a header read. Testing this bit where that ; information is needed eliminates duplicate code. ; Form a UIC string when the directory is opened in SRDOPR for ; use in UIC headings and diagnostic messages. ; Code for converting the file name to ASCII moved to a new ; routine CVTNAM within SRDLST. ; Calculation of end-of-file block number is done once rather ; than three times. % -,,/;BT003/ -/FUTABL:/ -/F.EFBK/,. .BYTE H.UFAT+F.EFBK ; FCS's end of file double word -/MITABL:/ -/F.EFBK/,. .BYTE H.UFAT+F.EFBK ; FCS's end of file double word -/LSTDIR:/ CLR VRSRM$ ; Zero number of file versions remaining -/BIC...#HDFL/,. BIC #HDFL,FLAGS$ ; Flag header listing not yet printed BIS #RDHDFL,FLAGS$ ; Set flag to read file header BIT #MISW!FUSW!DASW,SWMSK$ ; /MI, /FU, or any date switch used? BNE 20$ ; NE - yes, will need to read file headers BIT #COSW!LOSW!MUSW!ZESW,SWMS2$ ; /CO, /MU, or /ZE specified? BNE 20$ ; NE - yes, will need to read file headers BIT #GTSW!ERSW!TBSW!FOSW,SWMS3$ ; /GT, /ER, /TB or /FO specified? BNE 20$ ; NE - yes, will need to read file headers BIC #RDHDFL,FLAGS$ ; Clear flag - will not need file headers 20$: -/UNPACK:/ -/10$:/ BIT #CMSW,SWMS3$ ; Generating command lines? BNE 2$ ; NE - yes, omit summary lines -/1$:/ -/BIT...#,R3 ; Point back to first file name ADD #D.SIZ-<4*2>,R2 ; Point to file name following one just checked BR 10$ ; Check if that one has the same name ; ; Here we know the total number of versions for this file. ; Set the threshold for for the new/obsolete versions requested. ; 30$: MOV VRSCT$,R2 ; Get value specified in /SV, /NV, /OV, or /PU BNE 40$ ; NE - non-zero specified INC R2 ; If no value specified, use 1 40$: MOV R2,R1 ; First assume ascending version number - set ; ; threshold (number of versions from bottom) ; ; to value specified in switch CMP R2,#-1 ; Looking for last version? BNE 60$ ; NE - no BIT #ASCVER,FLAGS$ ; Are version numbers ascending? BEQ 50$ ; EQ - no MOV VRSRM$,R1 ; For "last version," ascending - set DEC R1 ; threshold to total minus 1 BR 70$ ; Proceed 50$: MOV #1,R1 ; For "last version," descending - set to 1 BR 70$ ; Proceed 60$: BIT #ASCVER,FLAGS$ ; Are version numbers ascending? BNE 70$ ; NE - yes NEG R1 ; For descending - set threshold to ADD VRSRM$,R1 ; total minus number of versions 70$: MOV R1,VRSLMT ; Store threshold CKHV: BIT #HVSW,SWMS2$ ; Selecting versions higher than? -/20$:/ -/BR...UNPACK/,. JMP UNPACK ; Look at next entry -/CVAS:/,/CLRB...(R0)/ CVAS: CALL CVTNAM ; Convert file name to ASCII at start of record -/CKVRSN:/,/BEQ...CKD1/ CKVRSN: BIT #SVSW,SWMSK$ ; Version selection needed? BEQ CKDATE ; EQ - no, proceed with date checks CMP VRSCT$,#-1 ; Looking for last version? BEQ 30$ ; EQ - yes, use reverse side of threshold line BIT #OVDSVA,FLAGS$ ; Versions (ascending, highest /SV) or ; ; (descending, lowest /OV) ? BNE 20$ ; NE - yes 10$: CMP VRSRM$,VRSLMT ; Are we above threshold line? BGT CKDATE ; HI - yes, proceed JMP UNPACK ; Otherwise, get the next entry 20$: CMP VRSRM$,VRSLMT ; Are we below threshold line? BLE CKDATE ; LOS - yes, proceed JMP UNPACK ; Otherwise, get the next entry 30$: BIT #OVDSVA,FLAGS$ ; Versions (ascending, highest /SV) or ; ; (descending, lowest /OV) ? BEQ 20$ ; EQ - yes, check for below threshold line BR 10$ ; Check for above threshold line CKDATE: BIC #HDRERR,FLAGS$ ; Clear header read error indicator BIT #RDHDFL,FLAGS$ ; Do we need to read file header? BNE 10$ ; NE - yes JMP LSTENT ; Otherwise, proceed -/10$:/ MOV #HDBUF$,HDPTR$ ; Set up to use main header buffer 15$: -/20$:/ -/BEQ...CKCLM/,/30$:/ BEQ 60$ BIS #HDRERR,FLAGS$ ; Indicate header read error MOVB IOSB$,IOSBSV ; Save I/O status block byte to issue diagnostic ; ; message after heading is printed BIT #ERSW,SWMS3$ ; /ER switch specified? BEQ 45$ ; EQ - no, just print file name INC NUMFS ; Count this file 45$: ; ; ; The code in this section is temporary -- there is apparently a problem ; reading an extension header if you are a non-privileged non-file owner. ; CMP HDPTR$,#HDBUF$ ; Is this the first header for this file? BEQ 50$ ; EQ - yes BIT #H2SW,SWMS3$ ; Report errors with extension headers? BNE 50$ ; NE - yes ; For now, ignore extension header; process as we would a single header file BIC #HDRERR,FLAGS$ ; Turn off the error flag we set MOV #HDBUF$,HDPTR$ ; Point back to the first header area BR 70$ ; Then process as single header file ; ; --- End of temporary section --- ; ; 50$: JMP LSTENT ; Print file name (with heading, if needed) 60$: BIT #ERSW,SWMS3$ ; /ER switch specified? BNE REJECT ; NE - yes, reject since file header valid ; ; Handle multi-header files ; TST HDBUF$+S.HDHD+S.IDHD+M.EFNU ; Are there extension headers? BEQ 70$ ; EQ - no, proceed CALL ABCALC ; Add the file blocks allocated by the retrieval ; ; pointers in this header to the total for this ; ; file MOV HDPTR$,R1 ; Get pointer to current header buffer TST S.HDHD+S.IDHD+M.EFNU(R1) ; Does this header have an extension? BEQ 80$ ; EQ - no, proceed CLR S.HDHD+S.IDHD+M.EFSQ+2(R1) ; Zero word to create 3 word ; ; file id/seq number block ADD #S.HDHD+S.IDHD+M.EFNU,R1 ; Point to file id/seq number block MOV R1,READHD+Q.IOPL ; Set pointer in header read QIO parameter list MOV #HDBF2$,HDPTR$ ; Use extension header buffer area BR 15$ ; Now read the extension header ; ; Obtain file blocks allocated ; 70$: MOV #HDBUF$+H.UFAT,R1 ; Pointer to user attributes MOV F.HIBK(R1),ALOCSZ ; Get file blocks allocated, high order word MOV F.HIBK+2(R1),ALOCSZ+2 ; Get file blocks allocated, low word BNE 80$ ; NE - non-zero blocks indicated (low order) CALL ABCALC ; Calculate allocation from retrieval pointers ; ; since the value in the header may be incorrect ; ; for headers showing zero blocks allocated ; ; Obtain file blocks used ; 80$: MOV #HDBUF$+H.UFAT,R1 ; Pointer to user attributes MOV F.EFBK(R1),USEDSZ ; Get file blocks used, high order word MOV F.EFBK+2(R1),USEDSZ+2 ; Get file blocks used, low order word BEQ 90$ ; EQ - zero blocks used (low order word) TST F.FFBY(R1) ; Is first free byte zero BNE 90$ ; NE - no, value does not need adjusting DEC USEDSZ+2 ; Otherwise don't count the last block ; ; Check file owner with /FO:grp:mem switch values ; A zero for either switch value means a wildcard. ; Zero for both (that is, simply /FO) means this directory - SRDOPR has ; filled in the values. ; 90$: CKFO: BIT #FOSW,SWMS3$ ; File owner check (/FO or /-FO) specified? BEQ CKCLM ; EQ - no TSTB FOGRP$ ; Is group a wildcard? BEQ 10$ ; EQ - yes CMPB FOGRP$,HDBUF$+H.PROJ ; Does the group match? BNE FODIF ; NE - no 10$: TSTB FOMEM$ ; Is member a wildcard? BEQ FOMAT ; EQ - yes CMPB FOMEM$,HDBUF$+H.PROG ; Does the member match? BNE FODIF ; NE - no BR FOMAT ; A match FODIF: BIT #NOFOSW,FLAGS$ ; /-FO specified? BNE CKCLM ; NE - yes, do not reject JMP UNPACK ; Otherwise, reject FOMAT: BIT #NOFOSW,FLAGS$ ; /-FO specified? BEQ CKCLM ; EQ - no, do not reject JMP UNPACK ; Otherwise, reject -/CKZE:/ -/BEQ...CKD1/,/CKD1:/ BEQ CKGT ; EQ - no, proceed TST USEDSZ ; Any blocks used (high order word)? BNE REJECT ; NE - yes, reject file TST USEDSZ+2 ; Any blocks used (low order word)? BNE REJECT ; NE - yes, reject file CKGT: BIT #GTSW,SWMS3$ ; /GT switch specified? BEQ CKD1 ; EQ - no 20$: CMP ALOCSZ,GTBUF$+2 ; Is file size larger or equal to /GT: value? BHI CKD1 ; HI - yes BLO REJECT ; LO - no, reject file CMP ALOCSZ+2,GTBUF$ ; Is file size larger or equal to /GT: value? BLO REJECT ; LO - no, reject file CKD1: -/5$:/ -/CALL...CVDATE/ BCC 7$ ; CC - no error in date format BIS #DATERR,FLAGS$ ; Indicate file date corrupt in file header BR LSTENT ; Proceed 7$: -/LSTENT:/,. LSTENT: BIT #CMSW,SWMS3$ ; Generating command lines? BEQ 1$ ; EQ - no CALL CMMAKE ; Generate the command line JMP UNPACK ; Proceed to next entry 1$: BIT #HDFL,FLAGS$ ; Has header been listed? -/2$:/ -/SUB...#D.SIZ/,/DEC...NUMFT/ -/6$:/ -/MOVB...#'[/,/MOVB...#']/ MOV #UICHD,R1 ; Point to UIC string formed in SRDOPR 8$: MOVB (R1)+,(R0)+ ; Copy in string BNE 8$ ; NE - not at end yet DEC R0 ; Backup over zero byte -/12$:/ -/TDTIM$/,.,/;BT003/ CMP R1,# ; FINISH TIME? -/PTNAM:/ -/11$:/,. 11$: SUB #,R5 ; Back up to current directory entry CALL CVTNAM ; Convert file name to ASCII as start of record JMP LSTE1 ; Continue with this entry -/20$:/,/RETURN/ -/LSTE1:/ -/INC...NUMFS/,/ADC...TBLKU/ BIT #HDRERR,FLAGS$ ; Was there a header read error? BEQ 12$ ; EQ - no, proceed CMP HDPTR$,#HDBUF$ ; Was this an extension header read? BEQ 4$ ; EQ - no DIAG XHDRD ; Issue msg indicating extension header error 4$: CMPB IOSBSV,#IE.SQC ; Was error file id/seq number check? BNE 6$ ; NE - no DIAG SQCHK ; Issue diagnostic BR 10$ 6$: CMPB IOSBSV,#IE.PRI ; Was error privilege violation? BNE 8$ ; NE - no DIAG HDPRV ; Issue diagnostic BR 10$ 8$: DIAG HDRE ; Issue diagnostic for some other header error 10$: JMP UNPACK ; Move on to next directory entry ; 12$: BIT #DATERR,FLAGS$ ; Do we know file date is corrupt? BEQ 15$ ; EQ - no DIAG BADDH ; File date corrupt in file header BIT #DASW,SWMSK$ ; Are we doing date selection? BEQ 15$ ; EQ - no, go ahead - list the file JMP UNPACK ; Do not list it if doing date selection ; 15$: INC NUMFS ; Count the file BIT #RDHDFL,FLAGS$ ; Was the file header read? BEQ 18$ ; EQ - no ADD ALOCSZ+2,TBLKA+2 ; Add file allocation size double word ADC TBLKA ; to total ADD ALOCSZ,TBLKA ADD USEDSZ+2,TBLKU+2 ; Add file blocks used double word ADC TBLKU ; to total ADD USEDSZ,TBLKU 18$: -/SIZECV:/ -/F.EFBK/,/$CBDMG...COVERT/ MOV #USEDSZ,R1 ; Point to file size used double word CALL $CDDMG ; Convert size to decimal MOVB #'.,(R0)+ ; Indicate decimal value MOVB #'/,(R0)+ ; Insert a separator CLR R2 ; Set zero suppress flag MOV #ALOCSZ,R1 ; Point to file allocation size double word CALL $CDDMG ; Convert size to decimal -/;ABCALC/ -/CALLED ONLY/,.+1 ; Called when value in header is zero, or for a multi-header file. ; Stores number of allocated blocks in ALOCSZ double word. ; Destroys R1 and R2. -/ABCALC:/ -/MOVB...HDBUF$+/,. MOV HDPTR$,R2 ; Get pointer to header buffer area in use MOVB S.HDHD+S.IDHD+M.USE(R2),R2 ; Get number of words of ptrs in use -/MOV...#HDBUF$+/,. MOV HDPTR$,R4 ; Get pointer to header buffer area in use ADD #S.HDHD+S.IDHD+M.RTRV,R4 ; Point to start of retrieval pointer -/20$:/ -/TST...HDBUF$/,/50$:/ MOV (SP)+,R4 ; Restore R4 -/60$:/,. 60$: CMP HDPTR$,#HDBUF$ ; Are we using the first header for this file? BNE 70$ ; NE - no MOV R1,ALOCSZ+2 ; Store the allocated size CLR ALOCSZ ; Zero high word BR 80$ ; 70$: ADD R1,ALOCSZ+2 ; Add to sum of sizes of previous headers ADC ALOCSZ ; Sum is a double word 80$: RETURN ; ; CVTNAM - converts file name pointed to by R5 in the directory to ASCII ; at the beginning of the record. ; At entry: R5 - address of entry in directory ; At exit: R0 - location in output record following file name ; R1, R2, R3 are destroyed ; CVTNAM: MOV LSTFDB+F.NRBD+2,R0 ; Point to start of record MOV #3,R3 ; Number of RAD50 words in name portion 20$: MOV (R5)+,R1 ; Get a RADIX-50 word CALL $C5TA ; Convert to ASCII DEC R3 ; Count number of entries done BGT 20$ ; GT - Still converting name portion BIT #PASW,SWMS3$ ; Pack the name-type-version field? BEQ 26$ ; EQ - no 24$: CMPB #' ,-(R0) ; Is there a blank here? BEQ 24$ ; EQ - yes, check previous character INC R0 ; Advance over non-blank found CMP R0,LSTFDB+F.NRBD+2 ; Did we back up beyond start of string? BHIS 26$ ; HIS - no MOV LSTFDB+F.NRBD+2,R0 ; Name field null - point to start of rec 26$: TST R3 ; Have we done the type field yet? BMI 30$ ; MI - yes MOV R0,LENNMF ; Store current location, then ... SUB LSTFDB+F.NRBD+2,LENNMF ; Calculate length of file name part MOVB #'.,(R0)+ ; Separate name and type BR 20$ ; Do type 30$: MOV R0,LENTYF ; Store current location, then ... SUB LSTFDB+F.NRBD+2,LENTYF ; Calculate length of file name and type SUB LENNMF,LENTYF ; Calculate length of file type part MOVB #';,(R0)+ ; Separate type and version MOV (R5)+,R1 ; Now get version CLR R2 ; Set leading zero suppress flag CALL $CBOMG ; Convert to ASCII CLRB (R0) ; Insert null after version number MOV R0,LENNTV ; Store current location, then ... SUB LSTFDB+F.NRBD+2,LENNTV ; Calculate length of name-type-version RETURN ; ; ; CMMAKE generates the command line requested by the /CM switch ; CMMAKE: BIS #FLFL,FLAGS$ ; Must set file-written flag MOV LSTFDB+F.NRBD+2,R0 ; Point to start of record (file name) MOV R0,R1 ; Copy pointer MOV #PRMPT,R3 ; Point to buffer to hold name-type-version MOV LENNTV,R4 ; Get length of name-type-version 10$: MOV (R1)+,(R3)+ ; Copy each byte of name-type-version to buffer SOB R4,10$ ; Repeat for entire string MOV LSTFDB+F.NRBD+2,R0 ; Point to start of record TSTB CMBUF$ ; Processor name entered in /CM: switch value? BEQ 20$ ; EQ - no CLR R2 ; Clear counter MOV #CMBUF$,R3 ; Point to first /CM: switch value 15$: MOVB (R3)+,(R0)+ ; Copy each character in switch value to record INC R2 ; Count number of characters in processor name TSTB (R3) ; At end of switch value string? BNE 15$ ; NE - no MOVB #' ,(R0)+ ; Insert a blank DEC R2 ; Was there just one character present? BNE 20$ ; NE - no CMPB #'@,-(R3) ; Was the character @ ? BNE 20$ ; NE - no DEC R0 ; If so, do not insert the blank 20$: MOV CMFLG$,R1 ; Get /CM flag word, with bit definitions ; (from low order): outfile, listfile, type, ; version, second file ASR R1 ; Outfile specified? BCC 30$ ; CC - no CALL INSRT ; Insert outfile name 30$: ASR R1 ; Listfile specified? BCC 40$ ; CC - no MOVB #',,(R0)+ ; Insert a comma CALL INSRT ; Insert listfile name 40$: BIT #3,CMFLG$ ; Do we need to insert an equal sign? BEQ 50$ ; EQ - no MOVB #'=,(R0)+ ; Insert an equal sign 50$: CALL INSRT ; Insert file name ASR R1 ; File type specified? BCC 55$ ; CC - no MOV LENTYF,R2 ; Get length of type string (including .) 52$: MOVB (R3)+,(R0)+ ; Move type string SOB R2,52$ ; Do entire string BR 60$ ; Proceed 55$: ADD LENTYF,R3 ; Move pointer to ; version number 60$: ASR R1 ; Version number specified? BCC 70$ ; CC - no MOV LENNTV,R2 ; Get number of characters in name-type-version SUB LENNMF,R2 ; Calculate number in just type-version fields SUB LENTYF,R2 ; Calculate length of ; version string 62$: MOVB (R3)+,(R0)+ ; Move version string SOB R2,62$ ; Do entire string 70$: ASR R1 ; Second file specified? BCC 80$ ; CC - no MOVB #',,(R0)+ ; Insert a comma CALL INSRT ; Insert second file name MOVB #';,(R0)+ ; Insert ; MOVB #'0,(R0)+ ; Insert version number 0 80$: CALL PUTLS1 ; Output line RETURN ; ; INSRT ----- Insert file name into output buffer ; INSRT: MOV #PRMPT,R3 ; Get address of file name buffer MOV LENNMF,R2 ; Get length of file name BEQ 20$ ; EQ - file name null 10$: MOVB (R3)+,(R0)+ ; Copy file name string SOB R2,10$ ; Do entire string 20$: RETURN /