ef6b1f0dce5613e27e943ac7543275d7618c5bff
[rodin/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 buflen;
46         gidispatch_rock_t buffer_rock;
47         /* Specific to file streams */
48         FILE *file_pointer;
49         gboolean binary;
50         gchar *filename; /* Displayable filename in UTF-8 for error handling */
51
52         gchar *style; /* Name of the current style */
53         gboolean hyperlink_mode; /* When turned on, text written to the stream will be a hyperlink */
54 };
55
56 G_GNUC_INTERNAL strid_t file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode);
57 G_GNUC_INTERNAL strid_t stream_new_common(glui32 rock);
58 G_GNUC_INTERNAL void stream_close_common(strid_t str, stream_result_t *result);
59
60 #endif