This works for me:

----8<----
use Inline C;

open FOO, ">foo" or die "Can't write foo";
print FOO "This is Perl speaking.\n";
c_print(FOO, "This is C speaking.\n");
c_print(\*FOO, "This is C again.\n");
c_print(\*STDOUT, "Verbosely C.\n");
close FOO;

__END__
__C__

void c_print(FILE *fd, char *msg) {
    fprintf(fd, msg);
}
---->8----

Later,
Neil

Inline Reader [20/08/01 14:17 -0700]:
> 
> 
> I would be grateful to get any clues as to how to get the fd (either FILE* 
> or PerlIO* or the lower level structs) out of an IO::File and similar 
> objects. I would like to be able to pass a filehandle as an alternative to 
> passing a string into C space. I've made the requisite forays into perlapi, 
> perlguts, perlapio, Inline::C, Inline::C-Cookbook, etc.
> 
> The upshot is that it's trivial to create and open a filehandle in C space, 
> but I would like to have the user open it in perl and pass it to the inlined 
> C.
> 
> Cheers!
> 
> 
> 
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

Reply via email to