#include <glib.h>
#include <glib/gstdio.h>
-/* Global current stream */
-static strid_t current_stream = NULL;
-/* List of streams currently in existence */
-static GList *stream_list = NULL;
+#include "chimara-glk-private.h"
+extern ChimaraGlkPrivate *glk_data;
/* Internal function: create a window stream to go with window. */
strid_t
str->window = window;
/* Add it to the global stream list */
- stream_list = g_list_prepend(stream_list, str);
- str->stream_list = stream_list;
+ glk_data->stream_list = g_list_prepend(glk_data->stream_list, str);
+ str->stream_list = glk_data->stream_list;
return str;
}
GList *retnode;
if(str == NULL)
- retnode = stream_list;
+ retnode = glk_data->stream_list;
else
retnode = str->stream_list->next;
strid_t retval = retnode? (strid_t)retnode->data : NULL;
return;
}
- current_stream = str;
+ glk_data->current_stream = str;
}
/**
strid_t
glk_stream_get_current()
{
- return current_stream;
+ return glk_data->current_stream;
}
/**
void
glk_put_char(unsigned char ch)
{
- g_return_if_fail(current_stream != NULL);
- glk_put_char_stream(current_stream, ch);
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_char_stream(glk_data->current_stream, ch);
+}
+
+/**
+ * glk_put_char_uni:
+ * @ch: A Unicode code point.
+ *
+ * Prints one character to the current stream. The character is assumed to be a
+ * Unicode code point.
+ */
+void
+glk_put_char_uni(glui32 ch)
+{
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_char_stream_uni(glk_data->current_stream, ch);
}
/**
void
glk_put_string(char *s)
{
- g_return_if_fail(current_stream != NULL);
- glk_put_string_stream(current_stream, s);
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_string_stream(glk_data->current_stream, s);
+}
+
+/**
+ * glk_put_string_uni:
+ * @s: A zero-terminated string of Unicode code points.
+ *
+ * Prints a string of Unicode characters to the current stream. It is equivalent
+ * to a series of glk_put_char_uni() calls. A string ends on a #glui32 whose
+ * value is 0.
+ */
+void
+glk_put_string_uni(glui32 *s)
+{
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_string_stream_uni(glk_data->current_stream, s);
}
/**
void
glk_put_buffer(char *buf, glui32 len)
{
- g_return_if_fail(current_stream != NULL);
- glk_put_buffer_stream(current_stream, buf, len);
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_buffer_stream(glk_data->current_stream, buf, len);
+}
+
+/**
+ * glk_put_buffer_uni:
+ * @buf: An array of Unicode code points.
+ * @len: Length of @buf.
+ *
+ * Prints a block of Unicode characters to the current stream. It is equivalent
+ * to a series of glk_put_char_uni() calls.
+ */
+void
+glk_put_buffer_uni(glui32 *buf, glui32 len)
+{
+ g_return_if_fail(glk_data->current_stream != NULL);
+ glk_put_buffer_stream_uni(glk_data->current_stream, buf, len);
}
/**
str->unicode = FALSE;
/* Add it to the global stream list */
- stream_list = g_list_prepend(stream_list, str);
- str->stream_list = stream_list;
+ glk_data->stream_list = g_list_prepend(glk_data->stream_list, str);
+ str->stream_list = glk_data->stream_list;
return str;
}
str->unicode = TRUE;
/* Add it to the global stream list */
- stream_list = g_list_prepend(stream_list, str);
- str->stream_list = stream_list;
+ glk_data->stream_list = g_list_prepend(glk_data->stream_list, str);
+ str->stream_list = glk_data->stream_list;
return str;
}
if(str->filename == NULL)
str->filename = g_strdup("Unknown file name"); /* fail silently */
/* Add it to the global stream list */
- stream_list = g_list_prepend(stream_list, str);
- str->stream_list = stream_list;
+ glk_data->stream_list = g_list_prepend(glk_data->stream_list, str);
+ str->stream_list = glk_data->stream_list;
return str;
}
stream_close_common(strid_t str, stream_result_t *result)
{
/* Remove the stream from the global stream list */
- stream_list = g_list_delete_link(stream_list, str->stream_list);
+ glk_data->stream_list = g_list_delete_link(glk_data->stream_list, str->stream_list);
/* If it was the current output stream, set that to NULL */
- if(current_stream == str)
- current_stream = NULL;
+ if(glk_data->current_stream == str)
+ glk_data->current_stream = NULL;
/* If it was one or more windows' echo streams, set those to NULL */
winid_t win;