From: Philip Chimento Date: Sat, 11 Feb 2012 10:21:59 +0000 (+0100) Subject: Add stub functions for Glk 0.7.4 API X-Git-Tag: v0.9~35 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=70f337d7209f9a26522b66f267b09658c60f4c17;p=projects%2Fchimara%2Fchimara.git Add stub functions for Glk 0.7.4 API Technically, we implement the spec now by having the gestalt function claim that the functions do nothing. --- diff --git a/libchimara/gestalt.c b/libchimara/gestalt.c index bf60e87..55ff57c 100644 --- a/libchimara/gestalt.c +++ b/libchimara/gestalt.c @@ -138,7 +138,8 @@ glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen) #endif /* Unsupported capabilities */ - /* none! */ + case gestalt_ResourceStream: + return 0; /* Selector not supported */ default: diff --git a/libchimara/stream.c b/libchimara/stream.c index 96ab73f..f9a6cf5 100644 --- a/libchimara/stream.c +++ b/libchimara/stream.c @@ -488,6 +488,64 @@ glk_stream_open_file_uni(frefid_t fileref, glui32 fmode, glui32 rock) return file_stream_new(fileref, fmode, rock, TRUE); } +/** + * glk_stream_open_resource: + * @filenum: Resource chunk number to open. + * @rock: The new stream's rock value. + * + * Open the given data resource for reading (only), as a normal stream. + * + * + * Note that there is no notion of file usage — the resource does not + * have to be specified as saved game or whatever. + * + * + * If no resource chunk of the given number exists, the open function returns + * %NULL. + * + * As with file streams, a binary resource stream reads the resource as bytes. A + * text resource stream reads characters encoded as Latin-1. + * + * When reading from a resource stream, newlines are not remapped, even if they + * normally would be when reading from a text file on the host OS. If you read a + * line (glk_get_line_stream() or glk_get_line_stream_uni()), a Unix newline + * (0x0A) terminates the line. + * + * Returns: the new stream, or %NULL. + */ +strid_t +glk_stream_open_resource(glui32 filenum, glui32 rock) +{ + g_warning("Not implemented"); + return NULL; +} + +/** + * glk_stream_open_resource_uni: + * @filenum: Resource chunk number to open. + * @rock: The new stream's rock value. + * + * Open the given data resource for reading (only), as a Unicode stream. See + * glk_stream_open_resource() for more information. + * + * As with file streams, a binary resource stream reads the resource as + * four-byte (big-endian) words. A text resource stream reads characters encoded + * as UTF-8. + * + * + * Thus, the difference between text and binary resources is only important + * when opened as a Unicode stream. + * + * + * Returns: the new stream, or %NULL. + */ +strid_t +glk_stream_open_resource_uni(glui32 filenum, glui32 rock) +{ + g_warning("Not implemented"); + return NULL; +} + /** * glk_stream_close: * @str: Stream to close.