The
fopencookie
function
associates a stream with up to four
"
I/O functions".
These
I/O
functions will be used to read, write, seek and
close the new stream.
In general, omitting a function means that any attempt to perform the
associated operation on the resulting stream will fail.
If the write function is omitted, data written to the stream is discarded.
If the close function is omitted, closing the stream will flush
any buffered output and then succeed.
The calling conventions of
read,
write,
and
close
must match those, respectively, of
read(2),
write(2),
and
close(2)
with the single exception that they are passed the
cookie
argument specified to
fopencookie
in place of the traditional file descriptor argument.
The
seek
function updates the current stream offset using
*offset
and
whence.
If
*offset
is non-NULL, it updates
*offset
with the current stream offset.
fopencookie
is implemented as a thin shim around the
funopen(3)
interface.
Limitations, possibilities, and requirements of that interface apply to
fopencookie.