04134f5807f307b592adc5779eaca1208743bc00
[rodin/chimara.git] / src / stream.h
1 #ifndef STREAM_H
2 #define STREAM_H
3
4 #include <gtk/gtk.h>
5 #include "glk.h"
6 #include "window.h"
7
8 enum StreamType
9 {
10         STREAM_TYPE_WINDOW,
11         STREAM_TYPE_MEMORY,
12         STREAM_TYPE_FILE
13 };
14
15 struct glk_stream_struct
16 {
17         glui32 rock;
18         /* Pointer to the list node in the global stream list that contains this
19         stream */
20         GList* stream_list;
21         /* Stream parameters */
22         glui32 file_mode;
23         glui32 read_count;
24         glui32 write_count;
25         enum StreamType type;
26         /* Specific to window stream: the window this stream is connected to */
27         winid_t window;
28         /* For memory and file streams */
29         gboolean unicode;
30         /* Specific to memory streams */
31         gchar *buffer;
32         glui32 *ubuffer;
33         glui32 mark;
34         glui32 buflen;
35         /* Specific to file streams */
36         FILE *file_pointer;
37         gboolean binary;
38         gchar *filename; /* Displayable filename in UTF-8 for error handling */
39 };
40
41 strid_t window_stream_new(winid_t window);
42 void stream_close_common(strid_t str, stream_result_t *result);
43 #endif