9 IV (*Pushed)(PerlIO *f,const char *mode,SV *arg);
10 IV (*Popped)(PerlIO *f);
11 PerlIO * (*Open)(pTHX_ PerlIO_funcs *tab,
14 int fd, int imode, int perm,
17 SV * (*Getarg)(PerlIO *f);
18 IV (*Fileno)(PerlIO *f);
19 /* Unix-like functions - cf sfio line disciplines */
20 SSize_t (*Read)(PerlIO *f, void *vbuf, Size_t count);
21 SSize_t (*Unread)(PerlIO *f, const void *vbuf, Size_t count);
22 SSize_t (*Write)(PerlIO *f, const void *vbuf, Size_t count);
23 IV (*Seek)(PerlIO *f, Off_t offset, int whence);
24 Off_t (*Tell)(PerlIO *f);
25 IV (*Close)(PerlIO *f);
26 /* Stdio-like buffered IO functions */
27 IV (*Flush)(PerlIO *f);
28 IV (*Fill)(PerlIO *f);
30 IV (*Error)(PerlIO *f);
31 void (*Clearerr)(PerlIO *f);
32 void (*Setlinebuf)(PerlIO *f);
33 /* Perl's snooping functions */
34 STDCHAR * (*Get_base)(PerlIO *f);
35 Size_t (*Get_bufsiz)(PerlIO *f);
36 STDCHAR * (*Get_ptr)(PerlIO *f);
37 SSize_t (*Get_cnt)(PerlIO *f);
38 void (*Set_ptrcnt)(PerlIO *f,STDCHAR *ptr,SSize_t cnt);
41 /*--------------------------------------------------------------------------------------*/
43 #define PERLIO_K_RAW 0x00000001
44 #define PERLIO_K_BUFFERED 0x00000002
45 #define PERLIO_K_CANCRLF 0x00000004
46 #define PERLIO_K_FASTGETS 0x00000008
47 #define PERLIO_K_DUMMY 0x00000010
48 #define PERLIO_K_UTF8 0x00008000
49 #define PERLIO_K_DESTRUCT 0x00010000
51 /*--------------------------------------------------------------------------------------*/
54 PerlIOl * next; /* Lower layer */
55 PerlIO_funcs * tab; /* Functions for this layer */
56 IV flags; /* Various flags for state */
59 /*--------------------------------------------------------------------------------------*/
62 #define PERLIO_F_EOF 0x00000100
63 #define PERLIO_F_CANWRITE 0x00000200
64 #define PERLIO_F_CANREAD 0x00000400
65 #define PERLIO_F_ERROR 0x00000800
66 #define PERLIO_F_TRUNCATE 0x00001000
67 #define PERLIO_F_APPEND 0x00002000
68 #define PERLIO_F_CRLF 0x00004000
69 #define PERLIO_F_UTF8 0x00008000
70 #define PERLIO_F_UNBUF 0x00010000
71 #define PERLIO_F_WRBUF 0x00020000
72 #define PERLIO_F_RDBUF 0x00040000
73 #define PERLIO_F_LINEBUF 0x00080000
74 #define PERLIO_F_TEMP 0x00100000
75 #define PERLIO_F_OPEN 0x00200000
76 #define PERLIO_F_FASTGETS 0x00400000
77 #define PERLIO_F_TTY 0x00800000
79 #define PerlIOBase(f) (*(f))
80 #define PerlIOSelf(f,type) ((type *)PerlIOBase(f))
81 #define PerlIONext(f) (&(PerlIOBase(f)->next))
83 /*--------------------------------------------------------------------------------------*/
84 /* Data exports - EXT rather than extern is needed for Cygwin */
85 EXT PerlIO_funcs PerlIO_unix;
86 EXT PerlIO_funcs PerlIO_perlio;
87 EXT PerlIO_funcs PerlIO_stdio;
88 EXT PerlIO_funcs PerlIO_crlf;
89 EXT PerlIO_funcs PerlIO_utf8;
90 EXT PerlIO_funcs PerlIO_byte;
91 EXT PerlIO_funcs PerlIO_raw;
92 EXT PerlIO_funcs PerlIO_pending;
94 EXT PerlIO_funcs PerlIO_mmap;
97 extern PerlIO *PerlIO_allocate(pTHX);
98 extern SV *PerlIO_arg_fetch(pTHX_ AV *av,IV n);
99 #define PerlIOArg PerlIO_arg_fetch(aTHX_ layers,n+1)
101 #if O_BINARY != O_TEXT
102 #define PERLIO_STDTEXT "t"
104 #define PERLIO_STDTEXT ""
107 /*--------------------------------------------------------------------------------------*/
108 /* Generic, or stub layer functions */
110 extern IV PerlIOBase_fileno (PerlIO *f);
111 extern IV PerlIOBase_pushed (PerlIO *f, const char *mode,SV *arg);
112 extern IV PerlIOBase_popped (PerlIO *f);
113 extern SSize_t PerlIOBase_read (PerlIO *f, void *vbuf, Size_t count);
114 extern SSize_t PerlIOBase_unread (PerlIO *f, const void *vbuf, Size_t count);
115 extern IV PerlIOBase_eof (PerlIO *f);
116 extern IV PerlIOBase_error (PerlIO *f);
117 extern void PerlIOBase_clearerr (PerlIO *f);
118 extern IV PerlIOBase_flush (PerlIO *f);
119 extern IV PerlIOBase_fill (PerlIO *f);
120 extern IV PerlIOBase_close (PerlIO *f);
121 extern void PerlIOBase_setlinebuf(PerlIO *f);
122 extern void PerlIOBase_flush_linebuf(void);
124 extern IV PerlIOBase_noop_ok (PerlIO *f);
125 extern IV PerlIOBase_noop_fail (PerlIO *f);
127 /*--------------------------------------------------------------------------------------*/
128 /* perlio buffer layer
129 As this is reasonably generic its struct and "methods" are declared here
130 so they can be used to "inherit" from it.
135 struct _PerlIO base; /* Base "class" info */
136 STDCHAR * buf; /* Start of buffer */
137 STDCHAR * end; /* End of valid part of buffer */
138 STDCHAR * ptr; /* Current position in buffer */
139 Off_t posn; /* Offset of buf into the file */
140 Size_t bufsiz; /* Real size of buffer */
141 IV oneword; /* Emergency buffer */
144 extern PerlIO * PerlIOBuf_open (pTHX_ PerlIO_funcs *self, AV *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *old, int narg, SV **args);
145 extern IV PerlIOBuf_pushed (PerlIO *f, const char *mode,SV *arg);
146 extern SSize_t PerlIOBuf_read (PerlIO *f, void *vbuf, Size_t count);
147 extern SSize_t PerlIOBuf_unread (PerlIO *f, const void *vbuf, Size_t count);
148 extern SSize_t PerlIOBuf_write (PerlIO *f, const void *vbuf, Size_t count);
149 extern IV PerlIOBuf_seek (PerlIO *f, Off_t offset, int whence);
150 extern Off_t PerlIOBuf_tell (PerlIO *f);
151 extern IV PerlIOBuf_close (PerlIO *f);
152 extern IV PerlIOBuf_flush (PerlIO *f);
153 extern IV PerlIOBuf_fill (PerlIO *f);
154 extern STDCHAR *PerlIOBuf_get_base (PerlIO *f);
155 extern Size_t PerlIOBuf_bufsiz (PerlIO *f);
156 extern STDCHAR *PerlIOBuf_get_ptr (PerlIO *f);
157 extern SSize_t PerlIOBuf_get_cnt (PerlIO *f);
158 extern void PerlIOBuf_set_ptrcnt (PerlIO *f, STDCHAR *ptr, SSize_t cnt);
160 /*--------------------------------------------------------------------------------------*/
162 #endif /* _PERLIOL_H */