• W
    implement the fopencookie extension to stdio · 06184334
    William Pitcock 提交于
    notes added by maintainer:
    
    this function is a GNU extension. it was chosen over the similar BSD
    function funopen because the latter depends on fpos_t being an
    arithmetic type as part of its public API, conflicting with our
    definition of fpos_t and with the intent that it be an opaque type. it
    was accepted for inclusion because, despite not being widely used, it
    is usually very difficult to extricate software using it from the
    dependency on it.
    
    calling pattern for the read and write callbacks is not likely to
    match glibc or other implementations, but should work with any
    reasonable callbacks. in particular the read function is never called
    without at least one byte being needed to satisfy its caller, so that
    spurious blocking is not introduced.
    
    contracts for what callbacks called from inside libc/stdio can do are
    always complicated, and at some point still need to be specified
    explicitly. at the very least, the callbacks must return or block
    indefinitely (they cannot perform nonlocal exits) and they should not
    make calls to stdio using their own FILE as an argument.
    06184334
stdio.h 5.6 KB