P
Pasquale Minervini
Hi everyone; it's a few days I'm trying to find a decent (and
portable) solution to the following problem:
Imagine you've a function whose prototype is like the following:
void function(FILE *);
i.e. it gets data from a FILE* stream, but the data you want to pass
is stored in an in-memory stream; in your opinion, what's the best
solution to this problem? (Note: I don't actually have access to
function's internals)
The best solution I've found is by using pipe(), i.e. creating two
piped descriptors (call them fdread and fdwrite), turning them in
FILE* streams using fdopen(), writing on the fdwrite and passing
fdread to the function, but it's quite a mess. Any idea?
Thanks a lot in advance for every comment/suggestion/anythin!
portable) solution to the following problem:
Imagine you've a function whose prototype is like the following:
void function(FILE *);
i.e. it gets data from a FILE* stream, but the data you want to pass
is stored in an in-memory stream; in your opinion, what's the best
solution to this problem? (Note: I don't actually have access to
function's internals)
The best solution I've found is by using pipe(), i.e. creating two
piped descriptors (call them fdread and fdwrite), turning them in
FILE* streams using fdopen(), writing on the fdwrite and passing
fdread to the function, but it's quite a mess. Any idea?
Thanks a lot in advance for every comment/suggestion/anythin!