--- glkloader-0.3.2/glk.h~ 2007-12-08 21:58:26.000000000 +0000 +++ glkloader-0.3.2/glk.h 2007-12-08 21:58:48.000000000 +0000 @@ -1,11 +1,11 @@ #ifndef GLK_H #define GLK_H -/* glk.h: Header file for Glk API, version 0.6.1. +/* glk.h: Header file for Glk API, version 0.7.0. Designed by Andrew Plotkin http://www.eblong.com/zarf/glk/index.html - This file is copyright 1998-2000 by Andrew Plotkin. You may copy, + This file is copyright 1998-2004 by Andrew Plotkin. You may copy, distribute, and incorporate it into your own programs, by any means and under any conditions, as long as you do not modify it. You may also modify this file, incorporate it into your own programs, @@ -22,6 +22,7 @@ /* These are the compile-time conditionals that reveal various Glk optional modules. */ +#define GLK_MODULE_UNICODE #define GLK_MODULE_IMAGE #define GLK_MODULE_SOUND #define GLK_MODULE_HYPERLINKS @@ -51,6 +52,7 @@ #define gestalt_HyperlinkInput (12) #define gestalt_SoundMusic (13) #define gestalt_GraphicsTransparency (14) +#define gestalt_Unicode (15) #define evtype_None (0) #define evtype_Timer (1) @@ -263,6 +265,37 @@ extern void glk_cancel_char_event(winid_t win); extern void glk_cancel_mouse_event(winid_t win); +#ifdef GLK_MODULE_UNICODE + +extern glui32 glk_buffer_to_lower_case_uni(glui32 *buf, glui32 len, + glui32 numchars); +extern glui32 glk_buffer_to_upper_case_uni(glui32 *buf, glui32 len, + glui32 numchars); +extern glui32 glk_buffer_to_title_case_uni(glui32 *buf, glui32 len, + glui32 numchars, glui32 lowerrest); + +extern void glk_put_char_uni(glui32 ch); +extern void glk_put_string_uni(glui32 *s); +extern void glk_put_buffer_uni(glui32 *buf, glui32 len); +extern void glk_put_char_stream_uni(strid_t str, glui32 ch); +extern void glk_put_string_stream_uni(strid_t str, glui32 *s); +extern void glk_put_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len); + +extern glsi32 glk_get_char_stream_uni(strid_t str); +extern glui32 glk_get_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len); +extern glui32 glk_get_line_stream_uni(strid_t str, glui32 *buf, glui32 len); + +extern strid_t glk_stream_open_file_uni(frefid_t fileref, glui32 fmode, + glui32 rock); +extern strid_t glk_stream_open_memory_uni(glui32 *buf, glui32 buflen, + glui32 fmode, glui32 rock); + +extern void glk_request_char_event_uni(winid_t win); +extern void glk_request_line_event_uni(winid_t win, glui32 *buf, + glui32 maxlen, glui32 initlen); + +#endif /* GLK_MODULE_UNICODE */ + #ifdef GLK_MODULE_IMAGE #define imagealign_InlineUp (0x01) --- glkloader-0.3.2/gi_dispa.c~ 2001-03-14 03:07:59.000000000 +0000 +++ glkloader-0.3.2/gi_dispa.c 2007-12-08 21:42:23.000000000 +0000 @@ -1,8 +1,8 @@ -/* gi_dispa.c: Dispatch layer for Glk API, version 0.6.1. +/* gi_dispa.c: Dispatch layer for Glk API, version 0.7.0. Designed by Andrew Plotkin http://www.eblong.com/zarf/glk/index.html - This file is copyright 1998-2000 by Andrew Plotkin. You may copy, + This file is copyright 1998-2004 by Andrew Plotkin. You may copy, distribute, and incorporate it into your own programs, by any means and under any conditions, as long as you do not modify it. You may also modify this file, incorporate it into your own programs, @@ -21,6 +21,9 @@ #define NULL 0 #endif +#define NUMCLASSES \ + (sizeof(class_table) / sizeof(gidispatch_intconst_t)) + #define NUMINTCONSTANTS \ (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t)) @@ -28,6 +31,14 @@ (sizeof(function_table) / sizeof(gidispatch_function_t)) /* The constants in this table must be ordered alphabetically. */ +static gidispatch_intconst_t class_table[] = { + { "fileref", (2) }, /* "Qc" */ + { "schannel", (3) }, /* "Qd" */ + { "stream", (1) }, /* "Qb" */ + { "window", (0) }, /* "Qa" */ +}; + +/* The constants in this table must be ordered alphabetically. */ static gidispatch_intconst_t intconstant_table[] = { { "evtype_Arrange", (5) }, { "evtype_CharInput", (2) }, @@ -66,6 +77,7 @@ { "gestalt_SoundNotify", (10) }, { "gestalt_SoundVolume", (9) }, { "gestalt_Timer", (5) }, + { "gestalt_Unicode", (15) }, { "gestalt_Version", (0) }, #ifdef GLK_MODULE_IMAGE { "imagealign_InlineCenter", (0x03) }, @@ -240,11 +252,36 @@ { 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" }, { 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" }, #endif /* GLK_MODULE_HYPERLINKS */ +#ifdef GLK_MODULE_UNICODE + { 0x0120, glk_buffer_to_lower_case_uni, "buffer_to_lower_case_uni" }, + { 0x0121, glk_buffer_to_upper_case_uni, "buffer_to_upper_case_uni" }, + { 0x0122, glk_buffer_to_title_case_uni, "buffer_to_title_case_uni" }, + { 0x0128, glk_put_char_uni, "put_char_uni" }, + { 0x0129, glk_put_string_uni, "put_string_uni" }, + { 0x012A, glk_put_buffer_uni, "put_buffer_uni" }, + { 0x012B, glk_put_char_stream_uni, "put_char_stream_uni" }, + { 0x012C, glk_put_string_stream_uni, "put_string_stream_uni" }, + { 0x012D, glk_put_buffer_stream_uni, "put_buffer_stream_uni" }, + { 0x0130, glk_get_char_stream_uni, "get_char_stream_uni" }, + { 0x0131, glk_get_buffer_stream_uni, "get_buffer_stream_uni" }, + { 0x0132, glk_get_line_stream_uni, "get_line_stream_uni" }, + { 0x0138, glk_stream_open_file_uni, "stream_open_file_uni" }, + { 0x0139, glk_stream_open_memory_uni, "stream_open_memory_uni" }, + { 0x0140, glk_request_char_event_uni, "request_char_event_uni" }, + { 0x0141, glk_request_line_event_uni, "request_line_event_uni" }, +#endif /* GLK_MODULE_UNICODE */ }; glui32 gidispatch_count_classes() { - return 4; + return NUMCLASSES; +} + +gidispatch_intconst_t *gidispatch_get_class(glui32 index) +{ + if (index < 0 || index >= NUMCLASSES) + return NULL; + return &(class_table[index]); } glui32 gidispatch_count_intconst() @@ -398,7 +435,7 @@ case 0x0087: /* set_style_stream */ return "2QbIu:"; case 0x0090: /* get_char_stream */ - return "2Qb:Iu"; + return "2Qb:Is"; case 0x0091: /* get_line_stream */ return "3Qb<+#Cn:Iu"; case 0x0092: /* get_buffer_stream */ @@ -480,6 +520,41 @@ return "1Qa:"; #endif /* GLK_MODULE_HYPERLINKS */ +#ifdef GLK_MODULE_UNICODE + case 0x0120: /* buffer_to_lower_case_uni */ + return "3&+#IuIu:Iu"; + case 0x0121: /* buffer_to_upper_case_uni */ + return "3&+#IuIu:Iu"; + case 0x0122: /* buffer_to_title_case_uni */ + return "4&+#IuIuIu:Iu"; + case 0x0128: /* put_char_uni */ + return "1Iu:"; + case 0x0129: /* put_string_uni */ + return "1U:"; + case 0x012A: /* put_buffer_uni */ + return "1>+#Iu:"; + case 0x012B: /* put_char_stream_uni */ + return "2QbIu:"; + case 0x012C: /* put_string_stream_uni */ + return "2QbU:"; + case 0x012D: /* put_buffer_stream_uni */ + return "2Qb>+#Iu:"; + case 0x0130: /* get_char_stream_uni */ + return "2Qb:Is"; + case 0x0131: /* get_buffer_stream_uni */ + return "3Qb<+#Iu:Iu"; + case 0x0132: /* get_line_stream_uni */ + return "3Qb<+#Iu:Iu"; + case 0x0138: /* stream_open_file_uni */ + return "4QcIuIu:Qb"; + case 0x0139: /* stream_open_memory_uni */ + return "4&+#!IuIuIu:Qb"; + case 0x0140: /* request_char_event_uni */ + return "1Qa:"; + case 0x0141: /* request_line_event_uni */ + return "3Qa&+#!IuIu:"; +#endif /* GLK_MODULE_UNICODE */ + default: return NULL; } @@ -697,7 +772,7 @@ glk_fileref_delete_file(arglist[0].opaqueref); break; case 0x0067: /* fileref_does_file_exist */ - arglist[1].uint = glk_fileref_does_file_exist(arglist[0].opaqueref); + arglist[2].uint = glk_fileref_does_file_exist(arglist[0].opaqueref); break; case 0x0068: /* fileref_create_from_fileref */ arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint, @@ -736,7 +811,7 @@ glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint); break; case 0x0090: /* get_char_stream */ - arglist[2].uint = glk_get_char_stream(arglist[0].opaqueref); + arglist[2].sint = glk_get_char_stream(arglist[0].opaqueref); break; case 0x0091: /* get_line_stream */ if (arglist[1].ptrflag) @@ -943,6 +1021,95 @@ break; #endif /* GLK_MODULE_HYPERLINKS */ +#ifdef GLK_MODULE_UNICODE + case 0x0120: /* buffer_to_lower_case_uni */ + if (arglist[0].ptrflag) + arglist[5].uint = glk_buffer_to_lower_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint); + else + arglist[3].uint = glk_buffer_to_lower_case_uni(NULL, 0, arglist[1].uint); + break; + case 0x0121: /* buffer_to_upper_case_uni */ + if (arglist[0].ptrflag) + arglist[5].uint = glk_buffer_to_upper_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint); + else + arglist[3].uint = glk_buffer_to_upper_case_uni(NULL, 0, arglist[1].uint); + break; + case 0x0122: /* buffer_to_title_case_uni */ + if (arglist[0].ptrflag) + arglist[6].uint = glk_buffer_to_title_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint); + else + arglist[4].uint = glk_buffer_to_title_case_uni(NULL, 0, arglist[1].uint, arglist[2].uint); + break; + case 0x0128: /* put_char_uni */ + glk_put_char_uni(arglist[0].uint); + break; + case 0x0129: /* put_string_uni */ + glk_put_string_uni(arglist[0].unicharstr); + break; + case 0x012A: /* put_buffer_uni */ + if (arglist[0].ptrflag) + glk_put_buffer_uni(arglist[1].array, arglist[2].uint); + else + glk_put_buffer_uni(NULL, 0); + break; + case 0x012B: /* put_char_stream_uni */ + glk_put_char_stream_uni(arglist[0].opaqueref, arglist[1].uint); + break; + case 0x012C: /* put_string_stream_uni */ + glk_put_string_stream_uni(arglist[0].opaqueref, arglist[1].unicharstr); + break; + case 0x012D: /* put_buffer_stream_uni */ + if (arglist[1].ptrflag) + glk_put_buffer_stream_uni(arglist[0].opaqueref, + arglist[2].array, arglist[3].uint); + else + glk_put_buffer_stream_uni(arglist[0].opaqueref, + NULL, 0); + break; + case 0x0130: /* get_char_stream_uni */ + arglist[2].sint = glk_get_char_stream_uni(arglist[0].opaqueref); + break; + case 0x0131: /* get_buffer_stream_uni */ + if (arglist[1].ptrflag) + arglist[5].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, + arglist[2].array, arglist[3].uint); + else + arglist[3].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, + NULL, 0); + break; + case 0x0132: /* get_line_stream_uni */ + if (arglist[1].ptrflag) + arglist[5].uint = glk_get_line_stream_uni(arglist[0].opaqueref, + arglist[2].array, arglist[3].uint); + else + arglist[3].uint = glk_get_line_stream_uni(arglist[0].opaqueref, + NULL, 0); + break; + case 0x0138: /* stream_open_file_uni */ + arglist[4].opaqueref = glk_stream_open_file_uni(arglist[0].opaqueref, arglist[1].uint, + arglist[2].uint); + break; + case 0x0139: /* stream_open_memory_uni */ + if (arglist[0].ptrflag) + arglist[6].opaqueref = glk_stream_open_memory_uni(arglist[1].array, + arglist[2].uint, arglist[3].uint, arglist[4].uint); + else + arglist[4].opaqueref = glk_stream_open_memory_uni(NULL, + 0, arglist[1].uint, arglist[2].uint); + break; + case 0x0140: /* request_char_event_uni */ + glk_request_char_event_uni(arglist[0].opaqueref); + break; + case 0x0141: /* request_line_event_uni */ + if (arglist[1].ptrflag) + glk_request_line_event_uni(arglist[0].opaqueref, arglist[2].array, + arglist[3].uint, arglist[4].uint); + else + glk_request_line_event_uni(arglist[0].opaqueref, NULL, + 0, arglist[2].uint); + break; +#endif /* GLK_MODULE_UNICODE */ + default: /* do nothing */ break; --- glkloader-0.3.2/gi_dispa.h~ 2001-03-14 03:07:59.000000000 +0000 +++ glkloader-0.3.2/gi_dispa.h 2007-12-08 21:42:25.000000000 +0000 @@ -1,11 +1,11 @@ #ifndef _GI_DISPA_H #define _GI_DISPA_H -/* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.6.1. +/* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.7.0. Designed by Andrew Plotkin http://www.eblong.com/zarf/glk/index.html - This file is copyright 1998-2000 by Andrew Plotkin. You may copy, + This file is copyright 1998-2004 by Andrew Plotkin. You may copy, distribute, and incorporate it into your own programs, by any means and under any conditions, as long as you do not modify it. You may also modify this file, incorporate it into your own programs, @@ -33,6 +33,7 @@ signed char sch; /* Cs */ char ch; /* Cn */ char *charstr; /* S */ + glui32 *unicharstr; /* U */ void *array; /* all # arguments */ glui32 ptrflag; /* [ ... ] or *? */ } gluniversal_t; @@ -36,8 +37,9 @@ void *array; /* all # arguments */ glui32 ptrflag; /* [ ... ] or *? */ } gluniversal_t; + /* Some well-known structures: - event_t : [4IuQwIuIu] + event_t : [4IuQaIuIu] stream_result_t : [2IuIu] */ @@ -79,6 +81,7 @@ gluniversal_t *arglist); extern char *gidispatch_prototype(glui32 funcnum); extern glui32 gidispatch_count_classes(void); +extern gidispatch_intconst_t *gidispatch_get_class(glui32 index); extern glui32 gidispatch_count_intconst(void); extern gidispatch_intconst_t *gidispatch_get_intconst(glui32 index); extern glui32 gidispatch_count_functions(void); --- glkloader-0.3.2/func.txt~ 2001-03-14 03:07:59.000000000 +0000 +++ glkloader-0.3.2/func.txt 2007-12-09 01:05:30.000000000 +0000 @@ -87,4 +87,20 @@ 0x0101: glk_set_hyperlink_stream 0x0102: glk_request_hyperlink_event 0x0103: glk_cancel_hyperlink_event +0x0120: glk_buffer_to_lower_case_uni +0x0121: glk_buffer_to_upper_case_uni +0x0122: glk_buffer_to_title_case_uni +0x0128: glk_put_char_uni +0x0129: glk_put_string_uni +0x012A: glk_put_buffer_uni +0x012B: glk_put_char_stream_uni +0x012C: glk_put_string_stream_uni +0x012D: glk_put_buffer_stream_uni +0x0130: glk_get_char_stream_uni +0x0131: glk_get_buffer_stream_uni +0x0132: glk_get_line_stream_uni +0x0138: glk_stream_open_file_uni +0x0139: glk_stream_open_memory_uni +0x0140: glk_request_char_event_uni +0x0141: glk_request_line_event_uni