7ff7618c61ef44dc78a75ebc1b60033f45c81718
[projects/chimara/chimara.git] / libchimara / stream.h
1 #ifndef STREAM_H
2 #define STREAM_H
3
4 #include <gtk/gtk.h>
5 #include "chimara-glk-private.h"
6 #include "glk.h"
7 #include "gi_dispa.h"
8 #include "window.h"
9 #include "fileref.h"
10
11 enum StreamType
12 {
13         STREAM_TYPE_WINDOW,
14         STREAM_TYPE_MEMORY,
15         STREAM_TYPE_FILE
16 };
17
18 /**
19  * glk_stream_struct:
20  *
21  * This is an opaque structure (see <link linkend="chimara-Opaque-Structures">
22  * Opaque Structures</link> and should not be accessed directly.
23  */
24 struct glk_stream_struct
25 {
26         /*< private >*/
27         glui32 magic, rock;
28         gidispatch_rock_t disprock;
29         /* Pointer to the list node in the global stream list that contains this
30         stream */
31         GList* stream_list;
32         /* Stream parameters */
33         glui32 file_mode;
34         glui32 read_count;
35         glui32 write_count;
36         enum StreamType type;
37         /* Specific to window stream: the window this stream is connected to */
38         winid_t window;
39         /* For memory and file streams */
40         gboolean unicode;
41         /* Specific to memory streams */
42         gchar *buffer;
43         glui32 *ubuffer;
44         glui32 mark;
45         glui32 endmark;
46         glui32 buflen;
47         gidispatch_rock_t buffer_rock;
48         /* Specific to file streams */
49         FILE *file_pointer;
50         gboolean binary;
51         gchar *filename; /* Displayable filename in UTF-8 for error handling */
52         glui32 lastop; /* 0, filemode_Write, or filemode_Read */
53
54         gchar *style; /* Name of the current style */
55         gchar *glk_style; /* Name of the current glk style override */
56         gboolean hyperlink_mode; /* When turned on, text written to the stream will be a hyperlink */
57 };
58
59 G_GNUC_INTERNAL strid_t file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode);
60 G_GNUC_INTERNAL strid_t stream_new_common(glui32 rock);
61 G_GNUC_INTERNAL void stream_close_common(strid_t str, stream_result_t *result);
62
63 #endif