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