.TITLE VTLNAM - Make File Name and Date .IDENT /1.4/ .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: VTLNAM.MAC ; Author: Robin Miller ; Date: June 30, 1983 ; ; 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: ; ; February 26, 1985 by Robin Miller. Edit (04), Version 1.4 ; o Change the SETNAM routine to only fill in a wildcard extension ; if there is no file ID (file error or no such file). ; o Change the MAKDAT routine to fill in the "19" for the year to ; use the same format as VAX/VMS. ; ; February 21, 1985 by Robin Miller. Edit (03), Version 1.3 ; Change the SETNAM routine to format a file which has a file ; type but no file name. ; ; October 3, 1984 by Robin Miller. Edit (02), Version 1.2 ; Check for and convert special wildcard characters in the file ; name and file type fields (needed for when errors occur). ; ; June 7, 1984 by Robin Miller. Edit (01), Version 1.1 ; On VMS, if using the RSX open routines instead of the VMS ; wildcard lookup routine, create the device/directory/filename. ; ( Removed this code since we're always using VMS wildcard lookup. ) ; ;- .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. TST N.FID(R4) ; Is the file open ? BEQ 10$ ; If EQ, no. CALL RDHDR ; Read file header information. BCS 100$ ; If CC, we failed. ; Now call the various routines to format the file name. 10$: ;*** BIT #S.RSX,(R5) ; Using the RSX open routines ? (01) ;*** BNE 15$ ; If NE, yes (make the filename)(01) BIT #B.NATV,SWMASK ; Using VMS wildcard lookup routine ? BNE 20$ ; If NE, yes (have expanded file name). 15$: MOV O.FNAM(R5),R0 ; Copy address to store file name. CALL SETDEV ; Setup the device and unit number. CALL SETUIC ; Setup the directory string. CALL SETNAM ; Setup the device name. 20$: MOV O.FDAT(R5),R0 ; Copy address to store file date. BEQ 100$ ; If EQ, there is none. MOV #HDRBUF,R2 ; Set address of the header buffer. CALL DOCDAT ; Do the creation date and time. 100$: 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 the directory is protected, there is no file name. MOV R0,R5 ; Save the buffer address. (02) MOV N.FNAM(R4),R1 ; Get 1st part of file name. BNE 10$ ; If NE, there is a name. (03) TST N.FTYP(R4) ; Any file type (extension) ? (03) BNE 30$ ; If NE, yes (format this). (03) BEQ 90$ ; Else, use dataset string. (03) 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. (02) 30$: MOVB #'.,(R0)+ ; Move in file name delimiter. ; Setup the file type. MOV R0,R5 ; Save the buffer address. (02) 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 ? (04) BNE 60$ ; If NE, yes (no file type). (04) 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. (02) ; Setup the version number in octal (RSX) or decimal (VMS). 60$: 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. (04) 110$: CLRB (R0) ; Terminate the file name. RETURN .SBTTL SETUIC - Setup the ASCII directory string. ;+ ; ; SETUIC - Setup the ASCII directory string. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The file descriptor block. ; R4 = The file name block 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) ; Is the file open ? BEQ 10$ ; If EQ, no. ;*** MOV HDRBUF+V.UIC,R1 ; Else, copy file owner UIC. ; On VAX/VMS, copy the directory string (if any). TSTB VAXFLG ; Are we running on VAX/VMS ? ;*** BEQ 40$ ; If EQ, no (format the UIC). 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. 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 MAKDAT - Make the ASCII date. ;+ ; ; MAKDAT - Make the ASCII date. ; ; This routine is used to format the ASCII date read from the file header. ; ; Inputs: ; R0 = The output buffer address. ; R1 = The date buffer address. ; ; Outputs: ; R0 = The updated output buffer address. ; ; All other registers are preserved. ; ;- MAKDAT::JSR R5,.SAVR1 ; Save R1 - R5. ; Format the date: dd-mmm-yy or yyyy for VMS. MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; day of month. MOVB #'-,(R0)+ ; Separate with minus sign. MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; month of MOVB (R1)+,(R0)+ ; the year. MOVB #'-,(R0)+ ; Separate with a minus sign. ; ; I like the VMS format better. ; ;*** TSTB VAXFLG ; Are we running on VAX/VMS ? (04) ;*** BEQ 10$ ; If EQ, no (must be RSX-11M). (04) MOVB #'1,(R0)+ ; Make system MOVB #'9,(R0)+ ; default date. 10$: MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; year of decade. CLRB (R0) ; Terminate with null. RETURN .SBTTL MAKTIM - Make the ASCII time. ;+ ; ; MAKTIM - Make the ASCII time. ; ; This routine is used to format the ASCII time read from the file header. ; ; Inputs: ; R0 = The output buffer address. ; R1 = The time buffer address. ; ; Outputs: ; R0 = The updated output buffer address. ; ; All other registers are preserved. ; ;- MAKTIM::JSR R5,.SAVR1 ; Save R1 - R5. ; Format the time: hh:mm:ss MOVB #SPACE,(R0)+ ; Space between date and time. MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; hour of the day. MOVB #':,(R0)+ ; Separate with a colon. MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; minute of the hour. MOVB #':,(R0)+ ; Separate with a colon. MOVB (R1)+,(R0)+ ; Move in the MOVB (R1)+,(R0)+ ; second of the minute. 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