.MCALL .MODULE .MODULE CLOSE,VERSION=05,COMMENT= GLOBAL=C.LOSE ; 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 Macro definitions .MCALL .CLOSE, .PURGE .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ; DEFINE FDB OFFSETS FERDF$ ; DEFINE FILE SERVICE ERROR CODES DEFIN$ ;Definitions for IND files .PSECT C$LOSE .SBTTL C$LOSE - Close file / $PURGE - Purge channel ;+ ;C$LOSE ;This routine closes the channel associated with the specified FDB. ;If the file was opened for write, any remaining data is written to the file ;before closing. ; ;$PURGE ;This routine purges the channel associated with the specified FDB. ; ; Input: R1 -> Address of FDB ; ; Output: R1 -> Address of FDB ;- .ENABL LSB $PURGE::SAVE 1$: .PURGE @R1 ;Purge the channel .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) BR 4$ C$LOSE::SAVE CALL $CKOPN ;Is the file open? BCS 5$ ;Branch if no BITB #F.OPNW,F$FLGS(R1) ;File opened for write? BEQ 2$ ;Branch if no CMP R1,$OOWNR ;Is the output buffer ours? BNE 3$ ;Branch if no CLR $OOWNR ;Release the output buffer CALL $WRLST ;Write the last block to file BCS 5$ ;Branch if error BR 3$ 2$: CALL ISFLST ;Is device file structured? BEQ 4$ ;Branch if not CLR $IOWNR ;Release the input buffer 3$: CMP #<-1>,F$BLKN(R1) ;Any data? BEQ 1$ ;No, purge chan for no zero length blk .CLOSE @R1 ;Close the file .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) 4$: MOV #,F$ERR(R1) ;Success CLRB F$FLGS(R1) ;Mark file closed 5$: RESTOR RETURN .DSABL LSB .END