diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-03 06:40:15 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-03 06:40:15 +0000 |
commit | 33c2a72871842138b67f364dece5097eece0c0df (patch) | |
tree | 59f29ddb395fb5c4490806e7414573415b47f9d2 /ext | |
parent | 4fdd92761144101d5374ee932c068086c661b214 (diff) | |
download | perl-33c2a72871842138b67f364dece5097eece0c0df.tar.gz |
use PerlIO abstraction rather than straight stdio (from
Chip Salzenberg)
p4raw-id: //depot/perl@4629
Diffstat (limited to 'ext')
-rw-r--r-- | ext/ByteLoader/ByteLoader.xs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/ext/ByteLoader/ByteLoader.xs b/ext/ByteLoader/ByteLoader.xs index c9d7d16d06..7c3746bba7 100644 --- a/ext/ByteLoader/ByteLoader.xs +++ b/ext/ByteLoader/ByteLoader.xs @@ -4,12 +4,22 @@ #include "XSUB.h" #include "byterun.h" -#ifdef NEED_FGETC_PROTOTYPE -extern int fgetc(); -#endif -#ifdef NEED_FREAD_PROTOTYPE -extern int fread(); -#endif +static int +xgetc(PerlIO *io) +{ + dTHX; + return PerlIO_getc(io); +} + +static int +xfread(char *buf, size_t size, size_t n, PerlIO *io) +{ + dTHX; + int i = PerlIO_read(io, buf, n * size); + if (i > 0) + i /= size; + return i; +} static void freadpv(U32 len, void *data, XPV *pv) @@ -30,8 +40,8 @@ byteloader_filter(pTHXo_ int idx, SV *buf_sv, int maxlen) struct bytestream bs; bs.data = PL_rsfp; - bs.pfgetc = (int(*) (void*))fgetc; - bs.pfread = (int(*) (char*,size_t,size_t,void*))fread; + bs.pfgetc = (int(*) (void*))xgetc; + bs.pfread = (int(*) (char*,size_t,size_t,void*))xfread; bs.pfreadpv = freadpv; byterun(aTHXo_ bs); |