magic cookies given back by ftell, and used in fseek
Dave Jones
djones at megatest.UUCP
Thu May 26 16:58:40 AEST 1988
in article <129 at lakart.UUCP>, dg at lakart.UUCP (David Goodenough) says:
>
> There has been much discussion in this group on the fact that on certain
> systems (VMS I believe), ftell & fseek use magic cookies to tell about
> file position. I have my asbestos suit ready if this suggestion is out of
> line, but have the ANSI comittee considered providing some means to convert
> from cookie format to and from character position in file.
The problem is that some operating systems have file-format built into
them :-(, whereas UNIX has unformated byte-streams :-).
One example is to store "lines" in variable length records, prefixed by a
line-length number. So now if the devil chooses a byte-count offset x, and
says fseek(x), you've got to do some pretty fancy stepping to find the
correct record and offset into it. For such a file, ftell would
presumably return a magic cookie which codes for record number and
offset.
Sigh.
-- Dave J.
More information about the Comp.lang.c
mailing list