.TITLE DIRNAM - Make File Name and Date .IDENT /1.5/ .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: DIRNAM.MAC ; Author: Robin Miller ; Date: February 19, 1985 ; ; Description: ; ; These routines format the file name and creation date of the ; current input file. ; ;- .ENABL AMA .NLIST BEX .MCALL CSI$, FDOFF$, NBOFF$ CSI$ ; Define the CSI offsets. FDOFF$ DEF$L ; Define the FDB offsets. NBOFF$ DEF$L ; Define the FNB offsets. ;+ ; ; Modification History: ; ; June 25, 1985 by Robin Miller. Edit (05), Version 1.5 ; When formatting the UIC, if the error code is "No such file" ; then we use the original directory string specified (if any). ; ; April 25, 1985 by Robin Miller. Edit (04), Version 1.4 ; Format files which have only a version number. ; ; April 11, 1985 by Robin Miller. Edit (03), Version 1.3 ; Save pointers to the uic, file type, and version number. ; ; April 10, 1985 by Robin Miller. Edit (02), Version 1.2 ; Add support for formatting an ANSI filename block. ; ; March 8, 1985 by Robin Miller. Edit (01), Version 1.1 ; Don't check for special characters (. and $) when copying the ; file name from the dataset descriptor. In most cases, we've ; failed from parsing the device and we don't want the dot "." ; to be converted to a "%" character. ; ;- ;+ ; Filename Block Format: ; ; ========================= ; | | 0 ; | N.FID | 2 File identification field. ; | | 4 ; +-----------------------+ ; | | 6 ; | N.FNAM | 10 File name field (Radix-50) ; | | 12 ; +-----------------------+ ; | N.FTYP | 14 File type field (Radix-50). ; +-----------------------+ ; | N.FVER | 16 File version field (binary). ; +-----------------------+ ; | N.STAT | 20 Filename status word. ; +-----------------------+ ; | N.NEXT | 22 Context for next .FIND operation. ; +-----------------------+ ; | | 24 ; | N.DID | 26 Directory identification field. ; | | 30 ; +-----------------------+ ; | N.DVNM | 32 Device name field (ASCII). ; +-----------------------+ ; | N.UNIT | 34 Unit number field (binary). ; ========================= ; ; ANSI Filename Block Format: ; ; ========================= ; | N.FID | 0 File identification field. ; +-----------------------+ ; | | 2 ; | | 4 ; | N.ANM1 | 6 First 12 bytes of ANSI file name. ; | | 10 (ASCII string padded with spaces) ; | | 12 ; | | 14 ; +-----------------------+ ; | N.FVER | 16 File version number field (binary). ; +-----------------------+ ; | N.STAT | 20 Filename block status word. ; +-----------------------+ ; | N.NEXT | 22 Context for next .FIND operation. ; +-----------------------+ ; | | 24 ; | N.ANM2 | 26 Remainder of the ANSI file name. ; | | 30 ; +-----------------------+ ; | N.DVNM | 32 Device name field (ASCII). ; +-----------------------+ ; | N.UNIT | 34 Unit number field (binary). ; ========================= ;- .SBTTL MAKNAM - Make the ASCII file name. ;+ ; ; MAKNAM - Make the ASCII file name and creation date. ; ; Inputs: ; R5 = The active file entry address. ; ; Outputs: ; All registers are preserved. ; ;- MAKNAM::CALL $SAVAL ; Save all registers. MOV O.FDB(R5),R3 ; Copy the FDB address. MOV O.FNB(R5),R4 ; Copy the FNB address. ; Now call the various routines to format the file name. MOV O.DEVU(R5),R0 ; Copy address to store file name. CALL SETDEV ; Setup the device and unit number. MOV R0,SOFUIC ; Save pointer to start of UIC. (03) CALL SETUIC ; Setup the directory string. CLRB (R0)+ ; Terminate the device/UIC string. MOV R0,O.FNAM(R5) ; Save address of file name. CALL SETNAM ; Setup the file name. RETURN .SBTTL SETDEV - Setup the device name and unit number. ;+ ; ; SETDEV - Setup the device name and unit number. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The file descriptor block address. ; R4 = The file name block address. ; ; Outputs: ; R0 = The updated output buffer address. ; ; All other registers are preserved. ; ;- SETDEV: JSR R5,.SAVR1 ; Save R1 - R5. MOV N.DVNM(R4),(R0)+ ; Copy the device name. BEQ 50$ ; If EQ, there is none. MOV N.UNIT(R4),R1 ; Get binary unit number. ; On VAX/VMS, convert unit number to controller/unit number. TSTB VAXFLG ; Are we running on VAX/VMS ? BEQ 30$ ; If EQ, no (unit number only). MOVB #'A,(R0) ; Presume first controller. 10$: CMP R1,#16. ; Do we have the right controller ? BLT 20$ ; If LT, yes (convert unit number). SUB #16.,R1 ; no, adjust the unit number. INCB (R0) ; Set for the next controller. BR 10$ ; And try again... 20$: INC R0 ; Point past the controller letter. 30$: CALL CVTOCT ; Convert unit # to octal ASCII. MOVB #':,(R0)+ ; Terminate the device name. BR 100$ ; And continue ... ; No device name in the FNB, check the CSI block. 50$: TST -(R0) ; Backup the buffer pointer. MOV F.DSPT(R3),R1 ; Copy the dataset desc address. BEQ 100$ ; If EQ, there is none. MOV N.DEVD(R1),R2 ; Copy the device name size. BEQ 100$ ; If EQ, none specified. MOV N.DEVD+2(R1),R1 ; Copy the buffer address. 60$: MOVB (R1)+,(R0)+ ; Copy the specified device name. SOB R2,60$ ; Loop until done. 100$: CLRB (R0) ; Terminate with null. RETURN .SBTTL SETNAM - Setup the ASCII file name. ;+ ; ; SETNAM - Setup the ASCII file name. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The FDB address. ; R4 = The FNB address. ; ; Outputs: ; R0 = The updated output buffer address. ; ;- SETNAM: JSR R5,.SAVR1 ; Save R1 - R5. ; If file name is in ANSI format, go format it. BITB #NB.ANS,N.STAT(R4) ; Is file name in ANSI format ? (02) BEQ 5$ ; If EQ, no (format normally). (02) CALL SETANS ; Setup the ANSI file name. (02) BR 60$ ; Now format the version number.(02) ; If the directory is protected, there is no file name. 5$: MOV R0,R5 ; Save the buffer address. MOV N.FNAM(R4),R1 ; Get 1st part of file name. BNE 10$ ; If NE, there is a name. TST N.FTYP(R4) ; Any file type (extension) ? BNE 30$ ; If NE, yes (format this). TST N.FVER(R4) ; Is there a version number ? (04) BEQ 90$ ; No, format dataset string. MOV R0,SOFTYP ; Save pointer to file type. (04) MOVB #'.,(R0)+ ; Move in file name delimiter. (04) BR 60$ ; And format the version #. (04) 10$: CALL $C5TA ; Convert RADIX-50 to ASCII. ; Note: Destroyes R1 and R2. MOV N.FNAM+2(R4),R1 ; Get 2nd part of file name. BEQ 20$ ; If EQ, all done. CALL $C5TA ; Convert it to ASCII. MOV N.FNAM+4(R4),R1 ; Get 3rd part of file name. BEQ 20$ ; If EQ, all done. CALL $C5TA ; Convert it to ASCII. 20$: CMPB #SPACE,-(R0) ; Last character a space ? BEQ 20$ ; If EQ, yes (backup). INC R0 ; No, adjust the pointer. CALL CHKSPC ; Check for special characters. 30$: MOV R0,SOFTYP ; Save pointer to file type. (03) MOVB #'.,(R0)+ ; Move in file name delimiter. ; Setup the file type. MOV R0,R5 ; Save the buffer address. MOV N.FTYP(R4),R1 ; Get the file type (extension). BNE 40$ ; If NE, there is one. BIT #NB.STP,N.STAT(R4) ; Was a wildcard file type used ? BEQ 60$ ; If EQ, no (presume no file type). TST N.FID(R4) ; Is there a file ID ? BNE 60$ ; If NE, yes (no file type). MOVB #'*,(R0)+ ; Yes, fill in the file type. BR 60$ ; And continue ... 40$: CALL $C5TA ; Convert it to ASCII. 50$: CMPB #SPACE,-(R0) ; Last character a space ? BEQ 50$ ; If EQ, yes (backup). INC R0 ; No, adjust the pointer. CALL CHKSPC ; Check for special characters. ; Setup the version number in octal (RSX) or decimal (VMS). 60$: MOV R0,SOFVER ; Save pointer to version #. (03) MOV N.FVER(R4),R1 ; Get the file version number. BNE 70$ ; If NE, there is one. BIT #NB.SVR,N.STAT(R4) ; Was a wildcard version used ? BEQ 110$ ; If EQ, no (presume no version). MOVB #';,(R0)+ ; Move in the version delimiter. MOVB #'*,(R0)+ ; Show a wildcard version number. BR 110$ ; And continue ... 70$: MOVB #';,(R0)+ ; Move in version delimiter. TSTB VAXFLG ; Are we running on VAX/VMS ? BEQ 80$ ; If EQ, no (must be RSX-11M). CALL CVTDEC ; Yes, convert to decimal ASCII. BR 110$ ; And continue ... 80$: CALL CVTOCT ; Convert binary to octal ASCII. BR 110$ ; And continue ... ; No file name in the FNB, check the CSI block. 90$: MOV F.DSPT(R3),R1 ; Copy the dataset desc address. BEQ 110$ ; If EQ, there is none. MOV N.FILD(R1),R2 ; Copy the file name size. BEQ 110$ ; If EQ, none specified. MOV N.FILD+2(R1),R1 ; Copy the buffer address. 100$: MOVB (R1)+,(R0)+ ; Copy the specified device name. SOB R2,100$ ; Loop until done. ;*** CALL CHKSPC ; Check for special characters. (01) 110$: CLRB (R0) ; Terminate the file name. RETURN .SBTTL SETANS - Setup the ANSI file name. ;+ ; ; SETANS - Setup the ANSI file name. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The FDB address. ; R4 = The FNB address. ; ; Outputs: ; R0 = The updated output buffer address. ; ;- SETANS: JSR R5,.SAVR1 ; Save R1 - R5. Added for edit (02) ; Copy the first part of the ANSI file name. MOV R4,R1 ; Copy the file name block. ADD #N.ANM1,R1 ; Point to first part of name. MOV #12.,R2 ; Set the number of characters. 10$: MOVB (R1)+,(R0)+ ; Copy the ANSI file name. SOB R2,10$ ; Loop until done. ; Copy the second part of the ANSI file name. MOV R4,R1 ; Copy the file name block. ADD #N.ANM2,R1 ; Point to second part of name. MOV #6,R2 ; Set the number of characters. 20$: MOVB (R1)+,(R0)+ ; Copy the ANSI file name. SOB R2,20$ ; Loop until done. ; Now, backup over spaces at end of file name (if any). 30$: CMPB -(R0),#SPACE ; Is this a space character ? BEQ 30$ ; If EQ, yes (check next). INC R0 ; Point to end of file name. RETURN .SBTTL SETUIC - Setup the ASCII directory string. ;+ ; ; SETUIC - Setup the ASCII directory string. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The FDB address. ; R4 = The FNB address. ; R5 = The file entry address. ; ; Outputs: ; R0 = The updated output buffer address. ; ; All other registers are preserved. ; ;- SETUIC: JSR R5,.SAVR1 ; Save R1 - R5. ; Read the file owner UIC and creation date/time if file is open. TST N.FID(R4) ; Do we have a file ID ? BEQ 10$ ; If EQ, no. ; On VAX/VMS, copy the directory string (if any). TSTB VAXFLG ; Are we running on VAX/VMS ? BEQ 10$ ; If EQ, no (use specifed or default). MOV @#.FSRPT,R1 ; Else, get address of FSR. ADD #A.DFDR,R1 ; Point to the directory descriptor. MOV (R1)+,R2 ; Copy the directory string size. BEQ 10$ ; If EQ, there is none (use UIC). MOV (R1),R1 ; Copy the directory string address. BR 20$ ; And use common copy loop ... ; Copy the directory string from the CSI block (if any). 10$: MOV F.DSPT(R3),R1 ; Copy the directory string address. BEQ 30$ ; If EQ, there is none. CMPB #IE.NSF,F.ERR(R3) ; Was error "No such file" ? (05) BNE 15$ ; If NE, no. (05) MOV O.DIRD(R5),R2 ; Yes, copy the byte count. (05) BEQ 30$ ; If EQ, there is none. (05) MOV O.DIRD+2(R5),R1 ; Copy the buffer address. (05) BR 20$ ; Now copy the directory string.(05) 15$: MOV N.DIRD(R1),R2 ; Else, copy the byte count. BEQ 30$ ; If EQ, there is none. MOV N.DIRD+2(R1),R1 ; Else, copy the buffer address. 20$: MOVB (R1)+,(R0)+ ; Copy the directory string. SOB R2,20$ ; Loop until done. BR 100$ ; All done ... ; Read and format the default UIC. 30$: CALL .RDFUI ; Read the default UIC into R1. 40$: MOV R0,R2 ; Copy output buffer address. MOV R1,R3 ; Copy binary UIC. CLR R4 ; Set for leading zeros/separators. CALL .PPASC ; Convert binary UIC to ascii. MOV R2,R0 ; Copy new output buffer address. 100$: CLRB (R0) ; Terminate with null. RETURN .SBTTL CHKSPC - Check for special characters. ;+ ; ; CHKSPC - Check for special wildcard characters. ; ; This routine is used to convert the special wildcard characters (. and $) ; back to the originally input characters (% and *). ; ; Inputs: ; R0 = The ending buffer address. ; R5 = The starting buffer address. ; ; Outputs: ; All registers are preserved. ; ; *** This routine was added for edit (02). *** ;- CHKSPC: JSR R2,$SAVVR ; Save R0 - R2. CLRB (R0) ; Set terminating character. MOV R5,R0 ; Copy the buffer address. 10$: MOVB (R0)+,R1 ; Copy the next character. BEQ 100$ ; If EQ, we're all done. CMPB R1,#'. ; Is this a period ? BNE 20$ ; If NE, no. MOVB #'%,-1(R0) ; Convert back to a percent. BR 10$ ; Check the next character. 20$: CMPB R1,#'$ ; Is this a dollar sign ? BNE 10$ ; If NE, no. MOVB #'*,-1(R0) ; Yes, convert back to asterisk. BR 10$ ; Check the next character. 100$: RETURN .END