Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: FILE * is opaque so now what ?
To:
tech@openbsd.org, millert@openbsd.org
Date:
Thu, 16 Jul 2026 17:00:45 +0200

Download raw body.

Thread
On Thu, Jul 16, 2026 at 04:57:09PM +0200, Marc Espie wrote:
> 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.

Not portable, but see __freadptr(3)

> 
> 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 ?
>