File: programming/cocoa/MacScare-Source.zip/MacScare-Source/gi_dispa.c


/* gi_dispa.c: Dispatch layer for Glk API, version 0.6.1.
    Designed by Andrew Plotkin <erkyrath@eblong.com>
    http://www.eblong.com/zarf/glk/index.html
 
    This file is copyright 1998-2000 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,
    and distribute the modified version, as long as you retain a notice
    in your program or documentation which mentions my name and the URL
    shown above.
*/
 
/* This code should be linked into every Glk library, without change. 
    Get the latest version from the URL above. */
 
#include "glk.h"
#include "gi_dispa.h"
 
#ifndef NULL
#define NULL 0
#endif
 
#define NUMINTCONSTANTS   \
#define NUMFUNCTIONS   \
/* The constants in this table must be ordered alphabetically. */"evtype_Arrange", (5)  },
    { "evtype_CharInput", (2) },
    { "evtype_Hyperlink", (8) },
    { "evtype_LineInput", (3) },
    { "evtype_MouseInput", (4) },
    { "evtype_None", (0) },
    { "evtype_Redraw", (6) },
    { "evtype_SoundNotify", (7) },
    { "evtype_Timer", (1) },
    { "filemode_Read", (0x02) },
    { "filemode_ReadWrite", (0x03) },
    { "filemode_Write", (0x01) },
    { "filemode_WriteAppend", (0x05) },
    { "fileusage_BinaryMode", (0x000) },
    { "fileusage_Data", (0x00) },
    { "fileusage_InputRecord", (0x03) },
    { "fileusage_SavedGame", (0x01) },
    { "fileusage_TextMode",   (0x100) },
    { "fileusage_Transcript", (0x02) },
    { "fileusage_TypeMask", (0x0f) },
    { "gestalt_CharInput", (1) },
    { "gestalt_CharOutput", (3) },
    { "gestalt_CharOutput_ApproxPrint", (1) },
    { "gestalt_CharOutput_CannotPrint", (0) },
    { "gestalt_CharOutput_ExactPrint", (2) },
    { "gestalt_DrawImage", (7) },
    { "gestalt_Graphics", (6) },
    { "gestalt_GraphicsTransparency", (14) },
    { "gestalt_HyperlinkInput", (12) },
    { "gestalt_Hyperlinks", (11) },
    { "gestalt_LineInput", (2) },
    { "gestalt_MouseInput", (4) },
    { "gestalt_Sound", (8) },
    { "gestalt_SoundMusic", (13) },
    { "gestalt_SoundNotify", (10) },
    { "gestalt_SoundVolume", (9) },
    { "gestalt_Timer", (5) },
    { "gestalt_Version", (0) },
#ifdef GLK_MODULE_IMAGE
    { "imagealign_InlineCenter",  (0x03) },
    { "imagealign_InlineDown",  (0x02) },
    { "imagealign_MarginLeft",  (0x04) },
    { "imagealign_MarginRight",  (0x05) },
    { "imagealign_InlineUp",  (0x01) },
#endif /* GLK_MODULE_IMAGE */
    { "keycode_Delete",   (0xfffffff9) },
    { "keycode_Down",     (0xfffffffb) },
    { "keycode_End",      (0xfffffff3) },
    { "keycode_Escape",   (0xfffffff8) },
    { "keycode_Func1",    (0xffffffef) },
    { "keycode_Func10",   (0xffffffe6) },
    { "keycode_Func11",   (0xffffffe5) },
    { "keycode_Func12",   (0xffffffe4) },
    { "keycode_Func2",    (0xffffffee) },
    { "keycode_Func3",    (0xffffffed) },
    { "keycode_Func4",    (0xffffffec) },
    { "keycode_Func5",    (0xffffffeb) },
    { "keycode_Func6",    (0xffffffea) },
    { "keycode_Func7",    (0xffffffe9) },
    { "keycode_Func8",    (0xffffffe8) },
    { "keycode_Func9",    (0xffffffe7) },
    { "keycode_Home",     (0xfffffff4) },
    { "keycode_Left",     (0xfffffffe) },
    { "keycode_MAXVAL",   (28)  },
    { "keycode_PageDown", (0xfffffff5) },
    { "keycode_PageUp",   (0xfffffff6) },
    { "keycode_Return",   (0xfffffffa) },
    { "keycode_Right",    (0xfffffffd) },
    { "keycode_Tab",      (0xfffffff7) },
    { "keycode_Unknown",  (0xffffffff) },
    { "keycode_Up",       (0xfffffffc) },
    { "seekmode_Current", (1) },
    { "seekmode_End", (2) },
    { "seekmode_Start", (0) },
    { "style_Alert", (5) },
    { "style_BlockQuote", (7) },
    { "style_Emphasized", (1) },
    { "style_Header", (3) },
    { "style_Input", (8) },
    { "style_NUMSTYLES", (11) },
    { "style_Normal", (0) },
    { "style_Note", (6) },
    { "style_Preformatted", (2) },
    { "style_Subheader", (4) },
    { "style_User1", (9) },
    { "style_User2", (10) },
    { "stylehint_BackColor", (8) },
    { "stylehint_Indentation", (0) },
    { "stylehint_Justification", (2)  },
    { "stylehint_NUMHINTS", (10) },
    { "stylehint_Oblique", (5) },
    { "stylehint_ParaIndentation", (1) },
    { "stylehint_Proportional", (6) },
    { "stylehint_ReverseColor", (9) },
    { "stylehint_Size", (3) },
    { "stylehint_TextColor", (7) },
    { "stylehint_Weight", (4) },
    { "stylehint_just_Centered", (2) },
    { "stylehint_just_LeftFlush", (0) },
    { "stylehint_just_LeftRight", (1) },
    { "stylehint_just_RightFlush", (3) },
    { "winmethod_Above", (0x02)  },
    { "winmethod_Below", (0x03)  },
    { "winmethod_DirMask", (0x0f) },
    { "winmethod_DivisionMask", (0xf0) },
    { "winmethod_Fixed", (0x10) },
    { "winmethod_Left",  (0x00)  },
    { "winmethod_Proportional", (0x20) },
    { "winmethod_Right", (0x01)  },
    { "wintype_AllTypes", (0)  },
    { "wintype_Blank", (2)  },
    { "wintype_Graphics", (5)  },
    { "wintype_Pair", (1)  },
    { "wintype_TextBuffer", (3) },
    { "wintype_TextGrid", (4) },
};
 
/* The functions in this table must be ordered by id. */"exit""set_interrupt_handler" },
    { 0x0003, glk_tick, "tick" },
    { 0x0004, glk_gestalt, "gestalt" },
    { 0x0005, glk_gestalt_ext, "gestalt_ext""window_iterate""window_get_rock""window_get_root""window_open""window_close""window_get_size""window_set_arrangement""window_get_arrangement""window_get_type""window_get_parent""window_clear""window_move_cursor""window_get_stream""window_set_echo_stream""window_get_echo_stream""set_window""window_get_sibling" },
    { 0x0040, glk_stream_iterate, "stream_iterate" },
    { 0x0041, glk_stream_get_rock, "stream_get_rock""stream_open_file" },
    { 0x0043, glk_stream_open_memory, "stream_open_memory" },
    { 0x0044, glk_stream_close, "stream_close" },
    { 0x0045, glk_stream_set_position, "stream_set_position" },
    { 0x0046, glk_stream_get_position, "stream_get_position" },
    { 0x0047, glk_stream_set_current, "stream_set_current" },
    { 0x0048, glk_stream_get_current, "stream_get_current""fileref_create_temp""fileref_create_by_name""fileref_create_by_prompt""fileref_destroy""fileref_iterate""fileref_get_rock""fileref_delete_file""fileref_does_file_exist""fileref_create_from_fileref""put_char""put_char_stream""put_string""put_string_stream" },
    { 0x0084, glk_put_buffer, "put_buffer" },
    { 0x0085, glk_put_buffer_stream, "put_buffer_stream" },
    { 0x0086, glk_set_style, "set_style" },
    { 0x0087, glk_set_style_stream, "set_style_stream""get_char_stream" },
    { 0x0091, glk_get_line_stream, "get_line_stream" },
    { 0x0092, glk_get_buffer_stream, "get_buffer_stream""char_to_lower""char_to_upper""stylehint_set""stylehint_clear" },
    { 0x00B2, glk_style_distinguish, "style_distinguish" },
    { 0x00B3, glk_style_measure, "style_measure" },
    { 0x00C0, glk_select, "select" },
    { 0x00C1, glk_select_poll, "select_poll" },
    { 0x00D0, glk_request_line_event, "request_line_event" },
    { 0x00D1, glk_cancel_line_event, "cancel_line_event""request_char_event""cancel_char_event" },
    { 0x00D4, glk_request_mouse_event, "request_mouse_event" },
    { 0x00D5, glk_cancel_mouse_event, "cancel_mouse_event""request_timer_events" },
#ifdef GLK_MODULE_IMAGE
    { 0x00E0, glk_image_get_info, "image_get_info" },
    { 0x00E1, glk_image_draw, "image_draw" },
    { 0x00E2, glk_image_draw_scaled, "image_draw_scaled""window_flow_break""window_erase_rect""window_fill_rect""window_set_background_color" },
#endif /* GLK_MODULE_IMAGE */
#ifdef GLK_MODULE_SOUND
    { 0x00F0, glk_schannel_iterate, "schannel_iterate" },
    { 0x00F1, glk_schannel_get_rock, "schannel_get_rock" },
    { 0x00F2, glk_schannel_create, "schannel_create" },
    { 0x00F3, glk_schannel_destroy, "schannel_destroy" },
    { 0x00F8, glk_schannel_play, "schannel_play" },
    { 0x00F9, glk_schannel_play_ext, "schannel_play_ext" },
    { 0x00FA, glk_schannel_stop, "schannel_stop" },
    { 0x00FB, glk_schannel_set_volume, "schannel_set_volume""sound_load_hint" },
#endif /* GLK_MODULE_SOUND */
#ifdef GLK_MODULE_HYPERLINKS
    { 0x0100, glk_set_hyperlink, "set_hyperlink" },
    { 0x0101, glk_set_hyperlink_stream, "set_hyperlink_stream" },
    { 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" },
    { 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" },
#endif /* GLK_MODULE_HYPERLINKS */
/* exit */"0:"/* set_interrupt_handler */
            /* cannot be invoked through dispatch layer *//* tick */"0:"/* gestalt */"3IuIu:Iu"/* gestalt_ext */"4IuIu&#Iu:Iu"/* window_iterate */"3Qa<Iu:Qa"/* window_get_rock */"2Qa:Iu"/* window_get_root */"1:Qa"/* window_open */"6QaIuIuIuIu:Qa"/* window_close */"2Qa<[2IuIu]:"/* window_get_size */"3Qa<Iu<Iu:"/* window_set_arrangement */"4QaIuIuQa:"/* window_get_arrangement */"4Qa<Iu<Iu<Qa:"/* window_get_type */"2Qa:Iu"/* window_get_parent */"2Qa:Qa"/* window_clear */"1Qa:"/* window_move_cursor */"3QaIuIu:"/* window_get_stream */"2Qa:Qb"/* window_set_echo_stream */"2QaQb:"/* window_get_echo_stream */"2Qa:Qb"/* set_window */"1Qa:"/* window_get_sibling */"2Qa:Qa"/* stream_iterate */"3Qb<Iu:Qb"/* stream_get_rock */"2Qb:Iu"/* stream_open_file */"4QcIuIu:Qb"/* stream_open_memory */"4&+#!CnIuIu:Qb"/* stream_close */"2Qb<[2IuIu]:"/* stream_set_position */"3QbIsIu:"/* stream_get_position */"2Qb:Iu"/* stream_set_current */"1Qb:"/* stream_get_current */"1:Qb"/* fileref_create_temp */"3IuIu:Qc"/* fileref_create_by_name */"4IuSIu:Qc"/* fileref_create_by_prompt */"4IuIuIu:Qc"/* fileref_destroy */"1Qc:"/* fileref_iterate */"3Qc<Iu:Qc"/* fileref_get_rock */"2Qc:Iu"/* fileref_delete_file */"1Qc:"/* fileref_does_file_exist */"2Qc:Iu"/* fileref_create_from_fileref */"4IuQcIu:Qc"/* put_char */"1Cu:"/* put_char_stream */"2QbCu:"/* put_string */"1S:"/* put_string_stream */"2QbS:"/* put_buffer */"1>+#Cn:"/* put_buffer_stream */"2Qb>+#Cn:"/* set_style */"1Iu:"/* set_style_stream */"2QbIu:"/* get_char_stream */"2Qb:Iu"/* get_line_stream */"3Qb<+#Cn:Iu"/* get_buffer_stream */"3Qb<+#Cn:Iu"/* char_to_lower */"2Cu:Cu"/* char_to_upper */"2Cu:Cu"/* stylehint_set */"4IuIuIuIs:"/* stylehint_clear */"3IuIuIu:"/* style_distinguish */"4QaIuIu:Iu"/* style_measure */"5QaIuIu<Iu:Iu"/* select */"1<+[4IuQaIuIu]:"/* select_poll */"1<+[4IuQaIuIu]:"/* request_line_event */"3Qa&+#!CnIu:"/* cancel_line_event */"2Qa<[4IuQaIuIu]:"/* request_char_event */"1Qa:"/* cancel_char_event */"1Qa:"/* request_mouse_event */"1Qa:"/* cancel_mouse_event */"1Qa:"/* request_timer_events */"1Iu:";
#ifdef GLK_MODULE_IMAGE
/* image_get_info */"4Iu<Iu<Iu:Iu"/* image_draw */"5QaIuIsIs:Iu"/* image_draw_scaled */"7QaIuIsIsIuIu:Iu"/* window_flow_break */"1Qa:"/* window_erase_rect */"5QaIsIsIuIu:"/* window_fill_rect */"6QaIuIsIsIuIu:"/* window_set_background_color */"2QaIu:";
#endif /* GLK_MODULE_IMAGE */
#ifdef GLK_MODULE_SOUND
/* schannel_iterate */"3Qd<Iu:Qd"/* schannel_get_rock */"2Qd:Iu"/* schannel_create */"2Iu:Qd"/* schannel_destroy */"1Qd:"/* schannel_play */"3QdIu:Iu"/* schannel_play_ext */"5QdIuIuIu:Iu"/* schannel_stop */"1Qd:"/* schannel_set_volume */"2QdIu:"/* sound_load_hint */"2IuIu:";
#endif /* GLK_MODULE_SOUND */
#ifdef GLK_MODULE_HYPERLINKS
/* set_hyperlink */"1Iu:"/* set_hyperlink_stream */"2QbIu:"/* request_hyperlink_event */"1Qa:"/* cancel_hyperlink_event */"1Qa:";
#endif /* GLK_MODULE_HYPERLINKS */
/* exit *//* set_interrupt_handler */
            /* cannot be invoked through dispatch layer *//* tick *//* gestalt *//* gestalt_ext *//* window_iterate *//* window_get_rock *//* window_get_root *//* window_open *//* window_close *//* window_get_size *//* window_set_arrangement *//* window_get_arrangement *//* window_get_type *//* window_get_parent *//* window_clear *//* window_move_cursor *//* window_get_stream *//* window_set_echo_stream *//* window_get_echo_stream *//* set_window *//* window_get_sibling *//* stream_iterate *//* stream_get_rock *//* stream_open_file *//* stream_open_memory *//* stream_close *//* stream_set_position *//* stream_get_position *//* stream_set_current *//* stream_get_current *//* fileref_create_temp *//* fileref_create_by_name *//* fileref_create_by_prompt *//* fileref_destroy *//* fileref_iterate *//* fileref_get_rock *//* fileref_delete_file *//* fileref_does_file_exist *//* fileref_create_from_fileref *//* put_char *//* put_char_stream *//* put_string *//* put_string_stream *//* put_buffer *//* put_buffer_stream *//* set_style *//* set_style_stream *//* get_char_stream *//* get_line_stream *//* get_buffer_stream *//* char_to_lower *//* char_to_upper *//* stylehint_set *//* stylehint_clear *//* style_distinguish *//* style_measure *//* select *//* select_poll *//* request_line_event *//* cancel_line_event *//* request_char_event *//* cancel_char_event *//* request_mouse_event *//* cancel_mouse_event *//* request_timer_events */#ifdef GLK_MODULE_IMAGE
/* image_get_info *//* image_draw *//* image_draw_scaled *//* window_flow_break *//* window_erase_rect *//* window_fill_rect *//* window_set_background_color */#endif /* GLK_MODULE_IMAGE */
#ifdef GLK_MODULE_SOUND
/* schannel_iterate *//* schannel_get_rock *//* schannel_create *//* schannel_destroy *//* schannel_play *//* schannel_play_ext *//* schannel_stop *//* schannel_set_volume *//* sound_load_hint */#endif /* GLK_MODULE_SOUND */
#ifdef GLK_MODULE_HYPERLINKS
/* set_hyperlink *//* set_hyperlink_stream *//* request_hyperlink_event *//* cancel_hyperlink_event */#endif /* GLK_MODULE_HYPERLINKS */
/* do nothing */

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.