1 /* gi_dispa.c: Dispatch layer for Glk API, version 0.7.0.
2 Designed by Andrew Plotkin <erkyrath@eblong.com>
3 http://www.eblong.com/zarf/glk/index.html
5 This file is copyright 1998-2004 by Andrew Plotkin. You may copy,
6 distribute, and incorporate it into your own programs, by any means
7 and under any conditions, as long as you do not modify it. You may
8 also modify this file, incorporate it into your own programs,
9 and distribute the modified version, as long as you retain a notice
10 in your program or documentation which mentions my name and the URL
14 /* This code should be linked into every Glk library, without change.
15 Get the latest version from the URL above. */
25 (sizeof(class_table) / sizeof(gidispatch_intconst_t))
27 #define NUMINTCONSTANTS \
28 (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t))
30 #define NUMFUNCTIONS \
31 (sizeof(function_table) / sizeof(gidispatch_function_t))
33 /* The constants in this table must be ordered alphabetically. */
34 static gidispatch_intconst_t class_table[] = {
35 { "fileref", (2) }, /* "Qc" */
36 { "schannel", (3) }, /* "Qd" */
37 { "stream", (1) }, /* "Qb" */
38 { "window", (0) }, /* "Qa" */
41 /* The constants in this table must be ordered alphabetically. */
42 static gidispatch_intconst_t intconstant_table[] = {
43 { "evtype_Arrange", (5) },
44 { "evtype_CharInput", (2) },
45 { "evtype_Hyperlink", (8) },
46 { "evtype_LineInput", (3) },
47 { "evtype_MouseInput", (4) },
48 { "evtype_None", (0) },
49 { "evtype_Redraw", (6) },
50 { "evtype_SoundNotify", (7) },
51 { "evtype_Timer", (1) },
52 { "filemode_Read", (0x02) },
53 { "filemode_ReadWrite", (0x03) },
54 { "filemode_Write", (0x01) },
55 { "filemode_WriteAppend", (0x05) },
56 { "fileusage_BinaryMode", (0x000) },
57 { "fileusage_Data", (0x00) },
58 { "fileusage_InputRecord", (0x03) },
59 { "fileusage_SavedGame", (0x01) },
60 { "fileusage_TextMode", (0x100) },
61 { "fileusage_Transcript", (0x02) },
62 { "fileusage_TypeMask", (0x0f) },
63 { "gestalt_CharInput", (1) },
64 { "gestalt_CharOutput", (3) },
65 { "gestalt_CharOutput_ApproxPrint", (1) },
66 { "gestalt_CharOutput_CannotPrint", (0) },
67 { "gestalt_CharOutput_ExactPrint", (2) },
68 { "gestalt_DrawImage", (7) },
69 { "gestalt_Graphics", (6) },
70 { "gestalt_GraphicsTransparency", (14) },
71 { "gestalt_HyperlinkInput", (12) },
72 { "gestalt_Hyperlinks", (11) },
73 { "gestalt_LineInput", (2) },
74 { "gestalt_MouseInput", (4) },
75 { "gestalt_Sound", (8) },
76 { "gestalt_SoundMusic", (13) },
77 { "gestalt_SoundNotify", (10) },
78 { "gestalt_SoundVolume", (9) },
79 { "gestalt_Timer", (5) },
80 { "gestalt_Unicode", (15) },
81 { "gestalt_Version", (0) },
82 #ifdef GLK_MODULE_IMAGE
83 { "imagealign_InlineCenter", (0x03) },
84 { "imagealign_InlineDown", (0x02) },
85 { "imagealign_MarginLeft", (0x04) },
86 { "imagealign_MarginRight", (0x05) },
87 { "imagealign_InlineUp", (0x01) },
88 #endif /* GLK_MODULE_IMAGE */
89 { "keycode_Delete", (0xfffffff9) },
90 { "keycode_Down", (0xfffffffb) },
91 { "keycode_End", (0xfffffff3) },
92 { "keycode_Escape", (0xfffffff8) },
93 { "keycode_Func1", (0xffffffef) },
94 { "keycode_Func10", (0xffffffe6) },
95 { "keycode_Func11", (0xffffffe5) },
96 { "keycode_Func12", (0xffffffe4) },
97 { "keycode_Func2", (0xffffffee) },
98 { "keycode_Func3", (0xffffffed) },
99 { "keycode_Func4", (0xffffffec) },
100 { "keycode_Func5", (0xffffffeb) },
101 { "keycode_Func6", (0xffffffea) },
102 { "keycode_Func7", (0xffffffe9) },
103 { "keycode_Func8", (0xffffffe8) },
104 { "keycode_Func9", (0xffffffe7) },
105 { "keycode_Home", (0xfffffff4) },
106 { "keycode_Left", (0xfffffffe) },
107 { "keycode_MAXVAL", (28) },
108 { "keycode_PageDown", (0xfffffff5) },
109 { "keycode_PageUp", (0xfffffff6) },
110 { "keycode_Return", (0xfffffffa) },
111 { "keycode_Right", (0xfffffffd) },
112 { "keycode_Tab", (0xfffffff7) },
113 { "keycode_Unknown", (0xffffffff) },
114 { "keycode_Up", (0xfffffffc) },
115 { "seekmode_Current", (1) },
116 { "seekmode_End", (2) },
117 { "seekmode_Start", (0) },
118 { "style_Alert", (5) },
119 { "style_BlockQuote", (7) },
120 { "style_Emphasized", (1) },
121 { "style_Header", (3) },
122 { "style_Input", (8) },
123 { "style_NUMSTYLES", (11) },
124 { "style_Normal", (0) },
125 { "style_Note", (6) },
126 { "style_Preformatted", (2) },
127 { "style_Subheader", (4) },
128 { "style_User1", (9) },
129 { "style_User2", (10) },
130 { "stylehint_BackColor", (8) },
131 { "stylehint_Indentation", (0) },
132 { "stylehint_Justification", (2) },
133 { "stylehint_NUMHINTS", (10) },
134 { "stylehint_Oblique", (5) },
135 { "stylehint_ParaIndentation", (1) },
136 { "stylehint_Proportional", (6) },
137 { "stylehint_ReverseColor", (9) },
138 { "stylehint_Size", (3) },
139 { "stylehint_TextColor", (7) },
140 { "stylehint_Weight", (4) },
141 { "stylehint_just_Centered", (2) },
142 { "stylehint_just_LeftFlush", (0) },
143 { "stylehint_just_LeftRight", (1) },
144 { "stylehint_just_RightFlush", (3) },
145 { "winmethod_Above", (0x02) },
146 { "winmethod_Below", (0x03) },
147 { "winmethod_DirMask", (0x0f) },
148 { "winmethod_DivisionMask", (0xf0) },
149 { "winmethod_Fixed", (0x10) },
150 { "winmethod_Left", (0x00) },
151 { "winmethod_Proportional", (0x20) },
152 { "winmethod_Right", (0x01) },
153 { "wintype_AllTypes", (0) },
154 { "wintype_Blank", (2) },
155 { "wintype_Graphics", (5) },
156 { "wintype_Pair", (1) },
157 { "wintype_TextBuffer", (3) },
158 { "wintype_TextGrid", (4) },
161 /* The functions in this table must be ordered by id. */
162 static gidispatch_function_t function_table[] = {
163 { 0x0001, glk_exit, "exit" },
164 { 0x0002, glk_set_interrupt_handler, "set_interrupt_handler" },
165 { 0x0003, glk_tick, "tick" },
166 { 0x0004, glk_gestalt, "gestalt" },
167 { 0x0005, glk_gestalt_ext, "gestalt_ext" },
168 { 0x0020, glk_window_iterate, "window_iterate" },
169 { 0x0021, glk_window_get_rock, "window_get_rock" },
170 { 0x0022, glk_window_get_root, "window_get_root" },
171 { 0x0023, glk_window_open, "window_open" },
172 { 0x0024, glk_window_close, "window_close" },
173 { 0x0025, glk_window_get_size, "window_get_size" },
174 { 0x0026, glk_window_set_arrangement, "window_set_arrangement" },
175 { 0x0027, glk_window_get_arrangement, "window_get_arrangement" },
176 { 0x0028, glk_window_get_type, "window_get_type" },
177 { 0x0029, glk_window_get_parent, "window_get_parent" },
178 { 0x002A, glk_window_clear, "window_clear" },
179 { 0x002B, glk_window_move_cursor, "window_move_cursor" },
180 { 0x002C, glk_window_get_stream, "window_get_stream" },
181 { 0x002D, glk_window_set_echo_stream, "window_set_echo_stream" },
182 { 0x002E, glk_window_get_echo_stream, "window_get_echo_stream" },
183 { 0x002F, glk_set_window, "set_window" },
184 { 0x0030, glk_window_get_sibling, "window_get_sibling" },
185 { 0x0040, glk_stream_iterate, "stream_iterate" },
186 { 0x0041, glk_stream_get_rock, "stream_get_rock" },
187 { 0x0042, glk_stream_open_file, "stream_open_file" },
188 { 0x0043, glk_stream_open_memory, "stream_open_memory" },
189 { 0x0044, glk_stream_close, "stream_close" },
190 { 0x0045, glk_stream_set_position, "stream_set_position" },
191 { 0x0046, glk_stream_get_position, "stream_get_position" },
192 { 0x0047, glk_stream_set_current, "stream_set_current" },
193 { 0x0048, glk_stream_get_current, "stream_get_current" },
194 { 0x0060, glk_fileref_create_temp, "fileref_create_temp" },
195 { 0x0061, glk_fileref_create_by_name, "fileref_create_by_name" },
196 { 0x0062, glk_fileref_create_by_prompt, "fileref_create_by_prompt" },
197 { 0x0063, glk_fileref_destroy, "fileref_destroy" },
198 { 0x0064, glk_fileref_iterate, "fileref_iterate" },
199 { 0x0065, glk_fileref_get_rock, "fileref_get_rock" },
200 { 0x0066, glk_fileref_delete_file, "fileref_delete_file" },
201 { 0x0067, glk_fileref_does_file_exist, "fileref_does_file_exist" },
202 { 0x0068, glk_fileref_create_from_fileref, "fileref_create_from_fileref" },
203 { 0x0080, glk_put_char, "put_char" },
204 { 0x0081, glk_put_char_stream, "put_char_stream" },
205 { 0x0082, glk_put_string, "put_string" },
206 { 0x0083, glk_put_string_stream, "put_string_stream" },
207 { 0x0084, glk_put_buffer, "put_buffer" },
208 { 0x0085, glk_put_buffer_stream, "put_buffer_stream" },
209 { 0x0086, glk_set_style, "set_style" },
210 { 0x0087, glk_set_style_stream, "set_style_stream" },
211 { 0x0090, glk_get_char_stream, "get_char_stream" },
212 { 0x0091, glk_get_line_stream, "get_line_stream" },
213 { 0x0092, glk_get_buffer_stream, "get_buffer_stream" },
214 { 0x00A0, glk_char_to_lower, "char_to_lower" },
215 { 0x00A1, glk_char_to_upper, "char_to_upper" },
216 { 0x00B0, glk_stylehint_set, "stylehint_set" },
217 { 0x00B1, glk_stylehint_clear, "stylehint_clear" },
218 { 0x00B2, glk_style_distinguish, "style_distinguish" },
219 { 0x00B3, glk_style_measure, "style_measure" },
220 { 0x00C0, glk_select, "select" },
221 { 0x00C1, glk_select_poll, "select_poll" },
222 { 0x00D0, glk_request_line_event, "request_line_event" },
223 { 0x00D1, glk_cancel_line_event, "cancel_line_event" },
224 { 0x00D2, glk_request_char_event, "request_char_event" },
225 { 0x00D3, glk_cancel_char_event, "cancel_char_event" },
226 { 0x00D4, glk_request_mouse_event, "request_mouse_event" },
227 { 0x00D5, glk_cancel_mouse_event, "cancel_mouse_event" },
228 { 0x00D6, glk_request_timer_events, "request_timer_events" },
229 #ifdef GLK_MODULE_IMAGE
230 { 0x00E0, glk_image_get_info, "image_get_info" },
231 { 0x00E1, glk_image_draw, "image_draw" },
232 { 0x00E2, glk_image_draw_scaled, "image_draw_scaled" },
233 { 0x00E8, glk_window_flow_break, "window_flow_break" },
234 { 0x00E9, glk_window_erase_rect, "window_erase_rect" },
235 { 0x00EA, glk_window_fill_rect, "window_fill_rect" },
236 { 0x00EB, glk_window_set_background_color, "window_set_background_color" },
237 #endif /* GLK_MODULE_IMAGE */
238 #ifdef GLK_MODULE_SOUND
239 { 0x00F0, glk_schannel_iterate, "schannel_iterate" },
240 { 0x00F1, glk_schannel_get_rock, "schannel_get_rock" },
241 { 0x00F2, glk_schannel_create, "schannel_create" },
242 { 0x00F3, glk_schannel_destroy, "schannel_destroy" },
243 { 0x00F8, glk_schannel_play, "schannel_play" },
244 { 0x00F9, glk_schannel_play_ext, "schannel_play_ext" },
245 { 0x00FA, glk_schannel_stop, "schannel_stop" },
246 { 0x00FB, glk_schannel_set_volume, "schannel_set_volume" },
247 { 0x00FC, glk_sound_load_hint, "sound_load_hint" },
248 #endif /* GLK_MODULE_SOUND */
249 #ifdef GLK_MODULE_HYPERLINKS
250 { 0x0100, glk_set_hyperlink, "set_hyperlink" },
251 { 0x0101, glk_set_hyperlink_stream, "set_hyperlink_stream" },
252 { 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" },
253 { 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" },
254 #endif /* GLK_MODULE_HYPERLINKS */
255 #ifdef GLK_MODULE_UNICODE
256 { 0x0120, glk_buffer_to_lower_case_uni, "buffer_to_lower_case_uni" },
257 { 0x0121, glk_buffer_to_upper_case_uni, "buffer_to_upper_case_uni" },
258 { 0x0122, glk_buffer_to_title_case_uni, "buffer_to_title_case_uni" },
259 { 0x0128, glk_put_char_uni, "put_char_uni" },
260 { 0x0129, glk_put_string_uni, "put_string_uni" },
261 { 0x012A, glk_put_buffer_uni, "put_buffer_uni" },
262 { 0x012B, glk_put_char_stream_uni, "put_char_stream_uni" },
263 { 0x012C, glk_put_string_stream_uni, "put_string_stream_uni" },
264 { 0x012D, glk_put_buffer_stream_uni, "put_buffer_stream_uni" },
265 { 0x0130, glk_get_char_stream_uni, "get_char_stream_uni" },
266 { 0x0131, glk_get_buffer_stream_uni, "get_buffer_stream_uni" },
267 { 0x0132, glk_get_line_stream_uni, "get_line_stream_uni" },
268 { 0x0138, glk_stream_open_file_uni, "stream_open_file_uni" },
269 { 0x0139, glk_stream_open_memory_uni, "stream_open_memory_uni" },
270 { 0x0140, glk_request_char_event_uni, "request_char_event_uni" },
271 { 0x0141, glk_request_line_event_uni, "request_line_event_uni" },
272 #endif /* GLK_MODULE_UNICODE */
275 glui32 gidispatch_count_classes()
280 gidispatch_intconst_t *gidispatch_get_class(glui32 index)
282 if (index < 0 || index >= NUMCLASSES)
284 return &(class_table[index]);
287 glui32 gidispatch_count_intconst()
289 return NUMINTCONSTANTS;
292 gidispatch_intconst_t *gidispatch_get_intconst(glui32 index)
294 if (index < 0 || index >= NUMINTCONSTANTS)
296 return &(intconstant_table[index]);
299 glui32 gidispatch_count_functions()
304 gidispatch_function_t *gidispatch_get_function(glui32 index)
306 if (index < 0 || index >= NUMFUNCTIONS)
308 return &(function_table[index]);
311 gidispatch_function_t *gidispatch_get_function_by_id(glui32 id)
314 gidispatch_function_t *func;
321 func = &(function_table[val]);
337 char *gidispatch_prototype(glui32 funcnum)
340 case 0x0001: /* exit */
342 case 0x0002: /* set_interrupt_handler */
343 /* cannot be invoked through dispatch layer */
345 case 0x0003: /* tick */
347 case 0x0004: /* gestalt */
349 case 0x0005: /* gestalt_ext */
350 return "4IuIu&#Iu:Iu";
351 case 0x0020: /* window_iterate */
353 case 0x0021: /* window_get_rock */
355 case 0x0022: /* window_get_root */
357 case 0x0023: /* window_open */
358 return "6QaIuIuIuIu:Qa";
359 case 0x0024: /* window_close */
360 return "2Qa<[2IuIu]:";
361 case 0x0025: /* window_get_size */
363 case 0x0026: /* window_set_arrangement */
365 case 0x0027: /* window_get_arrangement */
366 return "4Qa<Iu<Iu<Qa:";
367 case 0x0028: /* window_get_type */
369 case 0x0029: /* window_get_parent */
371 case 0x002A: /* window_clear */
373 case 0x002B: /* window_move_cursor */
375 case 0x002C: /* window_get_stream */
377 case 0x002D: /* window_set_echo_stream */
379 case 0x002E: /* window_get_echo_stream */
381 case 0x002F: /* set_window */
383 case 0x0030: /* window_get_sibling */
385 case 0x0040: /* stream_iterate */
387 case 0x0041: /* stream_get_rock */
389 case 0x0042: /* stream_open_file */
391 case 0x0043: /* stream_open_memory */
392 return "4&+#!CnIuIu:Qb";
393 case 0x0044: /* stream_close */
394 return "2Qb<[2IuIu]:";
395 case 0x0045: /* stream_set_position */
397 case 0x0046: /* stream_get_position */
399 case 0x0047: /* stream_set_current */
401 case 0x0048: /* stream_get_current */
403 case 0x0060: /* fileref_create_temp */
405 case 0x0061: /* fileref_create_by_name */
407 case 0x0062: /* fileref_create_by_prompt */
409 case 0x0063: /* fileref_destroy */
411 case 0x0064: /* fileref_iterate */
413 case 0x0065: /* fileref_get_rock */
415 case 0x0066: /* fileref_delete_file */
417 case 0x0067: /* fileref_does_file_exist */
419 case 0x0068: /* fileref_create_from_fileref */
421 case 0x0080: /* put_char */
423 case 0x0081: /* put_char_stream */
425 case 0x0082: /* put_string */
427 case 0x0083: /* put_string_stream */
429 case 0x0084: /* put_buffer */
431 case 0x0085: /* put_buffer_stream */
433 case 0x0086: /* set_style */
435 case 0x0087: /* set_style_stream */
437 case 0x0090: /* get_char_stream */
439 case 0x0091: /* get_line_stream */
440 return "3Qb<+#Cn:Iu";
441 case 0x0092: /* get_buffer_stream */
442 return "3Qb<+#Cn:Iu";
443 case 0x00A0: /* char_to_lower */
445 case 0x00A1: /* char_to_upper */
447 case 0x00B0: /* stylehint_set */
449 case 0x00B1: /* stylehint_clear */
451 case 0x00B2: /* style_distinguish */
453 case 0x00B3: /* style_measure */
454 return "5QaIuIu<Iu:Iu";
455 case 0x00C0: /* select */
456 return "1<+[4IuQaIuIu]:";
457 case 0x00C1: /* select_poll */
458 return "1<+[4IuQaIuIu]:";
459 case 0x00D0: /* request_line_event */
460 return "3Qa&+#!CnIu:";
461 case 0x00D1: /* cancel_line_event */
462 return "2Qa<[4IuQaIuIu]:";
463 case 0x00D2: /* request_char_event */
465 case 0x00D3: /* cancel_char_event */
467 case 0x00D4: /* request_mouse_event */
469 case 0x00D5: /* cancel_mouse_event */
471 case 0x00D6: /* request_timer_events */
474 #ifdef GLK_MODULE_IMAGE
475 case 0x00E0: /* image_get_info */
476 return "4Iu<Iu<Iu:Iu";
477 case 0x00E1: /* image_draw */
478 return "5QaIuIsIs:Iu";
479 case 0x00E2: /* image_draw_scaled */
480 return "7QaIuIsIsIuIu:Iu";
481 case 0x00E8: /* window_flow_break */
483 case 0x00E9: /* window_erase_rect */
484 return "5QaIsIsIuIu:";
485 case 0x00EA: /* window_fill_rect */
486 return "6QaIuIsIsIuIu:";
487 case 0x00EB: /* window_set_background_color */
489 #endif /* GLK_MODULE_IMAGE */
491 #ifdef GLK_MODULE_SOUND
492 case 0x00F0: /* schannel_iterate */
494 case 0x00F1: /* schannel_get_rock */
496 case 0x00F2: /* schannel_create */
498 case 0x00F3: /* schannel_destroy */
500 case 0x00F8: /* schannel_play */
502 case 0x00F9: /* schannel_play_ext */
503 return "5QdIuIuIu:Iu";
504 case 0x00FA: /* schannel_stop */
506 case 0x00FB: /* schannel_set_volume */
508 case 0x00FC: /* sound_load_hint */
510 #endif /* GLK_MODULE_SOUND */
512 #ifdef GLK_MODULE_HYPERLINKS
513 case 0x0100: /* set_hyperlink */
515 case 0x0101: /* set_hyperlink_stream */
517 case 0x0102: /* request_hyperlink_event */
519 case 0x0103: /* cancel_hyperlink_event */
521 #endif /* GLK_MODULE_HYPERLINKS */
523 #ifdef GLK_MODULE_UNICODE
524 case 0x0120: /* buffer_to_lower_case_uni */
525 return "3&+#IuIu:Iu";
526 case 0x0121: /* buffer_to_upper_case_uni */
527 return "3&+#IuIu:Iu";
528 case 0x0122: /* buffer_to_title_case_uni */
529 return "4&+#IuIuIu:Iu";
530 case 0x0128: /* put_char_uni */
532 case 0x0129: /* put_string_uni */
534 case 0x012A: /* put_buffer_uni */
536 case 0x012B: /* put_char_stream_uni */
538 case 0x012C: /* put_string_stream_uni */
540 case 0x012D: /* put_buffer_stream_uni */
542 case 0x0130: /* get_char_stream_uni */
544 case 0x0131: /* get_buffer_stream_uni */
545 return "3Qb<+#Iu:Iu";
546 case 0x0132: /* get_line_stream_uni */
547 return "3Qb<+#Iu:Iu";
548 case 0x0138: /* stream_open_file_uni */
550 case 0x0139: /* stream_open_memory_uni */
551 return "4&+#!IuIuIu:Qb";
552 case 0x0140: /* request_char_event_uni */
554 case 0x0141: /* request_line_event_uni */
555 return "3Qa&+#!IuIu:";
556 #endif /* GLK_MODULE_UNICODE */
563 void gidispatch_call(glui32 funcnum, glui32 numargs, gluniversal_t *arglist)
566 case 0x0001: /* exit */
569 case 0x0002: /* set_interrupt_handler */
570 /* cannot be invoked through dispatch layer */
572 case 0x0003: /* tick */
575 case 0x0004: /* gestalt */
576 arglist[3].uint = glk_gestalt(arglist[0].uint, arglist[1].uint);
578 case 0x0005: /* gestalt_ext */
579 if (arglist[2].ptrflag) {
580 arglist[6].uint = glk_gestalt_ext(arglist[0].uint, arglist[1].uint,
581 arglist[3].array, arglist[4].uint);
584 arglist[4].uint = glk_gestalt_ext(arglist[0].uint, arglist[1].uint,
588 case 0x0020: /* window_iterate */
589 if (arglist[1].ptrflag)
590 arglist[4].opaqueref = glk_window_iterate(arglist[0].opaqueref, &arglist[2].uint);
592 arglist[3].opaqueref = glk_window_iterate(arglist[0].opaqueref, NULL);
594 case 0x0021: /* window_get_rock */
595 arglist[2].uint = glk_window_get_rock(arglist[0].opaqueref);
597 case 0x0022: /* window_get_root */
598 arglist[1].opaqueref = glk_window_get_root();
600 case 0x0023: /* window_open */
601 arglist[6].opaqueref = glk_window_open(arglist[0].opaqueref, arglist[1].uint,
602 arglist[2].uint, arglist[3].uint, arglist[4].uint);
604 case 0x0024: /* window_close */
605 if (arglist[1].ptrflag) {
607 glk_window_close(arglist[0].opaqueref, &dat);
608 arglist[2].uint = dat.readcount;
609 arglist[3].uint = dat.writecount;
612 glk_window_close(arglist[0].opaqueref, NULL);
615 case 0x0025: /* window_get_size */
619 if (!arglist[ix].ptrflag) {
624 ptr1 = &(arglist[ix].uint);
627 if (!arglist[ix].ptrflag) {
632 ptr2 = &(arglist[ix].uint);
635 glk_window_get_size(arglist[0].opaqueref, ptr1, ptr2);
638 case 0x0026: /* window_set_arrangement */
639 glk_window_set_arrangement(arglist[0].opaqueref, arglist[1].uint,
640 arglist[2].uint, arglist[3].opaqueref);
642 case 0x0027: /* window_get_arrangement */
647 if (!arglist[ix].ptrflag) {
652 ptr1 = &(arglist[ix].uint);
655 if (!arglist[ix].ptrflag) {
660 ptr2 = &(arglist[ix].uint);
663 if (!arglist[ix].ptrflag) {
668 ptr3 = (winid_t *)(&(arglist[ix].opaqueref));
671 glk_window_get_arrangement(arglist[0].opaqueref, ptr1, ptr2, ptr3);
674 case 0x0028: /* window_get_type */
675 arglist[2].uint = glk_window_get_type(arglist[0].opaqueref);
677 case 0x0029: /* window_get_parent */
678 arglist[2].opaqueref = glk_window_get_parent(arglist[0].opaqueref);
680 case 0x002A: /* window_clear */
681 glk_window_clear(arglist[0].opaqueref);
683 case 0x002B: /* window_move_cursor */
684 glk_window_move_cursor(arglist[0].opaqueref, arglist[1].uint,
687 case 0x002C: /* window_get_stream */
688 arglist[2].opaqueref = glk_window_get_stream(arglist[0].opaqueref);
690 case 0x002D: /* window_set_echo_stream */
691 glk_window_set_echo_stream(arglist[0].opaqueref, arglist[1].opaqueref);
693 case 0x002E: /* window_get_echo_stream */
694 arglist[2].opaqueref = glk_window_get_echo_stream(arglist[0].opaqueref);
696 case 0x002F: /* set_window */
697 glk_set_window(arglist[0].opaqueref);
699 case 0x0030: /* window_get_sibling */
700 arglist[2].opaqueref = glk_window_get_sibling(arglist[0].opaqueref);
702 case 0x0040: /* stream_iterate */
703 if (arglist[1].ptrflag)
704 arglist[4].opaqueref = glk_stream_iterate(arglist[0].opaqueref, &arglist[2].uint);
706 arglist[3].opaqueref = glk_stream_iterate(arglist[0].opaqueref, NULL);
708 case 0x0041: /* stream_get_rock */
709 arglist[2].uint = glk_stream_get_rock(arglist[0].opaqueref);
711 case 0x0042: /* stream_open_file */
712 arglist[4].opaqueref = glk_stream_open_file(arglist[0].opaqueref, arglist[1].uint,
715 case 0x0043: /* stream_open_memory */
716 if (arglist[0].ptrflag)
717 arglist[6].opaqueref = glk_stream_open_memory(arglist[1].array,
718 arglist[2].uint, arglist[3].uint, arglist[4].uint);
720 arglist[4].opaqueref = glk_stream_open_memory(NULL,
721 0, arglist[1].uint, arglist[2].uint);
723 case 0x0044: /* stream_close */
724 if (arglist[1].ptrflag) {
726 glk_stream_close(arglist[0].opaqueref, &dat);
727 arglist[2].uint = dat.readcount;
728 arglist[3].uint = dat.writecount;
731 glk_stream_close(arglist[0].opaqueref, NULL);
734 case 0x0045: /* stream_set_position */
735 glk_stream_set_position(arglist[0].opaqueref, arglist[1].sint,
738 case 0x0046: /* stream_get_position */
739 arglist[2].uint = glk_stream_get_position(arglist[0].opaqueref);
741 case 0x0047: /* stream_set_current */
742 glk_stream_set_current(arglist[0].opaqueref);
744 case 0x0048: /* stream_get_current */
745 arglist[1].opaqueref = glk_stream_get_current();
747 case 0x0060: /* fileref_create_temp */
748 arglist[3].opaqueref = glk_fileref_create_temp(arglist[0].uint,
751 case 0x0061: /* fileref_create_by_name */
752 arglist[4].opaqueref = glk_fileref_create_by_name(arglist[0].uint,
753 arglist[1].charstr, arglist[2].uint);
755 case 0x0062: /* fileref_create_by_prompt */
756 arglist[4].opaqueref = glk_fileref_create_by_prompt(arglist[0].uint,
757 arglist[1].uint, arglist[2].uint);
759 case 0x0063: /* fileref_destroy */
760 glk_fileref_destroy(arglist[0].opaqueref);
762 case 0x0064: /* fileref_iterate */
763 if (arglist[1].ptrflag)
764 arglist[4].opaqueref = glk_fileref_iterate(arglist[0].opaqueref, &arglist[2].uint);
766 arglist[3].opaqueref = glk_fileref_iterate(arglist[0].opaqueref, NULL);
768 case 0x0065: /* fileref_get_rock */
769 arglist[2].uint = glk_fileref_get_rock(arglist[0].opaqueref);
771 case 0x0066: /* fileref_delete_file */
772 glk_fileref_delete_file(arglist[0].opaqueref);
774 case 0x0067: /* fileref_does_file_exist */
775 arglist[2].uint = glk_fileref_does_file_exist(arglist[0].opaqueref);
777 case 0x0068: /* fileref_create_from_fileref */
778 arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint,
779 arglist[1].opaqueref, arglist[2].uint);
781 case 0x0080: /* put_char */
782 glk_put_char(arglist[0].uch);
784 case 0x0081: /* put_char_stream */
785 glk_put_char_stream(arglist[0].opaqueref, arglist[1].uch);
787 case 0x0082: /* put_string */
788 glk_put_string(arglist[0].charstr);
790 case 0x0083: /* put_string_stream */
791 glk_put_string_stream(arglist[0].opaqueref, arglist[1].charstr);
793 case 0x0084: /* put_buffer */
794 if (arglist[0].ptrflag)
795 glk_put_buffer(arglist[1].array, arglist[2].uint);
797 glk_put_buffer(NULL, 0);
799 case 0x0085: /* put_buffer_stream */
800 if (arglist[1].ptrflag)
801 glk_put_buffer_stream(arglist[0].opaqueref,
802 arglist[2].array, arglist[3].uint);
804 glk_put_buffer_stream(arglist[0].opaqueref,
807 case 0x0086: /* set_style */
808 glk_set_style(arglist[0].uint);
810 case 0x0087: /* set_style_stream */
811 glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint);
813 case 0x0090: /* get_char_stream */
814 arglist[2].sint = glk_get_char_stream(arglist[0].opaqueref);
816 case 0x0091: /* get_line_stream */
817 if (arglist[1].ptrflag)
818 arglist[5].uint = glk_get_line_stream(arglist[0].opaqueref,
819 arglist[2].array, arglist[3].uint);
821 arglist[3].uint = glk_get_line_stream(arglist[0].opaqueref,
824 case 0x0092: /* get_buffer_stream */
825 if (arglist[1].ptrflag)
826 arglist[5].uint = glk_get_buffer_stream(arglist[0].opaqueref,
827 arglist[2].array, arglist[3].uint);
829 arglist[3].uint = glk_get_buffer_stream(arglist[0].opaqueref,
832 case 0x00A0: /* char_to_lower */
833 arglist[2].uch = glk_char_to_lower(arglist[0].uch);
835 case 0x00A1: /* char_to_upper */
836 arglist[2].uch = glk_char_to_upper(arglist[0].uch);
838 case 0x00B0: /* stylehint_set */
839 glk_stylehint_set(arglist[0].uint, arglist[1].uint,
840 arglist[2].uint, arglist[3].sint);
842 case 0x00B1: /* stylehint_clear */
843 glk_stylehint_clear(arglist[0].uint, arglist[1].uint,
846 case 0x00B2: /* style_distinguish */
847 arglist[4].uint = glk_style_distinguish(arglist[0].opaqueref, arglist[1].uint,
850 case 0x00B3: /* style_measure */
851 if (arglist[3].ptrflag)
852 arglist[6].uint = glk_style_measure(arglist[0].opaqueref, arglist[1].uint,
853 arglist[2].uint, &(arglist[4].uint));
855 arglist[5].uint = glk_style_measure(arglist[0].opaqueref, arglist[1].uint,
856 arglist[2].uint, NULL);
858 case 0x00C0: /* select */
859 if (arglist[0].ptrflag) {
862 arglist[1].uint = dat.type;
863 arglist[2].opaqueref = dat.win;
864 arglist[3].uint = dat.val1;
865 arglist[4].uint = dat.val2;
871 case 0x00C1: /* select_poll */
872 if (arglist[0].ptrflag) {
874 glk_select_poll(&dat);
875 arglist[1].uint = dat.type;
876 arglist[2].opaqueref = dat.win;
877 arglist[3].uint = dat.val1;
878 arglist[4].uint = dat.val2;
881 glk_select_poll(NULL);
884 case 0x00D0: /* request_line_event */
885 if (arglist[1].ptrflag)
886 glk_request_line_event(arglist[0].opaqueref, arglist[2].array,
887 arglist[3].uint, arglist[4].uint);
889 glk_request_line_event(arglist[0].opaqueref, NULL,
892 case 0x00D1: /* cancel_line_event */
893 if (arglist[1].ptrflag) {
895 glk_cancel_line_event(arglist[0].opaqueref, &dat);
896 arglist[2].uint = dat.type;
897 arglist[3].opaqueref = dat.win;
898 arglist[4].uint = dat.val1;
899 arglist[5].uint = dat.val2;
902 glk_cancel_line_event(arglist[0].opaqueref, NULL);
905 case 0x00D2: /* request_char_event */
906 glk_request_char_event(arglist[0].opaqueref);
908 case 0x00D3: /* cancel_char_event */
909 glk_cancel_char_event(arglist[0].opaqueref);
911 case 0x00D4: /* request_mouse_event */
912 glk_request_mouse_event(arglist[0].opaqueref);
914 case 0x00D5: /* cancel_mouse_event */
915 glk_cancel_mouse_event(arglist[0].opaqueref);
917 case 0x00D6: /* request_timer_events */
918 glk_request_timer_events(arglist[0].uint);
921 #ifdef GLK_MODULE_IMAGE
922 case 0x00E0: /* image_get_info */
926 if (!arglist[ix].ptrflag) {
931 ptr1 = &(arglist[ix].uint);
934 if (!arglist[ix].ptrflag) {
939 ptr2 = &(arglist[ix].uint);
943 arglist[ix].uint = glk_image_get_info(arglist[0].uint, ptr1, ptr2);
946 case 0x00E1: /* image_draw */
947 arglist[5].uint = glk_image_draw(arglist[0].opaqueref,
949 arglist[2].sint, arglist[3].sint);
951 case 0x00E2: /* image_draw_scaled */
952 arglist[7].uint = glk_image_draw_scaled(arglist[0].opaqueref,
954 arglist[2].sint, arglist[3].sint,
955 arglist[4].uint, arglist[5].uint);
957 case 0x00E8: /* window_flow_break */
958 glk_window_flow_break(arglist[0].opaqueref);
960 case 0x00E9: /* window_erase_rect */
961 glk_window_erase_rect(arglist[0].opaqueref,
962 arglist[1].sint, arglist[2].sint,
963 arglist[3].uint, arglist[4].uint);
965 case 0x00EA: /* window_fill_rect */
966 glk_window_fill_rect(arglist[0].opaqueref, arglist[1].uint,
967 arglist[2].sint, arglist[3].sint,
968 arglist[4].uint, arglist[5].uint);
970 case 0x00EB: /* window_set_background_color */
971 glk_window_set_background_color(arglist[0].opaqueref, arglist[1].uint);
973 #endif /* GLK_MODULE_IMAGE */
975 #ifdef GLK_MODULE_SOUND
976 case 0x00F0: /* schannel_iterate */
977 if (arglist[1].ptrflag)
978 arglist[4].opaqueref = glk_schannel_iterate(arglist[0].opaqueref, &arglist[2].uint);
980 arglist[3].opaqueref = glk_schannel_iterate(arglist[0].opaqueref, NULL);
982 case 0x00F1: /* schannel_get_rock */
983 arglist[2].uint = glk_schannel_get_rock(arglist[0].opaqueref);
985 case 0x00F2: /* schannel_create */
986 arglist[2].opaqueref = glk_schannel_create(arglist[0].uint);
988 case 0x00F3: /* schannel_destroy */
989 glk_schannel_destroy(arglist[0].opaqueref);
991 case 0x00F8: /* schannel_play */
992 arglist[3].uint = glk_schannel_play(arglist[0].opaqueref, arglist[1].uint);
994 case 0x00F9: /* schannel_play_ext */
995 arglist[5].uint = glk_schannel_play_ext(arglist[0].opaqueref,
996 arglist[1].uint, arglist[2].uint, arglist[3].uint);
998 case 0x00FA: /* schannel_stop */
999 glk_schannel_stop(arglist[0].opaqueref);
1001 case 0x00FB: /* schannel_set_volume */
1002 glk_schannel_set_volume(arglist[0].opaqueref, arglist[1].uint);
1004 case 0x00FC: /* sound_load_hint */
1005 glk_sound_load_hint(arglist[0].uint, arglist[1].uint);
1007 #endif /* GLK_MODULE_SOUND */
1009 #ifdef GLK_MODULE_HYPERLINKS
1010 case 0x0100: /* set_hyperlink */
1011 glk_set_hyperlink(arglist[0].uint);
1013 case 0x0101: /* set_hyperlink_stream */
1014 glk_set_hyperlink_stream(arglist[0].opaqueref, arglist[1].uint);
1016 case 0x0102: /* request_hyperlink_event */
1017 glk_request_hyperlink_event(arglist[0].opaqueref);
1019 case 0x0103: /* cancel_hyperlink_event */
1020 glk_cancel_hyperlink_event(arglist[0].opaqueref);
1022 #endif /* GLK_MODULE_HYPERLINKS */
1024 #ifdef GLK_MODULE_UNICODE
1025 case 0x0120: /* buffer_to_lower_case_uni */
1026 if (arglist[0].ptrflag)
1027 arglist[5].uint = glk_buffer_to_lower_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
1029 arglist[3].uint = glk_buffer_to_lower_case_uni(NULL, 0, arglist[1].uint);
1031 case 0x0121: /* buffer_to_upper_case_uni */
1032 if (arglist[0].ptrflag)
1033 arglist[5].uint = glk_buffer_to_upper_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
1035 arglist[3].uint = glk_buffer_to_upper_case_uni(NULL, 0, arglist[1].uint);
1037 case 0x0122: /* buffer_to_title_case_uni */
1038 if (arglist[0].ptrflag)
1039 arglist[6].uint = glk_buffer_to_title_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
1041 arglist[4].uint = glk_buffer_to_title_case_uni(NULL, 0, arglist[1].uint, arglist[2].uint);
1043 case 0x0128: /* put_char_uni */
1044 glk_put_char_uni(arglist[0].uint);
1046 case 0x0129: /* put_string_uni */
1047 glk_put_string_uni(arglist[0].unicharstr);
1049 case 0x012A: /* put_buffer_uni */
1050 if (arglist[0].ptrflag)
1051 glk_put_buffer_uni(arglist[1].array, arglist[2].uint);
1053 glk_put_buffer_uni(NULL, 0);
1055 case 0x012B: /* put_char_stream_uni */
1056 glk_put_char_stream_uni(arglist[0].opaqueref, arglist[1].uint);
1058 case 0x012C: /* put_string_stream_uni */
1059 glk_put_string_stream_uni(arglist[0].opaqueref, arglist[1].unicharstr);
1061 case 0x012D: /* put_buffer_stream_uni */
1062 if (arglist[1].ptrflag)
1063 glk_put_buffer_stream_uni(arglist[0].opaqueref,
1064 arglist[2].array, arglist[3].uint);
1066 glk_put_buffer_stream_uni(arglist[0].opaqueref,
1069 case 0x0130: /* get_char_stream_uni */
1070 arglist[2].sint = glk_get_char_stream_uni(arglist[0].opaqueref);
1072 case 0x0131: /* get_buffer_stream_uni */
1073 if (arglist[1].ptrflag)
1074 arglist[5].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref,
1075 arglist[2].array, arglist[3].uint);
1077 arglist[3].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref,
1080 case 0x0132: /* get_line_stream_uni */
1081 if (arglist[1].ptrflag)
1082 arglist[5].uint = glk_get_line_stream_uni(arglist[0].opaqueref,
1083 arglist[2].array, arglist[3].uint);
1085 arglist[3].uint = glk_get_line_stream_uni(arglist[0].opaqueref,
1088 case 0x0138: /* stream_open_file_uni */
1089 arglist[4].opaqueref = glk_stream_open_file_uni(arglist[0].opaqueref, arglist[1].uint,
1092 case 0x0139: /* stream_open_memory_uni */
1093 if (arglist[0].ptrflag)
1094 arglist[6].opaqueref = glk_stream_open_memory_uni(arglist[1].array,
1095 arglist[2].uint, arglist[3].uint, arglist[4].uint);
1097 arglist[4].opaqueref = glk_stream_open_memory_uni(NULL,
1098 0, arglist[1].uint, arglist[2].uint);
1100 case 0x0140: /* request_char_event_uni */
1101 glk_request_char_event_uni(arglist[0].opaqueref);
1103 case 0x0141: /* request_line_event_uni */
1104 if (arglist[1].ptrflag)
1105 glk_request_line_event_uni(arglist[0].opaqueref, arglist[2].array,
1106 arglist[3].uint, arglist[4].uint);
1108 glk_request_line_event_uni(arglist[0].opaqueref, NULL,
1109 0, arglist[2].uint);
1111 #endif /* GLK_MODULE_UNICODE */