.MCALL .MODULE .MODULE OPENR,VERSION=07,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL Macros, macro definitions. ;+ ;External macro library calls. ;- .MCALL .LOOKUP, .SERR, .HERR, .PURGE, .CSTAT .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ;Define FDB offsets FERDF$ ;Define file service error codes DEFIN$ ;Definitions for IND files .PSECT $OPENR .SBTTL $OPENR - Open file for read ;+ ;$OPENR ;This routine determines if the specified file exists ; ; Input: R1 -> address of FDB ; R2 -> address of 4 word RAD50 file specification ; ; Output: R1 -> address of FDB ; R2 -> address of 4 word RAD50 file specification ; FDB is initialized ; C-BIT set if error otherwise it is clear ;- .ENABL LSB $OPENR::SAVE CALL $CKIFS ;Check for valid input device BCS 5$ ;Exit this routine if error CALL ISFLST ; file-structured? BEQ 2$ ; can't do this if not SAVE R1 ;Save file entry address MOVB @R1,R1 ;Set up channel number .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) .SERR ;Retain program control .LOOKUP #EMTBLK,R1,R2 ;Look up the file BCS 3$ ;Error occured SAVE R0 ; save file size .CSTAT #EMTBLK,R1,#CSIBLK ;Get device name and unit number MOV CSIBLK+12,R0 ;Get handler name, MOV CSIBLK+10,R1 ; and unit number CALL $DEVTR ; translate to 64-unit compatible MOV R0,R2 ; move result to R2 RESTOR R0 ;Restore file size BNE 15$ ;branch if normal DEC R0 ; If zero, it's SPECL$ and unknown 15$: RESTOR R1 ;Restore file entry address MOV R2,F$DNAM(R1) ;store device name 2$: MOVB #,F$FLGS(R1) ;Mark file opened for read MOV R0,F$BLKM(R1) ;Save maximum blocks in file MOV #,F$ERR(R1) ;Store success code .HERR ;Make monitor handle serious errors BR 5$ ;Clean up and exit ;+ ;Routine to determine the type of error and process it. ;- 3$: MOVB @#52,R2 ;Save error return .PURGE R1 ;Clean up channel on error RESTOR R1 ;Restore file entry address .HERR ;Go back to monitor handling errors MOV #,R0 ;Assume file not found TST R2 ;What kind of error BPL 4$ ;Error from lookup specific MOV #,R0 ;Assume I/O error CMPB #<-3>,R2 ;Directory I/O error BEQ 4$ ;Yes MOV #<-1>,R0 ;Make it unrecognizable to cause SPR 4$: MOV R0,F$ERR(R1) ;Store in current FDB SEC ;Make sure bit is set 5$: RESTOR RETURN .DSABLE LSB .END