Commit | Line | Data |
---|---|---|
eb1102fc NIS |
1 | /* perlsdio.h |
2 | * | |
663f364b | 3 | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, |
1129b882 | 4 | * 2002, 2003, 2006, 2007, 2008 by Larry Wall and others |
eb1102fc NIS |
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 | ||
760ac839 | 11 | #ifdef PERLIO_IS_STDIO |
afd1eb53 NIS |
12 | |
13 | #ifdef NETWARE | |
14 | #include "nwstdio.h" | |
15 | #else | |
16 | ||
760ac839 | 17 | /* |
76ced9ad | 18 | * This file #define-s the PerlIO_xxx abstraction onto stdio functions. |
760ac839 LW |
19 | * Make this as close to original stdio as possible. |
20 | */ | |
76ced9ad | 21 | #define PerlIO FILE |
362d0d44 NIS |
22 | #define PerlIO_stderr() PerlSIO_stderr |
23 | #define PerlIO_stdout() PerlSIO_stdout | |
24 | #define PerlIO_stdin() PerlSIO_stdin | |
760ac839 | 25 | |
76ced9ad NIS |
26 | #define PerlIO_isutf8(f) 0 |
27 | ||
362d0d44 NIS |
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) | |
a15cef0c | 32 | #define PerlIO_unread(f,buf,count) (-1) |
362d0d44 NIS |
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) | |
50a4e535 JD |
37 | #define PerlIO_puts(f,s) PerlSIO_fputs(s,f) |
38 | #define PerlIO_putc(f,c) PerlSIO_fputc(c,f) | |
04ce8649 | 39 | #if defined(__VMS) |
486ec47a | 40 | /* Unusual definition of ungetc() here to accommodate fast_sv_gets()' |
9607fc9c | 41 | * belief that it can mix getc/ungetc with reads from stdio buffer */ |
04ce8649 | 42 | START_EXTERN_C |
9607fc9c | 43 | int decc$ungetc(int __c, FILE *__stream); |
04ce8649 | 44 | END_EXTERN_C |
9607fc9c | 45 | # define PerlIO_ungetc(f,c) ((c) == EOF ? EOF : \ |
46 | ((*(f) && !((*(f))->_flag & _IONBF) && \ | |
47 | ((*(f))->_ptr > (*(f))->_base)) ? \ | |
48 | ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f))) | |
1ac5d68d | 49 | #else |
04ce8649 | 50 | # define PerlIO_ungetc(f,c) ungetc(c,f) |
1ac5d68d | 51 | #endif |
04ce8649 CB |
52 | #define PerlIO_getc(f) PerlSIO_fgetc(f) |
53 | #define PerlIO_ungetc(f,c) PerlSIO_ungetc(c,f) | |
54 | #define PerlIO_read(f,buf,count) (SSize_t)PerlSIO_fread(buf,1,count,f) | |
55 | #define PerlIO_tell(f) PerlSIO_ftell(f) | |
362d0d44 | 56 | #define PerlIO_eof(f) PerlSIO_feof(f) |
a20bf0c3 | 57 | #define PerlIO_getname(f,b) fgetname(f,b) |
362d0d44 NIS |
58 | #define PerlIO_error(f) PerlSIO_ferror(f) |
59 | #define PerlIO_fileno(f) PerlSIO_fileno(f) | |
60 | #define PerlIO_clearerr(f) PerlSIO_clearerr(f) | |
61 | #define PerlIO_flush(f) PerlSIO_fflush(f) | |
04ce8649 | 62 | #define PerlIO_seek(f,o,w) PerlSIO_fseek(f,o,w) |
760ac839 | 63 | |
362d0d44 NIS |
64 | #define PerlIO_rewind(f) PerlSIO_rewind(f) |
65 | #define PerlIO_tmpfile() PerlSIO_tmpfile() | |
760ac839 | 66 | |
76ced9ad NIS |
67 | #define PerlIO_importFILE(f,fl) (f) |
68 | #define PerlIO_exportFILE(f,fl) (f) | |
69 | #define PerlIO_findFILE(f) (f) | |
70 | #define PerlIO_releaseFILE(p,f) ((void) 0) | |
760ac839 LW |
71 | |
72 | #ifdef HAS_SETLINEBUF | |
362d0d44 | 73 | #define PerlIO_setlinebuf(f) PerlSIO_setlinebuf(f); |
760ac839 | 74 | #else |
bd61b366 | 75 | #define PerlIO_setlinebuf(f) PerlSIO_setvbuf(f, NULL, _IOLBF, 0); |
760ac839 LW |
76 | #endif |
77 | ||
78 | /* Now our interface to Configure's FILE_xxx macros */ | |
79 | ||
80 | #ifdef USE_STDIO_PTR | |
76ced9ad | 81 | #define PerlIO_has_cntptr(f) 1 |
362d0d44 NIS |
82 | #define PerlIO_get_ptr(f) PerlSIO_get_ptr(f) |
83 | #define PerlIO_get_cnt(f) PerlSIO_get_cnt(f) | |
760ac839 | 84 | |
c7ae39e5 | 85 | #ifdef STDIO_CNT_LVALUE |
76ced9ad | 86 | #define PerlIO_canset_cnt(f) 1 |
362d0d44 | 87 | #define PerlIO_set_cnt(f,c) PerlSIO_set_cnt(f,c) |
c7ae39e5 | 88 | #ifdef STDIO_PTR_LVALUE |
a7ffa9b9 | 89 | #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT |
76ced9ad | 90 | #define PerlIO_fast_gets(f) 1 |
760ac839 | 91 | #endif |
a7ffa9b9 NC |
92 | #endif /* STDIO_PTR_LVALUE */ |
93 | #else /* STDIO_CNT_LVALUE */ | |
76ced9ad | 94 | #define PerlIO_canset_cnt(f) 0 |
a20bf0c3 | 95 | #define PerlIO_set_cnt(f,c) abort() |
760ac839 LW |
96 | #endif |
97 | ||
c7ae39e5 | 98 | #ifdef STDIO_PTR_LVALUE |
a7ffa9b9 | 99 | #ifdef STDIO_PTR_LVAL_NOCHANGE_CNT |
362d0d44 | 100 | #define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p), PerlIO_set_cnt(f,c);} STMT_END |
a7ffa9b9 NC |
101 | #else |
102 | #ifdef STDIO_PTR_LVAL_SETS_CNT | |
103 | /* assert() may pre-process to ""; potential syntax error (FILE_ptr(), ) */ | |
362d0d44 | 104 | #define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p); assert(PerlSIO_get_cnt(f) == (c));} STMT_END |
76ced9ad | 105 | #define PerlIO_fast_gets(f) 1 |
760ac839 | 106 | #else |
a20bf0c3 | 107 | #define PerlIO_set_ptrcnt(f,p,c) abort() |
760ac839 | 108 | #endif |
a7ffa9b9 NC |
109 | #endif |
110 | #endif | |
760ac839 LW |
111 | |
112 | #else /* USE_STDIO_PTR */ | |
113 | ||
114 | #define PerlIO_has_cntptr(f) 0 | |
c7ae39e5 | 115 | #define PerlIO_canset_cnt(f) 0 |
a20bf0c3 JH |
116 | #define PerlIO_get_cnt(f) (abort(),0) |
117 | #define PerlIO_get_ptr(f) (abort(),(void *)0) | |
118 | #define PerlIO_set_cnt(f,c) abort() | |
119 | #define PerlIO_set_ptrcnt(f,p,c) abort() | |
760ac839 LW |
120 | |
121 | #endif /* USE_STDIO_PTR */ | |
122 | ||
123 | #ifndef PerlIO_fast_gets | |
76ced9ad | 124 | #define PerlIO_fast_gets(f) 0 |
760ac839 LW |
125 | #endif |
126 | ||
127 | ||
128 | #ifdef FILE_base | |
76ced9ad | 129 | #define PerlIO_has_base(f) 1 |
362d0d44 NIS |
130 | #define PerlIO_get_base(f) PerlSIO_get_base(f) |
131 | #define PerlIO_get_bufsiz(f) PerlSIO_get_bufsiz(f) | |
760ac839 LW |
132 | #else |
133 | #define PerlIO_has_base(f) 0 | |
a20bf0c3 JH |
134 | #define PerlIO_get_base(f) (abort(),(void *)0) |
135 | #define PerlIO_get_bufsiz(f) (abort(),0) | |
760ac839 | 136 | #endif |
760ac839 | 137 | |
afd1eb53 | 138 | #endif /* NETWARE */ |
760ac839 | 139 | #endif /* PERLIO_IS_STDIO */ |
e9a8c099 MHM |
140 | |
141 | /* | |
142 | * Local variables: | |
143 | * c-indentation-style: bsd | |
144 | * c-basic-offset: 4 | |
14d04a33 | 145 | * indent-tabs-mode: nil |
e9a8c099 MHM |
146 | * End: |
147 | * | |
14d04a33 | 148 | * ex: set ts=8 sts=4 sw=4 et: |
e9a8c099 | 149 | */ |