Subject: Re: How to translate this stdio code to netbsd?
To: None <>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
List: current-users
Date: 03/10/1996 08:05:54
(By the way, something's wrong with some mailer.  The message I
received had in its headers

> Received: from phyhammer by (8.7.4/8.6.12) with SMTP id HAA00107 for <current-users@NetBSD.ORG>; Sat, 9 Mar 1996 07:57:31 -0500 (EST)
> Received: (from chammer@localhost) by phyhammer (8.6.12/8.6.12) id OAA05007 for current-users@NetBSD.ORG; Fri, 8 Mar 1996 14:54:19 GMT
> From: Carsten Hammer <chammer@phyhammer>
> Message-Id: <199603081454.OAA05007@phyhammer>

Not putting a FQDN after the @ is rather badly broken....)

> perhaps some kind soul i willing to enlighten me how to translate
> this code to netbsd style:

> FILE *f;
> charr *base, *ptr;
> int cnt;
> #ifdef __linux__
>     base = (char *)f->_IO_read_base;
>     ptr = (char *)f->_IO_read_ptr;
>     cnt = ptr - base;
> #else
>     base = (char *)f->_base;
>     ptr = (char *)f->_ptr;
>     cnt = f->_cnt;
> #endif

This is a gross abuse of the interface.  There is no guarantee that any
particular stdio implementation even _has_ structure elements allowing
the equivalent of the above, and indeed, ideally the FILE type would be
completely opaque to client code.

> what is the pseudonym of _IOEOF, _IOMYBU and _IOERR on netbsd?

Oh, even worse.  This is more looking-under-the-hood of stdio, and
again, there is no assurance that any particular implementation has any
analog of those.

> PS: it is maybe ridiculous to "translate" this to netbsd.

It is probably possible; NetBSD's stdio is designed in such a way that
you can look at its internals from client code, and based on a quick
skim it seems to have analogs of the above.  However, I strongly
recommend instead eliminating the code's dependence on being able to
look inside a FILE; it's only asking for future trouble as it is.  If
you really want to, go read /usr/include/stdio.h....

					der Mouse