tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: fun (not so much) with funopen
In article
<CAN6pqGTzai-37=E64f6YFqF1E9gF5nRtf28WQGMgx2w+MYErgA%mail.gmail.com@localhost>,
Takehiko NOZAKI <takehiko.nozaki%gmail.com@localhost> wrote:
>hi,
>
>POSIX2008 require open_w?memstream(3), but our stdio doesn't have
>chance to override FILE fflush handle.
>so it is hard to implement it. (and our fmemopen(3) implementation
>have bug related about this).
>
>i need read/write/seek/close/flush override point, but i don' t think
>funopen(3) is for it.
>funopen(3) is used by 3rd party application(such as tcsh), impact is
>not small, i think.
>(fpos_t -> off_t change breaks API, but still keep ABI, and tiny macro
>may be the salvation).
>
>i think we supply new library function or syscall is better.
>
Ok, fine. funopen2() it is:
I've made 2 different versions, first the header diff:
http://www.netbsd.org/~christos/stdio.h.diff
The first version lets you override completely the built-in __sflush(fp)
function, which uses the user-defined write function to flush. Doing so
does not make a lot of sense, because how will the application flush then?
http://www.netbsd.org/~christos/stdio1.diff
The second version just calls the user-supplied flush function if it exists
after the stream has been flushed using the regular __sflush(fp) function.
I think that this makes more sense:
http://www.netbsd.org/~christos/stdio2.diff
christos
Home |
Main Index |
Thread Index |
Old Index