1.0 Open a file (extended) ____ _ ____ __________ ********** * fopenx * ********** NAME: fopenx -- Open a file (extended) SYNOPSIS: FILE * fopenx(name, mode, inisiz, recsiz); char *name; /* File to open */ char *mode; /* Open modes */ int inisiz; /* initial size of file */ int recsiz; /* record size for random access files */ DESCRIPTION: Fopenx is an extended version of the standard DecusC fopen routine. It opens a new or existing file in the indicated mode: r Read the existing file sequentially w Create and write the file sequentially a Append to the file n Not record oriented u RSX-mode "unbuffered i/o" "eXtended" modes are: m Open existing file for modification p Preallocate file size x Open file as a random access file s Open file for shared access Either "r", "w", "a" or "m" must be given. "n" and "u" are optional. "n" should be given for "binary" files. Note that "n" mode will create fixed-block records on RSX systems with record size 512. Inisiz must be 0 unless the "p" option is given, then it should be the initial number of blocks to be allocated for the file. A positive value for inisiz requests a contiguous file, a negative value gives a non-contiguous file. Recsiz must be 0 unless the "x" option is given, then it is the record size for a random access file. The size should be given in bytes. Page 2 fopenx Open a file (extended) The "p" and "x" options are only valid when creating a new file. Note that "n", "u", "m", "p" and "x" are not compatible with other Unix systems. IMPLEMENTATION DETAILS: On RSX, "u" mode files will be created with the "variable-length" attribute. On RSX, if the record type bits in the record attribute byte (F.RATT in the FDB) is zero, the file will be read as if the "n" was specified. Files created with the "x" option also have the F.RATT byte set to 0. Note that, if the file contains carriage-return line-feed sequences, the entire sequence will be passed to the user's program. If record attributes are understandable, the carriage-return will be deleted from sequences. Don't use fopenx on non-disk devices, the results are unpredicatable. Fopenx() returns NULL on errors -- $$ferr gets an error code. On RSX, this will be the FCS error code. Note that "no buffer space available" (IE.NBF or E$$NSP) and "invalid lun" (IE.ILU or E$$NOC) may be generated by fopen. The same file may not be used for both reading and writing except if the program writes a disk file and uses fgetb and fputb. As with the standard DecusC fopen, using regular sequential io (fget,fput) will work only if you write, then repositions and reads it using ftell()/fseek(). In this case, the program should call rewind() or freopen() to reinitialize the file before using fseek(). You can get the status block info from FCS by defining $$stbk as an external word array. Look in the FCS manual for the meaning of each word. Note this value is volatile, the next fopenx overwrites it. BUGS: Only works with RSX FCS. You need to known what your doing.