1 #include <stddef.h> /* Surprisingly, the only symbol needed is NULL */
5 /* Version of the Glk specification implemented by this library */
6 #define MAJOR_VERSION 0
7 #define MINOR_VERSION 7
12 * @sel: A selector, representing which capability to request information
14 * @val: Extra information, depending on the value of @sel.
16 * Calls the gestalt system to request information about selector @sel, without
17 * passing an array to store extra information in (see glk_gestalt_ext()).
19 * Returns: an integer, depending on what selector was called.
22 glk_gestalt(glui32 sel, glui32 val)
24 return glk_gestalt_ext(sel, val, NULL, 0);
29 * @sel: A selector, representing which capability to request information
31 * @val: Extra information, depending on the value of @sel.
32 * @arr: Location of an array to store extra information in, or %NULL.
33 * @arrlen: Length of @arr, or 0 if @arr is %NULL.
35 * Calls the gestalt system to request information about the capabilities of the
36 * API. The selector @sel tells which capability you are requesting information
37 * about; the other three arguments are additional information, which may or may
38 * not be meaningful. The @arr and @arrlen arguments of glk_gestalt_ext() are
39 * always optional; you may always pass %NULL and 0, if you do not want whatever
40 * information they represent. glk_gestalt() is simply a shortcut for this;
41 * <code>#glk_gestalt(x, y)</code> is exactly the same as
42 * <code>#glk_gestalt_ext(x, y, %NULL, 0)</code>.
44 * The critical point is that if the Glk library has never heard of the selector
45 * @sel, it will return 0. It is <emphasis>always</emphasis> safe to call
46 * <code>#glk_gestalt(x, y)</code> (or <code>#glk_gestalt_ext(x, y, %NULL,
47 * 0)</code>). Even if you are using an old library, which was compiled before
48 * the given capability was imagined, you can test for the capability by calling
49 * glk_gestalt(); the library will correctly indicate that it does not support
52 * (It is also safe to call <code>#glk_gestalt_ext(x, y, z, zlen)</code> for an
53 * unknown selector <code>x</code>, where <code>z</code> is not %NULL, as long
54 * as <code>z</code> points at an array of at least <code>zlen</code> elements.
55 * The selector will be careful not to write beyond that point in the array, if
56 * it writes to the array at all.)
58 * (If a selector does not use the second argument, you should always pass 0; do
59 * not assume that the second argument is simply ignored. This is because the
60 * selector may be extended in the future. You will continue to get the current
61 * behavior if you pass 0 as the second argument, but other values may produce
64 * Returns: an integer, depending on what selector was called.
67 glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen)
73 return (MAJOR_VERSION << 16) + (MINOR_VERSION << 8) + SUB_VERSION;
75 /* Which characters can the player type in line input? */
76 case gestalt_LineInput:
77 /* Does not accept control chars */
78 if( val < 32 || (val >= 127 && val <= 159) )
82 /* Which characters can the player type in char input? */
83 case gestalt_CharInput:
84 /* Does not accept control chars or unknown */
85 if( val < 32 || (val >= 127 && val <= 159) || val == keycode_Unknown )
89 /* Which characters can we print? */
90 case gestalt_CharOutput:
91 /* All characters are printed as one character, in any case */
94 /* Cannot print control chars except \n */
95 if( (val < 32 && val != 10) || (val >= 127 && val <= 159) )
96 return gestalt_CharOutput_CannotPrint;
97 /* Can print all other characters */
98 return gestalt_CharOutput_ExactPrint;
100 /* Unicode capabilities present */
101 case gestalt_Unicode:
104 /* Timer capabilities present */
108 /* Hyperlink capabilities present */
109 case gestalt_Hyperlinks:
112 /* Hyperlinks supported on textbuffers and textgrids */
113 case gestalt_HyperlinkInput:
114 return val == wintype_TextBuffer || val == wintype_TextGrid;
116 /* Mouse support present in textgrids */
117 case gestalt_MouseInput:
118 return val == wintype_TextGrid;
120 case gestalt_Graphics:
123 case gestalt_DrawImage:
124 return val == wintype_Graphics || val == wintype_TextBuffer;
126 case gestalt_GraphicsTransparency:
129 /* Capabilities supported if compiled with GStreamer */
131 case gestalt_SoundVolume:
132 case gestalt_SoundNotify:
133 case gestalt_SoundMusic:
134 #ifdef GSTREAMER_SOUND
140 /* Unsupported capabilities */
141 case gestalt_DateTime:
142 case gestalt_LineInputEcho:
143 case gestalt_LineTerminatorKey:
144 case gestalt_LineTerminators:
145 case gestalt_UnicodeNorm:
146 /* Selector not supported */