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 
Takehiko NOZAKI  <> wrote:
>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: 

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? 

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: 


Home | Main Index | Thread Index | Old Index