summaryrefslogtreecommitdiff
path: root/ext/IO/IO.xs
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-10-06 22:08:34 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1996-10-06 22:08:34 +0000
commit2a0cf7534305b208c8a33f74a84757c0894c6439 (patch)
tree2db0991e7fe414b5826d85851226722ffb03c7ad /ext/IO/IO.xs
parentf6aff53ad72449dfefc5f6d9d303886bbb4ae545 (diff)
downloadperl-2a0cf7534305b208c8a33f74a84757c0894c6439.tar.gz
Updated to IO-1.12.
Diffstat (limited to 'ext/IO/IO.xs')
-rw-r--r--ext/IO/IO.xs50
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs
index 82dce85cb1..bfe1f5ae42 100644
--- a/ext/IO/IO.xs
+++ b/ext/IO/IO.xs
@@ -10,9 +10,16 @@
# include <fcntl.h>
#endif
+#ifdef PerlIO
typedef int SysRet;
typedef PerlIO * InputStream;
typedef PerlIO * OutputStream;
+#else
+#define PERLIO_IS_STDIO 1
+typedef int SysRet;
+typedef FILE * InputStream;
+typedef FILE * OutputStream;
+#endif
static int
not_here(s)
@@ -82,7 +89,11 @@ fgetpos(handle)
CODE:
if (handle) {
Fpos_t pos;
+#ifdef PerlIO
PerlIO_getpos(handle, &pos);
+#else
+ fgetpos(handle, &pos);
+#endif
ST(0) = sv_2mortal(newSVpv((char*)&pos, sizeof(Fpos_t)));
}
else {
@@ -96,7 +107,11 @@ fsetpos(handle, pos)
SV * pos
CODE:
if (handle)
+#ifdef PerlIO
RETVAL = PerlIO_setpos(handle, (Fpos_t*)SvPVX(pos));
+#else
+ RETVAL = fsetpos(handle, (Fpos_t*)SvPVX(pos));
+#endif
else {
RETVAL = -1;
errno = EINVAL;
@@ -110,7 +125,11 @@ OutputStream
new_tmpfile(packname = "IO::File")
char * packname
CODE:
+#ifdef PerlIO
RETVAL = PerlIO_tmpfile();
+#else
+ RETVAL = tmpfile();
+#endif
OUTPUT:
RETVAL
@@ -132,7 +151,11 @@ ungetc(handle, c)
int c
CODE:
if (handle)
+#ifdef PerlIO
RETVAL = PerlIO_ungetc(handle, c);
+#else
+ RETVAL = ungetc(c, handle);
+#endif
else {
RETVAL = -1;
errno = EINVAL;
@@ -145,7 +168,30 @@ ferror(handle)
InputStream handle
CODE:
if (handle)
+#ifdef PerlIO
RETVAL = PerlIO_error(handle);
+#else
+ RETVAL = ferror(handle);
+#endif
+ else {
+ RETVAL = -1;
+ errno = EINVAL;
+ }
+ OUTPUT:
+ RETVAL
+
+int
+clearerr(handle)
+ InputStream handle
+ CODE:
+ if (handle) {
+#ifdef PerlIO
+ PerlIO_clearerr(handle);
+#else
+ clearerr(handle);
+#endif
+ RETVAL = 0;
+ }
else {
RETVAL = -1;
errno = EINVAL;
@@ -158,7 +204,11 @@ fflush(handle)
OutputStream handle
CODE:
if (handle)
+#ifdef PerlIO
RETVAL = PerlIO_flush(handle);
+#else
+ RETVAL = Fflush(handle);
+#endif
else {
RETVAL = -1;
errno = EINVAL;