RSX RSX HEADER FILE MACRO V05.04 Friday 04-Oct-91 09:35 Page 1 1 .TITLE RSX RSX HEADER FILE 2 ; 3 ; Created by MMAKLB.CMD on 10-JUN-91 at 13:27:14 4 ; 5 000001 RSX = 1 ;Assemble for RSX 6 000000 C$$FLT = 0 ;Double precision default 7 000001 VMS3.0 = 1 ;Assemble VMS release-specific code 8 000010 N$$FIL = 8. ;Default number of block buffers 9 000004 C$PMTR = 4 ;Locally define C$PMTR and C$AUTO 10 177772 C$AUTO = -6 ;To minimize global symbol references Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2 1 .title fopen C library file opener 2 .ident /000042/ 3 ; 4 ;+ 5 ; 6 ; Index Open or reopen a file 7 ; 8 ; Usage 9 ; 10 ; FILE * 11 ; fopen(name, mode); 12 ; char *name; /* File to open */ 13 ; char *mode; /* Open modes */ 14 ; 15 ; FILE * 16 ; freopen(name, mode, iop); 17 ; char *name; /* File to open */ 18 ; char *mode; /* Open modes */ 19 ; FILE *iop; /* I/O pointer */ 20 ; 21 ; Internal 22 ; 23 ; mov iov,r4 ;r4 -> iov 24 ; jmp $$fopn ;Open the file and return to the 25 ; ;caller via $$fopx or $$fope if error. 26 ; ;On RSX, fixup append mode if the file 27 ; ;wasn't found. 28 ; 29 ; mov iov,r4 ;r4 -> iov 30 ; call $$fopo ;Normal open, then exit via $$fopx 31 ; ;On RSX, $$fopo returns if any error 32 ; ;occurred. On return, r0 := RSX error code. 33 ; 34 ; mov iov,r4 ;r4 -> iov, file is open 35 ; jmp $$fopx ;Normal exit from fopen 36 ; ;On RSX, $$fopx allocates the record 37 ; ;buffer. 38 ; 39 ; mov iov,r4 ;r4 -> iov (or r4 == 0) 40 ; mov code,r0 ;r0 := error code (to go to $$ferr) 41 ; jmp $$fope ;Error exit from fopen 42 ; ;$$fope deallocates buffers 43 ; 44 ; Description 45 ; 46 ; Fopen opens a new or existing file in the indicated mode: 47 ; 48 ; r Read the existing file sequentially 49 ; w Create and write the file sequentially 50 ; a Append to the file 51 ; n Not record oriented 52 ; u RSX-mode "unbuffered i/o" 53 ; RT11-mode: use .ttyin and .ttyout 54 ; 55 ; 56 ; Either "r", "w", or "a" must be given. "n" and "u" are 57 ; optional. "n" should be given for "binary" files. Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2-1 58 ; Note that "n" mode will create fixed-block records on 59 ; RSX systems. Append mode does not work on native RT11. 60 ; 61 ; Note that "n" and "u" are not compatible with other 62 ; Unix systems. 63 ; 64 ; Implementation Details 65 ; 66 ; On RSX, "u" mode files will be created with the 67 ; "variable-length" attribute. On RSTS/RSX emulation, text 68 ; files (neither "n" nor "u" specified) will be created with 69 ; "stream" attribute. 70 ; 71 ; On RSX, if the record type bits in the record attribute byte 72 ; (F.RATT in the FDB) is zero, the file will be read as if 73 ; the "n" was specified. Note that, if the file contains 74 ; carriage-return line-feed sequences, the entire sequence 75 ; will be passed to the user's program. If record attributes 76 ; are understandable, the carriage-return will be deleted 77 ; from sequences. 78 ; 79 ; On RSX, if the "file" is being opened for write to the same 80 ; device/unit 81 ; as stderr (the user's "command console), the character stream is 82 ; diverted to stderr. This avoids synchronization problems by 83 ; funnelling all output through the same buffer. In 84 ; addition, output to any terminal device is done via QIO's to 85 ; the terminal, IO.WLB for normal mode, IO.WAL for "n" mode. 86 ; 87 ; On RT11, when opening a file for writing, a specific block 88 ; allocation may be included in the Ascii file specification 89 ; following standard RT-11 syntax: "DKn:file.nam[nnn]" where the 90 ; "nnn" specifies the number of blocks to allocate to the file. 91 ; After opening a file successfully, the actual file size (or 92 ; number of blocks allocated) will be found in (FILE *)fd->io_size. 93 ; 94 ; If the RT11 library decides that the file is really the user's 95 ; command terminal, single-character I/O will be performed (by 96 ; calling .ttyin and .ttyout). Note that the "special-mode" 97 ; bits must be set in the Job Status Word by the program if it requires 98 ; true single-character or immediate return input. Output to the 99 ; terminal will be performed without buffering, which is useful 100 ; for screen updating, but otherwise expensive. 101 ; 102 ; Fopen() returns NULL on errors -- $$ferr gets an error code. 103 ; On RT11, this will be a RSTS/E compatible code (described in 104 ; iov), while on RSX, this will be the FCS error code. 105 ; 106 ; On RT11, the file name pointed to by the "io_name" field of 107 ; the iov is either the file name string as passed to fopen() 108 ; or an ascii string reconstructed from the 4-word Rad50 109 ; device block if the file was opened as part of a fwild/fnext 110 ; sequence. By saving the ascii string, RSTS/E is able to 111 ; re-parse logical device names and PPN's, which are not present 112 ; on native RT11. 113 ; 114 ; On VMS compatibility mode, the device and directory of the Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2-2 115 ; file name argument are saved in the iov "io_dname" 116 ; field for use by fgetname(). 117 ; 118 ; Note that "no buffer space available" (IE.NBF or E$$NSP) and 119 ; "invalid lun" (IE.ILU or E$$NOC) may be generated by fopen. 120 ; On RT11, if the file cannot be opened because the user's program 121 ; has already opened the channel, an E$$ILU error will be returned. 122 ; 123 ; The same file may not be used for both reading and writing 124 ; except if the program writes a disk file, then repositions 125 ; and reads it using ftell()/fseek(). In this case, the program 126 ; should call rewind() or freopen() to reinitialize the file before 127 ; using fseek(). 128 ; 129 ; Except in the one specific case of the RT11 console terminal 130 ; open in "u" mode, an open file must not be used for reading 131 ; and writing at the same time. 132 ; 133 ; Freopen() substitutes the named file in place of the open 134 ; file -- indicated by iop. The file currently open on 135 ; iop is closed. Freopen returns iop. If the open failed, 136 ; iop will be deallocated. Note that freopen loses any pending 137 ; fwild/fnext status. 138 ; 139 ; 140 ; Internal 141 ; 142 ; The following routines/globals are for use by fopen/fwild. 143 ; If any of these routines detect an error, they return to the 144 ; fopen() caller with an appropriate error code in $$ferr. 145 ; 146 ; $$fope Error exit from fopen 147 ; $$fopn Normal open, hack append 148 ; $$fopx Normal exit from fopen 149 ; 150 ; Warning: fopen() in RSX/RSTS mode uses unpublished information 151 ; to obtain the PPN [UIC] of an open file. This code (in iocsi.mac) 152 ; may require modification for subsequent releases of RSTS/E. 153 ; 154 ; Bugs 155 ; 156 ; Append mode cannot work on native RT11 given the design of the 157 ; RT11 file system. 158 ; 159 ; The RT11 file system does not support files greater than 160 ; 65535 blocks long. 161 ; 162 ; RT11 does not get the actual keyboard name of the console 163 ; terminal, although this isn't too hard to do on RT11/RSTS/E. 164 ; 165 ; Freopen() cannot be used to assign a file to stderr as there 166 ; is code throughout the i/o package for special treatment of 167 ; stderr. For example, it cannot be closed by a user-written 168 ; program. 169 ; 170 ; In RSX modes, the maximum number of files that may be simultaneously 171 ; open is defined at assembly time by a macro (FSRSZ$) which is Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2-3 172 ; expanded when fopen.mac is assembled. The default FSRSZ$ 173 ; parameter is 4. This may be modified by using the task builder 174 ; /ACTFIL=n option. The default FSRSZ$ value may be specified 175 ; when the RSX library is built by editing assembly parameter 176 ; N$$FIL in RSX.MAC. 177 ; 178 ; Internal 179 ; 180 ; This module contains release-specific code for VMS V3.0 to 181 ; enable Decus C programs to read "Ascii stream" files. 182 ; 183 ;- 184 ; 185 ; Edit history 186 ; 000001 24-Jul-79 MM Initial edit 187 ; 000002 10-Mar-80 MM Conversion for the newer library 188 ; 000003 27-Mar-80 MM Merged libraries 189 ; 000004 23-May-80 MM Added freopen(), changed RT11 stuff 190 ; 000005 10-Jun-80 MM Reorganized for fwild/fnext 191 ; NOTE: because of the reorganization, edit codes 192 ; have been removed from RSX fopen 193 ; 000006 15-Jun-80 MM More reorganization 194 ; 000007 22-Jun-80 MM Reorganized RT11 stuff. NOTE: because of the 195 ; reorganization, edit codes have been removed 196 ; from RT11 fopen. 197 ; 000008 02-Jul-80 MM Fixed dumb bug in $$flun 198 ; 000009 06-Jul-80 MM Added Stream under RSTS/E 199 ; 000010 09-Jul-80 MM Do a handler .fetch on RT11 200 ; 000011 10-Jul-80 MM Fixed typo in .dstatus call 201 ; 000012 18-Jul-80 MM Fixed up RT11 error status values 202 ; 000013 01-Aug-80 MM Track IOV changes 203 ; 000014 17-Aug-80 RBD Slight mods for RT11 fwild(). Changed stashed file 204 ; spec to the 4 word RAD50 CSI output 'dblk'. This 205 ; is consistent with fwild(), which does the same. 206 ; 000015 22-Aug-80 MM Reverted to storing an ascii file name for RT11. 207 ; This is needed to preserve logical device translation 208 ; for RSTS. There is some unfortunate hackery for 209 ; wild card files, as the 4-word device block must 210 ; be decompiled to ascii. No simple solutions. 211 ; 000016 04-Sep-80 MM Squeeze blanks from RT11 filenames 212 ; 000017 16-Sep-80 MM Get RSX Directory UIC 213 ; 000018 18-Sep-80 MM Bug in .parse call, fixed .psect names, added N$$FIL 214 ; 000019 22-Sep-80 RBD Minor changes (improvements) to uic handling. 215 ; 000020 23-Sep-80 MM Fix to RT11 file scan, removed VF$BAD 216 ; 000021 20-Oct-80 MM Bit by Standard Runoff on VMS -- missing attributes 217 ; 000022 24-Oct-80 MM Bit again. Missing attributes on VMS differnt 218 ; 000023 10-Dec-80 MM Changed vms test -- no functional changes 219 ; 000024 24-Dec-80 MM Use blank-squeezed RT11 filename (change 000016) 220 ; 000025 06-Jan-81 JSL Make append mode work on RT11/RSTS 221 ; 000026 17-Feb-81 MM Another runoff hack (see patch 21,22) This one's sick 222 ; 000027 02-Mar-81 MM $$fopo returns on any error. Needed for fwild() 223 ; 000028 14-Apr-81 MM Added "elephant directive" for VMS 224 ; 000029 02-Jun-81 RBD Enable tkb ACTFIL option 225 ; 000030 05-Aug-81 RBD Allow RT11 filesize, other hacks 226 ; 000031 07-Aug-81 MM "n" mode gives R.FIX output files 227 ; 000032 17-Aug-81 RBD Properly set VF$FIL on RSX. 228 ; 000033 21-Aug-81 MM Fix edit 31 (R.VAR for normal output on RSX or VMS) Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2-4 229 ; 000034 28-Aug-81 MM Branch becomes a JMP on RT11 230 ; 000035 14-Oct-81 MM Broken into lots of little modules 231 ; 000036 15-Jun-82 MM Stupendous vms v3.0 patch. 232 ; 000037 27-Jun-82 MM New library stuff: directory name, different offsets. 233 ; 000038 26-Jun-82 MM Terminal frob -- see IOPUT.MAC for the gory details. 234 ; 000039 04-Oct-82 MM Set VF$CMD bit if tty is open on same terminal as stderr 235 ; 000040 27-Oct-82 RBD Unterminal unfrob. See INIT.MAC for additional gore. 236 ; P.S ... Isn't it time for a rewrite of this mess?? (RBD) 237 ; Any volunteers? 238 ; 000041 22-Nov-82 TTC Fix append bug. Must clear read as well as append bit, 239 ; if get no such file error on first try. 240 ; 000042 14-Jan-83 MM Support stream (LF) files. 241 244 ; 245 ; Note the following tests (set in $$fopt) ;37+ 246 ; 247 ; reading: V$FLAG(r4) & VF$REA 248 ; writing: V$FLAG(r4) & VF$WRT 249 ; append: V$FLAG(r4) & VF$APN ;37- 250 ; 251 253 255 000020 F.BFHD == 20 ;For TKB so ACTFIL option works. ;29+ 256 ;When TKB gets to the psect expansion 257 ;section, if F.BFHD is not defined, 258 ;ACTFIL is ignored (F.BFHD is defined in 259 ;the fortran library). TKB adds the 260 ;value of F.BFHD + 512. (hard-wired), 261 ;multiplies this by ACTFIL, and makes 262 ;$$FSR1 this size. Happy now? ;29- 263 264 .MCALL FDBDF$, FDAT$R, FDOP$R 265 .MCALL FDBK$R, FDRC$R, FSRSZ$, FDOF$L 266 .MCALL OFNB$A, OFNB$R, OFNB$W 267 000000 FDOF$L 268 000004 R.STM = 4 ;Ascii stream (crlf) record format ;09 269 ;NOTE: R.STM is unpublished 270 ;WARNING: This bit has been known to 271 ;be set on VMS "Print format" files. 272 000005 R.STMLF = 5 ;Ascii stream record format. ;42+ 273 000006 R.STMCR = 6 ;Ascii stream record format (APL). 274 ;Note: these are unpublished and I'm just 275 ;guessing at the names. ;42- 276 277 000000 .psect c$data 278 ; 279 ; Since the RSX people do not understand reentrant coding, 280 ; the file system must be defined at assembly time. 281 ; 282 ; Note -- code in subroutine $$falo depends on the undocumented 283 ; fact that a dummy file data block is all zero. 284 ; 285 000000 FSRSZ$ N$$FIL ;Define block buffer area ;18 286 ; 287 000000 .psect c$code 288 000000 FREOPE:: 289 000000 004567 000000G JSR R5,CSV$ ;C save sequence Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 2-5 290 000004 016504 000010 MOV C$PMTR+4(R5),R4 ;Get IOV pointer 291 000010 010400 MOV R4,R0 ;Make R0 non-zero 292 000012 CALL $$CLOS ;Close file, keep IOV 293 000016 000403 BR FOPEN1 ;Continue with main sequence 294 ; 295 000020 FOPEN:: 296 000020 004567 000000G JSR R5,CSV$ ;C save sequence 297 000024 005004 CLR R4 ;Clear IOV pointer, too 298 000026 FOPEN1: ;Common code for fopen, freopen 299 000026 CALL $$FLUN ;Get a Lun 300 000032 CALL $$FOPT ;Scan options string 301 000036 CALL $$FCSI ;Parse the CSI string, setup the FDB 302 ;BR $$FOPN ;And open the file Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 3 304 ; 305 ; ** $$FOPN 306 ; 307 ; Open the file. This code is specific to fopen/freopen (and fwild if 308 ; no wildcards were found.) 309 ; 310 ; Note: if append and file-not-found, restart for writing 311 ; 312 000042 $$FOPN:: 313 000042 CALL $$FOPO ;Try to open it 314 000046 032764 000000G 000000G BIT #VF$APN,V$FLAG(R4) ;Oops, append mode? ;26+/37 315 000054 001412 BEQ 10$ ;No, return fatally 316 000056 120027 000000G CMPB R0,#IE.NSF ;Append, no such file? 317 000062 001007 BNE 10$ ;No, sorry. 318 000064 042764 000000C 000000G BIC #VF$REA!VF$APN,V$FLAG(R4) ;Clear out the mode bits ;37/41 319 000072 052764 000000G 000000G BIS #VF$WRT,V$FLAG(R4) ;Make it a write open ;37 320 000100 000760 BR $$FOPN ;And try, try, try. 321 322 000102 000167 000462 10$: JMP $$FOPE ;Sorry ;26-;35 Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 4 324 ; 325 ; ** $$FOPO 326 ; 327 ; Actually open the file which has been setup by $$FCSI (or fnext()) 328 ; If the file opened correctly, there is no return -- the program 329 ; exits to the fopen/fnext caller via $$fopx. On error, $$FOPO 330 ; returns to the caller with the error code in R0. 331 ; 332 000106 $$FOPO:: 333 000106 010400 MOV R4,R0 ;Get IOV 334 000110 062700 000000G ADD #V$FDB,R0 ;R0 -> fdb 335 000114 042764 000000G 000000G BIC #VF$NOS,V$FLAG(R4) ;Clear current VF$NOS ;26+/37 336 000122 032764 000000G 000000G BIT #VF$NLH,V$WFLG(R4) ;fopen/fwild (..., "n") ;37 337 000130 001403 BEQ 4$ ;Br if not 338 000132 052764 000000G 000000G BIS #VF$NOS,V$FLAG(R4) ;(re)set the bit ;37 339 ; 340 ; The above mess is needed if, on vms, the program executes fwild() and 341 ; the first file was a .MEM file (which has no attributes) while the 342 ; second file is a "vanilla" ascii file. (FOO.MEM, FOO.RNO). VF$NOS 343 ; is forced for FOO.MEM, but must be zero for FOO.RNO. Sorry, but it's 344 ; the best I could come up with. 345 ; 346 000140 4$: ;26- 347 000140 032764 000000G 000000G BIT #VF$NBF,V$FLAG(R4) ;User buffered? ;37 348 000146 001401 BEQ 10$ ;No, continue 349 ; 350 ; User-buffering. (The following may have to change) 351 ; 352 000150 FDRC$R R0 ;I/O via GET$ and PUT$ 353 000150 FDBK$R R0 ;No block buffers 354 000150 000407 BR DOOPEN ;Continue main sequence 355 ; 356 ; I/O package does buffering (record buffer in V$RBUF). 357 ; 358 000152 10$: 359 000152 032764 000000G 000000G BIT #VF$NOS,V$FLAG(R4) ;No newlines wanted? ;37 360 000160 001003 BNE 20$ ;Branch if so. 361 000162 FDAT$R R0,,#FD.CR ;Want them, so ask for it. 362 000170 20$: FDRC$R R0 ;Setup for GET$ or PUT$ 363 000170 FDOP$R R0 ;Initialize file open section 364 ; 365 ; Now for the fun part 366 ; 367 000170 DOOPEN: 368 000170 032764 000000C 000000G BIT #VF$WRT!VF$APN,V$FLAG(R4) ;Reading ;37 369 000176 001033 BNE 10$ ;Nope 370 000200 OFNB$R R0 ;Yep, try for it 374 000212 103473 BCS 40$ ;Error -- just exit 375 000214 005767 000000G TST $$VMS ;If not vms, 376 000220 001473 BEQ $$FOPX ;Exit normally. 377 ; 378 ; Check whether the file has stream-Ascii attributes. If so, change 379 ; the attributes to "fixed block, 512 byte records". 380 ; NOTE: init.mac contains code to patch the ".OFNB" (open by file name 381 ; block) routine in the RSX file control services to permit opening 382 ; stream files. This code may require revision for subsequent releases 383 ; of vms. Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 4-1 384 ; 387 000222 122710 000004 CMPB #R.STM,(R0) ;Stream file? 388 000226 003070 BGT $$FOPX ;No problems if small ;42+ 389 000230 122710 000005 CMPB #R.STMLF,(R0) ;Stream file? 390 000234 002465 BLT $$FOPX ;Bigger (R.STMCR) can't be handled ;42- 391 000236 012710 000000G MOV #R.FIX+<0*400>,(R0) ; Fixed length, embedded control. 392 000242 016060 000060 000002 MOV F.VBSZ(R0),F.RSIZ(R0) ; Set the record length, too. 393 000250 005001 CLR R1 ;Rewind the file 394 000252 012702 000001 MOV #1,R2 ;to clear out 395 000256 005003 CLR R3 ;the block buffer 396 000260 CALL .POINT ; 397 000264 000451 BR $$FOPX ;All done at last 399 ; 400 000266 032764 000000G 000000G 10$: BIT #VF$APN,V$FLAG(R4) ;Append? ;37 401 000274 001406 BEQ 20$ ;Nope, go open for write ;37 402 000276 OFNB$A R0 ;Try opening for append 403 000310 000433 BR 30$ ;Onward ;26 404 ; 405 000312 20$: 406 000312 032764 000000C 000000G BIT #VF$NOS!VF$NBF,V$FLAG(R4) ;"Binary" file? ;09+/37 407 000320 001007 BNE 24$ ;Br if so 408 000322 005767 000000G TST $$RSTS ;Stream, but is it RSTS? 409 000326 001414 BEQ 25$ ;No, do it in RSX style ;33 410 000330 FDAT$R R0,#R.STM ;It's an ascii file WARNING: unpublished. 411 000336 000413 BR 26$ ;Rejoin mainstream 412 413 000340 24$: ;09- 414 000340 032764 000000G 000000G BIT #VF$NBF,V$FLAG(R4) ;"u" mode (always variable length) ;31+/37 415 000346 001004 BNE 25$ ;Yes, do variable length 416 000350 FDAT$R R0,#R.FIX ;"n" mode, do fixed length output 417 000356 000403 BR 26$ ;Continue ;31- 418 419 000360 25$: ;True RSX or RSX/VMS stream output or 420 000360 FDAT$R R0,#R.VAR ;"u" or "un" -- do variable length 421 422 000366 26$: ;09 423 000366 OFNB$W R0 ;Go for it 424 ; 425 000400 30$: 426 000400 103003 BCC $$FOPX ;Any errors -- do final cleanup if not 427 000402 40$: 428 000402 116000 000052 MOVB F.ERR(R0),R0 ;Error code (sign extended) 429 000406 RETURN ;And let high-level stuff do it ;26 Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 5 431 ; 432 ; ** $$FOPX 433 ; 434 ; Normal exit from fopen(). Enter with r4 -> fdb. Returns to fopen 435 ; caller after allocating buffers and setting flag bits. Note: 436 ; the file has been successfully opened, but record buffers have not 437 ; been allocated. 438 ; 439 ; NOTE: If the file is being opened to the same device/unit as stderr, 440 ; the VF$CMD bit is set, indicating that the "file" is actually 441 ; just another channel to the user's "command console". Elsewhere, 442 ; output is diverted to stderr so all console output uses the 443 ; same buffer, nicely avoiding synchronization problems. Thank 444 ; you, Martin!. 445 ; 446 000410 $$FOPX:: 447 000410 052764 000000G 000000G BIS #VF$OPN,V$FLAG(R4) ;Mark opened for $$clos and fnext() ;37 448 000416 042764 000000G 000000G BIC #VF$EOR,V$FLAG(R4) ;Ensure not at end of file ;37 449 000424 016464 000060G 000000G MOV V$FDB+F.VBSZ(R4),V$RBSZ(R4) ;Get Virtual record size 450 000432 116400 000017G MOVB V$FDB+F.RCTL(R4),R0 ;R0 := Record flag bits 451 000436 005767 000000G TST $$VMS ;On vms? ;22/23 452 000442 001407 BEQ 5$ ;No, onward ;22/23 453 000444 132764 000007 000001G BITB #7,V$FDB+F.RATT(R4) ;Any attribute bits ;21+ 454 000452 001003 BNE 5$ ;Yes, continue 455 000454 052764 000000G 000000G BIS #VF$NOS,V$FLAG(R4) ;No, not stream ;21-/37 456 000462 5$: 457 000462 132700 000000G BITB #FD.DIR,R0 ;Is it a file 458 000466 001404 BEQ 10$ ;No, onward 459 000470 052764 000000G 000000G BIS #VF$FIL,V$FLAG(R4) ;A file, set bits ;37 460 000476 000431 BR 20$ ;And continue 461 462 000500 10$: 463 000500 132700 000000G BITB #FD.REC,R0 ;Record oriented device? ;32 464 000504 001426 BEQ 20$ ;No, onward ;32 465 000506 052764 000000G 000000G BIS #VF$REC,V$FLAG(R4) ;Record, no file. Flag same ;37 466 000514 132700 000000G BITB #FD.TTY,R0 ;True terminal? 467 000520 001420 BEQ 20$ ;No, continue 468 000522 052764 000000G 000000G BIS #VF$TTY,V$FLAG(R4) ;Yes, flag it ;37/38/39+/40 469 000530 016700 000000G mov stderr,r0 ; R0 --> stderr 470 ; 471 ; Check if the file is being opened to the same device/unit as 472 ; stderr. If so, indicate the file is open to the "console" 473 ; by setting VF$CMD (command terminal). 474 ; 475 000534 026460 000134G 000134G cmp V$FDB+F.FNB+N.DVNM(r4),V$FDB+F.FNB+N.DVNM(r0) ; Same name? 476 000542 001007 bne 20$ ; Branch if different devices 477 000544 026460 000136G 000136G cmp V$FDB+F.FNB+N.UNIT(r4),V$FDB+F.FNB+N.UNIT(R0) ; Same unit? 478 000552 001003 BNE 20$ ; (nope, not console) 479 000554 052764 000000G 000000G BIS #VF$CMD,V$FLAG(r4) ; Mark opening the console in FDB ;39- 480 481 000562 20$: 482 ;; NOTE: the record buffer is allocated by the first call to getch() ;37+ 483 ;; this allows the user to allocate his own buffer by calling setbuf() 484 ;; BIT #VF$NBF,V$FLAG(R4) ;User doing buffering? ;37 485 ;; BNE 30$ ;Yep, don't get buffer 486 ;; MOV V$RBSZ(R4),R0 ;Record buffer size 487 ;; INC R0 ;Just in case 'n' given Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 5-1 488 ;; CALL $$FALO ;Go for it -- note: if this fails, $$fcls 489 ;; ;will close the file. 490 ;; MOV R0,V$RBUF(R4) ;Set the first buffer 491 ;; MOV R0,V$BPTR(R4) ;and set free byte pointer ;37- 492 000562 30$: 493 000562 010400 MOV R4,R0 ;Return FILE pointer 494 000564 000167 000000G JMP CRET$ ;And exit C-style Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 7 520 ; 521 ; ** $$FOPE 522 ; 523 ; Error exit from fopen routines. If r4 is non-zero, the iov it points 524 ; to will be deallocated. 525 ; 526 ; Calling sequence: 527 ; 528 ; mov #IE.code,r0 ;Error code 529 ; jmp $$fope ;Jump here to die. 530 ; 531 000570 $$FOPE:: 532 000570 010067 000000G MOV R0,$$FERR ;Save error code 533 000574 005704 TST R4 ;Have we allocated an I/O vector? 534 000576 001403 BEQ 10$ ;No, just die. 535 000600 005000 CLR R0 ;Yes, force "full close" 536 000602 CALL $$FCLS ;Clean out buffers 537 000606 005000 10$: CLR R0 ;Return NULL 538 000610 000167 000000G JMP CRET$ ;Exit. 539 000001 .end Fopen C library file opener MACRO V05.04 Friday 04-Oct-91 09:35 Page 7-1 Symbol table CRET$ = ****** GX F.BKDN= 000026 F.NRBD= 000024 N.STAT= 000020 VF$OPN= ****** GX CSV$ = ****** GX F.BKDS= 000020 F.NREC= 000030 N.UNIT= 000034 VF$REA= ****** GX C$AUTO= 177772 F.BKEF= 000050 F.OVBS= 000030 PAR$$$= 000000 VF$REC= ****** GX C$PMTR= 000004 F.BKP1= 000051 F.RACC= 000016 RSX = 000001 VF$TTY= ****** GX C$$EIS= 000001 F.BKST= 000024 F.RATT= 000001 R.FIX = ****** GX VF$WRT= ****** GX C$$FLT= 000000 F.BKVB= 000064 F.RCNM= 000034 R.STM = 000004 VMS3.0= 000001 C$$SXT= 000001 F.CHR = 000075 F.RCTL= 000017 R.STMC= 000006 V$FDB = ****** GX DOOPEN 000170R 004 F.CNTG= 000034 F.RSIZ= 000002 R.STML= 000005 V$FLAG= ****** GX FD.CR = ****** GX F.DFNB= 000046 F.RTYP= 000000 R.VAR = ****** GX V$RBSZ= ****** GX FD.DIR= ****** GX F.DSPT= 000044 F.SEQN= 000100 STDERR= ****** GX V$WFLG= ****** GX FD.REC= ****** GX F.DVNM= 000134 F.SPDV= 000072 S.ANM1= 000014 XASCII= 000001 FD.TTY= ****** GX F.EFBK= 000010 F.SPUN= 000074 S.ANM2= 000005 $$CLOS= ****** GX FOPEN 000020RG 004 F.EFN = 000050 F.STBK= 000036 S.BFHD= 000020 $$FCLS= ****** GX FOPEN1 000026R 004 F.EOBB= 000032 F.UNIT= 000136 S.FATT= 000016 $$FCSI= ****** GX FO.APD= ****** GX F.ERR = 000052 F.URBD= 000020 S.FDB = 000140 $$FERR= ****** GX FO.RD = ****** GX F.EXT = 000072 F.VBN = 000064 S.FNAM= 000006 $$FLUN= ****** GX FO.WRT= ****** GX F.FACC= 000043 F.VBSZ= 000060 S.FNB = 000036 $$FOPE 000570RG 004 FREOPE 000000RG 004 F.FFBY= 000014 IE.NSF= ****** GX S.FNBW= 000017 $$FOPN 000042RG 004 FX.DIR= 000004 F.FLG = 000074 N$$FIL= 000010 S.FNTY= 000004 $$FOPO 000106RG 004 FX.DLN= 000003 F.FNAM= 000110 N.ANM1= 000002 S.FTYP= 000002 $$FOPT= ****** GX FX.DMX= 000002 F.FNB = 000102 N.ANM2= 000024 S.NFEN= 000020 $$FOPX 000410RG 004 FX.LEN= 000000 F.FTYP= 000116 N.DID = 000024 VF$APN= ****** GX $$RSTS= ****** GX F.ACTL= 000076 F.FVER= 000120 N.DVNM= 000032 VF$CMD= ****** GX $$VMS = ****** GX F.ALOC= 000040 F.HIBK= 000004 N.FID = 000000 VF$EOR= ****** GX .FSRCB= ****** G F.BBFS= 000062 F.LUN = 000042 N.FNAM= 000006 VF$FIL= ****** GX .OPFNB= ****** G F.BDB = 000070 F.MBCT= 000054 N.FTYP= 000014 VF$NBF= ****** GX .POINT= ****** GX F.BFHD= 000020 G F.MBC1= 000055 N.FVER= 000016 VF$NLH= ****** GX ...TPC= 000020 F.BGBC= 000057 F.MBFG= 000056 N.NEXT= 000022 VF$NOS= ****** GX . ABS. 000000 000 (RW,I,GBL,ABS,OVR) 000000 001 (RW,I,LCL,REL,CON) C$DATA 000000 002 (RW,I,LCL,REL,CON) $$FSR1 010200 003 (RW,D,GBL,REL,OVR) C$CODE 000614 004 (RW,I,LCL,REL,CON) Errors detected: 0 *** Assembler statistics Work file reads: 0 Work file writes: 0 Size of work file: 9990 Words ( 40 Pages) Size of core pool: 11356 Words ( 43 Pages) Operating system: RSX-11M/PLUS Elapsed time: 00:00:20.30 FOPEN,FOPEN=RSX,FOPEN