Subject: Re: How to translate this stdio code to netbsd?
To: None <current-users@NetBSD.ORG>
From: John F. Woods <jfw@FunHouse.com>
Date: 03/12/1996 23:28:20
>> As far as I can recall, all the code I've seen which tries to get under
>> the hood of stdio could be satisifed with a single call: a call which,
>> when applied to a readable FILE pointer, returns the number of bytes
>> currently buffered
>The MH 6.8.3 code attempts to avoid buffer copies by some way-too-clever code
>that does reads by extracting pointers to data in the stdio buffers.
And it occurs to me that it might be worth designing a stdio interface which
"reads" n bytes by returning a pointer and advancing the read pointer by n,
ASSUMING that there are n bytes available. One possible approach would be
to have stdio refuse to refill the buffer until you call back to release
the pointer, or you could just take your chances if you're foolish enough to
call read again while you're still interested in the previous data.
The trouble is that applications which want to be that tricky will probably
have finicky enough (and different enough) requirements that one interface
won't be useful to a majority of such applications. The proper answer, of
course, is generally "if you're so smart, do your OWN d*mned buffering!"
(i.e., drop back to read() and write())