projects
/
projects
/
chimara
/
chimara.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some cosmetic fixes, like giving a window the focus when it asks for character input
[projects/chimara/chimara.git]
/
libchimara
/
stream.c
diff --git
a/libchimara/stream.c
b/libchimara/stream.c
index 804399213ae7cbe87ebcbb96134130d5d4d51dd6..72b36a84087eadbdb0f54662e40c4779a6263947 100644
(file)
--- a/
libchimara/stream.c
+++ b/
libchimara/stream.c
@@
-7,12
+7,14
@@
#include <glib/gstdio.h>
#include "chimara-glk-private.h"
#include <glib/gstdio.h>
#include "chimara-glk-private.h"
-extern
ChimaraGlkPrivate *glk_data
;
+extern
GPrivate *glk_data_key
;
/* Internal function: create a stream with a specified rock value */
static strid_t
stream_new_common(glui32 rock, glui32 fmode, enum StreamType type)
{
/* Internal function: create a stream with a specified rock value */
static strid_t
stream_new_common(glui32 rock, glui32 fmode, enum StreamType type)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+
strid_t str = g_new0(struct glk_stream_struct, 1);
str->magic = MAGIC_STREAM;
str->rock = rock;
strid_t str = g_new0(struct glk_stream_struct, 1);
str->magic = MAGIC_STREAM;
str->rock = rock;
@@
-52,7
+54,8
@@
strid_t
glk_stream_iterate(strid_t str, glui32 *rockptr)
{
VALID_STREAM_OR_NULL(str, return NULL);
glk_stream_iterate(strid_t str, glui32 *rockptr)
{
VALID_STREAM_OR_NULL(str, return NULL);
-
+
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
GList *retnode;
if(str == NULL)
GList *retnode;
if(str == NULL)
@@
-96,6
+99,8
@@
void
glk_stream_set_current(strid_t str)
{
VALID_STREAM_OR_NULL(str, return);
glk_stream_set_current(strid_t str)
{
VALID_STREAM_OR_NULL(str, return);
+
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
if(str != NULL && str->file_mode == filemode_Read)
{
if(str != NULL && str->file_mode == filemode_Read)
{
@@
-116,6
+121,7
@@
glk_stream_set_current(strid_t str)
strid_t
glk_stream_get_current()
{
strid_t
glk_stream_get_current()
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
return glk_data->current_stream;
}
return glk_data->current_stream;
}
@@
-130,6
+136,7
@@
glk_stream_get_current()
void
glk_put_char(unsigned char ch)
{
void
glk_put_char(unsigned char ch)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_char_stream(glk_data->current_stream, ch);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_char_stream(glk_data->current_stream, ch);
}
@@
-145,6
+152,7
@@
glk_put_char(unsigned char ch)
void
glk_put_char_uni(glui32 ch)
{
void
glk_put_char_uni(glui32 ch)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_char_stream_uni(glk_data->current_stream, ch);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_char_stream_uni(glk_data->current_stream, ch);
}
@@
-156,7
+164,7
@@
glk_put_char_uni(glui32 ch)
* Prints a null-terminated string to the current stream. It is exactly
* equivalent to
* |[
* Prints a null-terminated string to the current stream. It is exactly
* equivalent to
* |[
- * for (ptr =
@
s; *ptr; ptr++)
+ * for (ptr = s; *ptr; ptr++)
* #glk_put_char(*ptr);
* ]|
* However, it may be more efficient.
* #glk_put_char(*ptr);
* ]|
* However, it may be more efficient.
@@
-164,6
+172,7
@@
glk_put_char_uni(glui32 ch)
void
glk_put_string(char *s)
{
void
glk_put_string(char *s)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_string_stream(glk_data->current_stream, s);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_string_stream(glk_data->current_stream, s);
}
@@
-179,6
+188,7
@@
glk_put_string(char *s)
void
glk_put_string_uni(glui32 *s)
{
void
glk_put_string_uni(glui32 *s)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_string_stream_uni(glk_data->current_stream, s);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_string_stream_uni(glk_data->current_stream, s);
}
@@
-191,14
+201,15
@@
glk_put_string_uni(glui32 *s)
* Prints a block of characters to the current stream. It is exactly equivalent
* to:
* |[
* Prints a block of characters to the current stream. It is exactly equivalent
* to:
* |[
- * for (i = 0; i <
@
len; i++)
- * #glk_put_char(
@
buf[i]);
+ * for (i = 0; i < len; i++)
+ * #glk_put_char(buf[i]);
* ]|
* However, it may be more efficient.
*/
void
glk_put_buffer(char *buf, glui32 len)
{
* ]|
* However, it may be more efficient.
*/
void
glk_put_buffer(char *buf, glui32 len)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_buffer_stream(glk_data->current_stream, buf, len);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_buffer_stream(glk_data->current_stream, buf, len);
}
@@
-214,6
+225,7
@@
glk_put_buffer(char *buf, glui32 len)
void
glk_put_buffer_uni(glui32 *buf, glui32 len)
{
void
glk_put_buffer_uni(glui32 *buf, glui32 len)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
VALID_STREAM(glk_data->current_stream, return);
glk_put_buffer_stream_uni(glk_data->current_stream, buf, len);
}
VALID_STREAM(glk_data->current_stream, return);
glk_put_buffer_stream_uni(glk_data->current_stream, buf, len);
}
@@
-223,7
+235,7
@@
glk_put_buffer_uni(glui32 *buf, glui32 len)
* @buf: An allocated buffer, or %NULL.
* @buflen: Length of @buf.
* @fmode: Mode in which the buffer will be opened. Must be one of
* @buf: An allocated buffer, or %NULL.
* @buflen: Length of @buf.
* @fmode: Mode in which the buffer will be opened. Must be one of
- *
#filemode_Read, #filemode_Write, or #
filemode_ReadWrite.
+ *
%filemode_Read, %filemode_Write, or %
filemode_ReadWrite.
* @rock: The new stream's rock value.
*
* Opens a stream which reads from or writes to a space in memory. @buf points
* @rock: The new stream's rock value.
*
* Opens a stream which reads from or writes to a space in memory. @buf points
@@
-253,7
+265,7
@@
glk_stream_open_memory(char *buf, glui32 buflen, glui32 fmode, glui32 rock)
* @buf: An allocated buffer, or %NULL.
* @buflen: Length of @buf.
* @fmode: Mode in which the buffer will be opened. Must be one of
* @buf: An allocated buffer, or %NULL.
* @buflen: Length of @buf.
* @fmode: Mode in which the buffer will be opened. Must be one of
- *
#filemode_Read, #filemode_Write, or #
filemode_ReadWrite.
+ *
%filemode_Read, %filemode_Write, or %
filemode_ReadWrite.
* @rock: The new stream's rock value.
*
* Works just like glk_stream_open_memory(), except that the buffer is an array
* @rock: The new stream's rock value.
*
* Works just like glk_stream_open_memory(), except that the buffer is an array
@@
-277,7
+289,7
@@
glk_stream_open_memory_uni(glui32 *buf, glui32 buflen, glui32 fmode, glui32 rock
}
/* Internal function: create a stream using the given parameters. */
}
/* Internal function: create a stream using the given parameters. */
-st
atic st
rid_t
+strid_t
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
{
VALID_FILEREF(fileref, return NULL);
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
{
VALID_FILEREF(fileref, return NULL);
@@
-353,15
+365,15
@@
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
/**
* glk_stream_open_file:
* @fileref: Indicates the file which will be opened.
/**
* glk_stream_open_file:
* @fileref: Indicates the file which will be opened.
- * @fmode: Mode in which the file will be opened. Can be any of
#
filemode_Read,
- *
#filemode_Write, #filemode_WriteAppend, or #
filemode_ReadWrite.
+ * @fmode: Mode in which the file will be opened. Can be any of
%
filemode_Read,
+ *
%filemode_Write, %filemode_WriteAppend, or %
filemode_ReadWrite.
* @rock: The new stream's rock value.
*
* Opens a stream which reads to or writes from a disk file. If @fmode is
* @rock: The new stream's rock value.
*
* Opens a stream which reads to or writes from a disk file. If @fmode is
- *
#
filemode_Read, the file must already exist; for the other modes, an empty
- * file is created if none exists. If @fmode is
#
filemode_Write, and the file
+ *
%
filemode_Read, the file must already exist; for the other modes, an empty
+ * file is created if none exists. If @fmode is
%
filemode_Write, and the file
* already exists, it is truncated down to zero length (an empty file). If
* already exists, it is truncated down to zero length (an empty file). If
- * @fmode is
#
filemode_WriteAppend, the file mark is set to the end of the
+ * @fmode is
%
filemode_WriteAppend, the file mark is set to the end of the
* file.
*
* When writing in binary mode, Unicode values (characters greater than 255)
* file.
*
* When writing in binary mode, Unicode values (characters greater than 255)
@@
-381,8
+393,8
@@
glk_stream_open_file(frefid_t fileref, glui32 fmode, glui32 rock)
/**
* glk_stream_open_file_uni:
* @fileref: Indicates the file which will be opened.
/**
* glk_stream_open_file_uni:
* @fileref: Indicates the file which will be opened.
- * @fmode: Mode in which the file will be opened. Can be any of
#
filemode_Read,
- *
#filemode_Write, #filemode_WriteAppend, or #
filemode_ReadWrite.
+ * @fmode: Mode in which the file will be opened. Can be any of
%
filemode_Read,
+ *
%filemode_Write, %filemode_WriteAppend, or %
filemode_ReadWrite.
* @rock: The new stream's rock value.
*
* This works just like glk_stream_open_file(), except that in binary mode,
* @rock: The new stream's rock value.
*
* This works just like glk_stream_open_file(), except that in binary mode,
@@
-452,6
+464,8
@@
glk_stream_close(strid_t str, stream_result_t *result)
void
stream_close_common(strid_t str, stream_result_t *result)
{
void
stream_close_common(strid_t str, stream_result_t *result)
{
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+
/* Remove the stream from the global stream list */
glk_data->stream_list = g_list_delete_link(glk_data->stream_list, str->stream_list);
/* Remove the stream from the global stream list */
glk_data->stream_list = g_list_delete_link(glk_data->stream_list, str->stream_list);