I'm trying to convert a program which uses C's standard io functions
(printf, puts etc) to a shared library. Problem is, how can a shared
library use the 'correct' stdin, stdout, and stderr?
The library creates a new library base for each program that opens the
lib, but where do the library's stdin, stdout, stderr come from?
And how can I set them correctly so the library uses the stdin, stdout,
stderr from the calling program?
(I reckon that because the library's functions are executed in the process
context of the calling process, it should be possible to let the library
use the standard io's from the calling process. But for each process that
uses the library, the standard io's are different :( )
Thanks in advance,
--
/ Irmen de Jong (email: ir...@cs.vu.nl WWW: http://www.cs.vu.nl/~irmen/) \
\ Computer Science, VU A'dam, NL. ``Nothing lasts forever'' -- Species /
>The library creates a new library base for each program that opens the
>lib, but where do the library's stdin, stdout, stderr come from?
It can create its own filehandles from the current input and output
streams of AmigaDOS.
>And how can I set them correctly so the library uses the stdin, stdout,
>stderr from the calling program?
Hmm. I don't think that you can pass FILE pointers to the library,
while the FILE structures are acessible I'm not sure wether the
stdio functions need other global ressources. In any case it depends
on the C library and the compiler you use.
Regards,
--
Michael van Elst
Internet: mle...@serpens.rhein.de
"A potential Snark may lurk in every tree."