FILE * is opaque so now what ?

Marc Espie <[email protected]> Thu, 16 Jul 2026 16:57:09 +0200
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
I've run into a language (unicon) that wants to do FILE* level polls
by first checking whether there's something stored in the internal
FILE* read buffer.

Specifically, checking whether that the old f->_r field is zero or not.

Now, I know of ZERO ways to do that check portably.

Do we have something like that anywhere ? it looks like a legitimate
question, and I'd hate to have the only answer be "hey, put everything
in non-buffered mode and get direct access to the fds"


(for now, I've disabled that part of the code entirely)


As far as libc is concerned, what I now is fgetc + ungetc, which tends to
be blocking and hence not at all what we want ?