.MCALL .MODULE .MODULE OPENW,VERSION=05,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 and macro definitions. ;+ ;External macro library calls. ;- .MCALL .ENTER, .SERR, .HERR, .PURGE .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ;Define FDB offsets FERDF$ ;Define file service error codes DEFIN$ ;Definitions for IND files .PSECT $OPENW .SBTTL $OPENW - open file for write ;+ ;$OPENW ;This routine creates the specified file. ; ; Input: R1 -> address of FDB ; R2 -> address of 5 word RAD50 file specification ; The 5th word of the file specification is the size indicator. ; -1 = allocate largest empty space on the device. ; 0 = allocate half the largest empty space or the entire ; second largest empty space whichever is larger. ; >0 = allocate a file of specified number of blocks. ; Output:R1 -> address of FDB ; R2 -> address of 5 word RAD50 file specification ; FDB initialized ; C-bit set if error ;- .ENABL LSB $OPENW::SAVE CALL $CKOFS ;Check for valid output device BCS 5$ ;Branch out if invalid ; SAVE R1 ;Save file entry address ; MOVB @R1,R1 ;Set up channel number .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) .SERR ;Avoid monitor taking control if error .ENTER #EMTBLK,@R1,R2,10(R2) ;Create the file BCS 1$ ;Branch out for error ; RESTOR R1 ;Restore file entry address BIT #SPECL$,F$STAT(R1) ;Special directory device? BEQ 111$ DEC R0 ;roll zero back to 65535 111$: MOV R0,F$BLKM(R1) ;Save maximum blocks in file .HERR ;Go back to monitor handling errors MOVB #F.OPNW,F$FLGS(R1) ;Mark file opened for write MOV #,F$ERR(R1) ;Store success message BR 5$ ;Clean up and return ;+ ;Routine to determine the type of error and process it. ;- 1$: 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 TST R2 ;What kind of error BPL 2$ ;Error from enter specific CMPB #<-6>,R2 ;No room on device BEQ 3$ ;Yes MOV #,R0 ;Assume I/O error CMPB #<-3>,R2 ;Directory I/O error BEQ 4$ ;Yes DEC R0 ;Make it unrecognizable to cause SPR BR 4$ ;Store error code and set c-bit 2$: DEC R2 ;Is there space for the file? BEQ 3$ ;Yes MOV #,R0 ;Duplicate entry in directory BR 4$ ;Set c-bit,restore reg and return 3$: MOV #,R0 ;Store device full error 4$: MOV R0,F$ERR(R1) ;Store in current FDB SEC ;Make sure bit is set 5$: RESTOR RETURN .DSABLE LSB .END