.TITLE RMS_RELATED Setup a related file NAM block for RMS_PARSE .IDENT /V01.01/ ;++RMSRELATD.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) routines for ; High Level Language access to RMS services. ; ; Abstract: ; Construct a NAM block for a related file specification for a later ; call RMS_PARSE. ; ; 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 provide related file processing for ; output files used in RMS_PARSE ; V01.01 15-Apr-83 FJN Standardizing help comments ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $FABDEF ;Define FAB offsets and constants $NAMDEF ;Define NAM offsets and constants $SSDEF ;System condition code values .CROSS ; ; Local Macros: ; .MACRO GET.STRING input_descr,out_byt_len,out_txt_addr,error ;Get input string using the input ; string descriptor MOVAQ input_descr,R0 ;Get address of input descriptor JSB G^LIB$ANALYZE_SDESC_R2 ;Analyze the descriptor, returning: BLBC R0,error ; status code (branch to error code), MOVB R1,out_byt_len ; string length (treat as byte), and MOVL R2,out_txt_addr ; address of the string's text. .ENDM GET.STRING ; ; Equated Symbols: ; nargs = 0 ;Offset to number of arguments fil_spec = 4 ;Offset to the address of the string ; descriptor of the file specification ; to be "parsed" dft_spec = 8 ;Offset to the address of the string ; descriptor of the default file ; specification. input_type = 12 ;Offset to the input file type argument .PAGE .SUBTITLE Impure data storage ; ; Read/write (inpure) local data program section ; .PSECT _RMS_DATA,PIC,USR,CON,REL,LCL,NOSHR,NOEXE,WRT,RD ; ; Save area for NAM pointer from RMS_GZ__PARSE.FAB block ; SAVE_NAM: .BLKL 1 ; ; Declare internal space for the resulting string text ; EXP_TEXT: .BLKB NAM$C_MAXRSS ;For expanded file string RES_TEXT: .BLKB NAM$C_MAXRSS ;For resultant file string ; ; NAMe block to return expanded string specification used in the internal ; $PARSE and to be the related file NAM block for the RMS_PARSE call. ; NAMB: $NAM ESA=EXP_TEXT,ESS=NAM$C_MAXRSS,- RSA=RES_TEXT,RSS=NAM$C_MAXRSS ; ; Program section for code ; .PSECT _RMS_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE Parse file specification to form related file NAM block ;+0RMS_RELATED ; ; Functional Description: ; This routine is to be called before a call to RMS_PARSE. It sets up ; a related file NAM block for the RMS_PARSE operation. ; ; Calling Sequence: ; status = RMS_RELATED( file_spec [,dft_spec] [,input_type] ) ; ; Input Parameters: ; file_spec - address of a string descriptor of the file specification to ; be parsed for the related file specification for a later ; RMS_PARSE call. ; dft_spec - (optional) address of a string descriptor of a second file ; specification for default resolution for the above file ; specification. ; input_type - (optional) set the value of this argument to 1 to indicate ; that the RMS_PARSE will be for an input file and so the ; OFP bit in the file options (FOP of FAB) will not be set. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; status - VMS completion status code returned in register R0. ; ; Implicit Outputs: ; RMS_GZ__PARSE.FAB - FAB block used in RMS_PARSE is also used here and ; restored except (possibly) for setting of OFP bit ; in the file options (FOP) longword. ; RMS_GZ__PARSE.NAM - RLF field is set to point to the internal NAM block ; (NAMB) as the related file NAM block. ; ; Condition Codes: ; RMS$_NORMAL Operation successful. ; LIB$_INVSTRDES Invalid string descriptor. ; RMS$_DNF Directory not found. ; RMS$_DNR Device not ready or not mounted. ; RMS$_WCC Invalid wild card context value ; ; Side Effects: ; Must be called before the RMS_PARSE call for which the specified file ; specification is to form the related file specification. ; ;- ;+ RMS_RELATED ; Used before a call to RMS_PARSE to setup a related file name block (NAM) ; for the $PARSE operation to be done in the RMS_PARSE. ; ; status.wlc.v = RMS_RELATED( file_spec.rt.dx [,dft_spec.rt.dx] ; [,inp_type.rlu.v] ) ; ; status completion status code. Passed by value. ; ; file_spec the file specification used to form the related file ; specification. Passed by descriptor. ; ; dft_spec (optional) a second file specification to provide defaults. ; Passed by descriptor. ; ; inp_type (optional) if value is TRUE (1), then the RMS_PARSE call ; is considered to be for an input file and the Output File ; Parse (OFP) in the file options will not be set. ; Passed by value. ; ; By default, the following RMS_PARSE call is considered to be for an ; output file parse and so the OFP file option is enabled (override with ; the inp_type argument). ; ;2 Condition_codes ; ; RMS$_NORMAL Success (no rtn_spec argument). ; SS$_NORMAL Success (expanded specification returned in rtn_spec). ; LIB$_STRTRU Success, expanded string truncated to fit in output ; parameter string (rtn_spec). ; LIB$_FATERRLIB Fatal internal library error. ; LIB$_INSVIRMEM Insufficient virtual memory. ; LIB$_INVSTRDES Invalid string descriptor. ; RMS$_DNF Directory not found. ; RMS$_DNR Device not ready or not mounted. ; RMS$_WCC Invalid wild card context value ; ;- .ENTRY RMS_RELATED,^M ; MOVAB RMS_GZ__PARSE.FAB,R3 ;Get address of FAB used in RMS_PARSE MOVAB NAMB,R4 ;Get address of internal NAM block MOVL FAB$L_NAM(R3),SAVE_NAM ;Save NAM address from FAB MOVAB B^RESTORE_NAM,(FP) ;Setup condition handler to restore NAM MOVL R4,FAB$L_NAM(R3) ;Point FAB at our internal NAM block ; ; Move address and length of file specification into FAB ; GET.STRING @fil_spec(AP),FAB$B_FNS(R3),FAB$L_FNA(R3),99$ $FAB_STORE FAB=(R3),DNS=#0 ;Init FAB to no default file spec. CMPB #2,nargs(AP) ;Was dft_spec argument specified? BGTR 10$ ;If not, then skip to parse file spec. ; ; Else move address and length of default file specification into FAB ; TSTL dft_spec(AP) ;Is there a default string specified? BEQL 10$ ;If defaulted treat as no defaults GET.STRING @dft_spec(AP),FAB$B_DNS(R3),FAB$L_DNA(R3),99$ ; ; Now "parse" the file specification (fill in the NAM block). ; 10$: $PARSE FAB=(R3) BLBC R0,50$ ;"Immediate" exit if $PARSE error ; ; Related file parsed successfully, set the OFP bit in the FAB block unless ; overridden by the inp_type argument and setup pointer in RMS_PARSE's NAM ; block to our (related file) NAM block. ; CMPB #3,nargs(AP) ;Is there an input_type argument? BGTR 20$ ;If not, set OFP bit in file options BLBS input_type(AP),30$ ;Will it be an input file parse? 20$: BBSS #FAB$V_OFP,FAB$L_FOP(R3),30$ ;Setup for output file parse 30$: MOVL R4,RMS_GZ__PARSE.NAM+NAM$L_RLF ;Set related file NAM block. ; ; Fake a "resultant" file specification in the NAM using the expanded file ; specification from the $PARSE operation. ; MOVB NAM$B_ESL(R4),NAM$B_RSL(R4) ;Move string length and MOVL NAM$L_ESA(R4),NAM$L_RSA(R4) ; its text address ; ; Restore NAM pointer in FAB to previous value. ; 50$: MOVL SAVE_NAM,FAB$L_NAM(R3) ;Restore old NAM pointer to FAB 99$: RET .PAGE .SUBTITLE Condition handler to restore FAB's NAM pointer and unwind ;+0RESTORE_NAM ; ; Functional Description: ; Internal condition handler to restore FAB (NAM pointer back to the ; NAM block used internally to RS_PARSE) in case of an exception during ; the execution of the RMS_RELATED routine. ; ; Calling Sequence: ; status = RESTORE_NAM( signal_args, mechanism_args ) ; ; Input Parameters: ; signal_args - the address of a vector of longwords indicating the ; nature of the signalled condition ; mechanism_args - the address of a vector of longwords that indicate the ; state of the process at the time of the signal. ; ; Implicit Inputs: ; SAVE_NAM - contains the original NAM block address saved from the FAB ; ; Output Parameters: ; status - completion status code ; ; Implicit Outputs: ; RMS_GZ__PARSE.FAB - restore original NAM block address ; ; Condition Codes: ; SS$_RESIGNAL - resignal condition ; ; Side Effects: ; Unwinds stack to caller of RMS_RELATED. ; ;- RESTORE_NAM: .WORD ^M<> MOVL SAVE_NAM,RMS_GZ__PARSE.FAB+FAB$L_NAM ;Restore old NAM pointer $UNWIND ;Unwind stack to caller of RMS_RELATED MOVZWL #SS$_RESIGNAL,R0 ;"resignal" the condition. RET .END