summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-12-03 06:40:15 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-12-03 06:40:15 +0000
commit33c2a72871842138b67f364dece5097eece0c0df (patch)
tree59f29ddb395fb5c4490806e7414573415b47f9d2 /ext
parent4fdd92761144101d5374ee932c068086c661b214 (diff)
downloadperl-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.xs26
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);