From: MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 15-APR-1992 18:40:23.10 To: INFO-VAX@KL.SRI.COM CC: Subj: re: C & shared file & fseek & !RMS I need a file format and access mode which allows: 1: seeks to any file position (actually, record) up to the end of file, Do you want to seek to any position or any record? There's a BIG difference! 2: sharing between a writer/reader process and a reader process. The file will contain binary data with a fixed (record) size. According to the VMS manuals: 3: shared files must have a record format (footnote for creat function, table of optional file attributes), Well, not quite. EVERY file on VMS has a record format. What you are trying to say is that you must use record access mode to do sharing. 4: the VAX C RTL functions can only access sequential file organization (intro to C RTL, Chapter 1); I don't think this causes a problem for me, it only means the file must be a sequence of records (no unused records). So I think I need a fopen (or open) which specifies: ctx = rec (force record-mode access to allow sharing; I assume the file will be sequential records), mrs = , rat = (i.e., don't specify a record attribute since data is binary), rfm = fix (fixed length record format), shr = get,put (all readers specify get,put and writer specifies get) So far, so good. But, with *record format* files an fseek (fsetpos) must be to a location returned by ftell (fgetpos); otherwise "unpredictable behavior" occurs (description of ftell function). What I'd like to avoid is keeping a ftell (fgetpos) value for every record in my file. I'd like to have a fseek function which simply takes a record number instead of an ftell return value. A relative or absolute record number would be OK. This being impossible, what are my alternatives (surely someone has done this...)? What you've just described is (essentially) an RMS relative file. It has a series of records which are accessed by number. Unfortunately, they can't be used with the VAX C I/O system. I guess I should say I also want to avoid direct calls to the RMS functions, but that's only because I want to keep the program simple for the eventual maintainers of the code. I could be persuaded to make their lives more miserable (if that's possible...) by dropping in some RMS stuff, but I'm fearful they'll put a curse on my children :-). I'm afraid the combination of functions you want really can't be done any other supported way. If you are willing to go UNsupported, the format of the value returned by ftell for files with fixed-length records is very simple and you should be able to figure it out with minimal effort. Then you can construct your own values. In theory, the format might change; in practice, that's very unlikely. Your choice. BTW, the RMS alternative wouldn't be very complex, and could easily be hidden behind a couple of functions that could easily be re-implemented on other systems. -- Jerry