This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Clean up temporary directories after testing.
[perl5.git] / dist / IO / IO.xs
CommitLineData
cf7fe8a2
GS
1/*
2 * Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
3 * This program is free software; you can redistribute it and/or
4 * modify it under the same terms as Perl itself.
5 */
6
6e22d046
JH
7#define PERL_EXT_IO
8
c5be433b 9#define PERL_NO_GET_CONTEXT
8add82fc 10#include "EXTERN.h"
760ac839 11#define PERLIO_NOT_STDIO 1
8add82fc 12#include "perl.h"
13#include "XSUB.h"
cf7fe8a2 14#include "poll.h"
8add82fc 15#ifdef I_UNISTD
16# include <unistd.h>
17#endif
cf7fe8a2 18#if defined(I_FCNTL) || defined(HAS_FCNTL)
760ac839
LW
19# include <fcntl.h>
20#endif
8add82fc 21
63a347c7
JH
22#ifndef SIOCATMARK
23# ifdef I_SYS_SOCKIO
24# include <sys/sockio.h>
25# endif
26#endif
27
2a0cf753 28#ifdef PerlIO
eb44fba6 29#if defined(MACOS_TRADITIONAL) && defined(USE_SFIO)
824215e2
JH
30#define PERLIO_IS_STDIO 1
31#undef setbuf
32#undef setvbuf
33#define setvbuf _stdsetvbuf
34#define setbuf(f,b) ( __sf_setbuf(f,b) )
35#endif
8add82fc 36typedef int SysRet;
760ac839
LW
37typedef PerlIO * InputStream;
38typedef PerlIO * OutputStream;
2a0cf753 39#else
40#define PERLIO_IS_STDIO 1
41typedef int SysRet;
42typedef FILE * InputStream;
43typedef FILE * OutputStream;
44#endif
8add82fc 45
cceca5ed 46#define MY_start_subparse(fmt,flags) start_subparse(fmt,flags)
cf7fe8a2
GS
47
48#ifndef gv_stashpvn
49#define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
50#endif
51
35a60386
RGS
52#ifndef __attribute__noreturn__
53# define __attribute__noreturn__
54#endif
55
56#ifndef NORETURN_FUNCTION_END
57# define NORETURN_FUNCTION_END /* NOT REACHED */ return 0
58#endif
59
986a805c
FC
60#ifndef dVAR
61# define dVAR dNOOP
62#endif
63
e6dae479
FC
64#ifndef OpSIBLING
65# define OpSIBLING(o) (o)->op_sibling
5a3da92c
FC
66#endif
67
7698c435 68static int not_here(const char *s) __attribute__noreturn__;
8add82fc 69static int
7698c435 70not_here(const char *s)
8add82fc 71{
72 croak("%s not implemented on this architecture", s);
c38693a5 73 NORETURN_FUNCTION_END;
8add82fc 74}
75
6ed60307
KW
76#ifndef UVCHR_IS_INVARIANT /* For use with Perls without this macro */
77# if ('A' == 65)
78# define UVCHR_IS_INVARIANT(cp) ((cp) < 128)
79# elif (defined(NATIVE_IS_INVARIANT)) /* EBCDIC on old Perl */
80# define UVCHR_IS_INVARIANT(cp) ((cp) < 256 && NATIVE_IS_INVARIANT(cp))
81# elif defined(isASCII) /* EBCDIC on very old Perl */
82 /* In EBCDIC, the invariants are the code points corresponding to ASCII,
83 * plus all the controls. All but one EBCDIC control is below SPACE; it
84 * varies depending on the code page, determined by the ord of '^' */
85# define UVCHR_IS_INVARIANT(cp) (isASCII(cp) \
86 || (cp) < ' ' \
87 || (('^' == 106) /* POSIX-BC */ \
88 ? (cp) == 95 \
89 : (cp) == 0xFF)) /* 1047 or 037 */
90# else /* EBCDIC on very very old Perl */
91 /* This assumes isascii() is available, but that could be fixed by
92 * having the macro test for each printable ASCII char */
93# define UVCHR_IS_INVARIANT(cp) (isascii(cp) \
94 || (cp) < ' ' \
95 || (('^' == 106) /* POSIX-BC */ \
96 ? (cp) == 95 \
97 : (cp) == 0xFF)) /* 1047 or 037 */
98# endif
99#endif
100
cf7fe8a2
GS
101
102#ifndef PerlIO
103#define PerlIO_fileno(f) fileno(f)
8add82fc 104#endif
cf7fe8a2
GS
105
106static int
e87a358a 107io_blocking(pTHX_ InputStream f, int block)
cf7fe8a2 108{
375ed12a 109 int fd = -1;
91f3b821 110#if defined(HAS_FCNTL)
cf7fe8a2 111 int RETVAL;
375ed12a 112 if (!f) {
cf7fe8a2
GS
113 errno = EBADF;
114 return -1;
115 }
375ed12a
JH
116 fd = PerlIO_fileno(f);
117 if (fd < 0) {
118 errno = EBADF;
119 return -1;
120 }
121 RETVAL = fcntl(fd, F_GETFL, 0);
cf7fe8a2
GS
122 if (RETVAL >= 0) {
123 int mode = RETVAL;
3b2f3eeb 124 int newmode = mode;
cf7fe8a2 125#ifdef O_NONBLOCK
766a733e 126 /* POSIX style */
cf7fe8a2 127
3b2f3eeb
BD
128# ifndef O_NDELAY
129# define O_NDELAY O_NONBLOCK
130# endif
131 /* Note: UNICOS and UNICOS/mk a F_GETFL returns an O_NDELAY
6fd254a4
JH
132 * after a successful F_SETFL of an O_NONBLOCK. */
133 RETVAL = RETVAL & (O_NONBLOCK | O_NDELAY) ? 0 : 1;
134
3b2f3eeb
BD
135 if (block == 0) {
136 newmode &= ~O_NDELAY;
137 newmode |= O_NONBLOCK;
138 } else if (block > 0) {
139 newmode &= ~(O_NDELAY|O_NONBLOCK);
cf7fe8a2 140 }
8add82fc 141#else
cf7fe8a2
GS
142 /* Not POSIX - better have O_NDELAY or we can't cope.
143 * for BSD-ish machines this is an acceptable alternative
766a733e 144 * for SysV we can't tell "would block" from EOF but that is
cf7fe8a2
GS
145 * the way SysV is...
146 */
147 RETVAL = RETVAL & O_NDELAY ? 0 : 1;
148
3b2f3eeb
BD
149 if (block == 0) {
150 newmode |= O_NDELAY;
151 } else if (block > 0) {
152 newmode &= ~O_NDELAY;
153 }
154#endif
155 if (newmode != mode) {
375ed12a 156 const int ret = fcntl(fd, F_SETFL, newmode);
3b2f3eeb 157 if (ret < 0)
cf7fe8a2 158 RETVAL = ret;
3b2f3eeb 159 }
cf7fe8a2
GS
160 }
161 return RETVAL;
8add82fc 162#else
20caf59d 163# ifdef WIN32
f5458e3a 164 if (block >= 0) {
1320cbfc 165 unsigned long flags = !block;
f5458e3a 166 /* ioctl claims to take char* but really needs a u_long sized buffer */
375ed12a 167 const int ret = ioctl(fd, FIONBIO, (char*)&flags);
f5458e3a
SO
168 if (ret != 0)
169 return -1;
170 /* Win32 has no way to get the current blocking status of a socket.
171 * However, we don't want to just return undef, because there's no way
172 * to tell that the ioctl succeeded.
173 */
174 return flags;
175 }
176 /* TODO: Perhaps set $! to ENOTSUP? */
177 return -1;
20caf59d 178# else
91f3b821 179 return -1;
20caf59d 180# endif
8add82fc 181#endif
8add82fc 182}
183
986a805c
FC
184static OP *
185io_pp_nextstate(pTHX)
186{
187 dVAR;
188 COP *old_curcop = PL_curcop;
189 OP *next = PL_ppaddr[PL_op->op_type](aTHX);
190 PL_curcop = old_curcop;
191 return next;
192}
193
194static OP *
195io_ck_lineseq(pTHX_ OP *o)
196{
197 OP *kid = cBINOPo->op_first;
e6dae479 198 for (; kid; kid = OpSIBLING(kid))
986a805c
FC
199 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE)
200 kid->op_ppaddr = io_pp_nextstate;
201 return o;
202}
203
204
8add82fc 205MODULE = IO PACKAGE = IO::Seekable PREFIX = f
206
8063af02 207void
8add82fc 208fgetpos(handle)
209 InputStream handle
210 CODE:
8add82fc 211 if (handle) {
2a0cf753 212#ifdef PerlIO
35a60386 213#if PERL_VERSION < 8
86413ec0
SH
214 Fpos_t pos;
215 ST(0) = sv_newmortal();
35a60386
RGS
216 if (PerlIO_getpos(handle, &pos) != 0) {
217 ST(0) = &PL_sv_undef;
218 }
219 else {
220 sv_setpvn(ST(0), (char *)&pos, sizeof(Fpos_t));
221 }
222#else
86413ec0 223 ST(0) = sv_newmortal();
766a733e
NIS
224 if (PerlIO_getpos(handle, ST(0)) != 0) {
225 ST(0) = &PL_sv_undef;
226 }
35a60386 227#endif
2a0cf753 228#else
35a60386 229 Fpos_t pos;
766a733e 230 if (fgetpos(handle, &pos)) {
a6a714bd
NC
231 ST(0) = &PL_sv_undef;
232 } else {
c7cffa0b
NC
233# if PERL_VERSION >= 11
234 ST(0) = newSVpvn_flags((char*)&pos, sizeof(Fpos_t), SVs_TEMP);
235# else
35a60386 236 ST(0) = sv_2mortal(newSVpvn((char*)&pos, sizeof(Fpos_t)));
c7cffa0b 237# endif
a6a714bd 238 }
766a733e 239#endif
8add82fc 240 }
241 else {
8add82fc 242 errno = EINVAL;
35a60386 243 ST(0) = &PL_sv_undef;
8add82fc 244 }
8add82fc 245
246SysRet
247fsetpos(handle, pos)
248 InputStream handle
249 SV * pos
250 CODE:
766a733e 251 if (handle) {
2a0cf753 252#ifdef PerlIO
35a60386
RGS
253#if PERL_VERSION < 8
254 char *p;
255 STRLEN len;
256 if (SvOK(pos) && (p = SvPV(pos,len)) && len == sizeof(Fpos_t)) {
257 RETVAL = PerlIO_setpos(handle, (Fpos_t*)p);
258 }
259 else {
260 RETVAL = -1;
261 errno = EINVAL;
262 }
263#else
766a733e 264 RETVAL = PerlIO_setpos(handle, pos);
35a60386 265#endif
2a0cf753 266#else
766a733e
NIS
267 char *p;
268 STRLEN len;
269 if ((p = SvPV(pos,len)) && len == sizeof(Fpos_t)) {
270 RETVAL = fsetpos(handle, (Fpos_t*)p);
271 }
272 else {
273 RETVAL = -1;
274 errno = EINVAL;
275 }
2a0cf753 276#endif
766a733e 277 }
8add82fc 278 else {
279 RETVAL = -1;
280 errno = EINVAL;
281 }
8add82fc 282 OUTPUT:
283 RETVAL
284
285MODULE = IO PACKAGE = IO::File PREFIX = f
286
8063af02 287void
8add82fc 288new_tmpfile(packname = "IO::File")
3e946625 289 const char * packname
a375a877
GB
290 PREINIT:
291 OutputStream fp;
292 GV *gv;
8add82fc 293 CODE:
2a0cf753 294#ifdef PerlIO
a375a877 295 fp = PerlIO_tmpfile();
2a0cf753 296#else
a375a877 297 fp = tmpfile();
2a0cf753 298#endif
a375a877 299 gv = (GV*)SvREFCNT_inc(newGVgen(packname));
71cd1c3f 300 if (gv)
c33e8be1 301 (void) hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD);
71cd1c3f 302 if (gv && do_open(gv, "+>&", 3, FALSE, 0, 0, fp)) {
6d5cdeed 303 ST(0) = sv_2mortal(newRV((SV*)gv));
a375a877 304 sv_bless(ST(0), gv_stashpv(packname, TRUE));
cf7fe8a2 305 SvREFCNT_dec(gv); /* undo increment in newRV() */
a375a877
GB
306 }
307 else {
a1ea39dc 308 ST(0) = &PL_sv_undef;
a375a877
GB
309 SvREFCNT_dec(gv);
310 }
8add82fc 311
cf7fe8a2
GS
312MODULE = IO PACKAGE = IO::Poll
313
766a733e 314void
cf7fe8a2
GS
315_poll(timeout,...)
316 int timeout;
317PPCODE:
318{
319#ifdef HAS_POLL
7698c435 320 const int nfd = (items - 1) / 2;
6de2dd46 321 SV *tmpsv = sv_2mortal(NEWSV(999,nfd * sizeof(struct pollfd)));
908febd9
DIM
322 /* We should pass _some_ valid pointer even if nfd is zero, but it
323 * doesn't matter what it is, since we're telling it to not check any fds.
324 */
325 struct pollfd *fds = nfd ? (struct pollfd *)SvPVX(tmpsv) : (struct pollfd *)tmpsv;
cf7fe8a2
GS
326 int i,j,ret;
327 for(i=1, j=0 ; j < nfd ; j++) {
328 fds[j].fd = SvIV(ST(i));
329 i++;
7c436af3 330 fds[j].events = (short)SvIV(ST(i));
cf7fe8a2
GS
331 i++;
332 fds[j].revents = 0;
333 }
334 if((ret = poll(fds,nfd,timeout)) >= 0) {
335 for(i=1, j=0 ; j < nfd ; j++) {
336 sv_setiv(ST(i), fds[j].fd); i++;
337 sv_setiv(ST(i), fds[j].revents); i++;
338 }
339 }
cf7fe8a2
GS
340 XSRETURN_IV(ret);
341#else
342 not_here("IO::Poll::poll");
343#endif
344}
345
346MODULE = IO PACKAGE = IO::Handle PREFIX = io_
347
348void
349io_blocking(handle,blk=-1)
350 InputStream handle
351 int blk
352PROTOTYPE: $;$
353CODE:
354{
7698c435 355 const int ret = io_blocking(aTHX_ handle, items == 1 ? -1 : blk ? 1 : 0);
cf7fe8a2
GS
356 if(ret >= 0)
357 XSRETURN_IV(ret);
358 else
359 XSRETURN_UNDEF;
360}
361
8add82fc 362MODULE = IO PACKAGE = IO::Handle PREFIX = f
363
8add82fc 364int
365ungetc(handle, c)
366 InputStream handle
10e621bc 367 SV * c
8add82fc 368 CODE:
10e621bc 369 if (handle) {
2a0cf753 370#ifdef PerlIO
10e621bc
CH
371 UV v;
372
373 if ((SvIOK_notUV(c) && SvIV(c) < 0) || (SvNOK(c) && SvNV(c) < 0.0))
374 croak("Negative character number in ungetc()");
375
376 v = SvUV(c);
6f2d5cbc 377 if (UVCHR_IS_INVARIANT(v) || (v <= 0xFF && !PerlIO_isutf8(handle)))
10e621bc
CH
378 RETVAL = PerlIO_ungetc(handle, (int)v);
379 else {
380 U8 buf[UTF8_MAXBYTES + 1], *end;
381 Size_t len;
382
383 if (!PerlIO_isutf8(handle))
384 croak("Wide character number in ungetc()");
385
386 /* This doesn't warn for non-chars, surrogate, and
387 * above-Unicodes */
388 end = uvchr_to_utf8_flags(buf, v, 0);
389 len = end - buf;
13142853 390 if ((Size_t)PerlIO_unread(handle, &buf, len) == len)
10e621bc
CH
391 XSRETURN_UV(v);
392 else
393 RETVAL = EOF;
394 }
2a0cf753 395#else
10e621bc 396 RETVAL = ungetc((int)SvIV(c), handle);
2a0cf753 397#endif
10e621bc 398 }
8add82fc 399 else {
400 RETVAL = -1;
401 errno = EINVAL;
402 }
403 OUTPUT:
404 RETVAL
405
406int
407ferror(handle)
408 InputStream handle
409 CODE:
410 if (handle)
2a0cf753 411#ifdef PerlIO
760ac839 412 RETVAL = PerlIO_error(handle);
2a0cf753 413#else
414 RETVAL = ferror(handle);
415#endif
416 else {
417 RETVAL = -1;
418 errno = EINVAL;
419 }
420 OUTPUT:
421 RETVAL
422
423int
424clearerr(handle)
425 InputStream handle
426 CODE:
427 if (handle) {
428#ifdef PerlIO
429 PerlIO_clearerr(handle);
430#else
431 clearerr(handle);
432#endif
433 RETVAL = 0;
434 }
8add82fc 435 else {
436 RETVAL = -1;
59629a13
RR
437 errno = EINVAL;
438 }
439 OUTPUT:
440 RETVAL
441
442int
443untaint(handle)
444 SV * handle
445 CODE:
7a4c00b4 446#ifdef IOf_UNTAINT
59629a13
RR
447 IO * io;
448 io = sv_2io(handle);
449 if (io) {
450 IoFLAGS(io) |= IOf_UNTAINT;
451 RETVAL = 0;
452 }
453 else {
7a4c00b4 454#endif
59629a13 455 RETVAL = -1;
8add82fc 456 errno = EINVAL;
7a4c00b4 457#ifdef IOf_UNTAINT
8add82fc 458 }
7a4c00b4 459#endif
8add82fc 460 OUTPUT:
461 RETVAL
462
463SysRet
464fflush(handle)
465 OutputStream handle
466 CODE:
467 if (handle)
2a0cf753 468#ifdef PerlIO
760ac839 469 RETVAL = PerlIO_flush(handle);
2a0cf753 470#else
471 RETVAL = Fflush(handle);
472#endif
8add82fc 473 else {
474 RETVAL = -1;
475 errno = EINVAL;
476 }
477 OUTPUT:
478 RETVAL
479
480void
c46a0ec2 481setbuf(handle, ...)
8add82fc 482 OutputStream handle
8add82fc 483 CODE:
484 if (handle)
760ac839 485#ifdef PERLIO_IS_STDIO
c46a0ec2
JH
486 {
487 char *buf = items == 2 && SvPOK(ST(1)) ?
488 sv_grow(ST(1), BUFSIZ) : 0;
8add82fc 489 setbuf(handle, buf);
c46a0ec2 490 }
760ac839
LW
491#else
492 not_here("IO::Handle::setbuf");
493#endif
8add82fc 494
495SysRet
c46a0ec2 496setvbuf(...)
8add82fc 497 CODE:
c46a0ec2
JH
498 if (items != 4)
499 Perl_croak(aTHX_ "Usage: IO::Handle::setvbuf(handle, buf, type, size)");
1eeb0f31 500#if defined(PERLIO_IS_STDIO) && defined(_IOFBF) && defined(HAS_SETVBUF)
c46a0ec2
JH
501 {
502 OutputStream handle = 0;
503 char * buf = SvPOK(ST(1)) ? sv_grow(ST(1), SvIV(ST(3))) : 0;
504 int type;
505 int size;
506
507 if (items == 4) {
508 handle = IoOFP(sv_2io(ST(0)));
509 buf = SvPOK(ST(1)) ? sv_grow(ST(1), SvIV(ST(3))) : 0;
510 type = (int)SvIV(ST(2));
511 size = (int)SvIV(ST(3));
512 }
d924de76
IZ
513 if (!handle) /* Try input stream. */
514 handle = IoIFP(sv_2io(ST(0)));
c46a0ec2 515 if (items == 4 && handle)
8add82fc 516 RETVAL = setvbuf(handle, buf, type, size);
517 else {
518 RETVAL = -1;
519 errno = EINVAL;
520 }
c46a0ec2 521 }
8add82fc 522#else
61839fa9 523 RETVAL = (SysRet) not_here("IO::Handle::setvbuf");
760ac839 524#endif
8add82fc 525 OUTPUT:
526 RETVAL
527
528
cf7fe8a2 529SysRet
2ba489e6
EM
530fsync(arg)
531 SV * arg
532 PREINIT:
533 OutputStream handle = NULL;
cf7fe8a2
GS
534 CODE:
535#ifdef HAS_FSYNC
2ba489e6
EM
536 handle = IoOFP(sv_2io(arg));
537 if (!handle)
538 handle = IoIFP(sv_2io(arg));
375ed12a
JH
539 if (handle) {
540 int fd = PerlIO_fileno(handle);
541 if (fd >= 0) {
542 RETVAL = fsync(fd);
543 } else {
544 RETVAL = -1;
545 errno = EBADF;
546 }
547 } else {
cf7fe8a2
GS
548 RETVAL = -1;
549 errno = EINVAL;
550 }
551#else
552 RETVAL = (SysRet) not_here("IO::Handle::sync");
553#endif
554 OUTPUT:
555 RETVAL
556
986a805c
FC
557SV *
558_create_getline_subs(const char *code)
986a805c
FC
559 CODE:
560 OP *(*io_old_ck_lineseq)(pTHX_ OP *) = PL_check[OP_LINESEQ];
561 PL_check[OP_LINESEQ] = io_ck_lineseq;
562 RETVAL = SvREFCNT_inc(eval_pv(code,FALSE));
563 PL_check[OP_LINESEQ] = io_old_ck_lineseq;
564 OUTPUT:
565 RETVAL
566
cf7fe8a2 567
63a347c7
JH
568MODULE = IO PACKAGE = IO::Socket
569
570SysRet
571sockatmark (sock)
572 InputStream sock
573 PROTOTYPE: $
574 PREINIT:
9ae155c4 575 int fd;
63a347c7 576 CODE:
9ae155c4 577 fd = PerlIO_fileno(sock);
375ed12a
JH
578 if (fd < 0) {
579 errno = EBADF;
580 RETVAL = -1;
9ae155c4
JH
581 }
582#ifdef HAS_SOCKATMARK
583 else {
375ed12a
JH
584 RETVAL = sockatmark(fd);
585 }
63a347c7 586#else
fa9804ae 587 else {
06c912bc 588 int flag = 0;
6d087280 589# ifdef SIOCATMARK
6e22d046 590# if defined(NETWARE) || defined(WIN32)
2c2a0333 591 if (ioctl(fd, SIOCATMARK, (char*)&flag) != 0)
f754b6e0
GS
592# else
593 if (ioctl(fd, SIOCATMARK, &flag) != 0)
594# endif
06c912bc 595 XSRETURN_UNDEF;
63a347c7 596# else
06c912bc
JH
597 not_here("IO::Socket::atmark");
598# endif
599 RETVAL = flag;
600 }
63a347c7 601#endif
63a347c7
JH
602 OUTPUT:
603 RETVAL
604
cf7fe8a2
GS
605BOOT:
606{
607 HV *stash;
608 /*
609 * constant subs for IO::Poll
610 */
611 stash = gv_stashpvn("IO::Poll", 8, TRUE);
612#ifdef POLLIN
613 newCONSTSUB(stash,"POLLIN",newSViv(POLLIN));
614#endif
615#ifdef POLLPRI
616 newCONSTSUB(stash,"POLLPRI", newSViv(POLLPRI));
617#endif
618#ifdef POLLOUT
619 newCONSTSUB(stash,"POLLOUT", newSViv(POLLOUT));
620#endif
621#ifdef POLLRDNORM
622 newCONSTSUB(stash,"POLLRDNORM", newSViv(POLLRDNORM));
623#endif
624#ifdef POLLWRNORM
625 newCONSTSUB(stash,"POLLWRNORM", newSViv(POLLWRNORM));
626#endif
627#ifdef POLLRDBAND
628 newCONSTSUB(stash,"POLLRDBAND", newSViv(POLLRDBAND));
629#endif
630#ifdef POLLWRBAND
631 newCONSTSUB(stash,"POLLWRBAND", newSViv(POLLWRBAND));
632#endif
633#ifdef POLLNORM
634 newCONSTSUB(stash,"POLLNORM", newSViv(POLLNORM));
635#endif
636#ifdef POLLERR
637 newCONSTSUB(stash,"POLLERR", newSViv(POLLERR));
638#endif
639#ifdef POLLHUP
640 newCONSTSUB(stash,"POLLHUP", newSViv(POLLHUP));
641#endif
642#ifdef POLLNVAL
643 newCONSTSUB(stash,"POLLNVAL", newSViv(POLLNVAL));
644#endif
645 /*
646 * constant subs for IO::Handle
647 */
648 stash = gv_stashpvn("IO::Handle", 10, TRUE);
649#ifdef _IOFBF
650 newCONSTSUB(stash,"_IOFBF", newSViv(_IOFBF));
651#endif
652#ifdef _IOLBF
653 newCONSTSUB(stash,"_IOLBF", newSViv(_IOLBF));
654#endif
655#ifdef _IONBF
656 newCONSTSUB(stash,"_IONBF", newSViv(_IONBF));
657#endif
658#ifdef SEEK_SET
659 newCONSTSUB(stash,"SEEK_SET", newSViv(SEEK_SET));
660#endif
661#ifdef SEEK_CUR
662 newCONSTSUB(stash,"SEEK_CUR", newSViv(SEEK_CUR));
663#endif
664#ifdef SEEK_END
665 newCONSTSUB(stash,"SEEK_END", newSViv(SEEK_END));
666#endif
cf7fe8a2 667}
63a347c7 668