diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-14 17:35:51 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-14 17:35:51 +0000 |
commit | 39f7a87036eb8d13c207511143dc7f2e620b3891 (patch) | |
tree | 6ff5e9911b13a8b869ce1243c9e8df24657f3f95 /perlio.c | |
parent | 119586db753fab6875f9973c20a57e0d66dbfbcf (diff) | |
download | perl-39f7a87036eb8d13c207511143dc7f2e620b3891.tar.gz |
Introduce PerlIO::get_layers() to allow people to peek
at the PerlIO layer stack.
p4raw-id: //depot/perl@19203
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -640,6 +640,36 @@ PerlIO_pop(pTHX_ PerlIO *f) } } +/* Return as an array the stack of layers on a filehandle. Note that + * the stack is returned top-first in the array, and there are three + * times as many array elements as there are layers in the stack: the + * first element of a layer triplet is the name, the second one is the + * arguments, and the third one is the flags. */ + +AV * +PerlIO_get_layers(pTHX_ PerlIO *f) +{ + AV *av = newAV(); + + if (PerlIOValid(f)) { + dSP; + PerlIOl *l = PerlIOBase(f); + + while (l) { + SV *name = l->tab && l->tab->name ? + newSVpv(l->tab->name, 0) : &PL_sv_undef; + SV *arg = l->tab && l->tab->Getarg ? + (*l->tab->Getarg)(aTHX_ &l, 0, 0) : &PL_sv_undef; + av_push(av, name); + av_push(av, arg); + av_push(av, newSViv((IV)l->flags)); + l = l->next; + } + } + + return av; +} + /*--------------------------------------------------------------------------------------*/ /* * XS Interface for perl code |