3 /* Version of the Glk specification implemented by this library */
4 #define MAJOR_VERSION 0
5 #define MINOR_VERSION 7
10 * @sel: A selector, representing which capability to request information
12 * @val: Extra information, depending on the value of @sel.
14 * Calls the gestalt system to request information about selector @sel, without
15 * passing an array to store extra information in (see glk_gestalt_ext()).
17 * Returns: an integer, depending on what selector was called.
20 glk_gestalt(glui32 sel, glui32 val)
22 return glk_gestalt_ext(sel, val, NULL, 0);
27 * @sel: A selector, representing which capability to request information
29 * @val: Extra information, depending on the value of @sel.
30 * @arr: Location of an array to store extra information in, or %NULL.
31 * @arrlen: Length of @arr, or 0 if @arr is %NULL.
33 * Calls the gestalt system to request information about the capabilities of the
34 * API. The selector @sel tells which capability you are requesting information
35 * about; the other three arguments are additional information, which may or may
36 * not be meaningful. The @arr and @arrlen arguments are always optional; you
37 * may always pass %NULL and 0, if you do not want whatever information they
38 * represent. glk_gestalt() is simply a shortcut for this; glk_gestalt(x, y) is
39 * exactly the same as glk_gestalt_ext(x, y, NULL, 0).
41 * The critical point is that if the Glk library has never heard of the selector
42 * sel, it will return 0. It is always safe to call glk_gestalt(x, y) (or
43 * glk_gestalt_ext(x, y, NULL, 0)). Even if you are using an old library, which
44 * was compiled before the given capability was imagined, you can test for the
45 * capability by calling glk_gestalt(); the library will correctly indicate that
46 * it does not support it, by returning 0.
49 * It is also safe to call glk_gestalt_ext(x, y, z, zlen) for an unknown
50 * selector x, where z is not %NULL, as long as z points at an array of at
51 * least zlen elements. The selector will be careful not to write beyond that
52 * point in the array, if it writes to the array at all.
56 * If a selector does not use the second argument, you should always pass 0; do
57 * not assume that the second argument is simply ignored. This is because the
58 * selector may be extended in the future. You will continue to get the current
59 * behavior if you pass 0 as the second argument, but other values may produce
63 * Returns: an integer, depending on what selector was called.
66 glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen)
72 return (MAJOR_VERSION << 16) + (MINOR_VERSION << 8) + SUB_VERSION;
74 /* Which characters can we print? */
75 case gestalt_CharOutput:
76 /* All characters are printed as one character, in any case */
79 /* Cannot print control chars except \n, or chars > 255 */
80 if( (val < 32 && val != 10) || (val >= 127 && val <= 159) || (val > 255) )
81 return gestalt_CharOutput_CannotPrint;
82 /* Can print all other Latin-1 characters */
83 return gestalt_CharOutput_ExactPrint;
85 /* Which characters can the player type in line input? */
86 case gestalt_LineInput:
87 /* Does not accept control chars */
88 if( val < 32 || (val >= 127 && val <= 159) )
92 /* Which characters can the player type in char input? */
93 case gestalt_CharInput:
94 /* Does not accept control chars or unknown */
95 if( val < 32 || (val >= 127 && val <= 159) || val == keycode_Unknown )
99 /* Selector not supported */