c - Is it possible to use functions that acts on FILE* on custom structures? -


very see libraries implements own stream functionalities, instead of using file*. typical interface have close function, similar fclose(), , several open functions, 1 of mimics fopen() , 1 of accepts few callbacks should used open/close stream, read to/write stream.

as reference, examples of talking http://www.xmlsoft.org/xmlio.html or https://developer.gnome.org/gio/.

the approach, in general, seems straightforward me, these libraries not implement replacement functions in standard library (e.g., fscanf(), fprintf(), ...).

thus wonder if extension mechanism available standard library file* (e.g.: opening providing callbacks low-level required functionalities). not able find reference capability, guess not part of standard.

anyway, here question: functionality available in c standard library (any standard fine, long portable)? if not there easy (i.e., not require re-implement whole stdio.h functions) option allows implement on top of standard library?

it depends on c library you're using. glibc, example, supports custom streams through fopencookie (further documentation here). freebsd (and other bsds well, including os x) have funopen. doesn't microsoft's c library supports such feature.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -