.TITLE RMS_FILESPEC Returns fields of parsed file specification .IDENT /V01.01/ ;++RMSFILSPE.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) routines for ; High Level Language access to RMS services. ; ; Abstract: ; Used with RMS_PARSE routine to parse a file specification and then ; return (as strings) selected portions of the resulting (expanded) ; file specification. ; ; Environment: ; Module stored in FERMILIB.OLB and linked in users' programs. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 22-Sep-82 ; ; V01.00 22-Sep-82 FJN Created to accompany RMS_PARSE and RMS_SEARCH ; V01.01 15-Apr-83 FJN Standardize help comments ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $LIBDEF ;Library completion status codes $NAMDEF ;Define offsets and max-size constants .CROSS ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; nargs = 0 ;Offset to number of arguments keyword = 4 ;Offset to address of string descriptor ; of keyword argument string = 8 ;Argument list offset to address of the ; output string descriptor length = 12 ;Argument list offset to the optional ; address of the word for the string ; length to be returned .PAGE .SUBTITLE Pure storage for keying tables ; ; Program section for code and pure data ; .PSECT _RMS_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY ; ; Table of keywords for the code arguments: ; ; Keyword: DEVICE DIRECTORY NODE NAME TYPE VERSION ; Search code: DE DI NO NA TY VE ; Index: 0 1 2 3 4 5 ; ; Table is a set of words, each with 2 ASCII characters (the search code). ; KEYS: .ASCII /DEDINONATYVE/ ; ; Table of the offsets to the string lengths in the NAM block. This table ; is in a one-to-one relationship to the search code (KEYS) table. ; LENS: .WORD NAM$B_DEV ;DE (device) .WORD NAM$B_DIR ;DI (directory) .WORD NAM$B_NODE ;NO (node name) .WORD NAM$B_NAME ;NA (file name) .WORD NAM$B_TYPE ;TY (file type) .WORD NAM$B_VER ;VE (file version) ; ; Table of the offsets to the string text addresses in the NAM block. This ; table is in a one-to-one relationship to the search code (KEYS) table. ; ADRS: .WORD NAM$L_DEV ;DE (device with :) .WORD NAM$L_DIR ;DI (directory with [] or <>) .WORD NAM$L_NODE ;NO (node name with ::) .WORD NAM$L_NAME ;NA (file name) .WORD NAM$L_TYPE ;TY (file type with leading .) .WORD NAM$L_VER ;VE (file version with leading ;) .PAGE .SUBTITLE Return selected fields of file specification ;+0RMS_FILESPEC ; ; Functional Description: ; After a call to RMS_PARSE or RMS_SEARCH, return specified fields ; from the expanded (RMS_PARSE) or resultant (RMS_SEARCH) file ; specifications. ; ; Calling Sequence: ; status = RMS_FILESPEC( keyword, string [,length] ) ; ; Input Parameters: ; keyword - address of a string descriptor for the keyword specifying the ; file specification field to be returned The recognized ; keywords are: DEVICE DIRECTORY NODE NAME TYPE VERSION. ; The keywords may be abbreviated to the 1st 2 characters. ; ; Implicit Inputs: ; RMS_GZ__PARSE.NAM - ; The NAM block setup by the RMS_PARSE or RMS_SEARCH call. ; ; Output Parameters: ; status - VMS completion status code returned in register R0. ; string - address of a string descriptor in which the field of the ; file specification identified by the keyword is returned. ; length - (optional) address of a word in which the length of the ; returned file specification string is also returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; SS$_NORMAL Operation successful ; LIB$_STRTRU Success, some returned string truncated to fit in its ; output string. ; LIB$_FATERRLIB Fatal internal library error. ; LIB$_INSVIRMEM Insufficient virtual memory. ; LIB$_INVSTRDES Invalid string descriptor. ; LIB$_UNRKEY Unrecognized keyword. ; ; Side Effects: ; NONE ; ;- ;+ RMS_FILESPEC ; Return specified fields of the file specification resulting from a ; previous call to RMS_PARSE or RMS_SEARCH. ; ; status.wlc.v = RMS_FILESPEC( keyword.rt.dx, string.wt.dx ; [,length.ww.r]) ; ; status completion status code returned in register R0. Passed ; by value. ; ; keyword text string specifying one of the file specification ; field keywords. Passed by descriptor. ; ; string string in which the field of the file specification ; indicated by the keyword argument is returned. Passed by ; descriptor. ; ; length word in which the length of the above string is also ; optionally returned. Passed by reference. ; ;2 Keywords ; The recognized keywords to be used in the keyword argument and the ; file specification fields they return are: ; ; DEVICE returns the device name (including trailing ":"). ; DIRECTORY returns the directory specification (including the ; enclosing brackets, "[]" or "<>"). ; NODE returns the node name (including trailing "::"). ; NAME returns the file name. ; TYPE returns the file type with a leading ".". ; VERSION returns the file version with a leading ";". ; ; The keywords may be abbreviated to the first 2 characters of the ; name. ; ;2 Condition_codes ; ; SS$_NORMAL Success. ; LIB$_STRTRU Success, some returned text truncated to fit in its ; output string. ; LIB$_FATERRLIB Fatal internal library error. ; LIB$_INSVIRMEM Insufficient virtual memory. ; LIB$_INVSTRDES Invalid string descriptor. ; LIB$_UNRKEY Unrecognized keyword. ; ;- .ENTRY RMS_FILESPEC,^M ; MOVAB RMS_GZ__PARSE.NAM,R6 ;Get address of NAM block used by ; RMS_PARSE and RMS_SEARCH ; ; Decode the keyword string descriptor and get 1st 2 characters of the keyword. ; MOVAQ @keyword(AP),R0 ;Get address of keyword descriptor JSB G^LIB$ANALYZE_SDESC_R2 ;Get keyword string length/address BLBC R0,99$ ;Immediate exit on error CMPW R1,#2 ;At least 2 characters in keyword? BLSSU 29$ ;If not, exit with unrecognized keyword ; ; Search for keyword in table, resulting in index to use in other tables. ; MOVW (R2),R2 ;Get 1st 2 keyword characters MOVL #5,R5 ;Search backwards in table 20$: CMPW R2,KEYS[R5] ;Keyword match this table entry? BEQL GOT_KEY ;If so, process return string SOBGEQ R5,20$ ;Loop over entire table 29$: MOVL #LIB$_UNRKEY,R0 ;Unrecognized key returned if too few ; characters or not in table 99$: RET ; ; Found valid keyword, have table index in R6 ; GOT_KEY: MOVZWL LENS[R5],R0 ;Get offset to field length byte MOVZBW (R6)[R0],R0 ;Use as NAM index to get text length CMPB nargs(AP),#3 ;Is there a length argument? BLSSU 10$ ;If not, just return the string TSTL length(AP) ;Yes, but was it defaulted? BEQL 10$ ;If so, ignore the length argument MOVW R0,@length(AP) ;Return string length also 10$: MOVZWL ADRS[R5],R1 ;Get offset to text address longword ADDL2 R6,R1 ;Get address of text address and MOVL (R1),R1 ; get the text address itself MOVAQ @string(AP),R2 ;Get address of output descriptor JSB G^LIB$SCOPY_R_DX6 ;Copy string to output RET ;Exit immediately if error .END