use strict ;
use warnings ;
use Inline (Config => DIRECTORY => "$ENV{HOME}/PLIB/INLINE") ;
use Inline 'C';
open my $fh, ">", "test.txt" ;
my $rc = my_puts($fh) ;
close $fh ;
print "\$rc = $rc\n" ;
__END__
__C__
int my_puts(PerlIO* fh) {
return PerlIO_puts(fh, "Hello World !!\n") ;
} ;
and got the expected non-negative return code and the file test.txt ended up containing "Hello World !!\n"...
...I regret I cannot say why your attempt to output to a fastcgi stream is failing... but I can confirm that it is generally possible to use PerlIO "file handles", and output via the PerlIO_xxx API as suggested. It's worth noting that PerlIO_puts has arguments in the opposite order to fputs -- but looks pretty straightforward otherwise. I guess there could be something peculiar about the $out file handle you have... Wish I could help more.
|