; This file updates SRDSRT.MAC;1 from SRD V6.3. SRDSRT.MAC;2/AU=SRDSRT.MAC;1 \ -/.IDENT/,. .IDENT -6.4- ; DEC-83 .ENABL LC -/CEF001/+1 ; ; ; VERSION 6.4 - 07-Nov-83 (;BT003 and ;DJS001) ; ; Bob Turkelson ; SRD Working Group ; ; Use additional LUN for reading headers. For directories too ; large to fit into memory, the directory is kept open while ; processing it in pieces. Thus the directory LUN can not be ; re-used for reading the headers. ; Issue a fatal message if write-back is specified and the ; directory is too large to fit into memory. Determined before ; any directory sorting is done, to save the sorting time. ; (Previously a directory write-back cancelled warning was ; issued, but the last piece of the directory was written ; anyway, wiping out most of the directory.) ; Add sort by date capability. Merged from Henry Tumblin's ; version of SRD (which does not appear on the SIG tapes). ; 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. % -,,/;BT003/ -/.PSECT...SRDCOD/,. .PSECT SRDATA,D,RW,LCL,REL,CON -/.MCALL/,. .MCALL CALLR,WRITE$,WAIT$,CLOSE$,QIOW$,DIR$ -/.MACRO/,/.ENDM/,/;DJS001/ .MACRO C$MP ARG,DIR .IF IDN DIR ASC ; Is the order ascending? CMP ARG(R3),ARG(R4) ; SEE WHICH IS BIGGER BHI EXCHNG ; IF HI EXCHANGE POINTERS BLO CONTINUE ; IF LO, CONTINUE .IFF ; Else... .IF IDN DIR DSC ; Is the order descending? CMP ARG(R3),ARG(R4) ; SEE WHICH IS SMALLER BLO EXCHNG ; IF LO EXCHANGE POINTERS BHI CONTINUE ; IF HI, CONTINUE .IFF ; Else... .ERROR ; Illegal value for direction argument. .ENDC .ENDC .ENDM -,,/;BT003/ ; READAT: QIOW$ IO.RAT,HDRLUN,EFN1,,IOSB$,,<0,ATTLST> ATTLST: .BYTE -15,43 ; Read creation date .WORD DTBUF ; Buffer to receive date/time .WORD 0 ; End of attribute list DTBUF: RVNO: .BLKW 1 ; Revision number RVDATE: .BLKB 7 ; Revision date .BLKB 6 ; Revision time CRDATE: .BLKB 7 ; Creation date .BLKB 6 ; Creation time .BLKB 7 ; Expiration date .EVEN SRTORD: .BLKW 6 ; Addresses for ordered sort ; .PSECT SRDCOD,I,RO,LCL,CON,REL ; -/SRDSRT::/,. SRDSRT:: BIT #WBSW,SWMS2$ ; Requested to write back directory? BEQ 5$ ; EQ - no, proceed CMPB #IE.EOF,F.ERR+UFDFDB ; Has entire directory been read? BEQ 5$ ; EQ - yes, proceed FERR WBCAN ; Issue fatal error (without sorting) to ; ; prevent last piece of directory being ; ; written later 5$: MOV F.BKDS+2+UFDFDB,R1 ; Point at end of buffer -/.ENABL...LSB/ BIT #DATSRT,FLAGS$ ; Sorting by date? BEQ 10$ ; EQ - no CALL GETDAT ; Read in file headers to get dates ; -/BEQ...63$/,. BNE 100$ ; NE - yes JMP WBACK ; Otherwise, check for write-back 100$: MOV #SRTORD,R3 ; Point to table to put sort code addresses MOV #SKBUF$,R5 ; Point to start of sort key buffer 110$: CMPB (R5),#'T ; Sort on file type? BNE 130$ ; NE - no TSTB (R5)+ ; Point to field for descending CMPB (R5)+,#'D ; Descending file type? BEQ 120$ ; EQ - yes MOV #STA,(R3)+ ; Ascending file type BR 250$ ; Proceed to next sort key 120$: MOV #STD,(R3)+ ; Descending file type BR 250$ ; Proceed to next sort key 130$: CMPB (R5),#'N ; Sort on file name? BNE 150$ ; NE - no TSTB (R5)+ ; Point to field for descending CMPB (R5)+,#'D ; Descending file type? BEQ 140$ ; EQ - yes MOV #SNA,(R3)+ ; Ascending file name BR 250$ ; Proceed to next sort key 140$: MOV #SND,(R3)+ ; Descending file name BR 250$ ; Proceed to next sort key 150$: CMPB (R5),#'V ; Sort on file version? BNE 170$ ; NE - no TSTB (R5)+ ; Point to field for descending CMPB (R5)+,#'D ; Descending file version? BEQ 160$ ; EQ - yes MOV #SVA,(R3)+ ; Ascending file version BIS #ASCVER,FLAGS$ ; Set ascending version flag BIT #PUSW,SWMSK$ ; Selecting obsolete versions? BNE 250$ ; NE - yes BIS #OVDSVA,FLAGS$ ; No, set for ascending, highest versions BR 250$ ; Proceed to next sort key 160$: MOV #SVD,(R3)+ ; Descending file version BIT #PUSW,SWMSK$ ; Selecting obsolete versions? BEQ 250$ ; EQ - no BIS #OVDSVA,FLAGS$ ; No, set for descending, lowest versions BR 250$ ; Proceed to next sort key 170$: CMPB (R5),#'D ; Sort on file date? BNE 190$ ; NE - no TSTB (R5)+ ; Point to field for descending CMPB (R5)+,#'D ; Descending date? BEQ 180$ ; EQ - yes MOV #SDA,(R3)+ ; Ascending date BR 250$ ; Proceed to next sort key 180$: MOV #SDD,(R3)+ ; Descending date BR 250$ ; Proceed to next sort key 190$: TST (R5)+ ; Future 250$: TST (R5) ; At end of sort keys? BNE 110$ ; No, process next one CLR (R3) ; Signal end of address table 15$: -/20$:/ -/BIT...#NASW/,/CONTINUE:/ MOV #SRTORD,R5 ; Point to table of addresses of sort code JMP @(R5)+ ; Check the first field for sorting NXTFLD: TST (R5) ; Are we at the end of the table? BEQ CONTINUE ; EQ - yes JMP @(R5)+ ; Check the next field for sorting EXCHNG: MOV R4,R3 CONTINUE: BR 20$ STA: C$MP D.TYP,ASC ; Ascending file type BR NXTFLD ; Proceed to next sort key STD: C$MP D.TYP,DSC ; Descending file type BR NXTFLD ; Proceed to next sort key SNA: C$MP D.FNAM,ASC ; Ascending file name C$MP D.FNAM+2,ASC C$MP D.FNAM+4,ASC BR NXTFLD ; Proceed to next sort key SND: C$MP D.FNAM,DSC ; Descending file name C$MP D.FNAM+2,DSC C$MP D.FNAM+4,DSC BR NXTFLD ; Proceed to next sort key SVA: C$MP D.VER,ASC ; Ascending file version BR NXTFLD ; Proceed to next sort key SVD: C$MP D.VER,DSC ; Descending file version BR NXTFLD ; Proceed to next sort key SDA: C$MP D.FLEV,ASC ; Ascending date BR NXTFLD ; Proceed to next sort key SDD: C$MP D.FLEV,DSC ; Descending date BR NXTFLD ; Proceed to next sort key -/60$:/ -/BLO...10$/,. BLO 15$ ; LO - no, more to do -/63$:/,. WBACK: MOV #WBTRY,R4 ; Re-try loop count -/CMPB...#IE.EOF/,/RETURN/ -/65$:/ -/BHIS...100$/ BIT #DATSRT,FLAGS$ ; Doing a date sort? BEQ 68$ ; EQ - no CALL CLRDAT ; Clear temporary dates out of header 68$: -/110$:/ -/RETURN/ ; ;+ ; This routine will fill in the file date in ; the file system level location in the file ID in ; the directory entry. On ODS-1 systems, this location ; is always zero. ;- GETDAT: MOV R0,-(SP) ; Save registers MOV R1,-(SP) ; ... MOV R2,-(SP) ; ... MOV R2,R3 ; Point to start of directory 10$: CMP R3,R1 ; At end yet ? BHIS 90$ ; HIS - then all thru MOV R1,-(SP) ; Save pointer MOV R3,READAT+Q.IOPL ; Set file ID pointer DIR$ #READAT ; Read attributes CMPB IOSB$,#IS.SUC ; Did it succeed ? BEQ 20$ ; EQ - yes DIAG BADDS ; Unable to read file dates CLR R2 ; Set to zero BR 30$ 20$: MOV #CRDATE,R1 ; Point to creation date string BIT #RDSW,SWMS2$ ; Use revision date? BEQ 25$ ; EQ - no TST RVNO ; Ever revised? BEQ 25$ ; EQ - no, use creation date MOV #RVDATE,R1 ; Point to revision date string 25$: CALL CVDATE ; Convert date (return value in R2) BCC 30$ ; CC - then read OK DIAG BADDS ; File header date corrupt CLR R2 ; Set to zero 30$: MOV R2,D.FLEV(R3) ; Insert date into directory MOV (SP)+,R1 ; Restore pointer ADD #D.SIZ,R3 ; Point to next entry BR 10$ ; And loop 90$: MOV (SP)+,R2 ; Restore registers MOV (SP)+,R1 ; ... MOV (SP)+,R0 ; ... RETURN ; ;+ ; This routine will zero the file level number in the ; directory entry. This is required before the directory is ; written back to disk. ;- CLRDAT: MOV DIRBF$,R3 ; Point to start 10$: CMP R3,R1 ; At end of buffer ? BHIS 90$ ; HIS - then all thru CLR D.FLEV(R3) ; Reset file level # ADD #D.SIZ,R3 ; Point to next entry BR 10$ ; And loop 90$: RETURN /