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