This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Win32/perlio Now just fails one io/argv.t test - lack
[perl5.git] / perliol.h
CommitLineData
76ced9ad
NIS
1#ifndef _PERLIOL_H
2#define _PERLIOL_H
3
4struct _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);
13 IV (*Pushed)(PerlIO *f,const char *mode);
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
37struct _PerlIO
38{
39 PerlIOl * next; /* Lower layer */
40 PerlIO_funcs * tab; /* Functions for this layer */
41 IV flags; /* Various flags for state */
42};
43
44/*--------------------------------------------------------------------------------------*/
45
46/* Flag values */
47#define PERLIO_F_EOF 0x00010000
48#define PERLIO_F_CANWRITE 0x00020000
49#define PERLIO_F_CANREAD 0x00040000
50#define PERLIO_F_ERROR 0x00080000
51#define PERLIO_F_TRUNCATE 0x00100000
52#define PERLIO_F_APPEND 0x00200000
53#define PERLIO_F_BINARY 0x00400000
54#define PERLIO_F_UTF8 0x00800000
55#define PERLIO_F_LINEBUF 0x01000000
56#define PERLIO_F_WRBUF 0x02000000
57#define PERLIO_F_RDBUF 0x04000000
58#define PERLIO_F_TEMP 0x08000000
59#define PERLIO_F_OPEN 0x10000000
60
61#define PerlIOBase(f) (*(f))
62#define PerlIOSelf(f,type) ((type *)PerlIOBase(f))
63#define PerlIONext(f) (&(PerlIOBase(f)->next))
64
65/*--------------------------------------------------------------------------------------*/
66
67extern PerlIO_funcs PerlIO_unix;
68extern PerlIO_funcs PerlIO_perlio;
69extern PerlIO_funcs PerlIO_stdio;
66ecd56b 70extern PerlIO_funcs PerlIO_crlf;
76ced9ad
NIS
71#ifdef HAS_MMAP
72extern PerlIO_funcs PerlIO_mmap;
73#endif
74
75extern PerlIO *PerlIO_allocate(void);
76
77/*--------------------------------------------------------------------------------------*/
78/* Generic, or stub layer functions */
79
80extern IV PerlIOBase_fileno (PerlIO *f);
81extern IV PerlIOBase_pushed (PerlIO *f, const char *mode);
82extern IV PerlIOBase_popped (PerlIO *f);
83extern SSize_t PerlIOBase_unread (PerlIO *f, const void *vbuf, Size_t count);
84extern IV PerlIOBase_eof (PerlIO *f);
85extern IV PerlIOBase_error (PerlIO *f);
86extern void PerlIOBase_clearerr (PerlIO *f);
87extern IV PerlIOBase_flush (PerlIO *f);
88extern IV PerlIOBase_fill (PerlIO *f);
89extern IV PerlIOBase_close (PerlIO *f);
90extern void PerlIOBase_setlinebuf(PerlIO *f);
91
92extern IV PerlIOBase_noop_ok (PerlIO *f);
93extern IV PerlIOBase_noop_fail (PerlIO *f);
94
95/*--------------------------------------------------------------------------------------*/
96/* perlio buffer layer
97 As this is reasonably generic its struct and "methods" are declared here
98 so they can be used to "inherit" from it.
99*/
100
101typedef struct
102{
103 struct _PerlIO base; /* Base "class" info */
104 STDCHAR * buf; /* Start of buffer */
105 STDCHAR * end; /* End of valid part of buffer */
106 STDCHAR * ptr; /* Current position in buffer */
107 Off_t posn; /* Offset of buf into the file */
108 Size_t bufsiz; /* Real size of buffer */
109 IV oneword; /* Emergency buffer */
110} PerlIOBuf;
111
112extern PerlIO * PerlIOBuf_fdopen (PerlIO_funcs *self, int fd, const char *mode);
113extern PerlIO * PerlIOBuf_open (PerlIO_funcs *self, const char *path, const char *mode);
114extern int PerlIOBuf_reopen (const char *path, const char *mode, PerlIO *f);
115extern SSize_t PerlIOBuf_read (PerlIO *f, void *vbuf, Size_t count);
116extern SSize_t PerlIOBuf_unread (PerlIO *f, const void *vbuf, Size_t count);
117extern SSize_t PerlIOBuf_write (PerlIO *f, const void *vbuf, Size_t count);
118extern IV PerlIOBuf_seek (PerlIO *f, Off_t offset, int whence);
119extern Off_t PerlIOBuf_tell (PerlIO *f);
120extern IV PerlIOBuf_close (PerlIO *f);
121extern IV PerlIOBuf_flush (PerlIO *f);
122extern IV PerlIOBuf_fill (PerlIO *f);
123extern void PerlIOBuf_setlinebuf (PerlIO *f);
124extern STDCHAR *PerlIOBuf_get_base (PerlIO *f);
125extern Size_t PerlIOBuf_bufsiz (PerlIO *f);
126extern STDCHAR *PerlIOBuf_get_ptr (PerlIO *f);
127extern SSize_t PerlIOBuf_get_cnt (PerlIO *f);
128extern void PerlIOBuf_set_ptrcnt (PerlIO *f, STDCHAR *ptr, SSize_t cnt);
129
130/*--------------------------------------------------------------------------------------*/
131
132#endif /* _PERLIOL_H */