Very often I see libraries that implements their own stream functionalities, instead of using FILE*
. The typical interface will have a close function, similar to fclose()
, and several open functions, one of which usually mimics fopen()
and one of which usually accepts a few callbacks that should be used to open/close the stream, read to/write from the stream.
As a reference, good examples of what I am talking about are http://www.xmlsoft.org/xmlio.html or https://developer.gnome.org/gio/.
The approach, in general, seems very straightforward to me, however these libraries do not usually implement a replacement for all the functions in the standard library (e.g., fscanf()
, fprintf()
, ...).
Thus I wonder if an extension mechanism is available for standard library FILE*
as well (e.g.: opening by providing callbacks for some low-level required functionalities). I was not able to find any reference about this capability, so I guess it is not part of any standard.
Anyway, here is my question: is this functionality available in the C standard library (any standard is fine, as long as it is portable)? If not is there any easy (i.e., it does not require to re-implement the whole stdio.h functions) option that allows to implement it on top of the standard library?