Commit | Line | Data |
eb1102fc |
1 | /* perlsdio.h |
2 | * |
3f774658 |
3 | * Copyright (c) 1997-2002, Larry Wall |
eb1102fc |
4 | * |
5 | * You may distribute under the terms of either the GNU General Public |
6 | * License or the Artistic License, as specified in the README file. |
7 | * |
8 | */ |
9 | |
760ac839 |
10 | #ifdef PERLIO_IS_STDIO |
afd1eb53 |
11 | |
12 | #ifdef NETWARE |
13 | #include "nwstdio.h" |
14 | #else |
15 | |
760ac839 |
16 | /* |
76ced9ad |
17 | * This file #define-s the PerlIO_xxx abstraction onto stdio functions. |
760ac839 |
18 | * Make this as close to original stdio as possible. |
19 | */ |
76ced9ad |
20 | #define PerlIO FILE |
362d0d44 |
21 | #define PerlIO_stderr() PerlSIO_stderr |
22 | #define PerlIO_stdout() PerlSIO_stdout |
23 | #define PerlIO_stdin() PerlSIO_stdin |
760ac839 |
24 | |
76ced9ad |
25 | #define PerlIO_isutf8(f) 0 |
26 | |
362d0d44 |
27 | #define PerlIO_printf PerlSIO_printf |
28 | #define PerlIO_stdoutf PerlSIO_stdoutf |
29 | #define PerlIO_vprintf(f,fmt,a) PerlSIO_vprintf(f,fmt,a) |
30 | #define PerlIO_write(f,buf,count) PerlSIO_fwrite(buf,1,count,f) |
a15cef0c |
31 | #define PerlIO_unread(f,buf,count) (-1) |
362d0d44 |
32 | #define PerlIO_open PerlSIO_fopen |
33 | #define PerlIO_fdopen PerlSIO_fdopen |
34 | #define PerlIO_reopen PerlSIO_freopen |
35 | #define PerlIO_close(f) PerlSIO_fclose(f) |
36 | #define PerlIO_puts(f,s) PerlSIO_fputs(f,s) |
37 | #define PerlIO_putc(f,c) PerlSIO_fputc(f,c) |
9607fc9c |
38 | #if defined(VMS) |
39 | # if defined(__DECC) |
40 | /* Unusual definition of ungetc() here to accomodate fast_sv_gets()' |
41 | * belief that it can mix getc/ungetc with reads from stdio buffer */ |
42 | int decc$ungetc(int __c, FILE *__stream); |
43 | # define PerlIO_ungetc(f,c) ((c) == EOF ? EOF : \ |
44 | ((*(f) && !((*(f))->_flag & _IONBF) && \ |
45 | ((*(f))->_ptr > (*(f))->_base)) ? \ |
46 | ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f))) |
47 | # else |
48 | # define PerlIO_ungetc(f,c) ungetc(c,f) |
49 | # endif |
50 | /* Work around bug in DECCRTL/AXP (DECC v5.x) and some versions of old |
51 | * VAXCRTL which causes read from a pipe after EOF has been returned |
52 | * once to hang. |
aa689395 |
53 | */ |
5b54f415 |
54 | # define PerlIO_getc(f) \ |
55 | (feof(f) ? EOF : getc(f)) |
56 | # define PerlIO_read(f,buf,count) \ |
57 | (feof(f) ? 0 : (SSize_t)fread(buf,1,count,f)) |
bf348c40 |
58 | # define PerlIO_tell(f) ftell(f) |
1ac5d68d |
59 | #else |
362d0d44 |
60 | # define PerlIO_getc(f) PerlSIO_fgetc(f) |
61 | # define PerlIO_ungetc(f,c) PerlSIO_ungetc(c,f) |
62 | # define PerlIO_read(f,buf,count) (SSize_t)PerlSIO_fread(buf,1,count,f) |
63 | # define PerlIO_tell(f) PerlSIO_ftell(f) |
1ac5d68d |
64 | #endif |
362d0d44 |
65 | #define PerlIO_eof(f) PerlSIO_feof(f) |
a20bf0c3 |
66 | #define PerlIO_getname(f,b) fgetname(f,b) |
362d0d44 |
67 | #define PerlIO_error(f) PerlSIO_ferror(f) |
68 | #define PerlIO_fileno(f) PerlSIO_fileno(f) |
69 | #define PerlIO_clearerr(f) PerlSIO_clearerr(f) |
70 | #define PerlIO_flush(f) PerlSIO_fflush(f) |
cf829ab0 |
71 | #if defined(VMS) && !defined(__DECC) |
72 | /* Old VAXC RTL doesn't reset EOF on seek; Perl folk seem to expect this */ |
73 | #define PerlIO_seek(f,o,w) (((f) && (*f) && ((*f)->_flag &= ~_IOEOF)),fseek(f,o,w)) |
fab3f3a7 |
74 | #else |
362d0d44 |
75 | # define PerlIO_seek(f,o,w) PerlSIO_fseek(f,o,w) |
17f28c40 |
76 | #endif |
760ac839 |
77 | |
362d0d44 |
78 | #define PerlIO_rewind(f) PerlSIO_rewind(f) |
79 | #define PerlIO_tmpfile() PerlSIO_tmpfile() |
760ac839 |
80 | |
76ced9ad |
81 | #define PerlIO_importFILE(f,fl) (f) |
82 | #define PerlIO_exportFILE(f,fl) (f) |
83 | #define PerlIO_findFILE(f) (f) |
84 | #define PerlIO_releaseFILE(p,f) ((void) 0) |
760ac839 |
85 | |
86 | #ifdef HAS_SETLINEBUF |
362d0d44 |
87 | #define PerlIO_setlinebuf(f) PerlSIO_setlinebuf(f); |
760ac839 |
88 | #else |
362d0d44 |
89 | #define PerlIO_setlinebuf(f) PerlSIO_setvbuf(f, Nullch, _IOLBF, 0); |
760ac839 |
90 | #endif |
91 | |
92 | /* Now our interface to Configure's FILE_xxx macros */ |
93 | |
94 | #ifdef USE_STDIO_PTR |
76ced9ad |
95 | #define PerlIO_has_cntptr(f) 1 |
362d0d44 |
96 | #define PerlIO_get_ptr(f) PerlSIO_get_ptr(f) |
97 | #define PerlIO_get_cnt(f) PerlSIO_get_cnt(f) |
760ac839 |
98 | |
c7ae39e5 |
99 | #ifdef STDIO_CNT_LVALUE |
76ced9ad |
100 | #define PerlIO_canset_cnt(f) 1 |
362d0d44 |
101 | #define PerlIO_set_cnt(f,c) PerlSIO_set_cnt(f,c) |
c7ae39e5 |
102 | #ifdef STDIO_PTR_LVALUE |
a7ffa9b9 |
103 | #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT |
76ced9ad |
104 | #define PerlIO_fast_gets(f) 1 |
760ac839 |
105 | #endif |
a7ffa9b9 |
106 | #endif /* STDIO_PTR_LVALUE */ |
107 | #else /* STDIO_CNT_LVALUE */ |
76ced9ad |
108 | #define PerlIO_canset_cnt(f) 0 |
a20bf0c3 |
109 | #define PerlIO_set_cnt(f,c) abort() |
760ac839 |
110 | #endif |
111 | |
c7ae39e5 |
112 | #ifdef STDIO_PTR_LVALUE |
a7ffa9b9 |
113 | #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT |
362d0d44 |
114 | #define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p), PerlIO_set_cnt(f,c);} STMT_END |
a7ffa9b9 |
115 | #else |
116 | #ifdef STDIO_PTR_LVAL_SETS_CNT |
117 | /* assert() may pre-process to ""; potential syntax error (FILE_ptr(), ) */ |
362d0d44 |
118 | #define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p); assert(PerlSIO_get_cnt(f) == (c));} STMT_END |
76ced9ad |
119 | #define PerlIO_fast_gets(f) 1 |
760ac839 |
120 | #else |
a20bf0c3 |
121 | #define PerlIO_set_ptrcnt(f,p,c) abort() |
760ac839 |
122 | #endif |
a7ffa9b9 |
123 | #endif |
124 | #endif |
760ac839 |
125 | |
126 | #else /* USE_STDIO_PTR */ |
127 | |
128 | #define PerlIO_has_cntptr(f) 0 |
c7ae39e5 |
129 | #define PerlIO_canset_cnt(f) 0 |
a20bf0c3 |
130 | #define PerlIO_get_cnt(f) (abort(),0) |
131 | #define PerlIO_get_ptr(f) (abort(),(void *)0) |
132 | #define PerlIO_set_cnt(f,c) abort() |
133 | #define PerlIO_set_ptrcnt(f,p,c) abort() |
760ac839 |
134 | |
135 | #endif /* USE_STDIO_PTR */ |
136 | |
137 | #ifndef PerlIO_fast_gets |
76ced9ad |
138 | #define PerlIO_fast_gets(f) 0 |
760ac839 |
139 | #endif |
140 | |
141 | |
142 | #ifdef FILE_base |
76ced9ad |
143 | #define PerlIO_has_base(f) 1 |
362d0d44 |
144 | #define PerlIO_get_base(f) PerlSIO_get_base(f) |
145 | #define PerlIO_get_bufsiz(f) PerlSIO_get_bufsiz(f) |
760ac839 |
146 | #else |
147 | #define PerlIO_has_base(f) 0 |
a20bf0c3 |
148 | #define PerlIO_get_base(f) (abort(),(void *)0) |
149 | #define PerlIO_get_bufsiz(f) (abort(),0) |
760ac839 |
150 | #endif |
760ac839 |
151 | |
afd1eb53 |
152 | #endif /* NETWARE */ |
760ac839 |
153 | #endif /* PERLIO_IS_STDIO */ |