summaryrefslogtreecommitdiff
path: root/ext/FileHandle/FileHandle.xs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/FileHandle/FileHandle.xs')
-rw-r--r--ext/FileHandle/FileHandle.xs34
1 files changed, 17 insertions, 17 deletions
diff --git a/ext/FileHandle/FileHandle.xs b/ext/FileHandle/FileHandle.xs
index 8b1c60eb25..413b312d4e 100644
--- a/ext/FileHandle/FileHandle.xs
+++ b/ext/FileHandle/FileHandle.xs
@@ -1,10 +1,11 @@
#include "EXTERN.h"
+#define PERLIO_NOT_STDIO 1
#include "perl.h"
#include "XSUB.h"
typedef int SysRet;
-typedef FILE * InputStream;
-typedef FILE * OutputStream;
+typedef PerlIO * InputStream;
+typedef PerlIO * OutputStream;
static int
not_here(s)
@@ -64,35 +65,27 @@ SV *
fgetpos(handle)
InputStream handle
CODE:
-#ifdef HAS_FGETPOS
if (handle) {
Fpos_t pos;
- fgetpos(handle, &pos);
+ PerlIO_getpos(handle, &pos);
ST(0) = sv_2mortal(newSVpv((char*)&pos, sizeof(Fpos_t)));
}
else {
ST(0) = &sv_undef;
errno = EINVAL;
}
-#else
- ST(0) = (SV *) not_here("fgetpos");
-#endif
SysRet
fsetpos(handle, pos)
InputStream handle
SV * pos
CODE:
-#ifdef HAS_FSETPOS
if (handle)
- RETVAL = fsetpos(handle, (Fpos_t*)SvPVX(pos));
+ RETVAL = PerlIO_setpos(handle, (Fpos_t*)SvPVX(pos));
else {
RETVAL = -1;
errno = EINVAL;
}
-#else
- RETVAL = (SysRet) not_here("fsetpos");
-#endif
OUTPUT:
RETVAL
@@ -102,7 +95,7 @@ ungetc(handle, c)
int c
CODE:
if (handle)
- RETVAL = ungetc(c, handle);
+ RETVAL = PerlIO_ungetc(handle, c);
else {
RETVAL = -1;
errno = EINVAL;
@@ -114,7 +107,7 @@ OutputStream
new_tmpfile(packname = "FileHandle")
char * packname
CODE:
- RETVAL = tmpfile();
+ RETVAL = PerlIO_tmpfile();
OUTPUT:
RETVAL
@@ -123,7 +116,7 @@ ferror(handle)
InputStream handle
CODE:
if (handle)
- RETVAL = ferror(handle);
+ RETVAL = PerlIO_error(handle);
else {
RETVAL = -1;
errno = EINVAL;
@@ -136,7 +129,7 @@ fflush(handle)
OutputStream handle
CODE:
if (handle)
- RETVAL = Fflush(handle);
+ RETVAL = PerlIO_flush(handle);
else {
RETVAL = -1;
errno = EINVAL;
@@ -149,9 +142,12 @@ setbuf(handle, buf)
OutputStream handle
char * buf = SvPOK(ST(1)) ? sv_grow(ST(1), BUFSIZ) : 0;
CODE:
+#ifdef PERLIO_IS_STDIO
if (handle)
setbuf(handle, buf);
-
+#else
+ not_here("setbuf");
+#endif
SysRet
@@ -161,6 +157,7 @@ setvbuf(handle, buf, type, size)
int type
int size
CODE:
+#ifdef PERLIO_IS_STDIO
#ifdef _IOFBF /* Should be HAS_SETVBUF once Configure tests for that */
if (handle)
RETVAL = setvbuf(handle, buf, type, size);
@@ -171,6 +168,9 @@ setvbuf(handle, buf, type, size)
#else
RETVAL = (SysRet) not_here("setvbuf");
#endif /* _IOFBF */
+#else
+ RETVAL = (SysRet) not_here("setvbuf");
+#endif
OUTPUT:
RETVAL