Sisyphus <[EMAIL PROTECTED]> writes:
>Hi,
>I guess the succinct way of asking the question is "how do I convert from a
>FILE* to a PerlIO* ?".

I can't remember where I put it, but there is some POD somewhere 
which relates to this.

If PerlIO happens to be using :stdio layer you can find the FILE *.
However in general the answer is you can't convert you have to "open" 
a new one to the same fileno() as the other.
And once you do that there are lifetime issues (who closes it when).



>
>By way of elaboration, consider the following Inline::C script (which works
>fine and as expected):
>
>---------------------
>use warnings;
>use Inline C => Config =>
>    BUILD_NOISY => 1;
>
>use Inline C => <<'EOC';
>
>void c_write(FILE * handle) {
>     fprintf(handle, "hello world\n");
>}
>
>EOC
>
>open($wr, '>', 'hello.txt') or die "Opening \$wr: $!";
>
>c_write($wr);
>
>close $wr or die "Closing \$wr: $!";
>__END__
>-------------------
>
>Suppose now that instead of having the c_write() function write to the
>filehandle using fprintf(), I wish it to write using PerlIO_printf(). What
>hoops does the c_write() function then have to jump through ?
>
>I'm not sure exactly why I'm asking this question .... I think I'm hoping to
>learn something, but I'm not exactly sure what  ..... if I learn anything at
>all, then I guess that's progress :-)
>
>One thing that puzzles me is that 'perldoc perlclib' recommends using the
>PerlIO* types instead of the FILE* types. If that's the recommendation, then
>it seems anomalous that perl facilitates the passing of a FILE* from perl to
>XS, but not the passing of a PerlIO* from perl to XS. (At least that's the
>way it appears to me at the moment.)

The PerlIO * mechanism is there...


>
>Cheers,
>Rob

Reply via email to