Unicode properties: fix L& (the #12319 didn't allow L&,
[p5sagit/p5-mst-13.2.git] / perliol.h
CommitLineData
76ced9ad 1#ifndef _PERLIOL_H
2#define _PERLIOL_H
3
14a5cf38 4typedef struct {
5 PerlIO_funcs *funcs;
6 SV *arg;
fcf2db38 7} PerlIO_pair_t;
8
14a5cf38 9typedef struct {
10 IV refcnt;
11 IV cur;
12 IV len;
13 PerlIO_pair_t *array;
fcf2db38 14} PerlIO_list_t;
15
14a5cf38 16struct _PerlIO_funcs {
17 char *name;
18 Size_t size;
19 IV kind;
20 IV (*Pushed) (PerlIO *f, const char *mode, SV *arg);
21 IV (*Popped) (PerlIO *f);
22 PerlIO *(*Open) (pTHX_ PerlIO_funcs *tab,
23 PerlIO_list_t *layers, IV n,
24 const char *mode,
25 int fd, int imode, int perm,
26 PerlIO *old, int narg, SV **args);
27 SV *(*Getarg) (PerlIO *f);
28 IV (*Fileno) (PerlIO *f);
29 /* Unix-like functions - cf sfio line disciplines */
30 SSize_t(*Read) (PerlIO *f, void *vbuf, Size_t count);
31 SSize_t(*Unread) (PerlIO *f, const void *vbuf, Size_t count);
32 SSize_t(*Write) (PerlIO *f, const void *vbuf, Size_t count);
33 IV (*Seek) (PerlIO *f, Off_t offset, int whence);
34 Off_t(*Tell) (PerlIO *f);
35 IV (*Close) (PerlIO *f);
36 /* Stdio-like buffered IO functions */
37 IV (*Flush) (PerlIO *f);
38 IV (*Fill) (PerlIO *f);
39 IV (*Eof) (PerlIO *f);
40 IV (*Error) (PerlIO *f);
41 void (*Clearerr) (PerlIO *f);
42 void (*Setlinebuf) (PerlIO *f);
43 /* Perl's snooping functions */
44 STDCHAR *(*Get_base) (PerlIO *f);
45 Size_t(*Get_bufsiz) (PerlIO *f);
46 STDCHAR *(*Get_ptr) (PerlIO *f);
47 SSize_t(*Get_cnt) (PerlIO *f);
48 void (*Set_ptrcnt) (PerlIO *f, STDCHAR * ptr, SSize_t cnt);
76ced9ad 49};
50
f5b9d040 51/*--------------------------------------------------------------------------------------*/
52/* Kind values */
5e2ab84b 53#define PERLIO_K_RAW 0x00000001
54#define PERLIO_K_BUFFERED 0x00000002
f5b9d040 55#define PERLIO_K_CANCRLF 0x00000004
5e2ab84b 56#define PERLIO_K_FASTGETS 0x00000008
dfebf958 57#define PERLIO_K_DUMMY 0x00000010
26fb694e 58#define PERLIO_K_UTF8 0x00008000
13621cfb 59#define PERLIO_K_DESTRUCT 0x00010000
f5b9d040 60
61/*--------------------------------------------------------------------------------------*/
14a5cf38 62struct _PerlIO {
63 PerlIOl *next; /* Lower layer */
64 PerlIO_funcs *tab; /* Functions for this layer */
65 IV flags; /* Various flags for state */
76ced9ad 66};
67
68/*--------------------------------------------------------------------------------------*/
69
70/* Flag values */
5e2ab84b 71#define PERLIO_F_EOF 0x00000100
72#define PERLIO_F_CANWRITE 0x00000200
73#define PERLIO_F_CANREAD 0x00000400
74#define PERLIO_F_ERROR 0x00000800
75#define PERLIO_F_TRUNCATE 0x00001000
76#define PERLIO_F_APPEND 0x00002000
77#define PERLIO_F_CRLF 0x00004000
78#define PERLIO_F_UTF8 0x00008000
79#define PERLIO_F_UNBUF 0x00010000
80#define PERLIO_F_WRBUF 0x00020000
81#define PERLIO_F_RDBUF 0x00040000
82#define PERLIO_F_LINEBUF 0x00080000
83#define PERLIO_F_TEMP 0x00100000
84#define PERLIO_F_OPEN 0x00200000
85#define PERLIO_F_FASTGETS 0x00400000
a9c883f6 86#define PERLIO_F_TTY 0x00800000
76ced9ad 87
88#define PerlIOBase(f) (*(f))
89#define PerlIOSelf(f,type) ((type *)PerlIOBase(f))
90#define PerlIONext(f) (&(PerlIOBase(f)->next))
91
92/*--------------------------------------------------------------------------------------*/
26fb694e 93/* Data exports - EXT rather than extern is needed for Cygwin */
94EXT PerlIO_funcs PerlIO_unix;
95EXT PerlIO_funcs PerlIO_perlio;
96EXT PerlIO_funcs PerlIO_stdio;
97EXT PerlIO_funcs PerlIO_crlf;
98EXT PerlIO_funcs PerlIO_utf8;
99EXT PerlIO_funcs PerlIO_byte;
100EXT PerlIO_funcs PerlIO_raw;
7ea3cd40 101EXT PerlIO_funcs PerlIO_pending;
76ced9ad 102#ifdef HAS_MMAP
26fb694e 103EXT PerlIO_funcs PerlIO_mmap;
76ced9ad 104#endif
0c4128ad 105#ifdef WIN32
106EXT PerlIO_funcs PerlIO_win32;
107#endif
5f1a76d0 108extern PerlIO *PerlIO_allocate(pTHX);
14a5cf38 109extern SV *PerlIO_arg_fetch(PerlIO_list_t *av, IV n);
fcf2db38 110#define PerlIOArg PerlIO_arg_fetch(layers,n)
76ced9ad 111
f5b9d040 112#if O_BINARY != O_TEXT
113#define PERLIO_STDTEXT "t"
114#else
115#define PERLIO_STDTEXT ""
116#endif
117
76ced9ad 118/*--------------------------------------------------------------------------------------*/
119/* Generic, or stub layer functions */
120
14a5cf38 121extern IV PerlIOBase_fileno(PerlIO *f);
122extern IV PerlIOBase_pushed(PerlIO *f, const char *mode, SV *arg);
123extern IV PerlIOBase_popped(PerlIO *f);
124extern SSize_t PerlIOBase_read(PerlIO *f, void *vbuf, Size_t count);
125extern SSize_t PerlIOBase_unread(PerlIO *f, const void *vbuf,
126 Size_t count);
127extern IV PerlIOBase_eof(PerlIO *f);
128extern IV PerlIOBase_error(PerlIO *f);
129extern void PerlIOBase_clearerr(PerlIO *f);
130extern IV PerlIOBase_close(PerlIO *f);
131extern void PerlIOBase_setlinebuf(PerlIO *f);
132extern void PerlIOBase_flush_linebuf(void);
133
134extern IV PerlIOBase_noop_ok(PerlIO *f);
135extern IV PerlIOBase_noop_fail(PerlIO *f);
76ced9ad 136
137/*--------------------------------------------------------------------------------------*/
138/* perlio buffer layer
139 As this is reasonably generic its struct and "methods" are declared here
140 so they can be used to "inherit" from it.
141*/
142
14a5cf38 143typedef struct {
144 struct _PerlIO base; /* Base "class" info */
145 STDCHAR *buf; /* Start of buffer */
146 STDCHAR *end; /* End of valid part of buffer */
147 STDCHAR *ptr; /* Current position in buffer */
148 Off_t posn; /* Offset of buf into the file */
149 Size_t bufsiz; /* Real size of buffer */
150 IV oneword; /* Emergency buffer */
76ced9ad 151} PerlIOBuf;
152
14a5cf38 153extern PerlIO *PerlIOBuf_open(pTHX_ PerlIO_funcs *self,
154 PerlIO_list_t *layers, IV n,
155 const char *mode, int fd, int imode,
156 int perm, PerlIO *old, int narg, SV **args);
157extern IV PerlIOBuf_pushed(PerlIO *f, const char *mode, SV *arg);
158extern SSize_t PerlIOBuf_read(PerlIO *f, void *vbuf, Size_t count);
159extern SSize_t PerlIOBuf_unread(PerlIO *f, const void *vbuf, Size_t count);
160extern SSize_t PerlIOBuf_write(PerlIO *f, const void *vbuf, Size_t count);
161extern IV PerlIOBuf_seek(PerlIO *f, Off_t offset, int whence);
162extern Off_t PerlIOBuf_tell(PerlIO *f);
163extern IV PerlIOBuf_close(PerlIO *f);
164extern IV PerlIOBuf_flush(PerlIO *f);
165extern IV PerlIOBuf_fill(PerlIO *f);
166extern STDCHAR *PerlIOBuf_get_base(PerlIO *f);
167extern Size_t PerlIOBuf_bufsiz(PerlIO *f);
168extern STDCHAR *PerlIOBuf_get_ptr(PerlIO *f);
169extern SSize_t PerlIOBuf_get_cnt(PerlIO *f);
170extern void PerlIOBuf_set_ptrcnt(PerlIO *f, STDCHAR * ptr, SSize_t cnt);
171
172extern int PerlIOUnix_oflags(const char *mode);
0c4128ad 173
76ced9ad 174/*--------------------------------------------------------------------------------------*/
175
14a5cf38 176#endif /* _PERLIOL_H */