Commit | Line | Data |
---|---|---|
76ced9ad NIS |
1 | #ifndef _PERLIOL_H |
2 | #define _PERLIOL_H | |
3 | ||
4 | struct _PerlIO_funcs | |
5 | { | |
6 | char * name; | |
7 | Size_t size; | |
8 | IV kind; | |
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); | |
33af2bc7 | 13 | IV (*Pushed)(PerlIO *f,const char *mode,const char *arg,STRLEN len); |
76ced9ad NIS |
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); | |
25 | IV (*Eof)(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); | |
35 | }; | |
36 | ||
f5b9d040 NIS |
37 | /*--------------------------------------------------------------------------------------*/ |
38 | /* Kind values */ | |
5e2ab84b NIS |
39 | #define PERLIO_K_RAW 0x00000001 |
40 | #define PERLIO_K_BUFFERED 0x00000002 | |
f5b9d040 | 41 | #define PERLIO_K_CANCRLF 0x00000004 |
5e2ab84b | 42 | #define PERLIO_K_FASTGETS 0x00000008 |
dfebf958 | 43 | #define PERLIO_K_DUMMY 0x00000010 |
f5b9d040 NIS |
44 | |
45 | /*--------------------------------------------------------------------------------------*/ | |
76ced9ad NIS |
46 | struct _PerlIO |
47 | { | |
48 | PerlIOl * next; /* Lower layer */ | |
49 | PerlIO_funcs * tab; /* Functions for this layer */ | |
50 | IV flags; /* Various flags for state */ | |
51 | }; | |
52 | ||
53 | /*--------------------------------------------------------------------------------------*/ | |
54 | ||
55 | /* Flag values */ | |
5e2ab84b NIS |
56 | #define PERLIO_F_EOF 0x00000100 |
57 | #define PERLIO_F_CANWRITE 0x00000200 | |
58 | #define PERLIO_F_CANREAD 0x00000400 | |
59 | #define PERLIO_F_ERROR 0x00000800 | |
60 | #define PERLIO_F_TRUNCATE 0x00001000 | |
61 | #define PERLIO_F_APPEND 0x00002000 | |
62 | #define PERLIO_F_CRLF 0x00004000 | |
63 | #define PERLIO_F_UTF8 0x00008000 | |
64 | #define PERLIO_F_UNBUF 0x00010000 | |
65 | #define PERLIO_F_WRBUF 0x00020000 | |
66 | #define PERLIO_F_RDBUF 0x00040000 | |
67 | #define PERLIO_F_LINEBUF 0x00080000 | |
68 | #define PERLIO_F_TEMP 0x00100000 | |
69 | #define PERLIO_F_OPEN 0x00200000 | |
70 | #define PERLIO_F_FASTGETS 0x00400000 | |
76ced9ad NIS |
71 | |
72 | #define PerlIOBase(f) (*(f)) | |
73 | #define PerlIOSelf(f,type) ((type *)PerlIOBase(f)) | |
74 | #define PerlIONext(f) (&(PerlIOBase(f)->next)) | |
75 | ||
76 | /*--------------------------------------------------------------------------------------*/ | |
77 | ||
78 | extern PerlIO_funcs PerlIO_unix; | |
79 | extern PerlIO_funcs PerlIO_perlio; | |
80 | extern PerlIO_funcs PerlIO_stdio; | |
66ecd56b | 81 | extern PerlIO_funcs PerlIO_crlf; |
dfebf958 NIS |
82 | extern PerlIO_funcs PerlIO_utf8; |
83 | extern PerlIO_funcs PerlIO_raw; | |
7ea3cd40 NIS |
84 | /* The EXT is need for Cygwin -- but why only for _pending? --jhi */ |
85 | EXT PerlIO_funcs PerlIO_pending; | |
76ced9ad NIS |
86 | #ifdef HAS_MMAP |
87 | extern PerlIO_funcs PerlIO_mmap; | |
88 | #endif | |
89 | ||
5f1a76d0 | 90 | extern PerlIO *PerlIO_allocate(pTHX); |
76ced9ad | 91 | |
f5b9d040 NIS |
92 | #if O_BINARY != O_TEXT |
93 | #define PERLIO_STDTEXT "t" | |
94 | #else | |
95 | #define PERLIO_STDTEXT "" | |
96 | #endif | |
97 | ||
76ced9ad NIS |
98 | /*--------------------------------------------------------------------------------------*/ |
99 | /* Generic, or stub layer functions */ | |
100 | ||
101 | extern IV PerlIOBase_fileno (PerlIO *f); | |
33af2bc7 | 102 | extern IV PerlIOBase_pushed (PerlIO *f, const char *mode,const char *arg,STRLEN len); |
76ced9ad NIS |
103 | extern IV PerlIOBase_popped (PerlIO *f); |
104 | extern SSize_t PerlIOBase_unread (PerlIO *f, const void *vbuf, Size_t count); | |
105 | extern IV PerlIOBase_eof (PerlIO *f); | |
106 | extern IV PerlIOBase_error (PerlIO *f); | |
107 | extern void PerlIOBase_clearerr (PerlIO *f); | |
108 | extern IV PerlIOBase_flush (PerlIO *f); | |
109 | extern IV PerlIOBase_fill (PerlIO *f); | |
110 | extern IV PerlIOBase_close (PerlIO *f); | |
111 | extern void PerlIOBase_setlinebuf(PerlIO *f); | |
112 | ||
113 | extern IV PerlIOBase_noop_ok (PerlIO *f); | |
114 | extern IV PerlIOBase_noop_fail (PerlIO *f); | |
115 | ||
116 | /*--------------------------------------------------------------------------------------*/ | |
117 | /* perlio buffer layer | |
118 | As this is reasonably generic its struct and "methods" are declared here | |
119 | so they can be used to "inherit" from it. | |
120 | */ | |
121 | ||
122 | typedef struct | |
123 | { | |
124 | struct _PerlIO base; /* Base "class" info */ | |
125 | STDCHAR * buf; /* Start of buffer */ | |
126 | STDCHAR * end; /* End of valid part of buffer */ | |
127 | STDCHAR * ptr; /* Current position in buffer */ | |
128 | Off_t posn; /* Offset of buf into the file */ | |
129 | Size_t bufsiz; /* Real size of buffer */ | |
130 | IV oneword; /* Emergency buffer */ | |
131 | } PerlIOBuf; | |
132 | ||
133 | extern PerlIO * PerlIOBuf_fdopen (PerlIO_funcs *self, int fd, const char *mode); | |
134 | extern PerlIO * PerlIOBuf_open (PerlIO_funcs *self, const char *path, const char *mode); | |
135 | extern int PerlIOBuf_reopen (const char *path, const char *mode, PerlIO *f); | |
136 | extern SSize_t PerlIOBuf_read (PerlIO *f, void *vbuf, Size_t count); | |
137 | extern SSize_t PerlIOBuf_unread (PerlIO *f, const void *vbuf, Size_t count); | |
138 | extern SSize_t PerlIOBuf_write (PerlIO *f, const void *vbuf, Size_t count); | |
139 | extern IV PerlIOBuf_seek (PerlIO *f, Off_t offset, int whence); | |
140 | extern Off_t PerlIOBuf_tell (PerlIO *f); | |
141 | extern IV PerlIOBuf_close (PerlIO *f); | |
142 | extern IV PerlIOBuf_flush (PerlIO *f); | |
143 | extern IV PerlIOBuf_fill (PerlIO *f); | |
144 | extern void PerlIOBuf_setlinebuf (PerlIO *f); | |
145 | extern STDCHAR *PerlIOBuf_get_base (PerlIO *f); | |
146 | extern Size_t PerlIOBuf_bufsiz (PerlIO *f); | |
147 | extern STDCHAR *PerlIOBuf_get_ptr (PerlIO *f); | |
148 | extern SSize_t PerlIOBuf_get_cnt (PerlIO *f); | |
149 | extern void PerlIOBuf_set_ptrcnt (PerlIO *f, STDCHAR *ptr, SSize_t cnt); | |
150 | ||
151 | /*--------------------------------------------------------------------------------------*/ | |
152 | ||
153 | #endif /* _PERLIOL_H */ |