3 * This file #define-s the PerlIO_xxx abstraction onto stdio functions.
4 * Make this as close to original stdio as possible.
7 #define PerlIO_stderr() stderr
8 #define PerlIO_stdout() stdout
9 #define PerlIO_stdin() stdin
11 #define PerlIO_fdupopen(f) (f)
12 #define PerlIO_isutf8(f) 0
14 #define PerlIO_printf fprintf
15 #define PerlIO_stdoutf printf
16 #define PerlIO_vprintf(f,fmt,a) vfprintf(f,fmt,a)
17 #define PerlIO_write(f,buf,count) fwrite1(buf,1,count,f)
18 #define PerlIO_open fopen
19 #define PerlIO_fdopen fdopen
20 #define PerlIO_reopen freopen
21 #ifdef SOCKS_64BIT_BUG
22 # define PerlIO_close(f) (Perl_do_s64_delete_buffer(f), fclose(f))
24 # define PerlIO_close(f) fclose(f)
26 #define PerlIO_puts(f,s) fputs(s,f)
27 #define PerlIO_putc(f,c) fputc(c,f)
30 /* Unusual definition of ungetc() here to accomodate fast_sv_gets()'
31 * belief that it can mix getc/ungetc with reads from stdio buffer */
32 int decc$ungetc(int __c, FILE *__stream);
33 # define PerlIO_ungetc(f,c) ((c) == EOF ? EOF : \
34 ((*(f) && !((*(f))->_flag & _IONBF) && \
35 ((*(f))->_ptr > (*(f))->_base)) ? \
36 ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
38 # define PerlIO_ungetc(f,c) ungetc(c,f)
40 /* Work around bug in DECCRTL/AXP (DECC v5.x) and some versions of old
41 * VAXCRTL which causes read from a pipe after EOF has been returned
44 # define PerlIO_getc(f) \
45 (feof(f) ? EOF : getc(f))
46 # define PerlIO_read(f,buf,count) \
47 (feof(f) ? 0 : (SSize_t)fread(buf,1,count,f))
49 # ifdef SOCKS_64BIT_BUG
50 # define PerlIO_getc(f) Perl_do_s64_getc(f)
51 # define PerlIO_ungetc(f,c) Perl_do_s64_ungetc(c,f)
52 # define PerlIO_read(f,buf,count) Perl_do_s64_fread(buf,count,f)
54 # define PerlIO_getc(f) getc(f)
55 # define PerlIO_ungetc(f,c) ungetc(c,f)
56 # define PerlIO_read(f,buf,count) (SSize_t)fread(buf,1,count,f)
57 # endif /* SOCKS_64BIT_BUG */
59 #define PerlIO_eof(f) feof(f)
60 #define PerlIO_getname(f,b) fgetname(f,b)
61 #define PerlIO_error(f) ferror(f)
62 #define PerlIO_fileno(f) fileno(f)
63 #define PerlIO_clearerr(f) clearerr(f)
64 #define PerlIO_flush(f) Fflush(f)
65 #ifdef SOCKS_64BIT_BUG
66 # define PerlIO_tell(f) Perl_do_s64_tell(f)
68 # define PerlIO_tell(f) ftell(f)
70 #if defined(VMS) && !defined(__DECC)
71 /* Old VAXC RTL doesn't reset EOF on seek; Perl folk seem to expect this */
72 # define PerlIO_seek(f,o,w) (((f) && (*f) && ((*f)->_flag &= ~_IOEOF)),fseek(f,o,w))
74 # ifdef SOCKS_64BIT_BUG
75 # define PerlIO_seek(f,o,w) Perl_do_s64_seek(f,o,w)
77 # define PerlIO_seek(f,o,w) fseek(f,o,w)
81 #define PerlIO_getpos(f,p) fgetpos(f,p)
84 #define PerlIO_setpos(f,p) fsetpos(f,p)
87 #define PerlIO_rewind(f) rewind(f)
88 #define PerlIO_tmpfile() tmpfile()
90 #define PerlIO_importFILE(f,fl) (f)
91 #define PerlIO_exportFILE(f,fl) (f)
92 #define PerlIO_findFILE(f) (f)
93 #define PerlIO_releaseFILE(p,f) ((void) 0)
96 #define PerlIO_setlinebuf(f) setlinebuf(f);
98 #define PerlIO_setlinebuf(f) setvbuf(f, Nullch, _IOLBF, 0);
101 /* Now our interface to Configure's FILE_xxx macros */
104 #define PerlIO_has_cntptr(f) 1
105 #define PerlIO_get_ptr(f) FILE_ptr(f)
106 #define PerlIO_get_cnt(f) FILE_cnt(f)
108 #ifdef STDIO_CNT_LVALUE
109 #define PerlIO_canset_cnt(f) 1
110 #define PerlIO_set_cnt(f,c) (FILE_cnt(f) = (c))
111 #ifdef STDIO_PTR_LVALUE
112 #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
113 #define PerlIO_fast_gets(f) 1
115 #endif /* STDIO_PTR_LVALUE */
116 #else /* STDIO_CNT_LVALUE */
117 #define PerlIO_canset_cnt(f) 0
118 #define PerlIO_set_cnt(f,c) abort()
121 #ifdef STDIO_PTR_LVALUE
122 #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
123 #define PerlIO_set_ptrcnt(f,p,c) STMT_START {FILE_ptr(f) = (p), PerlIO_set_cnt(f,c);} STMT_END
125 #ifdef STDIO_PTR_LVAL_SETS_CNT
126 /* assert() may pre-process to ""; potential syntax error (FILE_ptr(), ) */
127 #define PerlIO_set_ptrcnt(f,p,c) STMT_START {FILE_ptr(f) = (p); assert(FILE_cnt(f) == (c));} STMT_END
128 #define PerlIO_fast_gets(f) 1
130 #define PerlIO_set_ptrcnt(f,p,c) abort()
135 #else /* USE_STDIO_PTR */
137 #define PerlIO_has_cntptr(f) 0
138 #define PerlIO_canset_cnt(f) 0
139 #define PerlIO_get_cnt(f) (abort(),0)
140 #define PerlIO_get_ptr(f) (abort(),(void *)0)
141 #define PerlIO_set_cnt(f,c) abort()
142 #define PerlIO_set_ptrcnt(f,p,c) abort()
144 #endif /* USE_STDIO_PTR */
146 #ifndef PerlIO_fast_gets
147 #define PerlIO_fast_gets(f) 0
152 #define PerlIO_has_base(f) 1
153 #define PerlIO_get_base(f) FILE_base(f)
154 #define PerlIO_get_bufsiz(f) FILE_bufsiz(f)
156 #define PerlIO_has_base(f) 0
157 #define PerlIO_get_base(f) (abort(),(void *)0)
158 #define PerlIO_get_bufsiz(f) (abort(),0)
161 #endif /* PERLIO_IS_STDIO */