After a bit more research, I think I've figured out
how to get the PerlIO object from an SV:
IO *io;
if (!file) /* no arg == no change */
return 0;
/* XXX need to support file being a filehandle object */
if (SvROK(file)) {
/* DAA must be a filehandle...we hope */
/* but how do we tell, and how do we get the PerlIO object from an SV ? */
io = sv_2io(file);
if (io) {
fp = IoOFP(io);
}
else {
warn("Input trace filehandle is not valid");
return 0;
}
}
else { /* do things the old way */ }
Does that make sense ? (I kyped the code from some Perl/Tk internals)
- Dean