.TITLE RMS_GET_VRNSIZ Return version number and file size .IDENT /V01.02/ ;++RMSGTVNSZ.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) routines for ; High level Language access to RMS services. ; ; Commissioned by Kevin Cahill for use in VAX version of CPLD. ; ; Abstract: ; This routine uses RMS to provide additional information on a file ; that is not available to High-Level Language Programs. ; ; Environment: ; User mode library routine. ; Library routine to be placed in FERMILIB.OLB. ; Normally used with a FORTRAN program. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 20-Apr-81 ; ; V01.01 22-Sep-82 FJN Use NAM$x_VER fields to access version number ; and LIB$ANALYZE_SDESC to get input strings ; V01.02 15-Apr-83 FJN Standardize help comments ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $NAMDEF ;Offsets of NAM block and maximum ; resultant string size .CROSS ; ; Local Macros: ; .MACRO MOV.STR dsc,len.dest,adr.dest,error ;Move length and address of string from ; a string descriptor. MOVAQ dsc,R0 ;Get address of string descriptor JSB G^LIB$ANALYZE_SDESC_R2 ;Analyze the descriptor returning: BLBC R0,error ; status (if bad take error exit), MOVB R1,len.dest ; string length and MOVL R2,adr.dest ; address of string text. ; .ENDM MOV.STR ; ; Equated Symbols: ; ; ; Offsets in the argument list: ; filspec = 4 ;File specification string descriptor ; address dftspec = 8 ;Default file specification string ; descriptor address version = 12 ;Address of longword in which the ; file version number is returned. length = 16 ;Address of longword in which the ; file length (in blocks) is returned .PAGE .SUBTITLE Impure data storage ; ; Read/write (impure) local data program section ; .PSECT _RMS_DATA,PIC,USR,CON,REL,LCL,NOSHR,NOEXE,WRT,RD TMPFAB: $FAB FAC=GET,SHR=GET- ;File access block used to OPEN file NAM=TMPNAM,XAB=TMPXAB TMPNAM: $NAM RSA=RESSTR,RSS=NAM$C_MAXRSS ;NAM block used to get the ; resultant file spec string TMPXAB: $XABFHC ;XAB to get EOF block number RESSTR: .BLKB NAM$C_MAXRSS ;Resultant file specification string ; buffer ; ; Program section for code ; .PSECT _RMS_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE Get file version number and size ;+ RMS_GET_VRNSIZ ; Open a specified file using RMS and return the file's version ; number and size (in blocks). ; ; status.wlc.v = RMS_GET_VRNSIZ( filespec.rt.dx, [dftspec.rt.dx], ; version.wl.r, length.wl.r ) ; ; filespec file specification string. Passed by descriptor. ; ; dftspec optional default file specification string. Used ; by RMS to fill in missing fields in the input file ; specification. Passed by descriptor. ; ; version longword in which the file's version number (in ; binary) is returned. Passed by reference. ; ; length longword in which the file's size (in blocks) is ; returned. This is actually the virtual block number ; of the last used block (possibly the EOF virtual ; block number). Passed by reference. ; ; status completion status code. The RMS error condition code is ; returned if the OPEN fails. Passed by value. ; ;- ;+0RMS_GET_VRNSIZ ; ; Functional Description: ; OPEN a file with RMS using the file specification provided (along with ; and optional default file specification). Return the file's version ; number from the resultant file specification and the file's size in ; blocks. The file is then CLOSE'd. ; ; Calling Sequence: ; status = RMS_GET_VRNSIZ(filespec, [dftspec], version, length) ; ; Input Parameters: ; filespec - address of the string descriptor for the file specification ; string. If the string must be no longer than 255 ; characters ; dftspec - address of the string descriptor for the default file ; specification string (fields of this specification ; are used in place of missing fields in filespec). ; The string must be no longer than 255 characters. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; R0 - completion status code ; version - address of a longword in which the file's version number is ; returned (in binary). ; length - address of a longword in which the file's size (in blocks) is ; returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; RMS$_NORMAL success ; RMS$_KFF success, known file found ; LIB$_INVSTRDES invalid input string descriptor ; RMS$_ACC ACP file access error ; RMS$_ACT file activity precludes operation ; RMS$_DAC file deaccess error ; RMS$_DNF directory not found ; RMS$_DNR device not ready ; RMS$_FLK file locked; not available ; RMS$_FNF no such file exists ; RMS$_PRV file protection violation ; RMS$_WLK device write-locked ; ; Side Effects: ; The file is OPEN'ed with GET access and SHR for GET access by ; other users. ; ;- .ENTRY RMS_GET_VRNSIZ,^M ; MOVAB TMPFAB,R3 ;Get address of FAB ; ; Set FAB fields for the file specification and default file specification ; strings. ; MOV.STR @filspec(AP),- ;Move string size/address to FAB of FAB$B_FNS(R3),FAB$L_FNA(R3),99$ ; the file specification. CLRB FAB$B_DNS(R3) ;Assume no default spec. TSTL dftspec(AP) ;Was a default file spec given? BEQL 10$ ;If none, go do file OPEN MOV.STR @dftspec(AP),- ;Yes, move string size/address to FAB FAB$B_DNS(R3),FAB$L_DNA(R3),99$ ; of the default specification ; ; Open the file, but no record stream will be connected. ; 10$: $OPEN fab=R3 ;Open the file BLBC R0,99$ ;Exit on any RMS error ; ; Extract the information from the XAB and NAM blocks to return to caller. ; MOVL TMPXAB+XAB$L_EBK,- ;Get end-of-file block number to return @length(AP) ; as the file's size TSTW TMPXAB+XAB$W_FFB ;Check the first free byte (in block) BNEQ 15$ ;Is the EOF block used at all? DECL @length(AP) ;No, decrement length by 1 block 15$: MOVAB TMPNAM,R0 ;Get NAM block address DECB NAM$B_VER(R0) ;Decrement version field length to not ; count the ";" PUSHAL @version(AP) ;Address of longword to return version ADDL3 #1,NAM$L_VER(R0),-(SP) ;Address of version number text without ; the leading ";" MOVZBL NAM$B_VER(R0),-(SP) ;Length of version number itself CALLS #3,G^LIB$CVT_DTB ;Convert decimal ASCII to binary ; ; Close the file ; $CLOSE fab=R3 ; 99$: RET .END