YAP 7.1.0
stream.h
1/**************************************************************************
2 * *
3 * File: stream.h *
4 * Last rev: 5/2/88 *
5 * mods: *
6 * comments: Stream core routunes *
7 * *
8 *************************************************************************/
9#ifdef SCCS
10static char SccsId[] = "%W% %G%";
11#endif
12
13#if __ANDROID__
14#undef HAVE_FMEMOPEN
15#undef HAVE_OPEN_MEMSTREAM
16#endif
17
18#if _WIN32
19#undef MAY_WRITE
20#undef MAY_READ
21#endif
22
23typedef struct mem_desc {
24 char *buf; /* where the file is being read from/written to */
25 int src; /* where the space comes from, 0 code space, 1 malloc */
26 Int max_size; /* maximum buffer size (may be changed dynamically) */
27 UInt pos; /* cursor */
28 volatile void *error_handler;
29} memHandle;
30
31typedef struct stream_desc {
32 Atom name;
33 Term user_name;
34 FILE *file;
35 // useful in memory streams
36 char *nbuf;
37 size_t nsize;
38 union {
39 struct {
40#define PLGETC_BUF_SIZE 4096
41 unsigned char *buf, *ptr;
42 int left;
43 } file;
44 memHandle mem_string;
45 struct {
46 int fd;
47 } pipe;
48#if HAVE_SOCKET
49 struct {
50 socket_domain domain;
51 socket_info flags;
52 int fd;
53 } socket;
54#endif
55 struct {
56 const unsigned char *buf, *ptr;
57 } irl;
58 } u;
59
60 Int charcount, linecount, linestart;
61 stream_flags_t status;
62#if defined(YAPOR) || defined(THREADS)
63 lockvar streamlock; /* protect stream access */
64#endif
65 int (*stream_putc)(
66 int, int);
67 int (*stream_wputc)(
68 int, wchar_t);
69 int (*stream_getc)(int);
70 int (*stream_wgetc)(
71 int);
72 struct vfs *vfs;
73 void *vfs_handle;
75 int); /* function the stream uses for parser. It may be different
76 from above if the ISO character conversion is on */
77 encoding_t encoding;
79
int(* stream_getc)(int)
function the stream uses for writing a character
Definition: YapStreams.h:256
int(* stream_wputc)(int, wchar_t)
function the stream uses for writing a single octet
Definition: YapStreams.h:254
void * vfs_handle
stream belongs to a space
Definition: YapStreams.h:260
encoding_t encoding
check if the next wide character is available
Definition: YapStreams.h:265
int(* stream_wgetc)(int)
function the stream uses for reading an octet
Definition: YapStreams.h:257
struct vfs * vfs
function the stream uses for reading a character
Definition: YapStreams.h:259
int(* stream_wgetc_for_read)(int)
direct handle to stream in that space
Definition: YapStreams.h:261
Definition: VFS.h:74