in reply to Re: Redirecting XS stdout
in thread Redirecting XS stdout

++ You know what, that's just the key I needed!

I'm trying to wrap some C with as little modification as possible (staying current with the upstream). I didn't want to replace any IO calls directly, but after *seeing* your PerlIO call it dawned on me to simply override the stdio calls with PerlIO.

#define fprintf(fh,...) PerlIO_printf(fh,__VA_ARGS__); #define stdout PerlIO_stdout() #define stderr PerlIO_stderr()
Thanks!

Replies are listed 'Best First'.
Re^3: Redirecting XS stdout
by ikegami (Patriarch) on Feb 21, 2010 at 06:18 UTC
    Exactly. You'd think something like this already exists. Maybe it does. (Google code search?)
      Maybe it does

      fakesdio.h

      It is part of the base perl source code. See also perlsdio.h.

      I think I've figured out why I didn't stumble on this method before..

      After redefining the macros, I discovered the code I'm wrapping is taking the "return early, return often" concept to the extreme by way of exits.

      Oh well, back to the drawing board!

      Thanks again :)