9 IV (*Fileno)(PerlIO *f);
10 PerlIO * (*Fdopen)(PerlIO_funcs *tab, int fd, const char *mode);
11 PerlIO * (*Open)(PerlIO_funcs *tab, const char *path, const char *mode);
12 int (*Reopen)(const char *path, const char *mode, PerlIO *f);
13 IV (*Pushed)(PerlIO *f,const char *mode,const char *arg,STRLEN len);
14 IV (*Popped)(PerlIO *f);
15 /* Unix-like functions - cf sfio line disciplines */
16 SSize_t (*Read)(PerlIO *f, void *vbuf, Size_t count);
17 SSize_t (*Unread)(PerlIO *f, const void *vbuf, Size_t count);
18 SSize_t (*Write)(PerlIO *f, const void *vbuf, Size_t count);
19 IV (*Seek)(PerlIO *f, Off_t offset, int whence);
20 Off_t (*Tell)(PerlIO *f);
21 IV (*Close)(PerlIO *f);
22 /* Stdio-like buffered IO functions */
23 IV (*Flush)(PerlIO *f);
24 IV (*Fill)(PerlIO *f);
26 IV (*Error)(PerlIO *f);
27 void (*Clearerr)(PerlIO *f);
28 void (*Setlinebuf)(PerlIO *f);
29 /* Perl's snooping functions */
30 STDCHAR * (*Get_base)(PerlIO *f);
31 Size_t (*Get_bufsiz)(PerlIO *f);
32 STDCHAR * (*Get_ptr)(PerlIO *f);
33 SSize_t (*Get_cnt)(PerlIO *f);
34 void (*Set_ptrcnt)(PerlIO *f,STDCHAR *ptr,SSize_t cnt);
37 /*--------------------------------------------------------------------------------------*/
39 #define PERLIO_K_RAW 0x00000001
40 #define PERLIO_K_BUFFERED 0x00000002
41 #define PERLIO_K_CANCRLF 0x00000004
42 #define PERLIO_K_FASTGETS 0x00000008
43 #define PERLIO_K_DUMMY 0x00000010
44 #define PERLIO_K_UTF8 0x00008000
46 /*--------------------------------------------------------------------------------------*/
49 PerlIOl * next; /* Lower layer */
50 PerlIO_funcs * tab; /* Functions for this layer */
51 IV flags; /* Various flags for state */
54 /*--------------------------------------------------------------------------------------*/
57 #define PERLIO_F_EOF 0x00000100
58 #define PERLIO_F_CANWRITE 0x00000200
59 #define PERLIO_F_CANREAD 0x00000400
60 #define PERLIO_F_ERROR 0x00000800
61 #define PERLIO_F_TRUNCATE 0x00001000
62 #define PERLIO_F_APPEND 0x00002000
63 #define PERLIO_F_CRLF 0x00004000
64 #define PERLIO_F_UTF8 0x00008000
65 #define PERLIO_F_UNBUF 0x00010000
66 #define PERLIO_F_WRBUF 0x00020000
67 #define PERLIO_F_RDBUF 0x00040000
68 #define PERLIO_F_LINEBUF 0x00080000
69 #define PERLIO_F_TEMP 0x00100000
70 #define PERLIO_F_OPEN 0x00200000
71 #define PERLIO_F_FASTGETS 0x00400000
73 #define PerlIOBase(f) (*(f))
74 #define PerlIOSelf(f,type) ((type *)PerlIOBase(f))
75 #define PerlIONext(f) (&(PerlIOBase(f)->next))
77 /*--------------------------------------------------------------------------------------*/
78 /* Data exports - EXT rather than extern is needed for Cygwin */
79 EXT PerlIO_funcs PerlIO_unix;
80 EXT PerlIO_funcs PerlIO_perlio;
81 EXT PerlIO_funcs PerlIO_stdio;
82 EXT PerlIO_funcs PerlIO_crlf;
83 EXT PerlIO_funcs PerlIO_utf8;
84 EXT PerlIO_funcs PerlIO_byte;
85 EXT PerlIO_funcs PerlIO_raw;
86 EXT PerlIO_funcs PerlIO_pending;
88 EXT PerlIO_funcs PerlIO_mmap;
91 extern PerlIO *PerlIO_allocate(pTHX);
93 #if O_BINARY != O_TEXT
94 #define PERLIO_STDTEXT "t"
96 #define PERLIO_STDTEXT ""
99 /*--------------------------------------------------------------------------------------*/
100 /* Generic, or stub layer functions */
102 extern IV PerlIOBase_fileno (PerlIO *f);
103 extern IV PerlIOBase_pushed (PerlIO *f, const char *mode,const char *arg,STRLEN len);
104 extern IV PerlIOBase_popped (PerlIO *f);
105 extern SSize_t PerlIOBase_unread (PerlIO *f, const void *vbuf, Size_t count);
106 extern IV PerlIOBase_eof (PerlIO *f);
107 extern IV PerlIOBase_error (PerlIO *f);
108 extern void PerlIOBase_clearerr (PerlIO *f);
109 extern IV PerlIOBase_flush (PerlIO *f);
110 extern IV PerlIOBase_fill (PerlIO *f);
111 extern IV PerlIOBase_close (PerlIO *f);
112 extern void PerlIOBase_setlinebuf(PerlIO *f);
114 extern IV PerlIOBase_noop_ok (PerlIO *f);
115 extern IV PerlIOBase_noop_fail (PerlIO *f);
117 /*--------------------------------------------------------------------------------------*/
118 /* perlio buffer layer
119 As this is reasonably generic its struct and "methods" are declared here
120 so they can be used to "inherit" from it.
125 struct _PerlIO base; /* Base "class" info */
126 STDCHAR * buf; /* Start of buffer */
127 STDCHAR * end; /* End of valid part of buffer */
128 STDCHAR * ptr; /* Current position in buffer */
129 Off_t posn; /* Offset of buf into the file */
130 Size_t bufsiz; /* Real size of buffer */
131 IV oneword; /* Emergency buffer */
134 extern PerlIO * PerlIOBuf_fdopen (PerlIO_funcs *self, int fd, const char *mode);
135 extern PerlIO * PerlIOBuf_open (PerlIO_funcs *self, const char *path, const char *mode);
136 extern int PerlIOBuf_reopen (const char *path, const char *mode, PerlIO *f);
137 extern SSize_t PerlIOBuf_read (PerlIO *f, void *vbuf, Size_t count);
138 extern SSize_t PerlIOBuf_unread (PerlIO *f, const void *vbuf, Size_t count);
139 extern SSize_t PerlIOBuf_write (PerlIO *f, const void *vbuf, Size_t count);
140 extern IV PerlIOBuf_seek (PerlIO *f, Off_t offset, int whence);
141 extern Off_t PerlIOBuf_tell (PerlIO *f);
142 extern IV PerlIOBuf_close (PerlIO *f);
143 extern IV PerlIOBuf_flush (PerlIO *f);
144 extern IV PerlIOBuf_fill (PerlIO *f);
145 extern void PerlIOBuf_setlinebuf (PerlIO *f);
146 extern STDCHAR *PerlIOBuf_get_base (PerlIO *f);
147 extern Size_t PerlIOBuf_bufsiz (PerlIO *f);
148 extern STDCHAR *PerlIOBuf_get_ptr (PerlIO *f);
149 extern SSize_t PerlIOBuf_get_cnt (PerlIO *f);
150 extern void PerlIOBuf_set_ptrcnt (PerlIO *f, STDCHAR *ptr, SSize_t cnt);
152 /*--------------------------------------------------------------------------------------*/
154 #endif /* _PERLIOL_H */