Gnulib modules: freadable, fwritable, freading, fwriting
The freadable function returns
true if the given stream supports reading,
false if it supports only writing,
i.e. if it was opened write-only or append-only.
The fwritable function returns
true if the given stream supports writing,
false if it supports only reading.
The freading function returns
true if the given stream is opened read-only,
or if the last operation on the stream was a read operation.
The fwriting function returns
true if the given stream is opened write-only or append-only,
or if the last operation on the stream was a write operation.
freading and fwriting will never both be true
on the same stream at the same time.
If the stream supports both reads and writes, then
freading and fwriting might be false
when the stream is first opened, after read encounters EOF,
or after fflush,
freading might be false or true and fwriting might be false
after repositioning (such as fseek, fsetpos, or rewind),
depending on the underlying implementation.