I rather start XS, and I am studying the modification of an existing XS module that makes heavy use of the 15-year-old C base library (in fact, the module is basically just glued to this library). The problem is that I would like to be able to use PerlIO string traversal, for example:
open($fh, '<', \$string);
and then skip $fh to the XS glue, where the library expects FILE . The problem is that XS has:
int _parse (entry_ref, filename, file, preserve=FALSE) SV * entry_ref; char * filename; FILE * file; boolean preserve;
and I guess it should be:
PerlIO * file;
This does not work, of course, because there must be more to it. When I look at the _parse code in the library, it ends with:
AST * bt_parse_entry (FILE * infile, char * filename, btshort options, boolean * status) { AST * entry_ast = NULL; static int * err_counts = NULL; static FILE * prev_file = NULL;
with FILE again. Now the main question I have to start is even possible without changing the library; that is, can I get pseudo-filehandle from lines of PerlIO behavior just by changing XS?
perl perl-io xs
Plk
source share