Document all incomplete symbols
[projects/chimara/chimara.git] / libchimara / doc.c
1 /*
2  * doc.c - Contains the short and long descriptions of all the documentation
3  *         sections in the Glk spec, as well as the GtkDoc comments for symbols
4  *         defined only in glk.h.
5  */
6
7 /**
8  * SECTION:glk-exiting
9  * @short_description: How to terminate a Glk program cleanly
10  * @include: libchimara/glk.h
11  *
12  * A Glk program usually ends when the end of the glk_main() function is 
13  * reached. You can also terminate it earlier.
14  */ 
15
16 /**
17  * SECTION:glk-interrupt
18  * @short_description: Specifying an interrupt handler for cleaning up critical
19  * resources
20  * @include: libchimara/glk.h
21  *
22  * Most platforms have some provision for interrupting a program —
23  * <keycombo action="simul"><keycap function="command">command</keycap>
24  * <keycap>period</keycap></keycombo> on the Macintosh, <keycombo 
25  * action="simul"><keycap function="control">control</keycap><keycap>C</keycap>
26  * </keycombo> in Unix, possibly a window manager item, or other possibilities.
27  * This can happen at any time, including while execution is nested inside one 
28  * of your own functions, or inside a Glk library function.
29  *
30  * If you need to clean up critical resources, you can specify an interrupt
31  * handler function.
32  */
33
34 /**
35  * SECTION:glk-tick
36  * @short_description: Yielding time to the operating system
37  * @include: libchimara/glk.h
38  *
39  * Many platforms have some annoying thing that has to be done every so often,
40  * or the gnurrs come from the voodvork out and eat your computer.
41  * 
42  * Well, not really. But you should call glk_tick() every so often, just in
43  * case. It may be necessary to yield time to other applications in a
44  * cooperative-multitasking OS, or to check for player interrupts in an infinite
45  * loop.
46  */
47
48 /**
49  * SECTION:glk-types
50  * @short_description: Basic types used in Glk
51  * @include: libchimara/glk.h
52  *
53  * For simplicity, all the arguments used in Glk calls are of a very few types.
54  * <variablelist>
55  *  <varlistentry>
56  *    <term>32-bit unsigned integer</term>
57  *    <listitem><para>Unsigned integers are used wherever possible, which is
58  *    nearly everywhere. This type is called #glui32.</para></listitem>
59  *  </varlistentry>
60  *  <varlistentry>
61  *    <term>32-bit signed integer</term>
62  *    <listitem><para>This type is called #glsi32. Rarely used.</para>
63  *    </listitem>
64  *  </varlistentry>
65  *  <varlistentry>
66  *    <term>References to library objects</term>
67  *    <listitem><para>These are pointers to opaque C structures; each library
68  *    will use different structures, so you can not and should not try to
69  *    manipulate their contents. See <link 
70  *    linkend="chimara-Opaque-Objects">Opaque Objects</link>.</para></listitem>
71  *  </varlistentry>
72  *  <varlistentry>
73  *    <term>Pointer to one of the above types</term>
74  *    <listitem><para>Pointer to a structure which consists entirely of the
75  *    above types.</para></listitem>
76  *  </varlistentry>
77  *  <varlistentry>
78  *    <term><type>unsigned char</type></term> 
79  *    <listitem><para>This is used only for Latin-1 text characters; see 
80  *    <link linkend="chimara-Character-Encoding">Character Encoding</link>.
81  *    </para></listitem>
82  *  </varlistentry>
83  *  <varlistentry>
84  *    <term>Pointer to <type>char</type></term> 
85  *    <listitem><para>Sometimes this means a null-terminated string; sometimes
86  *    an unterminated buffer, with length as a separate #glui32 argument. The
87  *    documentation says which.</para></listitem>
88  *  </varlistentry>
89  *  <varlistentry>
90  *    <term>Pointer to <type>void</type></term> 
91  *    <listitem><para>When nothing else will do.</para></listitem>
92  *  </varlistentry>
93  * </variablelist>
94  */
95
96 /**
97  * SECTION:glk-opaque-objects
98  * @short_description: Complex objects in Glk
99  * @include: libchimara/glk.h
100  *
101  * Glk keeps track of a few classes of special objects. These are opaque to your
102  * program; you always refer to them using pointers to opaque C structures.
103  * 
104  * Currently, these classes are:
105  * <variablelist>
106  *  <varlistentry>
107  *    <term>Windows</term>
108  *    <listitem><para>Screen panels, used to input or output information.
109  *    </para></listitem>
110  *  </varlistentry>
111  *  <varlistentry>
112  *    <term>Streams</term>
113  *    <listitem><para>Data streams, to which you can input or output text.
114  *    </para>
115  *    <note><para>There are file streams and window streams, since you can
116  *    output data to windows or files.</para></note>
117  *    </listitem>
118  *  </varlistentry>
119  *  <varlistentry>
120  *    <term>File references</term>
121  *    <listitem><para>Pointers to files in permanent storage.</para>
122  *    <note><para>In Unix a file reference is a pathname; on the Mac, an
123  *    <type>FSSpec</type>. Actually there's a little more information included,
124  *    such as file type and whether it is a text or binary file.</para></note>
125  *    </listitem>
126  *  </varlistentry>
127  *  <varlistentry>
128  *    <term>Sound channels</term>
129  *    <listitem><para>Audio output channels.</para>
130  *    <note><para>Not all Glk libraries support sound.</para></note>
131  *    </listitem>
132  *  </varlistentry>
133  * </variablelist>
134  *
135  * <note><para>
136  * Note that there may be more object classes in future versions of the Glk API.
137  * </para></note>
138  * 
139  * When you create one of these objects, it is always possible that the creation
140  * will fail (due to lack of memory, or some other OS error.) When this happens,
141  * the allocation function will return %NULL instead of a valid pointer. You
142  * should always test for this possibility.
143  * 
144  * %NULL is never the identifier of any object (window, stream, file reference,
145  * or sound channel). The value %NULL is often used to indicate <quote>no
146  * object</quote> or <quote>nothing</quote>, but it is not a valid reference. If
147  * a Glk function takes an object reference as an argument, it is illegal to
148  * pass in %NULL unless the function definition says otherwise.
149  * 
150  * The <filename class="headerfile">glk.h</filename> file defines types
151  * #winid_t, #strid_t, #frefid_t, #schanid_t to store references. These are
152  * pointers to struct #glk_window_struct, #glk_stream_struct, 
153  * #glk_fileref_struct, and #glk_schannel_struct respectively. It is, of course,
154  * illegal to pass one kind of pointer to a function which expects another.
155  * 
156  * <note><para>
157  * This is how you deal with opaque objects from a C program. If you are using
158  * Glk through a virtual machine, matters will probably be different. Opaque
159  * objects may be represented as integers, or as VM objects of some sort.
160  * </para></note></para>
161  * <para>
162  * <refsect2 id="chimara-Rocks"><!-- Indeed it does. -->
163  * <title>Rocks</title>
164  * <para>
165  * Every one of these objects (window, stream, file reference, or sound channel)
166  * has a <quote>rock</quote> value. This is simply a 32-bit integer value which
167  * you provide, for your own purposes, when you create the object.
168  * </para>
169  * <note><para>The library &mdash; so to speak &mdash; stuffs this value under a
170  * rock for safe-keeping, and gives it back to you when you ask for it.
171  * </para></note>
172  * <note><para>If you don't know what to use the rocks for, provide 0 and forget
173  * about it.</para></note>
174  * </refsect2>
175  * <refsect2 id="chimara-Iterating-Through-Opaque-Objects">
176  * <title>Iteration Through Opaque Objects</title>
177  * <para>
178  * For each class of opaque objects, there is an iterate function, which you can
179  * use to obtain a list of all existing objects of that class. It takes the form
180  * |[
181  * CLASSid_t glk_CLASS_iterate(CLASSid_t obj, glui32 *rockptr);
182  * ]|
183  * ...where <code><replaceable>CLASS</replaceable></code> represents one of the
184  * opaque object classes. 
185  * </para>
186  * <note><para>
187  *   So, at the current time, these are the functions glk_window_iterate(),
188  *   glk_stream_iterate(), glk_fileref_iterate(), and glk_schannel_iterate().  
189  *   There may be more classes in future versions of the spec; they all behave
190  *   the same.
191  * </para></note>
192  * <para>
193  * Calling <code>glk_<replaceable>CLASS</replaceable>_iterate(%NULL, r)</code>
194  * returns the first object; calling 
195  * <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> returns
196  * the next object, until there aren't any more, at which time it returns %NULL.
197  * </para>
198  * <para>
199  * The @rockptr argument is a pointer to a location; whenever  
200  * <code>glk_<replaceable>CLASS</replaceable>_iterate()</code> returns an
201  * object, the object's rock is stored in the location <code>(*@rockptr)</code>.
202  * If you don't want the rocks to be returned, you may set @rockptr to %NULL.
203  * </para>
204  * <para>
205  * You usually use this as follows:
206  * |[
207  * obj = glk_CLASS_iterate(NULL, NULL);
208  * while (obj) {
209  *    /* ...do something with obj... *<!-- -->/
210  *    obj = glk_CLASS_iterate(obj, NULL);
211  * }
212  * ]|
213  * </para>
214  * <para>
215  * If you create or destroy objects inside this loop, obviously, the results are
216  * unpredictable. However it is always legal to call 
217  * <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> as long as
218  * @obj is a valid object id, or %NULL.
219  * </para>
220  * <para>
221  * The order in which objects are returned is entirely arbitrary. The library
222  * may even rearrange the order every time you create or destroy an object of
223  * the given class. As long as you do not create or destroy any object, the rule
224  * is that <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> has
225  * a fixed result, and iterating through the results as above will list every
226  * object exactly once. 
227  * </para>
228  * </refsect2>
229  */
230
231 /**
232  * SECTION:glk-gestalt
233  * @short_description: Testing Glk's capabilities
234  * @include: libchimara/glk.h
235  *
236  * The <quote>gestalt</quote> mechanism (cheerfully stolen from the Mac OS) is a
237  * system by which the Glk API can be upgraded without making your life
238  * impossible. New capabilities (graphics, sound, or so on) can be added without
239  * changing the basic specification. The system also allows for 
240  * <quote>optional</quote> capabilities &mdash; those which not all Glk library
241  * implementations will support &mdash; and allows you to check for their
242  * presence without trying to infer them from a version number.
243  * 
244  * The basic idea is that you can request information about the capabilities of
245  * the API, by calling the gestalt functions.
246  */
247
248 /**
249  * SECTION:glk-character-input
250  * @short_description: Waiting for a single keystroke
251  * @include: libchimara/glk.h
252  *
253  * You can request that the player hit a single key. See <link 
254  * linkend="chimara-Character-Input-Events">Character Input Events</link>.
255  * 
256  * If you use the basic text API, the character code which is returned can be
257  * any value from 0 to 255. The printable character codes have already been
258  * described. The remaining codes are typically control codes: <keycombo  
259  * action="simul"><keycap function="control">control</keycap>
260  * <keycap>A</keycap></keycombo> to <keycombo action="simul"><keycap 
261  * function="control">control</keycap><keycap>Z</keycap></keycombo> and a few
262  * others.
263  * 
264  * There are also a number of special codes, representing special keyboard
265  * keys, which can be returned from a char-input event. These are represented
266  * as 32-bit integers, starting with 4294967295 (0xFFFFFFFF) and working down.
267  * The special key codes are defined in the <filename 
268  * class="headerfile">glk.h</filename> file. They include one code for <keycap
269  * function="enter">return</keycap> or <keycap function="enter">enter</keycap>,
270  * one for <keycap function="delete">delete</keycap> or <keycap
271  * function="backspace">backspace</keycap>, twelve function keys, and one code
272  * for any key which has no Latin-1 or special code. The full list of key codes
273  * is included below.
274  * 
275  * Various implementations of Glk will vary widely in which characters the
276  * player can enter. The most obvious limitation is that some characters are
277  * mapped to others. For example, most keyboards return a <keycombo
278  * action="simul"><keycap function="control">control</keycap><keycap>I</keycap>
279  * </keycombo> code when the <keycap function="tab">tab</keycap> key is
280  * pressed. The Glk library, if it can recognize this at all, will generate a
281  * <keysym>%keycode_Tab</keysym> event (value 0xFFFFFFF7) when this occurs.
282  * Therefore, for these keyboards, no keyboard key will generate a <keycombo
283  * action="simul"><keycap function="control">control</keycap><keycap>I</keycap>
284  * </keycombo> event (value 9.) The Glk library will probably map many of the
285  * control codes to the other special keycodes.
286  * 
287  * <note><para>
288  *   On the other hand, the library may be very clever and discriminate between
289  *   <keycap>tab</keycap> and <keycombo action="simul"><keycap
290  *   function="control">control</keycap><keycap>I</keycap></keycombo>. This is
291  *   legal. The idea is, however, that if your program asks the player to
292  *   <quote><computeroutput>press the <keycap function="tab">tab</keycap>
293  *   key</computeroutput></quote>, you should check for a 
294  *   <keysym>%keycode_Tab</keysym> event as opposed to a <keycombo 
295  *   action="simul"><keycap function="control">control</keycap>
296  *   <keycap>I</keycap></keycombo> event.
297  * </para></note>
298  * 
299  * Some characters may not be enterable simply because they do not exist.
300  * 
301  * <note><para>
302  *   Not all keyboards have a <keycap function="home">home</keycap> or <keycap
303  *   function="end">end</keycap> key. A pen-based platform may not recognize
304  *   any control characters at all.
305  * </para></note>
306  * 
307  * Some characters may not be enterable because they are reserved for the
308  * purposes of the interface. For example, the Mac Glk library reserves the 
309  * <keycap function="tab">tab</keycap> key for switching between different Glk
310  * windows. Therefore, on the Mac, the library will never generate a
311  * <keysym>%keycode_Tab</keysym> event or a <keycombo action="simul">
312  * <keycap function="control">control</keycap><keycap>I</keycap></keycombo>
313  * event.
314  * 
315  * <note><para>
316  *   Note that the linefeed or <keycombo action="simul"><keycap  
317  *   function="control">control</keycap><keycap>J</keycap></keycombo> 
318  *   character, which is the only printable control character, is probably not
319  *   typable. This is because, in most libraries, it will be converted to
320  *   <keysym>%keycode_Return</keysym>. Again, you should check for
321  *   <keysym>%keycode_Return</keysym> if your program asks the player to 
322  *   <quote><computeroutput>press the <keycap function="enter">return</keycap>
323  *   key</computeroutput></quote>.
324  * </para></note>
325  * 
326  * <note><para>
327  *   The <keycap function="delete">delete</keycap> and <keycap
328  *   function="backspace">backspace</keycap> keys are merged into a single
329  *   keycode because they have such an astonishing history of being confused in
330  *   the first place... this spec formally waives any desire to define the
331  *   difference. Of course, a library is free to distinguish <keycap
332  *   function="delete">delete</keycap> and <keycap
333  *   function="backspace">backspace</keycap> during line input. This is when it
334  *   matters most; conflating the two during character input should not be a
335  *   large problem.
336  * </para></note>
337  *
338  * You can test for this by using the %gestalt_CharInput selector.
339  * 
340  * <note><para>
341  *   Glk porters take note: it is not a goal to be able to generate every
342  *   single possible key event. If the library says that it can generate a
343  *   particular keycode, then game programmers will assume that it is
344  *   available, and ask players to use it. If a <keysym>%keycode_Home</keysym>
345  *   event can only be generated by typing <keycombo action="seq"><keycap
346  *   function="escape">escape</keycap><keycombo action="simul"><keycap
347  *   function="control">control</keycap><keycap>A</keycap></keycombo>
348  *   </keycombo>, and the player does not know this, the player will be lost
349  *   when the game says <quote><computeroutput>Press the <keycap
350  *   function="home">home</keycap> key to see the next 
351  *   hint.</computeroutput></quote> It is better for the library to say that it
352  *   cannot generate a <keysym>%keycode_Home</keysym> event; that way the game
353  *   can detect the situation and ask the user to type <keycap>H</keycap>
354  *   instead.
355  * </para>
356  * <para>
357  *   Of course, it is better not to rely on obscure keys in any case. The arrow
358  *   keys and <keycap function="enter">return</keycap> are nearly certain to be
359  *   available; the others are of gradually decreasing reliability, and you
360  *   (the game programmer) should not depend on them. You must be certain to
361  *   check for the ones you want to use, including the arrow keys and <keycap
362  *   function="enter">return</keycap>, and be prepared to use different keys in
363  *   your interface if %gestalt_CharInput says they are not available.
364  * </para></note>
365  */
366
367 /**
368  * SECTION:glk-case
369  * @short_description: Changing the case of strings
370  * @include: libchimara/glk.h
371  *
372  * Glk has functions to manipulate the case of both Latin-1 and Unicode strings.
373  * One Latin-1 lowercase character corresponds to one uppercase character, and
374  * vice versa, so the Latin-1 functions act on single characters. The Unicode
375  * functions act on whole strings, since the length of the string may change.
376  */
377
378 /**
379  * SECTION:glk-normalize
380  * @short_description: Combining characters
381  * @include: libchimara/glk.h
382  *
383  * Comparing Unicode strings is difficult, because there can be several ways to
384  * represent a piece of text as a Unicode string. For example, the one-character
385  * string <quote>&egrave;</quote> (an accented <quote>e</quote>) will be
386  * displayed the same as the two-character string containing <quote>e</quote>
387  * followed by Unicode character 0x0300 (COMBINING GRAVE ACCENT). These strings
388  * should be considered equal.
389  *
390  * Therefore, a Glk program that accepts line input should convert its text to a
391  * normalized form before parsing it. These functions offer those conversions.
392  * The algorithms are defined by the Unicode spec (chapter 3.7) and <ulink
393  * url="http://www.unicode.org/reports/tr15/">Unicode Standard Annex
394  * &num;15</ulink>.
395  */
396
397 /**
398  * SECTION:glk-window-opening
399  * @short_description: Creating new windows and closing them
400  * @include: libchimara/glk.h
401  *
402  * You can open a new window using glk_window_open() and close it again using
403  * glk_window_close().
404  */
405
406 /**
407  * SECTION:glk-window-constraints
408  * @short_description: Manipulating the size of a window
409  * @include: libchimara/glk.h
410  *
411  * There are library functions to change and to measure the size of a window.
412  */
413
414 /**
415  * SECTION:glk-window-types
416  * @short_description: Blank, pair, text grid, text buffer, and graphics windows
417  * @include: libchimara/glk.h
418  * 
419  * A technical description of all the window types, and exactly how they behave.
420  */
421
422 /**
423  * SECTION:glk-echo-streams
424  * @short_description: Creating a copy of a window's output
425  * @include: libchimara/glk.h
426  *
427  * Every window has an associated window stream; you print to the window by
428  * printing to this stream. However, it is possible to attach a second stream to
429  * a window. Any text printed to the window is also echoed to this second
430  * stream, which is called the window's <quote>echo stream.</quote>
431  * 
432  * Effectively, any call to glk_put_char() (or the other output commands) which
433  * is directed to the window's window stream, is replicated to the window's echo
434  * stream. This also goes for the style commands such as glk_set_style().
435  * 
436  * Note that the echoing is one-way. You can still print text directly to the
437  * echo stream, and it will go wherever the stream is bound, but it does not
438  * back up and appear in the window. 
439  *
440  * An echo stream can be of any type, even another window's window stream.
441  * 
442  * <note><para>
443  *   This would be somewhat silly, since it would mean that any text printed to
444  *   the window would be duplicated in another window. More commonly, you would
445  *   set a window's echo stream to be a file stream, in order to create a
446  *   transcript file from that window.
447  * </para></note>
448  *
449  * A window can only have one echo stream. But a single stream can be the echo
450  * stream of any number of windows, sequentially or simultaneously.
451  *
452  * If a window is closed, its echo stream remains open; it is not automatically
453  * closed. 
454  *
455  * <note><para>
456  *   Do not confuse the window's window stream with its echo stream. The window
457  *   stream is <quote>owned</quote> by the window, and dies with it. The echo
458  *   stream is merely temporarily associated with the window.
459  * </para></note>
460  * 
461  * If a stream is closed, and it is the echo stream of one or more windows,
462  * those windows are reset to not echo anymore. (So then calling
463  * glk_window_get_echo_stream() on them will return %NULL.) 
464  */
465
466 /**
467  * SECTION:glk-window-other
468  * @short_description: Miscellaneous functions for windows
469  * @include: libchimara/glk.h
470  *
471  * This section contains functions for windows that don't fit anywhere else.
472  */
473
474 /**
475  * SECTION:glk-events
476  * @short_description: Waiting for events
477  * @include: libchimara/glk.h
478  *
479  * As described in <link linkend="chimara-Your-Programs-Main-Function">Your
480  * Program's Main Function</link>, all player input is handed to your program by
481  * the glk_select() call, in the form of events. You should write at least one
482  * event loop to retrieve these events.
483  */
484
485 /**
486  * SECTION:glk-character-input-events
487  * @short_description: Events representing a single keystroke
488  * @include: libchimara/glk.h
489  *
490  * You can request character input from text buffer and text grid windows. See 
491  * %evtype_CharInput. There are separate functions for requesting Latin-1 input
492  * and Unicode input; see %gestalt_Unicode.
493  */
494
495 /**
496  * SECTION:glk-line-input-events
497  * @short_description: Events representing a line of user input
498  * @include: libchimara/glk.h
499  *
500  * You can request line input from text buffer and text grid windows. See
501  * %evtype_LineInput. There are separate functions for requesting Latin-1 input
502  * and Unicode input; see %gestalt_Unicode.
503  */
504
505 /**
506  * SECTION:glk-mouse-events
507  * @short_description: Events representing a mouse click
508  * @include: libchimara/glk.h
509  *
510  * On some platforms, Glk can recognize when the mouse (or other pointer) is 
511  * used to select a spot in a window. You can request mouse input only in text 
512  * grid windows and graphics windows.
513  * 
514  * A window can have mouse input and character/line input pending at the same
515  * time.
516  * 
517  * If the player clicks in a window which has a mouse input event pending,
518  * glk_select() will return an event whose type is %evtype_MouseInput. Again,
519  * once this happens, the request is complete, and you must request another if
520  * you want further mouse input.
521  * 
522  * In the event structure, @win tells what window the event came from.
523  * 
524  * In a text grid window, the @val1 and @val2 fields are the x and y coordinates
525  * of the character that was clicked on. 
526  * <note><para>So @val1 is the column, and @val2 is the row.</para></note>
527  * The top leftmost character is considered to be (0,0).
528  * 
529  * In a graphics window, they are the x and y coordinates of the pixel that was
530  * clicked on. Again, the top left corner of the window is (0,0).
531  * 
532  * <note><para>
533  *   Most mouse-based idioms define standard functions for mouse hits in text
534  *   windows &mdash; typically selecting or copying text. It is up to the
535  *   library to separate this from Glk mouse input. The library may choose to
536  *   select text when it is clicked normally, and cause Glk mouse events when
537  *   text is control-clicked. Or the other way around. Or it may be the
538  *   difference between clicking and double-clicking. Or the library may
539  *   reserve a particular mouse button, on a multi-button mouse. It may even
540  *   specify a keyboard key to be the "mouse button", referring to wherever the
541  *   mouse cursor is when the key is hit. Or some even more esoteric positioning
542  *   system. You need only know that the user can do it, or not.
543  * </para></note> 
544  * <note><para>
545  *   However, since different platforms will handle this issue differently, you
546  *   should be careful how you instruct the player in your program. Do not tell
547  *   the player to <quote>double-click</quote>, <quote>right-click</quote>, or
548  *   <quote>control-click</quote> in a window. The preferred term is <quote>to
549  *   touch the window</quote>, or a spot in the window.
550  * </para></note>
551  * <note><para>
552  *   Goofy, but preferred.
553  * </para></note>
554  */
555
556 /**
557  * SECTION:glk-timer-events
558  * @short_description: Events sent at fixed intervals
559  * @include: libchimara/glk.h
560  *
561  * You can request that an event be sent at fixed intervals, regardless of what
562  * the player does. Unlike input events, timer events can be tested for with
563  * glk_select_poll() as well as glk_select().
564  *
565  * It is possible that the library does not support timer events. You can check
566  * this with the %gestalt_Timer selector.
567  */
568  
569 /**
570  * SECTION:glk-streams
571  * @short_description: Input and output abstractions
572  * @include: libchimara/glk.h
573  *
574  * All character output in Glk is done through streams. Every window has an
575  * output stream associated with it. You can also write to files on disk; every
576  * open file is represented by an output stream as well.
577  *
578  * There are also input streams; these are used for reading from files on disk.
579  * It is possible for a stream to be both an input and an output stream. 
580  *
581  * <note><para>
582  *   Player input is done through line and character input events, not streams.
583  *   This is a small inelegance in theory. In practice, player input is slow and
584  *   things can interrupt it, whereas file input is immediate. If a network
585  *   extension to Glk were proposed, it would probably use events and not
586  *   streams, since network communication is not immediate.
587  * </para></note>
588  *
589  * It is also possible to create a stream that reads or writes to a buffer in
590  * memory.
591  * 
592  * Finally, there may be platform-specific types of streams, which are created
593  * before your program starts running. 
594  *
595  * <note><para>
596  *   For example, a program running under Unix may have access to standard input
597  *   as a stream, even though there is no Glk call to explicitly open standard
598  *   input. On the Mac, data in a Mac resource may be available through a
599  *   resource-reading stream.
600  * </para></note>
601  *
602  * You do not need to worry about the origin of such streams; just read or write
603  * them as usual. For information about how platform-specific streams come to
604  * be, see <link linkend="chimara-Startup-Options">Startup Options</link>.
605  * 
606  * A stream is opened with a particular file mode, see the 
607  * <code>filemode_</code> constants below.
608  *
609  * For information on opening streams, see the discussion of each specific type
610  * of stream in <link linkend="chimara-The-Types-of-Streams">The Types of
611  * Streams</link>. Remember that it is always possible that opening a stream
612  * will fail, in which case the creation function will return %NULL.
613  * 
614  * Each stream remembers two character counts, the number of characters printed
615  * to and read from that stream. The write-count is exactly one per 
616  * glk_put_char() call; it is figured before any platform-dependent character
617  * cookery. 
618  *
619  * <note><para>
620  *   For example, if a newline character is converted to 
621  *   linefeed-plus-carriage-return, the stream's count still only goes up by
622  *   one; similarly if an accented character is displayed as two characters.
623  * </para></note>
624  * 
625  * The read-count is exactly one per glk_get_char_stream() call, as long as the
626  * call returns an actual character (as opposed to an end-of-file token.) 
627  *
628  * Glk has a notion of the <quote>current (output) stream</quote>. If you print
629  * text without specifying a stream, it goes to the current output stream. The
630  * current output stream may be %NULL, meaning that there isn't one. It is
631  * illegal to print text to stream %NULL, or to print to the current stream when
632  * there isn't one.
633  *
634  * If the stream which is the current stream is closed, the current stream
635  * becomes %NULL. 
636  */
637  
638 /**
639  * SECTION:glk-print
640  * @short_description: Printing to streams
641  * @include: libchimara/glk.h
642  *
643  * You can print Latin-1 and Unicode characters, null-terminated strings, or
644  * buffers to any stream. The characters will be converted into the appropriate
645  * format for that stream.
646  */
647  
648 /**
649  * SECTION:glk-read
650  * @short_description: Reading from streams
651  * @include: libchimara/glk.h
652  *
653  * You can read Latin-1 or Unicode characters, buffers, or whole lines from any
654  * stream. The characters will be converted into the form in which you request
655  * them.
656  */
657  
658 /**
659  * SECTION:glk-closing-streams
660  * @short_description: Closing streams and retrieving their character counts
661  * @include: libchimara/glk.h
662  *
663  * When you close a Glk stream, you have the opportunity to examine the
664  * character counts &mdash; the number of characters written to or read from the
665  * stream.
666  */
667
668 /**
669  * SECTION:glk-stream-positions
670  * @short_description: Moving the read/write mark
671  * @include: libchimara/glk.h
672  *
673  * You can set the position of the read/write mark in a stream.
674  *
675  * <note><para>
676  *   Which makes one wonder why they're called <quote>streams</quote> in the
677  *   first place. Oh well.
678  * </para></note>
679  */
680
681 /**
682  * SECTION:glk-styles
683  * @short_description: Changing the appearance of printed text
684  * @include: libchimara/glk.h
685  *
686  * You can send style-changing commands to an output stream. After a style
687  * change, new text which is printed to that stream will be given the new style,
688  * whatever that means for the stream in question. For a window stream, the text
689  * will appear in that style. For a memory stream, style changes have no effect.
690  * For a file stream, if the machine supports styled text files, the styles may
691  * be written to the file; more likely the style changes will have no effect.
692  * 
693  * Styles are exclusive. A character is shown with exactly one style, not a 
694  * subset of the possible styles.
695  *
696  * <note><para>
697  *  Note that every stream and window has its own idea of the <quote>current 
698  *  style.</quote> Sending a style command to one window or stream does not
699  *  affect any others.
700  * </para></note>
701  * <note><para>
702  *  Except for a window's echo stream; see <link 
703  *  linkend="chimara-Echo-Streams">Echo Streams</link>.
704  * </para></note>
705  * 
706  * The styles are intended to distinguish meaning and use, not formatting. There
707  * is no standard definition of what each style will look like. That is left up
708  * to the Glk library, which will choose an appearance appropriate for the
709  * platform's interface and the player's preferences.
710  * 
711  * There are currently eleven styles defined. More may be defined in the future.
712  * 
713  * Styles may be distinguished on screen by font, size, color, indentation,
714  * justification, and other attributes. Note that some attributes (notably
715  * justification and indentation) apply to entire paragraphs. If possible and
716  * relevant, you should apply a style to an entire paragraph &mdash; call 
717  * glk_set_style() immediately after printing the newline at the beginning of
718  * the text, and do the same at the end.
719  * 
720  * <note><para>
721  *  For example, %style_Header may well be centered text. If you print 
722  *  <quote>Welcome to Victim (a short interactive mystery)</quote>, and only the
723  *  word <quote>Victim</quote> is in the %style_Header, the center-justification
724  *  attribute will be lost. Similarly, a block quote is usually indented on both
725  *  sides, but indentation is only meaningful when applied to an entire line or
726  *  paragraph, so block quotes should take up an entire paragraph. Contrariwise,
727  *  %style_Emphasized need not be used on an entire paragraph. It is often used
728  *  for single emphasized words in normal text, so you can expect that it will
729  *  appear properly that way; it will be displayed in italics or underlining, 
730  *  not center-justified or indented.
731  * </para></note> 
732  * 
733  * <note><para>
734  *  Yes, this is all a matter of mutual agreement between game authors and game
735  *  players. It's not fixed by this specification. That's natural language for
736  *  you.
737  * </para></note>
738  */
739
740 /**
741  * SECTION:glk-stylehints
742  * @short_description: Setting style hints
743  * @include: libchimara/glk.h
744  *
745  * There are no guarantees of how styles will look, but you can make 
746  * suggestions.
747  *
748  * Initially, no hints are set for any window type or style. Note that having no
749  * hint set is not the same as setting a hint with value 0.
750  * 
751  * These functions do <emphasis>not</emphasis> affect 
752  * <emphasis>existing</emphasis> windows. They affect the windows which you
753  * create subsequently. If you want to set hints for all your game windows, call
754  * glk_stylehint_set() before you start creating windows. If you want different
755  * hints for different windows, change the hints before creating each window.
756  * 
757  * <note><para>
758  *  This policy makes life easier for the interpreter. It knows everything about
759  *  a particular window's appearance when the window is created, and it doesn't
760  *  have to change it while the window exists.
761  * </para></note>
762  * 
763  * Hints are hints. The interpreter may ignore them, or give the player a choice
764  * about whether to accept them. Also, it is never necessary to set hints. You
765  * don't have to suggest that %style_Preformatted be fixed-width, or 
766  * %style_Emphasized be boldface or italic; they will have appropriate defaults.
767  * Hints are for situations when you want to <emphasis>change</emphasis> the 
768  * appearance of a style from what it would ordinarily be. The most common case
769  * when this is appropriate is for the styles %style_User1 and %style_User2.
770  * 
771  * There are currently ten style hints defined. More may be defined in the 
772  * future. 
773  * 
774  * Again, when passing a style hint to a Glk function, any value is actually 
775  * legal. If the interpreter does not recognize the stylehint value, it will 
776  * ignore it. 
777  * <note><para>
778  *  This policy allows for the future definition of style hints without breaking
779  *  old Glk libraries.
780  * </para></note> 
781  */
782
783 /**
784  * SECTION:glk-style-measure
785  * @short_description: Finding out how the library displays your style hints
786  * @include: libchimara/glk.h
787  *
788  * You can suggest the appearance of a window's style before the window is
789  * created; after the window is created, you can test the style's actual
790  * appearance. These functions do not test the style hints; they test the
791  * attribute of the style as it appears to the player.
792  *
793  * Note that although you cannot change the appearance of a window's styles
794  * after the window is created, the library can. A platform may support dynamic
795  * preferences, which allow the player to change text formatting while your
796  * program is running.
797  * <note><para>
798  *   Changes that affect window size (such as font size changes) will be
799  *   signalled by an %evtype_Arrange event. However, more subtle changes (such
800  *   as text color differences) are not signalled. If you test the appearance of
801  *   styles at the beginning of your program, you must keep in mind the
802  *   possibility that the player will change them later.
803  * </para></note>
804  */
805
806 /**
807  * SECTION:glk-stream-types
808  * @short_description: Window, memory, and file streams
809  * @include: libchimara/glk.h
810  *
811  * <refsect2 id="chimara-Window-Streams"><title>Window Streams</title>
812  * <para>
813  * Every window has an output stream associated with it. This is created
814  * automatically, with %filemode_Write, when you open the window. You get it
815  * with glk_window_get_stream(). Window streams always have rock value 0.
816  * 
817  * A window stream cannot be closed with glk_stream_close(). It is closed
818  * automatically when you close its window with glk_window_close().
819  * 
820  * Only printable characters (including newline) may be printed to a window
821  * stream. See <link linkend="chimara-Character-Encoding">Character 
822  * Encoding</link>.
823  * </para>
824  * </refsect2>
825  * <refsect2 id="chimara-Memory-Streams"><title>Memory Streams</title>
826  * <para>
827  * You can open a stream which reads from or writes to a space in memory. See
828  * glk_stream_open_memory() and glk_stream_open_memory_uni(). When opening a
829  * memory stream, you specify a buffer to which the stream's output will be
830  * written, and its length @buflen.
831  *
832  * When outputting, if more than @buflen characters are written to the stream,
833  * all of them beyond the buffer length will be thrown away, so as not to
834  * overwrite the buffer. (The character count of the stream will still be
835  * maintained correctly. That is, it will count the number of characters written
836  * into the stream, not the number that fit into the buffer.)
837  *
838  * If the buffer is %NULL, or for that matter if @buflen is zero, then 
839  * <emphasis>everything</emphasis> written to the stream is thrown away. This
840  * may be useful if you are interested in the character count.
841  *
842  * When inputting, if more than @buflen characters are read from the stream, the
843  * stream will start returning -1 (signalling end-of-file.) If the buffer is 
844  * %NULL, the stream will always return end-of-file.
845  *
846  * The data is written to the buffer exactly as it was passed to the printing
847  * functions (glk_put_char(), etc.); input functions will read the data exactly
848  * as it exists in memory. No platform-dependent cookery will be done on it.
849  *
850  * <note><para>
851  *   You can write a disk file in text mode, but a memory stream is effectively
852  *   always in binary mode.
853  * </para></note>
854  * 
855  * Whether reading or writing, the contents of the buffer are undefined until
856  * the stream is closed. The library may store the data there as it is written,
857  * or deposit it all in a lump when the stream is closed. It is illegal to
858  * change the contents of the buffer while the stream is open.
859  * </para>
860  * </refsect2>
861  * <refsect2 id="chimara-File-Streams"><title>File Streams</title>
862  * <para>
863  * You can open a stream which reads from or writes to a disk file. See 
864  * glk_stream_open_file() and glk_stream_open_file_uni().
865  *
866  * The file may be written in text or binary mode; this is determined by the
867  * file reference you open the stream with. Similarly, platform-dependent
868  * attributes such as file type are determined by the file reference. See <link
869  * linkend="chimara-File-References">File References</link>.
870  * </para>
871  * </refsect2>
872  */
873  
874 /**
875  * SECTION:glk-stream-other
876  * @short_description: Miscellaneous functions for streams
877  * @include: libchimara/glk.h
878  *
879  * This section includes functions for streams that don't fit anywhere else.
880  */
881
882 /**
883  * SECTION:glk-fileref
884  * @short_description: A platform-independent way to refer to disk files
885  * @include: libchimara/glk.h
886  *
887  * You deal with disk files using file references. Each fileref is an opaque C
888  * structure pointer; see <link linkend="chimara-Opaque-Objects">Opaque 
889  * Objects</link>.
890  * 
891  * A file reference contains platform-specific information about the name and
892  * location of the file, and possibly its type, if the platform has a notion of
893  * file type. It also includes a flag indication whether the file is a text file
894  * or binary file. 
895  *
896  * <note><para>
897  *   Note that this is different from the standard C I/O library, in which you
898  *   specify text or binary mode when the file is opened.
899  * </para></note>
900  * 
901  * A fileref does not have to refer to a file which actually exists. You can
902  * create a fileref for a nonexistent file, and then open it in write mode to
903  * create a new file.
904  * 
905  * You always provide a usage argument when you create a fileref. The usage
906  * indicates the file type and the mode (text or binary.) It must be the
907  * logical-or of a file-type constant and a mode constant. These values are used
908  * when you create a new file, and also to filter file lists when the player is
909  * selecting a file to load.
910  * 
911  * In general, you should use text mode if the player expects to read the file
912  * with a platform-native text editor; you should use binary mode if the file is
913  * to be read back by your program, or if the data must be stored exactly. Text
914  * mode is appropriate for %fileusage_Transcript; binary mode is appropriate for
915  * %fileusage_SavedGame and probably for %fileusage_InputRecord. %fileusage_Data
916  * files may be text or binary, depending on what you use them for. 
917  */
918  
919 /**
920  * SECTION:glk-fileref-types
921  * @short_description: Four different ways to create a file reference
922  * @include: libchimara/glk.h
923  *
924  * There are four different functions for creating a fileref, depending on how
925  * you wish to specify it. Remember that it is always possible that a fileref
926  * creation will fail and return %NULL.
927  */
928  
929 /**
930  * SECTION:glk-fileref-other
931  * @short_description: Miscellaneous functions for file references
932  * @include: libchimara/glk.h
933  *
934  * This section includes functions for file references that don't fit anywhere
935  * else.
936  */
937
938 /**
939  * SECTION:glk-image-resources
940  * @short_description: Graphics in Glk
941  * @include: libchimara/glk.h
942  *
943  * In accordance with this modern age, Glk provides for a modicum of graphical
944  * flair. It does not attempt to be a complete graphical toolkit. Those already
945  * exist. Glk strikes the usual uncomfortable balance between power, 
946  * portability, and ease of implementation: commands for arranging pre-supplied
947  * images on the screen and intermixed with text.
948  * 
949  * Graphics is an optional capability in Glk; not all libraries support 
950  * graphics. This should not be a surprise.
951  * 
952  * Most of the graphics commands in Glk deal with image resources. Your program
953  * does not have to worry about how images are stored. Everything is a resource,
954  * and a resource is referred to by an integer identifier. You may, for example,
955  * call a function to display image number 17. The format, loading, and 
956  * displaying of that image is entirely up to the Glk library for the platform
957  * in question.
958  * 
959  * Of course, it is also desirable to have a platform-independent way to store
960  * sounds and images. Blorb is the official resource-storage format of Glk. A
961  * Glk library does not have to understand Blorb, but it is more likely to
962  * understand Blorb than any other format.
963  *
964  * <note><para>
965  *   Glk does not specify the exact format of images, but Blorb does. Images in 
966  *   a Blorb archive must be PNG or JPEG files. More formats may be added if 
967  *   real-world experience shows it to be desirable. However, that is in the 
968  *   domain of the Blorb specification. The Glk spec, and Glk programming, will
969  *   not change.
970  * </para></note>
971  * 
972  * At present, images can only be drawn in graphics windows and text buffer 
973  * windows. In fact, a library may not implement both of these possibilities.
974  * You should test each with the %gestalt_DrawImage selector if you plan to use
975  * it. See <link linkend="chimara-Testing-for-Graphics-Capabilities">Testing for
976  * Graphics Capabilities</link>. 
977  */
978
979 /**
980  * SECTION:glk-graphics-windows
981  * @short_description: Drawing graphics in graphics windows
982  * @include: libchimara/glk.h
983  *
984  * A graphics window is a rectangular canvas of pixels, upon which you can draw
985  * images. The contents are entirely under your control. You can draw as many
986  * images as you like, at any positions &mdash; overlapping if you like. If the
987  * window is resized, you are responsible for redrawing everything. See <link
988  * linkend="wintype-Graphics">Graphics Windows</link>.
989  * 
990  * <note><para>
991  *   Note that graphics windows do not support a full set of object-drawing 
992  *   commands, nor can you draw text in them. That may be available in a future 
993  *   Glk extension. For now, it seems reasonable to limit the task to a single 
994  *   primitive, the drawing of a raster image. And then there's the ability to
995  *   fill a rectangle with a solid color &mdash; a small extension, and 
996  *   hopefully no additional work for the library, since it can already clear 
997  *   with arbitrary background colors. In fact, if glk_window_fill_rect() did 
998  *   not exist, an author could invent it &mdash; by briefly setting the
999  *   background color, erasing a rectangle, and restoring.
1000  * </para></note>
1001  * 
1002  * If you call glk_image_draw() or glk_image_draw_scaled() in a graphics window,
1003  * @val1 and @val2 are interpreted as X and Y coordinates. The image will be 
1004  * drawn with its upper left corner at this position.
1005  * 
1006  * It is legitimate for part of the image to fall outside the window; the excess
1007  * is not drawn. Note that these are signed arguments, so you can draw an image
1008  * which falls outside the left or top edge of the window, as well as the right
1009  * or bottom.
1010  * 
1011  * There are a few other commands which apply to graphics windows.
1012  */
1013
1014 /**
1015  * SECTION:glk-graphics-text
1016  * @short_description: Drawing graphics inside or beside text
1017  * @include: libchimara/glk.h
1018  *
1019  * A text buffer is a linear text stream. You can draw images in-line with this
1020  * text. If you are familiar with HTML, you already understand this model. You
1021  * draw images with flags indicating alignment. The library takes care of
1022  * scrolling, resizing, and reformatting text buffer windows.
1023  *
1024  * If you call glk_image_draw() or glk_image_draw_scaled() in a text buffer
1025  * window, @val1 gives the image alignment. The @val2 argument is currently
1026  * unused, and should always be zero.
1027  *
1028  * The two <quote>margin</quote> alignments require some care. To allow proper 
1029  * positioning, images using %imagealign_MarginLeft and %imagealign_MarginRight 
1030  * must be placed at the beginning of a line. That is, you may only call 
1031  * glk_image_draw() (with these two alignments) in a window, if you have just 
1032  * printed a newline to the window's stream, or if the window is entirely empty.
1033  * If you margin-align an image in a line where text has already appeared, no 
1034  * image will appear at all.
1035  * 
1036  * Inline-aligned images count as <quote>text</quote> for the purpose of this 
1037  * rule.
1038  * 
1039  * You may have images in both margins at the same time.
1040  * 
1041  * It is also legal to have more than one image in the same margin (left or 
1042  * right.) However, this is not recommended. It is difficult to predict how text
1043  * will wrap in that situation, and libraries may err on the side of 
1044  * conservatism. 
1045  */
1046
1047 /**
1048  * SECTION:glk-graphics-testing
1049  * @short_description: Checking whether the library supports graphics
1050  * @include: libchimara/glk.h
1051  *
1052  * Before calling Glk graphics functions, you should use the gestalt selector
1053  * %gestalt_Graphics. To test for additional capabilities, you can also use the
1054  * %gestalt_DrawImage and %gestalt_GraphicsTransparency selectors.
1055  */
1056
1057 /**
1058  * SECTION:glk-sound-channels
1059  * @short_description: Creating new sound channels and closing them
1060  * @include: libchimara/glk.h
1061  *
1062  * Sounds in Glk are played through sound channels. Sound channels are another
1063  * type of opaque object, like windows, streams, and file references.
1064  */
1065
1066 /**
1067  * SECTION:glk-playing-sounds
1068  * @short_description: Producing noise
1069  * @include: libchimara/glk.h
1070  *
1071  * These functions play the actual sounds through the sound channels.
1072  */
1073
1074 /**
1075  * SECTION:glk-sound-other
1076  * @short_description: Miscellaneous functions for sound channels
1077  * @include: libchimara/glk.h
1078  *
1079  * This section includes functions for sound channels that don't fit anywhere
1080  * else.
1081  */
1082
1083 /**
1084  * SECTION:glk-sound-testing
1085  * @short_description: Checking whether the library supports sound
1086  * @include: libchimara/glk.h
1087  *
1088  * Before calling Glk sound functions, you should use the %gestalt_Sound
1089  * selector. To test for additional capabilities, you can use the 
1090  * %gestalt_SoundMusic, %gestalt_SoundVolume, and %gestalt_SoundNotify 
1091  * selectors.
1092  */
1093
1094 /**
1095  * SECTION:glk-creating-hyperlinks
1096  * @short_description: Printing text as a hyperlink
1097  * @include: libchimara/glk.h
1098  *
1099  * Some games may wish to mark up text in their windows with hyperlinks, which
1100  * can be selected by the player &mdash; most likely by mouse click. Glk allows
1101  * this in a manner similar to the way text styles are set.
1102  *
1103  * Hyperlinks are an optional capability in Glk.
1104  */
1105
1106 /**
1107  * SECTION:glk-accepting-hyperlinks
1108  * @short_description: Generating and catching hyperlink navigation events
1109  * @include: libchimara/glk.h
1110  *
1111  * When you request a hyperlink event in a window, you will receive a hyperlink
1112  * event when the player clicks on a hyperlink.
1113  */
1114
1115 /**
1116  * SECTION:glk-hyperlinks-testing
1117  * @short_description: Checking whether the library supports hyperlinks
1118  * @include: libchimara/glk.h
1119  *
1120  * Before calling Glk hyperlink functions, you should use the gestalt selectors
1121  * %gestalt_Hyperlinks and %gestalt_HyperlinkInput.
1122  */
1123
1124 /**
1125  * SECTION:glk-clock
1126  * @short_description: Getting the current time from the system clock
1127  * @include: libchimara/glk.h
1128  *
1129  * You can get the current time, either as a Unix timestamp (seconds since 1970)
1130  * or as a broken-out structure of time elements (year, month, day, hour,
1131  * minute, second).
1132  *
1133  * The system clock is not guaranteed to line up with timer events (see <link 
1134  * linkend="chimara-Timer-Events">Timer Events</link>). Timer events may be
1135  * delivered late according to the system clock.
1136  */
1137
1138 /**
1139  * SECTION:glk-clock-conversions
1140  * @short_description: Converting from timestamps to date structures and back
1141  * @include: libchimara/glk.h
1142  *
1143  * This section describes functions for converting timestamps to more
1144  * human-readable date structures and back.
1145  */
1146
1147 /**
1148  * SECTION:glk-clock-testing
1149  * @short_description: Checking whether the library supports the clock functions
1150  * @include: libchimara/glk.h
1151  *
1152  * Before calling Glk date and time functions, you should use the following
1153  * gestalt selector.
1154  */
1155  
1156 /**
1157  * SECTION:dispatch-interrogating
1158  * @short_description: Finding out what functions the Glk library exports
1159  * @include: libchimara/glk.h, libchimara/gi_dispa.h
1160  *
1161  * These are the ancilliary functions that let you enumerate.
1162  */
1163  
1164 /**
1165  * SECTION:dispatch-dispatching
1166  * @short_description: Dispatching the call to the Glk library
1167  * @include: libchimara/glk.h, libchimara/gi_dispa.h
1168  *
1169  * The function gidispatch_call() invokes a function from the Glk library.
1170  */
1171  
1172 /**
1173  * SECTION:dispatch-prototypes
1174  * @short_description: Querying Glk function prototypes
1175  * @include: libchimara/glk.h, libchimara/gi_dispa.h
1176  *
1177  * There are many possible ways to set up a #gluniversal_t array, and it's
1178  * illegal to call gidispatch_call() with an array which doesn't match the
1179  * function. Furthermore, some references are passed in, some passed out, and
1180  * some both. How do you know how to handle the argument list?
1181  * 
1182  * One possibility is to recognize each function selector, and set up the
1183  * arguments appropriately. However, this entails writing special code for each
1184  * Glk function; which is exactly what we don't want to do.
1185  * 
1186  * Instead, you can call gidispatch_prototype(). 
1187  */
1188
1189 /**
1190  * SECTION:dispatch-library-functions
1191  * @short_description: Platform-dependent dispatch layer functions
1192  * @include: libchimara/glk.h, libchimara/gi_dispa.h
1193  *
1194  * Ideally, the three layers &mdash; program, dispatch layer, Glk library
1195  * &mdash; would be completely modular; each would refer only to the layers
1196  * beneath it. Sadly, there are a few places where the library must notify the
1197  * program that something has happened. Worse, these situations are only
1198  * relevant to programs which use the dispatch layer, and then only some of
1199  * those.
1200  * 
1201  * Since C is uncomfortable with the concept of calling functions which may not
1202  * exist, Glk handles this with call-back function pointers. The program can
1203  * pass callbacks in to the library; if it does, the library will call them, and
1204  * if not, the library doesn't try.
1205  * 
1206  * These callbacks are optional, in the sense that the program may or may not
1207  * set them. However, any library which wants to interoperate with the dispatch
1208  * layer must <emphasis>allow</emphasis> the program to set them; it is the
1209  * program's choice. The library does this by implementing
1210  * <code>set_registry functions</code> &mdash; the functions to which the
1211  * program passes its callbacks.
1212  * 
1213  * <note><para>
1214  *   Even though these callbacks and the functions to set them are declared in
1215  *   <filename class="headerfile">gi_dispa.h</filename>, they are not defined in
1216  *   <filename>gi_dispa.c</filename>. The dispatch layer merely coordinates
1217  *   them. The program defines the callback functions; the library calls them.
1218  * </para></note>
1219  */
1220
1221 /** 
1222  * SECTION:blorb-program
1223  * @short_description: How to use the Blorb layer in your program
1224  * @include: libchimara/glk.h, libchimara/gi_blorb.h
1225  *
1226  * If you wish your program to load its resources from a Blorb file, you need to
1227  * find and open that file in your startup code. (See <link 
1228  * linkend="chimara-Startup-Options">Startup Options</link>.) Each platform will
1229  * have appropriate functions available for finding startup data. Be sure to
1230  * open the file in binary mode, not text mode. Once you have opened the file as
1231  * a Glk stream, pass it to giblorb_set_resource_map().
1232  *
1233  * If you do not call giblorb_set_resource_map() in your startup code, or if it
1234  * fails, the library is left to its own devices for finding resources. Some
1235  * libraries may try to load resources from individual files &mdash; 
1236  * <filename>PIC1</filename>, <filename>PIC2</filename>, 
1237  * <filename>PIC3</filename>, and so on. (See the Blorb specification for more 
1238  * on this approach.) Other libraries will not have any other loading mechanism
1239  * at all; no resources will be available. 
1240  */
1241
1242 /**
1243  * SECTION:blorb-layer
1244  * @short_description: The platform-independent functions in the Blorb layer
1245  * @include: libchimara/glk.h, libchimara/gi_blorb.h
1246  *
1247  * These are the functions which are implemented in 
1248  * <filename>gi_blorb.c</filename>. They will be compiled into the library, but
1249  * they are the same on every platform. In general, only the library needs to
1250  * call these functions. The Glk program should allow the library to do all the
1251  * resource handling.
1252  */ 
1253  
1254 /** 
1255  * SECTION:blorb-errors
1256  * @short_description: Error codes returned by the Blorb layer functions
1257  * @include: libchimara/glk.h, libchimara/gi_blorb.h
1258  *
1259  * All Blorb layer functions, including giblorb_set_resource_map(), return the
1260  * following error codes.
1261  */
1262
1263 /**
1264  * SECTION:glkext-startup
1265  * @short_description: Parsing startup options
1266  * @include: libchimara/glk.h, libchimara/glkstart.h
1267  *
1268  * This section describes an extension to Glk for parsing command-line startup
1269  * options. It was written by Andrew Plotkin for the Glk libraries CheapGlk and
1270  * GlkTerm. 
1271  *
1272  * When you compile a Glk program, you may define a function called 
1273  * <function>glkunix_startup_code&lpar;&rpar;</function>, and an array 
1274  * <code>glkunix_arguments[]</code>. These set up various Unix-specific options
1275  * used by the Glk library. There is a sample 
1276  * <quote><filename>glkstart.c</filename></quote> file included in this package;
1277  * you should modify it to your needs.
1278  * 
1279  * |[ extern glkunix_argumentlist_t glkunix_arguments[]; ]|
1280  *  
1281  * The <code>glkunix_arguments[]</code> array is a list of command-line 
1282  * arguments that your program can accept. The library will sort these out of 
1283  * the command line and pass them on to your code.
1284  */
1285
1286 /**
1287  * SECTION:glkext-unix
1288  * @short_description: Unix-specific functions
1289  * @include: libchimara/glk.h, libchimara/glkstart.h
1290  *
1291  * This section describes an extension to Glk for various Unix functions. It was
1292  * written by Andrew Plotkin for the Glk libraries CheapGlk and GlkTerm.
1293  *
1294  * You can put other startup code in glkunix_startup_code(). This should
1295  * generally be limited to finding and opening data files. There are a few Unix
1296  * Glk library functions which are convenient for this purpose.
1297  */
1298
1299 /**
1300  * SECTION:glkext-garglk
1301  * @short_description: Gargoyle extensions to Glk
1302  * @include: libchimara/glk.h, libchimara/garglk.h
1303  *
1304  * This section describes various extensions to Glk that were written for the
1305  * popular interpreter <ulink 
1306  * url="http://www.ccxvii.net/gargoyle/">Gargoyle</ulink> by Tor Andersson (now 
1307  * maintained by Ben Cressey).
1308  *
1309  * These functions mostly serve to close the gap between Glk's input/output
1310  * capabilities and what some interpreters expect. For example, 
1311  * garglk_set_zcolors() displays the colors defined in the Z-machine standard,
1312  * and garglk_set_story_name() can be used to give the host program a hint
1313  * about what to display in the title bar of its window.
1314  */ 
1315  
1316 /*---------------- TYPES AND CONSTANTS FROM GLK.H ----------------------------*/
1317
1318 /**
1319  * glui32:
1320  *
1321  * A 32-bit unsigned integer type, used wherever possible in Glk.
1322  */
1323  
1324 /**
1325  * glsi32:
1326  *
1327  * A 32-bit signed integer type, rarely used.
1328  */
1329
1330 /**
1331  * GLK_MODULE_UNICODE:
1332  *
1333  * If this preprocessor symbol is defined, so are the core Unicode functions and
1334  * constants (see %gestalt_Unicode). If not, not.
1335  */
1336
1337 /**
1338  * GLK_MODULE_IMAGE:
1339  *
1340  * If you are writing a C program, there is an additional complication. A
1341  * library which does not support graphics may not implement the graphics
1342  * functions at all. Even if you put gestalt tests around your graphics calls,
1343  * you may get link-time errors. If the <filename
1344  * class="headerfile">glk.h</filename> file is so old that it does not declare
1345  * the graphics functions and constants, you may even get compile-time errors.
1346  *
1347  * To avoid this, you can perform a preprocessor test for the existence of
1348  * %GLK_MODULE_IMAGE. If this is defined, so are all the functions and constants
1349  * described in this section. If not, not.
1350  *
1351  * <note><para>
1352  *   To be extremely specific, there are two ways this can happen. If the 
1353  *   <filename class="headerfile">glk.h</filename> file that comes with the
1354  *   library is too old to have the graphics declarations in it, it will of
1355  *   course lack %GLK_MODULE_IMAGE as well. If the <filename 
1356  *   class="headerfile">glk.h</filename> file is recent, but the library is old,
1357  *   the definition of %GLK_MODULE_IMAGE should be removed from <filename 
1358  *   class="headerfile">glk.h</filename>, to avoid link errors. This is not a
1359  *   great solution. A better one is for the library to implement the graphics
1360  *   functions as stubs that do nothing (or cause run-time errors). Since no
1361  *   program will call the stubs without testing %gestalt_Graphics, this is
1362  *   sufficient.
1363  * </para></note>
1364  */
1365
1366 /**
1367  * GLK_MODULE_SOUND:
1368  *
1369  * If you are writing a C program, there is an additional complication. A 
1370  * library which does not support sound may not implement the sound functions at
1371  * all. Even if you put gestalt tests around your sound calls, you may get 
1372  * link-time errors. If the <filename class="headerfile">glk.h</filename> file 
1373  * is so old that it does not declare the sound functions and constants, you may
1374  * even get compile-time errors.
1375  * 
1376  * To avoid this, you can perform a preprocessor test for the existence of
1377  * %GLK_MODULE_SOUND. If this is defined, so are all the functions and constants
1378  * described in this section. If not, not.
1379  */ 
1380  
1381 /**
1382  * GLK_MODULE_HYPERLINKS:
1383  * 
1384  * If you are writing a C program, you can perform a preprocessor test for the
1385  * existence of %GLK_MODULE_HYPERLINKS. If this is defined, so are all the
1386  * functions and constants described in this section. If not, not.
1387  */
1388
1389 /**
1390  * GLK_MODULE_UNICODE_NORM:
1391  *
1392  * If this preprocessor symbol is defined, so are the Unicode normalization
1393  * functions (see %gestalt_UnicodeNorm). If not, not.
1394  */
1395
1396 /**
1397  * GLK_MODULE_DATETIME:
1398  *
1399  * If you are writing a C program, you can perform a preprocessor test for the
1400  * existence of %GLK_MODULE_DATETIME. If this is defined, so are all the
1401  * functions and data types described in this section.
1402  */
1403
1404 /**
1405  * GLK_MODULE_LINE_ECHO:
1406  *
1407  * If this preprocessor symbol is defined, so is glk_set_echo_line_event(). If
1408  * not, not.
1409  */
1410
1411 /**
1412  * GLK_MODULE_LINE_TERMINATORS:
1413  *
1414  * If this preprocessor symbol is defined, so is
1415  * glk_set_terminators_line_event(). If not, not.
1416  */
1417
1418 /**
1419  * winid_t:
1420  *
1421  * Opaque structure representing a Glk window. It has no user-accessible 
1422  * members.
1423  */
1424  
1425 /**
1426  * strid_t:
1427  *
1428  * Opaque structure representing an input or output stream. It has no
1429  * user-accessible members.
1430  */
1431  
1432 /**
1433  * frefid_t:
1434  * 
1435  * Opaque structure representing a file reference. It has no user-accessible
1436  * members.
1437  */
1438
1439 /**
1440  * schanid_t:
1441  * 
1442  * Opaque structure representing a sound channel. It has no user-accessible
1443  * members.
1444  */
1445   
1446 /**
1447  * gestalt_Version:
1448  *
1449  * For an example of the gestalt mechanism, consider the selector
1450  * %gestalt_Version. If you do
1451  * |[
1452  * glui32 res;
1453  * res = glk_gestalt(gestalt_Version, 0);
1454  * ]|
1455  * <code>res</code> will be set to a 32-bit number which encodes the version of
1456  * the Glk spec which the library implements. The upper 16 bits stores the major
1457  * version number; the next 8 bits stores the minor version number; the low 8 
1458  * bits stores an even more minor version number, if any.
1459  *
1460  * <note><para>
1461  *   So the version number 78.2.11 would be encoded as 0x004E020B.
1462  * </para></note>
1463  *
1464  * The current Glk specification version is 0.7.2, so this selector will return
1465  * 0x00000702.
1466  *
1467  * |[
1468  * glui32 res;
1469  * res = glk_gestalt_ext(gestalt_Version, 0, NULL, 0);
1470  * ]|
1471  * does exactly the same thing. Note that, in either case, the second argument 
1472  * is not used; so you should always pass 0 to avoid future surprises.
1473  */
1474
1475 /**
1476  * gestalt_CharInput:
1477  *
1478  * If you set <code>ch</code> to a character code, or a special code (from
1479  * 0xFFFFFFFF down), and call
1480  * |[
1481  * glui32 res;
1482  * res = glk_gestalt(gestalt_CharInput, ch);
1483  * ]|
1484  * then <code>res</code> will be %TRUE (1) if that character can be typed by
1485  * the player in character input, and %FALSE (0) if not. See <link
1486  * linkend="chimara-Character-Input">Character Input</link>.
1487  */
1488
1489 /**
1490  * gestalt_LineInput:
1491  *
1492  * If you set <code>ch</code> to a character code, and call
1493  * |[
1494  * glui32 res;
1495  * res = glk_gestalt(gestalt_LineInput, ch);
1496  * ]|
1497  * then <code>res</code> will be %TRUE (1) if that character can be typed by the
1498  * player in line input, and %FALSE (0) if not. Note that if <code>ch</code> is 
1499  * a nonprintable Latin-1 character (0 to 31, 127 to 159), then this is 
1500  * guaranteed to return %FALSE. See <link linkend="chimara-Line-Input">Line
1501  * Input</link>.
1502  */
1503
1504 /**
1505  * gestalt_CharOutput:
1506  *
1507  * If you set <code>ch</code> to a character code (Latin-1 or higher), and call
1508  * |[
1509  * glui32 res, len;
1510  * res = glk_gestalt_ext(gestalt_CharOutput, ch, &amp;len, 1);
1511  * ]|
1512  * then <code>res</code> will be one of %gestalt_CharOutput_CannotPrint,
1513  * %gestalt_CharOutput_ExactPrint, or %gestalt_CharOutput_ApproxPrint (see 
1514  * below.)
1515  * 
1516  * In all cases, <code>len</code> (the #glui32 value pointed at by the third
1517  * argument) will be the number of actual glyphs which will be used to represent
1518  * the character. In the case of %gestalt_CharOutput_ExactPrint, this will 
1519  * always be 1; for %gestalt_CharOutput_CannotPrint, it may be 0 (nothing 
1520  * printed) or higher; for %gestalt_CharOutput_ApproxPrint, it may be 1 or 
1521  * higher. This information may be useful when printing text in a fixed-width 
1522  * font.
1523  *
1524  * <note><para>
1525  *   As described in <link linkend="chimara-Other-API-Conventions">Other API
1526  *   Conventions</link>, you may skip this information by passing %NULL as the
1527  *   third argument in glk_gestalt_ext(), or by calling glk_gestalt() instead.
1528  * </para></note>
1529  *
1530  * This selector will always return %gestalt_CharOutput_CannotPrint if 
1531  * <code>ch</code> is an unprintable eight-bit character (0 to 9, 11 to 31, 127 
1532  * to 159.)
1533  *
1534  * <note><para>
1535  *   Make sure you do not get confused by signed byte values. If you set a
1536  *   <quote><type>signed char</type></quote> variable <code>ch</code> to 0xFE,
1537  *   the small-thorn character (&thorn;), it will wind up as -2. (The same is
1538  *   true of a <quote><type>char</type></quote> variable, if your compiler
1539  *   treats <quote><type>char</type></quote> as signed!) If you then call
1540  *   |[ res = glk_gestalt(gestalt_CharOutput, ch); ]|
1541  *   then (by the definition of C/C++) <code>ch</code> will be sign-extended to
1542  *   0xFFFFFFFE, which is not a legitimate character, even in Unicode. You
1543  *   should write
1544  *   |[ res = glk_gestalt(gestalt_CharOutput, (unsigned char)ch); ]|
1545  *   instead.
1546  * </para></note>
1547  * <note><para>
1548  *   Unicode includes the concept of non-spacing or combining characters, which 
1549  *   do not represent glyphs; and double-width characters, whose glyphs take up
1550  *   two spaces in a fixed-width font. Future versions of this spec may 
1551  *   recognize these concepts by returning a <code>len</code> of 0 or 2 when
1552  *   %gestalt_CharOutput_ExactPrint is used. For the moment, we are adhering to 
1553  *   a policy of <quote>simple stuff first</quote>.
1554  * </para></note>
1555  */
1556  
1557 /**
1558  * gestalt_CharOutput_CannotPrint:
1559  *
1560  * When the %gestalt_CharOutput selector returns this for a character, the
1561  * character cannot be meaningfully printed. If you try, the player may see
1562  * nothing, or may see a placeholder.
1563  */
1564
1565 /**
1566  * gestalt_CharOutput_ApproxPrint:
1567  *
1568  * When the %gestalt_CharOutput selector returns this for a character, the 
1569  * library will print some approximation of the character. It will be more or 
1570  * less right, but it may not be precise, and it may not be distinguishable from
1571  * other, similar characters. (Examples: 
1572  * <quote><computeroutput>ae</computeroutput></quote> for the one-character
1573  * <quote>&aelig;</quote> ligature, 
1574  * <quote><computeroutput>e</computeroutput></quote> for 
1575  * <quote>&egrave;</quote>, <quote><computeroutput>|</computeroutput></quote> 
1576  * for a broken vertical bar (&brvbar;).)
1577  */
1578  
1579 /**
1580  * gestalt_CharOutput_ExactPrint:
1581  *
1582  * When the %gestalt_CharOutput selector returns this for a character, the
1583  * character will be printed exactly as defined.
1584  */
1585
1586 /**
1587  * gestalt_MouseInput:
1588  *
1589  * You can test whether mouse input is supported with the %gestalt_MouseInput 
1590  * selector.
1591  * |[ res = glk_gestalt(gestalt_MouseInput, windowtype); ]|
1592  * This will return %TRUE (1) if windows of the given type support mouse input.
1593  * If this returns %FALSE (0), it is still legal to call
1594  * glk_request_mouse_event(), but it will have no effect, and you will never get
1595  * mouse events.
1596  */ 
1597  
1598 /**
1599  * gestalt_Timer:
1600  *
1601  * You can test whether the library supports timer events:
1602  * |[ res = glk_gestalt(gestalt_Timer, 0); ]|
1603  * This returns %TRUE (1) if timer events are supported, and %FALSE (0) if they 
1604  * are not.
1605  */
1606
1607 /**
1608  * gestalt_Graphics:
1609  * 
1610  * Before calling Glk graphics functions, you should use the following gestalt
1611  * selector:
1612  * |[
1613  * glui32 res;
1614  * res = glk_gestalt(gestalt_Graphics, 0);
1615  * ]|
1616  * This returns 1 if the overall suite of graphics functions is available. This
1617  * includes glk_image_draw(), glk_image_draw_scaled(), glk_image_get_info(),
1618  * glk_window_erase_rect(), glk_window_fill_rect(),
1619  * glk_window_set_background_color(), and glk_window_flow_break(). It also
1620  * includes the capability to create graphics windows.
1621  * 
1622  * If this selector returns 0, you should not try to call these functions. They
1623  * may have no effect, or they may cause a run-time error. If you try to create
1624  * a graphics window, you will get %NULL. 
1625  */
1626
1627 /**
1628  * gestalt_DrawImage:
1629  * 
1630  * This selector returns 1 if images can be drawn in windows of the given type. 
1631  * If it returns 0, glk_image_draw() will fail and return %FALSE (0). You should 
1632  * test %wintype_Graphics and %wintype_TextBuffer separately, since libraries 
1633  * may implement both, neither, or only one.  
1634  */
1635
1636 /**
1637  * gestalt_Sound:
1638  *
1639  * You can test whether the library supports sound: 
1640  * |[
1641  * glui32 res;
1642  * res = glk_gestalt(gestalt_Sound, 0);
1643  * ]|
1644  * This returns 1 if the overall suite of sound functions is available. This 
1645  * includes glk_schannel_create(), glk_schannel_destroy(), 
1646  * glk_schannel_iterate(), glk_schannel_get_rock(), glk_schannel_play(),
1647  * glk_schannel_play_ext(), glk_schannel_stop(), glk_schannel_set_volume(), and
1648  * glk_sound_load_hint().
1649  *
1650  * If this selector returns 0, you should not try to call these functions. They 
1651  * may have no effect, or they may cause a run-time error. 
1652  */
1653
1654 /**
1655  * gestalt_SoundVolume:
1656  *
1657  * You can test whether the library supports setting the volume of sound 
1658  * channels: 
1659  * |[
1660  * glui32 res;
1661  * res = glk_gestalt(gestalt_SoundVolume, 0);
1662  * ]|
1663  * This selector returns 1 if the glk_schannel_set_volume() function works. If 
1664  * it returns zero, glk_schannel_set_volume() has no effect.     
1665  */
1666
1667 /**
1668  * gestalt_SoundNotify:
1669  *
1670  * You can test whether the library supports sound notification events:
1671  * |[
1672  * glui32 res;
1673  * res = glk_gestalt(gestalt_SoundNotify, 0);
1674  * ]| 
1675  * This selector returns 1 if the library supports sound notification events. If
1676  * it returns zero, you will never get such events. 
1677  */
1678
1679 /**
1680  * gestalt_Hyperlinks:
1681  *
1682  * You can test whether the library supports hyperlinks:
1683  * |[ 
1684  * glui32 res;
1685  * res = glk_gestalt(gestalt_Hyperlinks, 0); 
1686  * ]|
1687  * This returns 1 if the overall suite of hyperlinks functions is available.
1688  * This includes glk_set_hyperlink(), glk_set_hyperlink_stream(),
1689  * glk_request_hyperlink_event(), glk_cancel_hyperlink_event().
1690  *
1691  * If this selector returns 0, you should not try to call these functions. They
1692  * may have no effect, or they may cause a run-time error.
1693  */
1694
1695 /**
1696  * gestalt_HyperlinkInput:
1697  *
1698  * You can test whether hyperlinks are supported with the 
1699  * %gestalt_HyperlinkInput selector:
1700  * |[ res = glk_gestalt(gestalt_HyperlinkInput, windowtype); ]|
1701  * This will return %TRUE (1) if windows of the given type support hyperlinks.
1702  * If this returns %FALSE (0), it is still legal to call glk_set_hyperlink() and
1703  * glk_request_hyperlink_event(), but they will have no effect, and you will
1704  * never get hyperlink events.
1705  */
1706
1707 /** 
1708  * gestalt_SoundMusic:
1709  *
1710  * You can test whether music resources are supported:
1711  * |[ res = glk_gestalt(gestalt_SoundMusic, 0); ]|
1712  * This returns 1 if the library is capable of playing music sound resources. If 
1713  * it returns 0, only sampled sounds can be played.
1714  * <note><para>
1715  *   <quote>Music sound resources</quote> means MOD songs &mdash; the only music
1716  *   format that Blorb currently supports. The presence of this selector is, of 
1717  *   course, an ugly hack. It is a concession to the current state of the Glk 
1718  *   libraries, some of which can handle AIFF but not MOD sounds.
1719  * </para></note>
1720  */ 
1721   
1722 /**
1723  * gestalt_GraphicsTransparency:
1724  *
1725  * This returns 1 if images with alpha channels can actually be drawn with the
1726  * appropriate degree of transparency. If it returns 0, the alpha channel is
1727  * ignored; fully transparent areas will be drawn in an implementation-defined
1728  * color.
1729  * <note><para>
1730  *   The JPEG format does not support transparency or alpha channels; the PNG 
1731  *   format does.
1732  * </para></note>
1733  */
1734
1735 /**
1736  * gestalt_Unicode:
1737  *
1738  * The basic text functions will be available in every Glk library. The Unicode
1739  * functions may or may not be available. Before calling them, you should use
1740  * the %gestalt_Unicode and %gestalt_UnicodeNorm gestalt selectors.
1741  *
1742  * |[
1743  * glui32 res;
1744  * res = glk_gestalt(gestalt_Unicode, 0);
1745  * ]|
1746  * This returns 1 if the core Unicode functions are available. If it returns 0,
1747  * you should not try to call them. They may print nothing, print gibberish, or
1748  * cause a run-time error. The Unicode functions include
1749  * glk_buffer_to_lower_case_uni(), glk_buffer_to_upper_case_uni(),  
1750  * glk_buffer_to_title_case_uni(), glk_put_char_uni(), glk_put_string_uni(),
1751  * glk_put_buffer_uni(), glk_put_char_stream_uni(), glk_put_string_stream_uni(),
1752  * glk_put_buffer_stream_uni(), glk_get_char_stream_uni(),
1753  * glk_get_buffer_stream_uni(), glk_get_line_stream_uni(),
1754  * glk_request_char_event_uni(), glk_request_line_event_uni(),
1755  * glk_stream_open_file_uni(), glk_stream_open_memory_uni().
1756  * 
1757  * If you are writing a C program, there is an additional complication. A
1758  * library which does not support Unicode may not implement the Unicode
1759  * functions at all. Even if you put gestalt tests around your Unicode calls,
1760  * you may get link-time errors. If the 
1761  * <filename class="headerfile">glk.h</filename> file is so old that it does not
1762  * declare the Unicode functions and constants, you may even get compile-time
1763  * errors.
1764  * 
1765  * To avoid this, you can perform a preprocessor test for the existence of
1766  * %GLK_MODULE_UNICODE.
1767  */
1768
1769 /**
1770  * gestalt_UnicodeNorm:
1771  *
1772  * |[
1773  * glui32 res;
1774  * res = glk_gestalt(gestalt_UnicodeNorm, 0);
1775  * ]|
1776  * This code returns 1 if the Unicode normalization functions are available. If
1777  * it returns 0, you should not try to call them. The Unicode normalization
1778  * functions include glk_buffer_canon_decompose_uni() and
1779  * glk_buffer_canon_normalize_uni().
1780  *
1781  * The equivalent preprocessor test for these functions is
1782  * %GLK_MODULE_UNICODE_NORM.
1783  */
1784
1785 /**
1786  * gestalt_LineInputEcho:
1787  *
1788  * |[
1789  * res = glk_gestalt(gestalt_LineInputEcho, 0);
1790  * ]|
1791  *
1792  * This returns 1 if glk_set_echo_line_event() is supported, and 0 if it is not.
1793  * <note><para>
1794  *   Remember that if it is not supported, the behavior is always the default,
1795  *   which is line echoing <emphasis>enabled</emphasis>.
1796  * </para></note>
1797  */
1798
1799 /**
1800  * gestalt_LineTerminators:
1801  *
1802  * |[
1803  * res = glk_gestalt(gestalt_LineTerminators, 0);
1804  * ]|
1805  *
1806  * This returns 1 if glk_set_terminators_line_event() is supported, and 0 if it
1807  * is not.
1808  */
1809
1810 /**
1811  * gestalt_LineTerminatorKey:
1812  *
1813  * |[
1814  * res = glk_gestalt(gestalt_LineTerminatorKey, ch);
1815  * ]|
1816  *
1817  * This returns 1 if the keycode @ch can be passed to
1818  * glk_set_terminators_line_event(). If it returns 0, that keycode will be
1819  * ignored as a line terminator. Printable characters and %keycode_Return will
1820  * always return 0.
1821  */
1822
1823 /**
1824  * gestalt_DateTime:
1825  *
1826  * |[
1827  * res = glk_gestalt(gestalt_DateTime, 0);
1828  * ]|
1829  *
1830  * This returns 1 if the overall suite of system clock functions, as described
1831  * in this chapter, is available.
1832  *
1833  * If this selector returns 0, you should not try to call these functions. They
1834  * may have no effect, or they may cause a run-time error.
1835  *
1836  * <note><para>
1837  *   Glk timer events are covered by a different selector. See %gestalt_Timer.
1838  * </para></note>
1839  */
1840
1841 /**
1842  * evtype_None:
1843  *
1844  * No event. This is a placeholder, and glk_select() never returns it.
1845  */
1846
1847 /**
1848  * evtype_Timer:
1849  *
1850  * An event that repeats at fixed intervals. See <link 
1851  * linkend="chimara-Timer-Events">Timer Events</link>.
1852  */
1853  
1854 /**
1855  * evtype_CharInput:
1856  *
1857  * A keystroke event in a window. See <link 
1858  * linkend="chimara-Character-Input-Events">Character Input Events</link>.
1859  *
1860  * If a window has a pending request for character input, and the player hits a
1861  * key in that window, glk_select() will return an event whose type is
1862  * %evtype_CharInput. Once this happens, the request is complete; it is no 
1863  * longer pending. You must call glk_request_char_event() or
1864  * glk_request_char_event_uni() if you want another character from that window.
1865  * 
1866  * In the event structure, @win tells what window the event came from. @val1 
1867  * tells what character was entered; this will be a character code, or a special
1868  * keycode. (See <link linkend="chimara-Character-Input">Character 
1869  * Input</link>.) If you called glk_request_char_event(), @val1 will be in 
1870  * 0..255, or else a special keycode. In any case, @val2 will be 0.
1871  */
1872
1873 /**
1874  * evtype_LineInput:
1875  *
1876  * A full line of input completed in a window. See <link 
1877  * linkend="chimara-Line-Input-Events">Line Input Events</link>.
1878  *
1879  * If a window has a pending request for line input, the player can generally
1880  * hit the <keycap>enter</keycap> key (in that window) to complete line input.
1881  * The details will depend on the platform's native user interface.
1882  *
1883  * When line input is completed, glk_select() will return an event whose type is
1884  * %evtype_LineInput. Once this happens, the request is complete; it is no
1885  * longer pending. You must call glk_request_line_event() if you want another
1886  * line of text from that window.
1887  *
1888  * In the event structure, @win tells what window the event came from. @val1
1889  * tells how many characters were entered. @val2 will be 0 unless input was
1890  * ended by a special terminator key, in which case @val2 will be the keycode
1891  * (one of the values passed to glk_set_terminators_line_event()).
1892  *
1893  * The characters themselves are stored in the buffer specified in the original
1894  * glk_request_line_event() or glk_request_line_event_uni() call.
1895  *
1896  * <note><para>
1897  *   There is no null terminator or newline stored in the buffer.
1898  * </para></note>
1899  * 
1900  * It is illegal to print anything to a window which has line input pending. 
1901  *
1902  * <note><para>
1903  *   This is because the window may be displaying and editing the player's 
1904  *   input, and printing anything would make life unnecessarily complicated for
1905  *   the library.
1906  * </para></note>
1907  */
1908
1909 /**
1910  * evtype_MouseInput:
1911  *
1912  * A mouse click in a window. See <link 
1913  * linkend="chimara-Mouse-Input-Events">Mouse Input Events</link>.
1914  */
1915  
1916 /**
1917  * evtype_Arrange:
1918  *
1919  * An event signalling that the sizes of some windows have changed. 
1920  * 
1921  * Some platforms allow the player to resize the Glk window during play. This 
1922  * will naturally change the sizes of your windows. If this occurs, then
1923  * immediately after all the rearrangement, glk_select() will return an event
1924  * whose type is %evtype_Arrange. You can use this notification to redisplay the
1925  * contents of a graphics or text grid window whose size has changed.
1926  *
1927  * <note><para>
1928  *   The display of a text buffer window is entirely up to the library, so you
1929  *   don't need to worry about those.
1930  * </para></note>
1931  * 
1932  * In the event structure, @win will be %NULL if all windows are affected. If 
1933  * only some windows are affected, @win will refer to a window which contains 
1934  * all the affected windows. @val1 and @val2 will be 0.
1935  *
1936  * <note><para>
1937  *   You can always play it safe, ignore @win, and redraw every graphics and 
1938  *   text grid window.
1939  * </para></note>
1940  *
1941  * An arrangement event is guaranteed to occur whenever the player causes any
1942  * window to change size, as measured by its own metric. 
1943  *
1944  * <note><para>
1945  *   Size changes caused by you &mdash; for example, if you open, close, or 
1946  *   resize a window &mdash; do not trigger arrangement events. You must be 
1947  *   aware of the effects of your window management, and redraw the windows that
1948  *   you affect.
1949  * </para></note>
1950  * 
1951  * <note><para>
1952  *   It is possible that several different player actions can cause windows to
1953  *   change size. For example, if the player changes the screen resolution, an
1954  *   arrangement event might be triggered. This might also happen if the player
1955  *   changes his display font to a different size; the windows would then be
1956  *   different <quote>sizes</quote> in the metric of rows and columns, which is
1957  *   the important metric and the only one you have access to.
1958  * </para></note>
1959  * 
1960  * Arrangement events, like timer events, can be returned by glk_select_poll().
1961  * But this will not occur on all platforms. You must be ready to receive an
1962  * arrangement event when you call glk_select_poll(), but it is possible that it
1963  * will not arrive until the next time you call glk_select(). 
1964  *
1965  * <note><para>
1966  *   This is because on some platforms, window resizing is handled as part of
1967  *   player input; on others, it can be triggered by an external process such as 
1968  *   a window manager.
1969  * </para></note>
1970  */
1971
1972 /**
1973  * evtype_Redraw:
1974  *
1975  * An event signalling that graphics windows must be redrawn.
1976  *
1977  * On platforms that support graphics, it is possible that the contents of a
1978  * graphics window will be lost, and have to be redrawn from scratch. If this
1979  * occurs, then glk_select() will return an event whose type is %evtype_Redraw.
1980  *
1981  * In the event structure, @win will be %NULL if all windows are affected. If 
1982  * only some windows are affected, @win will refer to a window which contains 
1983  * all the affected windows. @val1 and @val2 will be 0.
1984  *
1985  * <note><para>
1986  *   You can always play it safe, ignore @win, and redraw every graphics window.
1987  * </para></note>
1988  *
1989  * Affected windows are already cleared to their background color when you 
1990  * receive the redraw event.
1991  * 
1992  * Redraw events can be returned by glk_select_poll(). But, like arrangement
1993  * events, this is platform-dependent. See %evtype_Arrange.
1994  *
1995  * For more about redraw events and how they affect graphics windows, see <link
1996  * linkend="wintype-Graphics">Graphics Windows</link>.
1997  */
1998
1999 /**
2000  * evtype_SoundNotify:
2001  *
2002  * On platforms that support sound, you can request to receive an 
2003  * %evtype_SoundNotify event when a sound finishes playing. See <link
2004  * linkend="chimara-Playing-Sounds">Playing Sounds</link>.
2005  */
2006  
2007 /**
2008  * evtype_Hyperlink:
2009  * 
2010  * On platforms that support hyperlinks, you can request to receive an
2011  * %evtype_Hyperlink event when the player selects a link. See <link
2012  * linkend="chimara-Accepting-Hyperlink-Events">Accepting Hyperlink 
2013  * Events</link>.
2014  */
2015
2016 /**
2017  * event_t:
2018  * @type: the event type
2019  * @win: the window that spawned the event, or %NULL
2020  * @val1: information, the meaning of which depends on the type of event
2021  * @val2: more information, the meaning of which depends on the type of event
2022  *
2023  * The event structure is self-explanatory. @type is the event type. The window
2024  * that spawned the event, if relevant, is in @win. The remaining fields contain
2025  * more information specific to the event.
2026  *
2027  * The event types are described below. Note that %evtype_None is zero, and the
2028  * other values are positive. Negative event types (0x80000000 to 0xFFFFFFFF) 
2029  * are reserved for implementation-defined events. 
2030  */
2031
2032 /**
2033  * keycode_Unknown:
2034  *
2035  * Represents any key that has no Latin-1 or special code.
2036  */
2037
2038 /**
2039  * keycode_Left:
2040  *
2041  * Represents the <keycap function="left">left arrow</keycap> key.
2042  */
2043  
2044 /**
2045  * keycode_Right:
2046  *
2047  * Represents the <keycap function="right">right arrow</keycap> key.
2048  */
2049  
2050 /**
2051  * keycode_Up:
2052  *
2053  * Represents the <keycap function="up">up arrow</keycap> key.
2054  */
2055  
2056 /**
2057  * keycode_Down:
2058  *
2059  * Represents the <keycap function="down">down arrow</keycap> key.
2060  */
2061  
2062 /**
2063  * keycode_Return:
2064  *
2065  * Represents the <keycap function="enter">return</keycap> or <keycap 
2066  * function="enter">enter</keycap> keys.
2067  */
2068
2069 /**
2070  * keycode_Delete:
2071  *
2072  * Represents the <keycap function="delete">delete</keycap> or <keycap
2073  * function="backspace">backspace</keycap> keys.
2074  */
2075  
2076 /**
2077  * keycode_Escape:
2078  *
2079  * Represents the <keycap function="escape">escape</keycap> key.
2080  */
2081  
2082 /**
2083  * keycode_Tab:
2084  *
2085  * Represents the <keycap function="tab">tab</keycap> key.
2086  */
2087
2088 /**
2089  * keycode_PageUp:
2090  *
2091  * Represents the <keycap function="pageup">page up</keycap> key.
2092  */
2093
2094 /**
2095  * keycode_PageDown:
2096  *
2097  * Represents the <keycap function="pagedown">page down</keycap> key.
2098  */
2099
2100 /**
2101  * keycode_Home:
2102  *
2103  * Represents the <keycap function="home">home</keycap> key.
2104  */
2105  
2106 /**
2107  * keycode_End:
2108  *
2109  * Represents the <keycap function="end">end</keycap> key.
2110  */
2111
2112 /**
2113  * keycode_Func1:
2114  *
2115  * Represents the <keycap>F1</keycap> key.
2116  */
2117  
2118 /**
2119  * keycode_Func2:
2120  *
2121  * Represents the <keycap>F2</keycap> key.
2122  */
2123
2124 /**
2125  * keycode_Func3:
2126  *
2127  * Represents the <keycap>F3</keycap> key.
2128  */
2129
2130 /**
2131  * keycode_Func4:
2132  *
2133  * Represents the <keycap>F4</keycap> key.
2134  */
2135
2136 /**
2137  * keycode_Func5:
2138  *
2139  * Represents the <keycap>F5</keycap> key.
2140  */
2141  
2142 /**
2143  * keycode_Func6:
2144  *
2145  * Represents the <keycap>F6</keycap> key.
2146  */
2147
2148 /**
2149  * keycode_Func7:
2150  *
2151  * Represents the <keycap>F7</keycap> key.
2152  */
2153
2154 /**
2155  * keycode_Func8:
2156  *
2157  * Represents the <keycap>F8</keycap> key.
2158  */
2159
2160 /**
2161  * keycode_Func9:
2162  *
2163  * Represents the <keycap>F9</keycap> key.
2164  */
2165
2166 /**
2167  * keycode_Func10:
2168  *
2169  * Represents the <keycap>F10</keycap> key.
2170  */
2171
2172 /**
2173  * keycode_Func11:
2174  *
2175  * Represents the <keycap>F11</keycap> key.
2176  */
2177
2178 /**
2179  * keycode_Func12:
2180  *
2181  * Represents the <keycap>F12</keycap> key.
2182  */
2183
2184 /**
2185  * style_Normal: 
2186  *
2187  * The style of normal or body text. A new window or stream always starts with
2188  * %style_Normal as the current style.
2189  */
2190
2191 /**
2192  * style_Emphasized: 
2193  *
2194  * Text which is emphasized.
2195  */
2196
2197 /**
2198  * style_Preformatted: 
2199  *
2200  * Text which has a particular arrangement of characters.
2201  * <note><para>
2202  *  This style, unlike the others, does have a standard appearance; it will 
2203  *  always be a fixed-width font. This is a concession to practicality. Games 
2204  *  often want to display maps or diagrams using character graphics, and this is
2205  *  the style for that.
2206  * </para></note>
2207  */
2208  
2209 /**
2210  * style_Header: 
2211  * 
2212  * Text which introduces a large section. This is suitable for the title of an 
2213  * entire game, or a major division such as a chapter.
2214  */
2215
2216 /**
2217  * style_Subheader: 
2218  * 
2219  * Text which introduces a smaller section within a large section. 
2220  * <note><para>
2221  *  In a Colossal-Cave-style game, this is suitable for the name of a room (when
2222  *  the player looks around.)
2223  * </para></note>
2224  */
2225
2226 /**
2227  * style_Alert: 
2228  *
2229  * Text which warns of a dangerous condition, or one which the player should pay
2230  * attention to.
2231  */
2232
2233 /**
2234  * style_Note: 
2235  *
2236  * Text which notifies of an interesting condition.
2237  * <note><para>
2238  *  This is suitable for noting that the player's score has changed.
2239  * </para></note>
2240  */
2241
2242 /**
2243  * style_BlockQuote: 
2244  *
2245  * Text which forms a quotation or otherwise abstracted text.
2246  */
2247
2248 /**
2249  * style_Input: 
2250  *
2251  * Text which the player has entered. You should generally not use this style at
2252  * all; the library uses it for text which is typed during a line-input request.
2253  * One case when it is appropriate for you to use %style_Input is when you are 
2254  * simulating player input by reading commands from a text file.
2255  */
2256
2257 /**
2258  * style_User1: 
2259  * 
2260  * This style has no particular semantic meaning. You may define a meaning 
2261  * relevant to your own work, and use it as you see fit.
2262  */
2263
2264 /**
2265  * style_User2: 
2266  *
2267  * Another style available for your use. 
2268  */
2269
2270 /**
2271  * stream_result_t:
2272  * @readcount: Number of characters read from the stream.
2273  * @writecount: Number of characters printed to the stream, including ones that
2274  * were thrown away.
2275  *
2276  * If you are interested in the character counts of a stream (see <link
2277  * linkend="chimara-Streams">Streams</link>), then you can pass a pointer to
2278  * #stream_result_t as an argument of glk_stream_close() or glk_window_close().
2279  * The structure will be filled with the stream's final character counts.
2280  */
2281
2282 /**
2283  * wintype_AllTypes:
2284  *
2285  * A constant representing all window types, which may be used as the @wintype
2286  * argument in glk_stylehint_set().
2287  */
2288
2289 /** 
2290  * wintype_Pair:
2291  * 
2292  * A pair window is completely filled by the two windows it contains. It
2293  * supports no input and no output, and it has no size.
2294  * 
2295  * You cannot directly create a pair window; one is automatically created
2296  * every time you split a window with glk_window_open(). Pair windows are
2297  * always created with a rock value of 0.
2298  * 
2299  * You can close a pair window with glk_window_close(); this also closes every
2300  * window contained within the pair window.
2301  * 
2302  * It is legal to split a pair window when you call glk_window_open().
2303  */
2304  
2305 /**
2306  * wintype_Blank:
2307  * 
2308  * A blank window is always blank. It supports no input and no output. (You
2309  * can call glk_window_get_stream() on it, as you can with any window, but
2310  * printing to the resulting stream has no effect.) A blank window has no
2311  * size; glk_window_get_size() will return (0,0), and it is illegal to set a
2312  * window split with a fixed size in the measurement system of a blank window.
2313  * 
2314  * <note><para>
2315  *   A blank window is not the same as there being no windows. When Glk starts
2316  *   up, there are no windows at all, not even a window of the blank type.
2317  * </para></note>
2318  */
2319  
2320 /**
2321  * wintype_TextBuffer: 
2322  *
2323  * A text buffer window contains a linear stream of text. It supports output;
2324  * when you print to it, the new text is added to the end. There is no way for
2325  * you to affect text which has already been printed. There are no guarantees
2326  * about how much text the window keeps; old text may be stored forever, so
2327  * that the user can scroll back to it, or it may be thrown away as soon as it
2328  * scrolls out of the window. 
2329  * 
2330  * <note><para>
2331  *   Therefore, there may or may not be a player-controllable scroll bar or
2332  *   other scrolling widget.
2333  * </para></note>
2334  * 
2335  * The display of the text in a text buffer is up to the library. Lines will
2336  * probably not be broken in the middles of words &mdash; but if they are, the
2337  * library is not doing anything illegal, only ugly. Text selection and copying
2338  * to a clipboard, if available, are handled however is best on the player's
2339  * machine. Paragraphs (as defined by newline characters in the output) may be
2340  * indented. 
2341  * 
2342  * <note><para>
2343  *   You should not, in general, fake this by printing spaces before each
2344  *   paragraph of prose text. Let the library and player preferences handle
2345  *   that. Special cases (like indented lists) are of course up to you.
2346  * </para></note>
2347  * 
2348  * When a text buffer is cleared (with glk_window_clear()), the library will do
2349  * something appropriate; the details may vary. It may clear the window, with
2350  * later text appearing at the top &mdash; or the bottom. It may simply print
2351  * enough blank lines to scroll the current text out of the window. It may
2352  * display a distinctive page-break symbol or divider.
2353  * 
2354  * The size of a text buffer window is necessarily imprecise. Calling
2355  * glk_window_get_size() will return the number of rows and columns that would
2356  * be available <emphasis>if</emphasis> the window was filled with 
2357  * <quote>0</quote> (zero) characters in the <quote>normal</quote> font.
2358  * However, the window may use a non-fixed-width font, so that number of
2359  * characters in a line could vary. The window might even support 
2360  * variable-height text (say, if the player is using large text for emphasis);
2361  * that would make the number of lines in the window vary as well.
2362  * 
2363  * Similarly, when you set a fixed-size split in the measurement system of a
2364  * text buffer, you are setting a window which can handle a fixed number of rows
2365  * (or columns) of <quote>0</quote> characters. The number of rows (or
2366  * characters) that will actually be displayed depends on font variances.
2367  * 
2368  * A text buffer window supports both character and line input, but not mouse
2369  * input.
2370  * 
2371  * In character input, there will be some visible signal that the window is
2372  * waiting for a keystroke. (Typically, a cursor at the end of the text.) When
2373  * the player hits a key in that window, an event is generated, but the key is
2374  * <emphasis>not</emphasis> printed in the window.
2375  * 
2376  * In line input, again, there will be some visible signal. It is most common
2377  * for the player to compose input in the window itself, at the end of the text.
2378  * (This is how IF story input usually looks.) But it's not strictly required.
2379  * An alternative approach is the way MUD clients usually work: there is a
2380  * dedicated one-line input window, outside of Glk's window space, and the user
2381  * composes input there.
2382  * 
2383  * <note><para>
2384  *   If this approach is used, there will still be some way to handle input from
2385  *   two windows at once. It is the library's responsibility to make this
2386  *   available to the player. You only need request line input and  wait for the
2387  *   result.
2388  * </para></note>
2389  * 
2390  * By default, when the player finishes his line of input, the library will
2391  * display the input text at the end of the buffer text (if it wasn't there
2392  * already.) It will be followed by a newline, so that the next text you print
2393  * will start a new line (paragraph) after the input.
2394  * 
2395  * If you call glk_cancel_line_event(), the same thing happens; whatever text
2396  * the user was composing is visible at the end of the buffer text, followed by
2397  * a newline.
2398  *
2399  * However, this default behavior can be changed with the
2400  * glk_set_echo_line_event() call. If the default echoing is disabled, the
2401  * library will <emphasis>not</emphasis> display the input text (plus newline)
2402  * after input is either completed or cancelled. The buffer will end with
2403  * whatever prompt you displayed before requesting input. If you want the
2404  * traditional input behavior, it is then your responsibility to print the text,
2405  * using the Input text style, followed by a newline (in the original style).
2406  */
2407  
2408 /**
2409  * wintype_TextGrid: 
2410  * 
2411  * A text grid contains a rectangular array of characters, in a fixed-width
2412  * font. Its size is the number of columns and rows of the array.
2413  * 
2414  * A text grid window supports output. It maintains knowledge of an output
2415  * cursor position. When the window is opened, it is filled with blanks (space
2416  * characters), and the output cursor starts in the top left corner &mdash;
2417  * character (0,0). If the window is cleared with glk_window_clear(), the window
2418  * is filled with blanks again, and the cursor returns to the top left corner.
2419  * 
2420  * When you print, the characters of the output are laid into the array in
2421  * order, left to right and top to bottom. When the cursor reaches the end of a
2422  * line, or if a newline (0x0A) is printed, the cursor goes to the beginning of
2423  * the next line. The library makes <emphasis>no</emphasis> attempt to wrap
2424  * lines at word breaks. If the cursor reaches the end of the last line, further
2425  * printing has no effect on the window until the cursor is moved.
2426  * 
2427  * <note><para>
2428  *   Note that printing fancy characters may cause the cursor to advance more
2429  *   than one position per character. (For example, the <quote>&aelig;</quote>
2430  *   ligature may print as two characters.) See <link 
2431  *   linkend="chimara-Output">Output</link>, for how to test this situation.
2432  * </para></note>
2433  * 
2434  * You can set the cursor position with glk_window_move_cursor().
2435  * 
2436  * When a text grid window is resized smaller, the bottom or right area is
2437  * thrown away, but the remaining area stays unchanged. When it is resized
2438  * larger, the new bottom or right area is filled with blanks.
2439  * 
2440  * <note><para>
2441  *   You may wish to watch for %evtype_Arrange events, and clear-and-redraw your
2442  *   text grid windows when you see them change size.
2443  * </para></note>
2444  * 
2445  * Text grid window support character and line input, as well as mouse input (if
2446  * a mouse is available.)
2447  * 
2448  * Mouse input returns the position of the character that was touched, from
2449  * (0,0) to 
2450  * <inlineequation>
2451  *   <alt>(width-1,height-1)</alt>
2452  *   <mathphrase>(width - 1, height - 1)</mathphrase>
2453  * </inlineequation>
2454  * .
2455  * 
2456  * Character input is as described in the previous section.
2457  * 
2458  * Line input is slightly different; it is guaranteed to take place in the
2459  * window, at the output cursor position. The player can compose input only to
2460  * the right edge of the window; therefore, the maximum input length is
2461  * <inlineequation>
2462  *   <alt>(windowwidth - 1 - cursorposition)</alt>
2463  *   <mathphrase>(windowwidth - 1 - cursorposition)</mathphrase>
2464  * </inlineequation>
2465  * . If the maxlen argument of glk_request_line_event() is smaller than this,
2466  * the library will not allow the input cursor to go more than maxlen characters
2467  * past its start point. 
2468  * 
2469  * <note><para>
2470  *   This allows you to enter text in a fixed-width field, without the player
2471  *   being able to overwrite other parts of the window.
2472  * </para></note>
2473  * 
2474  * When the player finishes his line of input, it will remain visible in the
2475  * window, and the output cursor will be positioned at the beginning of the 
2476  * <emphasis>next</emphasis> row. Again, if you glk_cancel_line_event(), the
2477  * same thing happens. The glk_set_echo_line_event() call has no effect in grid
2478  * windows.
2479  */
2480  
2481 /**
2482  * wintype_Graphics: 
2483  * 
2484  * A graphics window contains a rectangular array of pixels. Its size is the
2485  * number of columns and rows of the array.
2486  * 
2487  * Each graphics window has a background color, which is initially white. You
2488  * can change this; see <link 
2489  * linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics 
2490  * Windows</link>.
2491  * 
2492  * When a graphics window is resized smaller, the bottom or right area is
2493  * thrown away, but the remaining area stays unchanged. When it is resized
2494  * larger, the new bottom or right area is filled with the background color.
2495  * 
2496  * <note><para>
2497  *   You may wish to watch for %evtype_Arrange events, and clear-and-redraw your
2498  *   graphics windows when you see them change size.
2499  * </para></note>
2500  * 
2501  * In some libraries, you can receive a graphics-redraw event (%evtype_Redraw)
2502  * at any time. This signifies that the window in question has been cleared to
2503  * its background color, and must be redrawn. If you create any graphics
2504  * windows, you <emphasis>must</emphasis> handle these events.
2505  * 
2506  * <note><para>
2507  *   Redraw events can be triggered when a Glk window is uncovered or made
2508  *   visible by the platform's window manager. On the other hand, some Glk
2509  *   libraries handle these problem automatically &mdash; for example, with a
2510  *   backing store &mdash; and do not send you redraw events. On the third hand,
2511  *   the backing store may be discarded if memory is low, or for other reasons
2512  *   &mdash; perhaps the screen's color depth has changed. So redraw events are
2513  *   always a possibility, even in clever libraries. This is why you must be
2514  *   prepared to handle them.
2515  * 
2516  *   However, you will not receive a redraw event when you create a graphics
2517  *   window. It is assumed that you will do the initial drawing of your own
2518  *   accord. You also do not get redraw events when a graphics window is
2519  *   enlarged. If you ordered the enlargement, you already know about it; if the
2520  *   player is responsible, you receive a window-arrangement event, which covers
2521  *   the situation.
2522  * </para></note>
2523  * 
2524  * For a description of the drawing functions that apply to graphics windows,
2525  * see <link linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
2526  * Windows</link>.
2527  * 
2528  * Graphics windows support no text input or output.
2529  * 
2530  * Not all libraries support graphics windows. You can test whether Glk graphics
2531  * are available using the gestalt system. In a C program, you can also test
2532  * whether the graphics functions are defined at compile-time. See <link 
2533  * linkend="chimara-Testing-for-Graphics-Capabilities">Testing for Graphics
2534  * Capabilities</link>. 
2535  *
2536  * <note><para>
2537  *   As with all windows, you should also test for %NULL when you create a
2538  *   graphics window.
2539  * </para></note>
2540  */
2541  
2542 /**
2543  * winmethod_Left:
2544  *
2545  * When calling glk_window_open() with this @method, the new window will be 
2546  * to the left of the old one which was split.
2547  */
2548
2549 /**
2550  * winmethod_Right:
2551  *
2552  * When calling glk_window_open() with this @method, the new window will be 
2553  * to the right of the old one which was split.
2554  */
2555
2556 /**
2557  * winmethod_Above:
2558  *
2559  * When calling glk_window_open() with this @method, the new window will be 
2560  * above the old one which was split.
2561  */
2562  
2563 /**
2564  * winmethod_Below:
2565  *
2566  * When calling glk_window_open() with this @method, the new window will be 
2567  * below the old one which was split.
2568  */
2569  
2570 /**
2571  * winmethod_Fixed:
2572  *
2573  * When calling glk_window_open() with this @method, the new window will be 
2574  * a fixed size. (See glk_window_open()).
2575  */
2576
2577 /**
2578  * winmethod_Proportional:
2579  *
2580  * When calling glk_window_open() with this @method, the new window will be 
2581  * a given proportion of the old window's size. (See glk_window_open()).
2582  */
2583
2584 /**
2585  * winmethod_Border:
2586  *
2587  * When calling glk_window_open() with this @method, it specifies that there
2588  * should be a visible window border between the new window and its sibling.
2589  * (This is a hint to the library.)
2590  */
2591
2592 /**
2593  * winmethod_NoBorder:
2594  *
2595  * When calling glk_window_open() with this @method, it specifies that there
2596  * should not be a visible window border between the new window and its sibling.
2597  * (This is a hint to the library; you might specify NoBorder between two
2598  * graphics windows that should form a single image.)
2599  */
2600
2601 /** 
2602  * fileusage_Data: 
2603  *
2604  * Any other kind of file (preferences, statistics, arbitrary data.) 
2605  */
2606
2607 /**
2608  * fileusage_SavedGame: 
2609  * 
2610  * A file which stores game state.
2611  */
2612
2613 /**
2614  * fileusage_Transcript: 
2615  * 
2616  * A file which contains a stream of text from the game (often an echo stream
2617  * from a window.)
2618  */
2619  
2620 /** 
2621  * fileusage_InputRecord: 
2622  * 
2623  * A file which records player input.
2624  */
2625
2626 /** 
2627  * fileusage_TextMode: 
2628  *
2629  * The file contents will be transformed to a platform-native text file as they
2630  * are written out. Newlines may be converted to linefeeds or 
2631  * linefeed-plus-carriage-return combinations; Latin-1 characters may be
2632  * converted to native character codes. When reading a file in text mode, native
2633  * line breaks will be converted back to newline (0x0A) characters, and native
2634  * character codes may be converted to Latin-1. 
2635  *
2636  * <note><para>
2637  *   Line breaks will always be converted; other conversions are more
2638  *   questionable. If you write out a file in text mode, and then read it back
2639  *   in text mode, high-bit characters (128 to 255) may be transformed or lost.
2640  * </para></note>
2641  * <note><title>Chimara</title>
2642  * <para>
2643  * Text mode files in Chimara are in UTF-8, which is GTK+'s native file
2644  * encoding.
2645  * </para></note>
2646  */
2647
2648 /**
2649  * fileusage_BinaryMode: 
2650  *
2651  * The file contents will be stored exactly as they are written, and read back
2652  * in the same way. The resulting file may not be viewable on platform-native
2653  * text file viewers.
2654  */
2655
2656 /**
2657  * fileusage_TypeMask:
2658  *
2659  * Bitwise AND this value with a file usage argument to find whether the file
2660  * type is %fileusage_SavedGame, %fileusage_Transcript, %fileusage_InputRecord,
2661  * or %fileusage_Data.
2662  */
2663
2664 /**
2665  * filemode_Write: 
2666  *
2667  * An output stream.
2668  *
2669  * <note><para>
2670  *   Corresponds to mode <code>"w"</code> in the stdio library, using fopen().
2671  * </para></note>
2672  */
2673
2674 /** 
2675  * filemode_Read: 
2676  *
2677  * An input stream.
2678  *
2679  * <note><para>
2680  *   Corresponds to mode <code>"r"</code> in the stdio library, using fopen().
2681  * </para></note>
2682  */
2683
2684 /**
2685  * filemode_ReadWrite: 
2686  *
2687  * Both an input and an output stream.
2688  *
2689  * <note><para>
2690  *   Corresponds to mode <code>"r+"</code> in the stdio library, using fopen().
2691  * </para></note>
2692  */
2693
2694 /**
2695  * filemode_WriteAppend: 
2696  *
2697  * An output stream, but the data will added to the end of whatever already
2698  * existed in the destination, instead of replacing it. 
2699  *
2700  * <note><para>
2701  *   Confusingly, %filemode_WriteAppend cannot be mode <code>"a"</code>, because
2702  *   the stdio spec says that when you open a file with mode <code>"a"</code>,
2703  *   then fseek() doesn't work. So we have to use mode <code>"r+"</code> for
2704  *   appending. Then we run into the <emphasis>other</emphasis> stdio problem,
2705  *   which is that <code>"r+"</code> never creates a new file. So
2706  *   %filemode_WriteAppend has to <emphasis>first</emphasis> open the file with
2707  *   <code>"a"</code>, close it, reopen with <code>"r+"</code>, and then fseek()
2708  *   to the end of the file. For %filemode_ReadWrite, the process is the same,
2709  *   except without the fseek() &mdash; we begin at the beginning of the file.
2710  * </para></note>
2711  */
2712  
2713 /**
2714  * seekmode_Start:
2715  *
2716  * In glk_stream_set_position(), signifies that @pos is counted in characters
2717  * after the beginning of the file.
2718  */
2719  
2720 /**
2721  * seekmode_Current: 
2722  *
2723  * In glk_stream_set_position(), signifies that @pos is counted in characters
2724  * after the current position (moving backwards if @pos is negative.)
2725  */
2726
2727 /** 
2728  * seekmode_End: 
2729  *
2730  * In glk_stream_set_position(), signifies that @pos is counted in characters
2731  * after the end of the file. (@pos should always be zero or negative, so that
2732  * this will move backwards to a  position within the file.
2733  */
2734
2735 /**
2736  * stylehint_Indentation: 
2737  *
2738  * How much to indent lines of text in the given style. May be a negative 
2739  * number, to shift the text out (left) instead of in (right). The exact metric
2740  * isn't precisely specified; you can assume that +1 is the smallest indentation
2741  * possible which is clearly visible to the player.
2742  */
2743
2744 /**
2745  * stylehint_ParaIndentation: 
2746  *
2747  * How much to indent the first line of each paragraph. This is in addition to 
2748  * the indentation specified by %stylehint_Indentation. This too may be 
2749  * negative, and is measured in the same units as %stylehint_Indentation.
2750  */
2751
2752 /**
2753  * stylehint_Justification: 
2754  *
2755  * The value of this hint must be one of the constants 
2756  * %stylehint_just_LeftFlush, %stylehint_just_LeftRight (full justification), 
2757  * %stylehint_just_Centered, or %stylehint_just_RightFlush.
2758  */
2759
2760 /** 
2761  * stylehint_Size: 
2762  *
2763  * How much to increase or decrease the font size. This is relative; 0 means the
2764  * interpreter's default font size will be used, positive numbers increase it, 
2765  * and negative numbers decrease it. Again, +1 is the smallest size increase 
2766  * which is easily visible. 
2767  * <note><para>
2768  *  The amount of this increase may not be constant. +1 might increase an 
2769  *  8-point font to 9-point, but a 16-point font to 18-point.
2770  * </para></note>
2771  */
2772
2773 /**
2774  * stylehint_Weight: 
2775  *
2776  * The value of this hint must be 1 for heavy-weight fonts (boldface), 0 for 
2777  * normal weight, and -1 for light-weight fonts.
2778  */
2779
2780 /**
2781  * stylehint_Oblique: 
2782  *
2783  * The value of this hint must be 1 for oblique fonts (italic), or 0 for normal
2784  * angle.
2785  */
2786  
2787 /** 
2788  * stylehint_Proportional: 
2789  * 
2790  * The value of this hint must be 1 for proportional-width fonts, or 0 for 
2791  * fixed-width.
2792  */
2793
2794 /**
2795  * stylehint_TextColor: 
2796  * 
2797  * The foreground color of the text. This is encoded in the 32-bit hint value: 
2798  * the top 8 bits must be zero, the next 8 bits are the red value, the next 8 
2799  * bits are the green value, and the bottom 8 bits are the blue value. Color 
2800  * values range from 0 to 255. 
2801  * <note><para>
2802  *   So 0x00000000 is black, 0x00FFFFFF is white, and 0x00FF0000 is bright red.
2803  * </para></note>
2804  */
2805  
2806 /** 
2807  * stylehint_BackColor: 
2808  *
2809  * The background color behind the text. This is encoded the same way as 
2810  * %stylehint_TextColor.
2811  */
2812  
2813 /** 
2814  * stylehint_ReverseColor: 
2815  *
2816  * The value of this hint must be 0 for normal printing (%stylehint_TextColor on 
2817  * %stylehint_BackColor), or 1 for reverse printing (%stylehint_BackColor on 
2818  * %stylehint_TextColor). 
2819  * <note><para>
2820  *  Some libraries may support this hint but not the %stylehint_TextColor and 
2821  *  %stylehint_BackColor hints. Other libraries may take the opposite tack; 
2822  *  others may support both, or neither.
2823  * </para></note>
2824  */
2825  
2826 /**
2827  * stylehint_just_LeftFlush:
2828  *
2829  * A value for %stylehint_Justification representing left-justified text.
2830  */ 
2831  
2832 /**
2833  * stylehint_just_LeftRight:
2834  *
2835  * A value for %stylehint_Justification representing fully justified text.
2836  */ 
2837  
2838 /**
2839  * stylehint_just_Centered:
2840  *
2841  * A value for %stylehint_Justification representing centered text.
2842  */ 
2843  
2844 /**
2845  * stylehint_just_RightFlush:
2846  *
2847  * A value for %stylehint_Justification representing right-justified text.
2848  */
2849
2850 /**
2851  * imagealign_InlineUp:
2852  *
2853  * The image appears at the current point in the text, sticking up. That is, the
2854  * bottom edge of the image is aligned with the baseline of the line of text.
2855  */
2856
2857 /**
2858  * imagealign_InlineDown:
2859  *
2860  * The image appears at the current point, and the top edge is aligned with the
2861  * top of the line of text.
2862  */
2863
2864 /**
2865  * imagealign_InlineCenter:
2866  *
2867  * The image appears at the current point, and it is centered between the top
2868  * and baseline of the line of text. If the image is taller than the line of
2869  * text, it will stick up and down equally.
2870  */
2871
2872 /**
2873  * imagealign_MarginLeft:
2874  * 
2875  * The image appears in the left margin. Subsequent text will be displayed to
2876  * the right of the image, and will flow around it &mdash; that is, it will be
2877  * left-indented for as many lines as it takes to pass the image.
2878  *
2879  * <warning><para>Margin images are not implemented yet.</para></warning>
2880  */
2881
2882 /**
2883  * imagealign_MarginRight:
2884  *
2885  * The image appears in the right margin, and subsequent text will flow around
2886  * it on the left.
2887  *
2888  * <warning><para>Margin images are not implemented yet.</para></warning>
2889  */
2890
2891 /**
2892  * glkdate_t:
2893  * @year: The full (four-digit) year
2894  * @month: The month number, ranging from 1-12, 1 is January
2895  * @day: The day of the month, ranging from 1-31
2896  * @weekday: The day of the week, ranging from 0-6, 0 is Sunday
2897  * @hour: The hour of the day, ranging from 0-23
2898  * @minute: The minute of the hour, ranging from 0-59
2899  * @second: The second of the minute, ranging from 0-59; may be 60 during a leap
2900  * second
2901  * @microsec: The fraction of the second in microseconds, ranging from 0-999999
2902  *
2903  * This structure represents a human-readable date in a specific timezone.
2904  */
2905
2906 /**
2907  * glktimeval_t:
2908  * @high_sec: The most significant 32 bits of the timestamp in seconds.
2909  * @low_sec: The least significant 32 bits of the timestamp in seconds.
2910  * @microsec: The fraction of the timestamp, in microseconds, ranging from
2911  * 0-999999.
2912  *
2913  * This structure represents the Unix timestamp, i.e. the number of seconds
2914  * since January 1, 1970.
2915  */
2916  
2917 /*---------- TYPES, FUNCTIONS AND CONSTANTS FROM GI_DISPA.H ------------------*/
2918
2919 /**
2920  * gidispatch_count_classes:
2921  * 
2922  * Returns the number of opaque object classes used by the library. You will
2923  * need to know this if you want to keep track of opaque objects as they are
2924  * created; see <link linkend="gidispatch-set-object-registry">Opaque Object
2925  * Registry</link>.
2926  * 
2927  * As of Glk API 0.7.0, there are four classes: windows, streams, filerefs, and
2928  * sound channels (numbered 0, 1, 2, and 3 respectively.)
2929  *
2930  * Returns: Number of opaque object classes used by the library.
2931  */
2932
2933 /**
2934  * gidispatch_get_class:
2935  * @index: Unique integer index of the class.
2936  *
2937  * Returns a structure describing an opaque class that the library exports.
2938  * @index can range from 0 to <inlineequation><mathphrase>N -
2939  * 1</mathphrase><alt>N - 1</alt></inlineequation>, where N is the value
2940  * returned by gidispatch_count_classes().
2941  *
2942  * Returns: A #gidispatch_intconst_t structure describing the class.
2943  */
2944
2945 /**
2946  * gidispatch_count_intconst:
2947  *
2948  * Returns the number of integer constants exported by the library.
2949  *
2950  * Returns: Number of integer constants exported by the library.
2951  */
2952  
2953 /**
2954  * gidispatch_get_intconst:
2955  * @index: Unique integer index of the integer constant.
2956  *
2957  * Returns a structure describing an integer constant which the library exports.
2958  * These are, roughly, all the constants defined in the <filename
2959  * class="headerfile">glk.h</filename> file. @index can range from 0 to
2960  * <inlineequation><mathphrase>N - 1</mathphrase><alt>N - 
2961  * 1</alt></inlineequation>, where N is the value returned by 
2962  * gidispatch_count_intconst().
2963  *
2964  * Returns: A #gidispatch_intconst_t structure describing the integer constant.
2965  */
2966
2967 /**
2968  * gidispatch_intconst_t:
2969  * @name: Symbolic name of the integer constant.
2970  * @val: Value of the integer constant.
2971  *
2972  * This structure simply contains a string and a value. The string is a
2973  * symbolic name of the value, and can be re-exported to anyone interested in
2974  * using Glk constants.
2975  *
2976  * <note><para>
2977  *   In the current <filename>gi_dispa.c</filename> library, these structures
2978  *   are static and immutable, and will never be deallocated. However, it is
2979  *   safer to assume that the structure may be reused in future
2980  *   gidispatch_get_intconst() calls.
2981  * </para></note>
2982  */
2983  
2984 /**
2985  * gidispatch_count_functions:
2986  *
2987  * Returns the number of functions exported by the library.
2988  *
2989  * Returns: Number of functions exported by the library.
2990  */
2991  
2992 /**
2993  * gidispatch_get_function:
2994  * @index: Unique integer index of the function.
2995  *
2996  * Returns a structure describing a Glk function. @index can range from 0 to
2997  * <inlineequation><mathphrase>N - 1</mathphrase><alt>N - 
2998  * 1</alt></inlineequation>, where N is the value returned by 
2999  * gidispatch_count_functions().
3000  *
3001  * <note><para>
3002  *   Again, it is safest to assume that the structure is only valid until the
3003  *   next gidispatch_get_function() or gidispatch_get_function_by_id() call.
3004  * </para></note>
3005  *
3006  * Returns: A #gidispatch_function_t structure describing the function.
3007  */
3008  
3009 /**
3010  * gidispatch_function_t:
3011  * @id: Dispatch selector of the function.
3012  * @fnptr: Pointer to the function.
3013  * @name: Name of the function, without the <code>glk_</code> prefix.
3014  *
3015  * The @id field is a selector &mdash; a numeric constant used to refer to the
3016  * function in question. @name is the function name, as it is given in the
3017  * <filename class="headerfile">glk.h</filename> file, but without the 
3018  * <quote><code>glk_</code></quote> prefix. And @fnptr is the address of the
3019  * function itself.
3020  *
3021  * <note><para>
3022  *   This is included because it might be useful, but it is not recommended. To
3023  *   call an arbitrary Glk function, you should use gidispatch_call().
3024  * </para></note>
3025  *
3026  * See <link linkend="chimara-Table-of-Selectors">Table of Selectors</link> for
3027  * the selector definitions. See <link 
3028  * linkend="chimara-Dispatching">Dispatching</link> for more about calling Glk
3029  * functions by selector.
3030  */
3031  
3032 /**
3033  * gidispatch_get_function_by_id:
3034  * @id: A selector.
3035  *
3036  * Returns a structure describing the Glk function with selector @id. If there 
3037  * is no such function in the library, this returns %NULL.
3038  *
3039  * <note><para>
3040  *   Again, it is safest to assume that the structure is only valid until the
3041  *   next gidispatch_get_function() or gidispatch_get_function_by_id() call.
3042  * </para></note>
3043  *
3044  * Returns: a #gidispatch_function_t structure, or %NULL.
3045  */
3046  
3047 /**
3048  * gidispatch_call:
3049  * @funcnum: Selector of the function to call.
3050  * @numargs: Length of @arglist.
3051  * @arglist: List of arguments to pass to the function.
3052  *
3053  * @funcnum is the function number to invoke; see <link 
3054  * linkend="chimara-Table-of-Selectors">Table of Selectors</link>. @arglist is
3055  * the list of arguments, and @numargs is the length of the list.
3056  * 
3057  * The arguments are all stored as #gluniversal_t objects. 
3058  * </para><refsect3 id="chimara-Basic-Dispatch-Types"><title>Basic Dispatch
3059  * Types</title><para>
3060  * Numeric arguments are passed in the obvious way &mdash; one argument per
3061  * #gluniversal_t, with the @uint or @sint field set to the numeric value.
3062  * Characters and strings are also passed in this way &mdash; #char<!---->s in
3063  * the @uch, @sch, or @ch fields (depending on whether the #char is signed) and
3064  * strings in the @charstr field. Opaque objects (windows, streams, etc) are
3065  * passed in the @opaqueref field (which is <code>void*</code>, in order to
3066  * handle all opaque pointer types.)
3067  * 
3068  * However, pointers (other than C strings), arrays, and structures complicate
3069  * life. So do return values.
3070  * </para></refsect3>
3071  * <refsect3 id="chimara-References"><title>References</title><para>
3072  * A reference to a numeric type or object reference &mdash; that is,
3073  * <code>#glui32*</code>, <code>#winid_t*</code>, and so on &mdash; takes
3074  * <emphasis>one or two</emphasis> #gluniversal_t objects. The first is a flag
3075  * indicating whether the reference argument is %NULL or not. The @ptrflag field
3076  * of this #gluniversal_t should be %FALSE (0) if the reference is %NULL, and
3077  * %TRUE (1) otherwise. If %FALSE, that is the end of the argument; you should
3078  * not use a #gluniversal_t to explicitly store the %NULL reference. If the flag
3079  * is %TRUE, you must then put a #gluniversal_t storing the base type of the
3080  * reference.
3081  *
3082  * For example, consider a hypothetical function, with selector 
3083  * <code>0xABCD</code>:
3084  * |[ 
3085  * void glk_glomp(glui32 num, winid_t win, glui32 *numref, strid_t *strref);
3086  * ]|
3087  * ...and the calls:
3088  * |[
3089  * glui32 value;
3090  * winid_t mainwin;
3091  * strid_t gamefile;
3092  * glk_glomp(5, mainwin, &value, &gamefile);
3093  * ]|
3094  *
3095  * To perform this through gidispatch_call(), you would do the following:
3096  * |[
3097  * gluniversal_t arglist[6];
3098  * arglist[0].uint = 5;
3099  * arglist[1].opaqueref = mainwin;
3100  * arglist[2].ptrflag = TRUE;
3101  * arglist[3].uint = value;
3102  * arglist[4].ptrflag = TRUE;
3103  * arglist[5].opaqueref = gamefile;
3104  * gidispatch_call(0xABCD, 6, arglist);
3105  * value = arglist[3].uint;
3106  * gamefile = arglist[5].opaqueref;
3107  * ]|
3108  * 
3109  * Note that you copy the value of the reference arguments into and out of
3110  * @arglist. Of course, it may be that 
3111  * <function>glk_glomp&lpar;&rpar;</function> only uses these as pass-out
3112  * references or pass-in references; if so, you could skip copying in or out.
3113  *
3114  * For further examples:
3115  * |[
3116  * glk_glomp(7, mainwin, NULL, NULL);
3117  * ...or...
3118  * gluniversal_t arglist[4];
3119  * arglist[0].uint = 7;
3120  * arglist[1].opaqueref = mainwin;
3121  * arglist[2].ptrflag = FALSE;
3122  * arglist[3].ptrflag = FALSE;
3123  * gidispatch_call(0xABCD, 4, arglist);
3124  * ]|
3125  *
3126  * |[
3127  * glk_glomp(13, NULL, NULL, &gamefile);
3128  * ...or...
3129  * gluniversal_t arglist[5];
3130  * arglist[0].uint = 13;
3131  * arglist[1].opaqueref = NULL;
3132  * arglist[2].ptrflag = FALSE;
3133  * arglist[3].ptrflag = TRUE;
3134  * arglist[4].opaqueref = gamefile;
3135  * gidispatch_call(0xABCD, 5, arglist);
3136  * gamefile = arglist[4].opaqueref;
3137  * ]|
3138  *
3139  * |[
3140  * glk_glomp(17, NULL, &value, NULL);
3141  * ...or...
3142  * gluniversal_t arglist[5];
3143  * arglist[0].uint = 17;
3144  * arglist[1].opaqueref = NULL;
3145  * arglist[2].ptrflag = TRUE;
3146  * arglist[3].uint = value;
3147  * arglist[4].ptrflag = FALSE;
3148  * gidispatch_call(0xABCD, 5, arglist);
3149  * value = arglist[3].uint;
3150  * ]|
3151  * 
3152  * As you see, the length of @arglist depends on how many of the reference
3153  * arguments are %NULL.
3154  * </para></refsect3>
3155  * <refsect3 id="chimara-Structures"><title>Structures</title><para>
3156  * A structure pointer is represented by a single @ptrflag, possibly followed by
3157  * a sequence of #gluniversal_t objects (one for each field of the structure.)
3158  * Again, if the structure pointer is non-%NULL, the @ptrflag should be %TRUE
3159  * and be followed by values; if not, the @ptrflag should be %NULL and stands
3160  * alone.
3161  * 
3162  * For example, the function glk_select() can be invoked as follows:
3163  * |[
3164  * event_t ev;
3165  * gluniversal_t arglist[5];
3166  * arglist[0].ptrflag = TRUE;
3167  * gidispatch_call(0x00C0, 5, arglist);
3168  * ev.type = arglist[1].uint;
3169  * ev.win = arglist[2].opaqueref;
3170  * ev.val1 = arglist[3].uint;
3171  * ev.val2 = arglist[4].uint;
3172  * ]|
3173  * 
3174  * Since the structure passed to glk_select() is a pass-out reference (the entry
3175  * values are ignored), you don't need to fill in <code>arglist[1..4]</code>
3176  * before calling gidispatch_call().
3177  * 
3178  * <note><para>
3179  *   Theoretically, you would invoke <code>#glk_select(%NULL)</code> by setting'
3180  *   <code>arglist[0].ptrflag</code> to %FALSE, and using a one-element @arglist
3181  *   instead of five-element. But it's illegal to pass %NULL to glk_select(). So
3182  *   you cannot actually do this.
3183  * </para></note></para></refsect3>
3184  * <refsect3 id="chimara-Arrays"><title>Arrays</title><para>
3185  * In the Glk API, an array argument is always followed by a numeric argument
3186  * giving the array's length. These two C arguments are a single logical
3187  * argument, which is represented by <emphasis>one or three</emphasis>
3188  * #gluniversal_t objects. The first is a @ptrflag, indicating whether the
3189  * argument is %NULL or not. The second is a pointer, stored in the @array
3190  * field. The third is the array length, stored in the @uint field. And again,
3191  * if the @ptrflag is %NULL, the following two are omitted.
3192  * 
3193  * For example, the function glk_put_buffer() can be invoked as follows:
3194  * |[
3195  * char buf[64];
3196  * glui32 len = 64;
3197  * glk_put_buffer(buf, len);
3198  * ...or...
3199  * gluniversal_t arglist[3];
3200  * arglist[0].ptrflag = TRUE;
3201  * arglist[1].array = buf;
3202  * arglist[2].uint = len;
3203  * gidispatch_call(0x0084, 3, arglist);
3204  * ]|
3205  * 
3206  * Since you are passing a C char array to gidispatch_call(), the contents will
3207  * be read directly from that. There is no need to copy data into @arglist, as
3208  * you would for a basic type.
3209  * 
3210  * If you are implementing a VM whose native representation of char arrays is
3211  * more complex, you will have to do more work. You should allocate a C char
3212  * array, copy your characters into it, make the call, and then free the array.
3213  *
3214  * <note><para>
3215  *   glk_put_buffer() does not modify the array passed to it, so there is no
3216  *   need to copy the characters out.
3217  * </para></note></para></refsect3>
3218  * <refsect3 id="chimara-Return-Values"><title>Return Values</title><para>
3219  * The return value of a function is not treated specially. It is simply
3220  * considered to be a pass-out reference argument which may not be %NULL. It
3221  * comes after all the other arguments of the function.
3222  * 
3223  * For example, the function glk_window_get_rock() can be invoked as follows:
3224  * |[
3225  * glui32 rock;
3226  * winid_t win;
3227  * rock = glk_window_get_rock(win);
3228  * ...or...
3229  * gluniversal_t arglist[3];
3230  * arglist[0].opaqueref = win;
3231  * arglist[1].ptrflag = TRUE;
3232  * gidispatch_call(0x0021, 3, arglist);
3233  * rock = arglist[2].uint;
3234  * ]|
3235  * </para></refsect3><para>
3236  */
3237
3238 /**
3239  * gluniversal_t:
3240  * @uint: Stores a #glui32.
3241  * @sint: Stores a #glsi32.
3242  * @opaqueref: Stores a #winid_t, #strid_t, #frefid_t, or #schanid_t.
3243  * @uch: Stores an #unsigned #char.
3244  * @sch: Stores a #signed #char.
3245  * @ch: Stores a #char with the default signedness.
3246  * @charstr: Stores a null-terminated string.
3247  * @unicharstr: Stores a zero-terminated string of #glui32 values representing
3248  * Unicode characters.
3249  * @array: Stores a pointer to an array, and should be followed by another 
3250  * #gluniversal_t with the array length stored in the @uint member.
3251  * @ptrflag: If %FALSE, represents an opaque reference or array that is %NULL,
3252  * in which case it represents the entire argument. If %TRUE, should be followed
3253  * by another #gluniversal_t with the pointer in its @opaqueref or @array field.
3254  *
3255  * This is a union, encompassing all the types that can be passed to Glk
3256  * functions.
3257  */
3258  
3259 /**
3260  * gidispatch_prototype:
3261  * @funcnum: A selector for the function to be queried.
3262  *
3263  * This returns a string which encodes the proper argument list for the given
3264  * function. If there is no such function in the library, this returns %NULL.
3265  * 
3266  * The prototype string for the <function>glk_glomp&lpar;&rpar;</function> 
3267  * function described above would be: <code>"4IuQa&amp;Iu&amp;Qb:"</code>. The 
3268  * <code>"4"</code> is the number of arguments (including the return value, if 
3269  * there is one, which in this case there isn't.) <code>"Iu"</code> denotes an 
3270  * unsigned integer; <code>"Qa"</code> is an opaque object of class 0 (window).
3271  * <code>"&amp;Iu"</code> is a <emphasis>reference</emphasis> to an unsigned
3272  * integer, and <code>"&amp;Qb"</code> is a reference to a stream. The colon at
3273  * the end terminates the argument list; the return value would follow it, if
3274  * there was one.
3275  * 
3276  * Note that the initial number (<code>"4"</code> in this case) is the number of
3277  * logical arguments, not the number of #gluniversal_t objects which will be
3278  * passed to gidispatch_call(). The <function>glk_glomp&lpar;&rpar;</function> 
3279  * call uses anywhere from four to six #gluniversal_t objects, as demonstrated 
3280  * above.
3281  * 
3282  * The basic type codes:
3283  * <variablelist>
3284  * <varlistentry>
3285  *   <term><code>Iu, Is</code></term>
3286  *   <listitem><para>Unsigned and signed 32-bit integer.</para></listitem>
3287  * </varlistentry>
3288  * <varlistentry>
3289  *   <term><code>Cn, Cu, Cs</code></term>
3290  *   <listitem><para>Character, #unsigned #char, and #signed #char.</para>
3291  *     <note><para>Of course <code>Cn</code> will be the same as either 
3292  *     <code>Cu</code> or <code>Cs</code>, depending on the platform. For this
3293  *     reason, Glk avoids using it, but it is included here for completeness.
3294  *     </para></note>
3295  *   </listitem>
3296  * </varlistentry>
3297  * <varlistentry>
3298  *   <term><code>S</code></term>
3299  *   <listitem><para>A C-style string (null-terminated array of #char). In Glk,
3300  *   strings are always treated as read-only and used immediately; the library
3301  *   does not retain a reference to a string between Glk calls. A Glk call that
3302  *   wants to use writable char arrays will use an array type 
3303  *   (<code>"&num;C"</code>), not string (<code>"S"</code>).</para></listitem>
3304  * </varlistentry>
3305  * <varlistentry>
3306  *   <term><code>U</code></term>
3307  *   <listitem><para>A zero-terminated array of 32-bit integers. This is
3308  *   primarily intended as a Unicode equivalent of <code>"S"</code>. Like 
3309  *   <code>"S"</code> strings, <code>"U"</code> strings are read-only and used
3310  *   immediately. A Glk call that wants to use writable Unicode arrays will use
3311  *   an array type (<code>"&num;Iu"</code>) instead of <code>"U"</code>.</para>
3312  *   </listitem>
3313  * </varlistentry>
3314  * <varlistentry>
3315  *   <term><code>F</code></term>
3316  *   <listitem><para>A floating-point value. Glk does not currently use
3317  *   floating-point values, but we might as well define a code for them.</para>
3318  *   </listitem>
3319  * </varlistentry>
3320  * <varlistentry>
3321  *   <term><code>Qa, Qb, Qc...</code></term>
3322  *   <listitem><para>A reference to an opaque object. The second letter
3323  *   determines which class is involved. (The number of classes can be gleaned
3324  *   from gidispatch_count_classes(); see <link 
3325  *   linkend="chimara-Interrogating-the-Interface">Interrogating the
3326  *   Interface</link>).</para>
3327  *   <note><para>
3328  *     If Glk expands to have more than 26 classes, we'll think of something.
3329  *   </para></note></listitem>
3330  * </varlistentry>
3331  * </variablelist>
3332  * Any type code can be prefixed with one or more of the following characters:
3333  * <variablelist>
3334  * <varlistentry>
3335  *   <term><code>&amp;</code></term>
3336  *   <listitem><para>A reference to the type; or, if you like, a variable passed
3337  *   by reference. The reference is passed both in and out, so you must copy the
3338  *   value in before calling gidispatch_call() and copy it out afterward.</para>
3339  *   </listitem>
3340  * </varlistentry>
3341  * <varlistentry>
3342  *   <term><code>&lt;</code></term>
3343  *   <listitem><para>A reference which is pass-out only. The initial value is
3344  *   ignored, so you only need copy out the value after the call.</para>
3345  *   </listitem>
3346  * </varlistentry>
3347  * <varlistentry>
3348  *   <term><code>&gt;</code></term>
3349  *   <listitem><para>A reference which is pass-in only.</para>
3350  *   <note><para>
3351  *     This is not generally used for simple types, but is useful for structures
3352  *     and arrays.
3353  *   </para></note></listitem>
3354  * </varlistentry>
3355  * <varlistentry>
3356  *   <term><code>+</code></term>
3357  *   <listitem><para>Combined with <code>"&"</code>, <code>"&lt;"</code>, or 
3358  *   <code>"&gt;"</code>, indicates that a valid reference is mandatory; %NULL
3359  *   cannot be passed.</para>
3360  *   <note><para>
3361  *     Note that even though the @ptrflag #gluniversal_t for a <code>"+"</code>
3362  *     reference is always %TRUE, it cannot be omitted.
3363  *   </para></note></listitem>
3364  * </varlistentry>
3365  * <varlistentry>
3366  *   <term><code>:</code></term>
3367  *   <listitem><para>The colon separates the arguments from the return value, or
3368  *   terminates the string if there is no return value. Since return values are
3369  *   always non-%NULL pass-out references, you may treat <code>":"</code> as
3370  *   equivalent to <code>"&lt;+"</code>. The colon is never combined with any
3371  *   other prefix character.</para></listitem>
3372  * </varlistentry>
3373  * <varlistentry>
3374  *   <term><code>[...]</code></term>
3375  *   <listitem><para>Combined with <code>"&amp;"</code>, <code>"&lt;"</code>, or 
3376  *   <code>"&gt;"</code>, indicates a structure reference. Between the brackets
3377  *   is a complete argument list encoding string, including the number of
3378  *   arguments.</para>
3379  *   <note><para>
3380  *     For example, the prototype string for glk_select() is
3381  *     <code>"1&lt;+[4IuQaIuIu]:"</code> &mdash; one argument, which is a
3382  *     pass-out non-%NULL reference to a structure, which contains four
3383  *     arguments.
3384  *   </para></note>
3385  *   <para>Currently, structures in Glk contain only basic types.</para>
3386  *   </listitem>
3387  * </varlistentry>
3388  * <varlistentry>
3389  *   <term><code>&num;</code></term>
3390  *   <listitem><para>Combined with <code>"&amp;"</code>, <code>"&lt;"</code>, or 
3391  *   <code>"&gt;"</code>, indicates an array reference. As described above, this
3392  *   encompasses up to three #gluniversal_t objects &mdash; @ptrflag, pointer,
3393  *   and integer length.</para>
3394  *   <note><para>
3395  *     Depending on the design of your program, you may wish to pass a pointer
3396  *     directly to your program's memory, or allocate an array and copy the
3397  *     contents in and out. See <link linkend="chimara-Arrays">Arrays</link>.
3398  *   </para></note></listitem>
3399  * </varlistentry>
3400  * <varlistentry>
3401  *   <term><code>!</code></term>
3402  *   <listitem><para>Combined with <code>"&num;"</code>, indicates that the
3403  *   array is retained by the library. The library will keep a reference to the
3404  *   array; the contents are undefined until further notice. You should not use
3405  *   or copy the contents of the array out after the call, even for 
3406  *   <code>"&amp;&num;!"</code> or <code>"&lt;&num;!"</code> arrays. Instead, do
3407  *   it when the library releases the array.</para>
3408  *   <note><para>
3409  *     For example, glk_stream_open_memory() retains the array that you pass it,
3410  *     and releases it when the stream is closed. The library can notify you
3411  *     automatically when arrays are retained and released; see <link
3412  *     linkend="gidispatch-set-retained-registry">Retained Array
3413  *     Registry</link>.
3414  *   </para></note></listitem>
3415  * </varlistentry>
3416  * </variablelist>
3417  *
3418  * The order of these characters and prefixes is not completely arbitrary. Here
3419  * is a formal grammar for the prototype strings.
3420  *
3421  * <note><para>Thanks to Neil Cerutti for working this out.</para></note>
3422  *
3423  * <productionset>
3424  * <production id="prototype">
3425  *   <lhs>prototype</lhs>
3426  *   <rhs>ArgCount [ <nonterminal def="&num;arg_list">arg_list</nonterminal> ]
3427  *     ':' [ <nonterminal def="&num;arg">arg</nonterminal> ] EOL</rhs>
3428  * </production>
3429  * <production id="arg_list">
3430  *   <lhs>arg_list</lhs>
3431  *   <rhs><nonterminal def="&num;arg">arg</nonterminal> { <nonterminal
3432  *     def="&num;arg">arg</nonterminal> }</rhs>
3433  * </production>
3434  * <production id="arg">
3435  *   <lhs>arg</lhs>
3436  *   <rhs>TypeName | <nonterminal def="&num;ref_type">ref_type</nonterminal>
3437  *   </rhs>
3438  * </production>
3439  * <production id="ref_type">
3440  *   <lhs>ref_type</lhs>
3441  *   <rhs>RefType [ '+' ] <nonterminal
3442  *     def="&num;target_type">target_type</nonterminal></rhs>
3443  * </production>
3444  * <production id="target_type">
3445  *   <lhs>target_type</lhs>
3446  *   <rhs>TypeName | <nonterminal def="&num;array">array</nonterminal> |
3447  *     <nonterminal def="&num;struct">struct</nonterminal></rhs>
3448  * </production>
3449  * <production id="array">
3450  *   <lhs>array</lhs>
3451  *   <rhs>'&num;' [ '!' ] TypeName</rhs>
3452  * </production>
3453  * <production id="struct">
3454  *   <lhs>struct</lhs>
3455  *   <rhs>'[' ArgCount [ <nonterminal def="&num;arg_list">arg_list</nonterminal>
3456  *     ] ']'</rhs>
3457  * </production>
3458  * </productionset>
3459  * <constraintdef id="TypeName">
3460  *   <para>TypeName is <code>I[us]<!---->|C[nus]<!---->|S|U|F|Q[a-z]</code>
3461  *   </para>
3462  * </constraintdef>
3463  * <constraintdef id="ArgCount">
3464  *   <para>ArgCount is <code>\d+</code></para>
3465  * </constraintdef>
3466  * <constraintdef id="RefType">
3467  *   <para>RefType is <code>&amp;|&lt;|&gt;</code></para>
3468  * </constraintdef>
3469  * <constraintdef id="EOL">
3470  *   <para>EOL is end of input</para>
3471  * </constraintdef>
3472  *
3473  * Returns: A string which encodes the prototype of the specified Glk function.
3474  */
3475
3476 /**
3477  * gidisp_Class_Window:
3478  *
3479  * Represents a #winid_t opaque object.
3480  */
3481  
3482 /**
3483  * gidisp_Class_Stream:
3484  *
3485  * Represents a #strid_t opaque object.
3486  */
3487  
3488 /**
3489  * gidisp_Class_Fileref:
3490  *
3491  * Represents a #frefid_t opaque object.
3492  */
3493
3494 /**
3495  * gidisp_Class_Schannel:
3496  * 
3497  * Represents a #schanid_t opaque object.
3498  */
3499
3500 /**
3501  * gidispatch_rock_t:
3502  * @num: Space for storing an integer.
3503  * @ptr: Space for storing a pointer.
3504  *
3505  * You can store any value you want in this object; return it from your object
3506  * registry and retained array registry callbacks, and the library will stash it
3507  * away. You can retrieve it with gidispatch_get_objrock().
3508  */ 
3509
3510 /*---------- TYPES, FUNCTIONS AND CONSTANTS FROM GI_BLORB.H ------------------*/
3511  
3512 /**
3513  * giblorb_err_t: 
3514  *
3515  * An integer type that can hold the Blorb error codes.
3516  */ 
3517  
3518 /**
3519  * giblorb_err_None:
3520  *
3521  * No error.
3522  */
3523  
3524 /**
3525  * giblorb_err_CompileTime: 
3526  *
3527  * Something is compiled wrong in the Blorb layer.
3528  */
3529  
3530 /**
3531  * giblorb_err_Alloc: 
3532  *
3533  * Memory could not be allocated.
3534  * <note><title>Chimara</title>
3535  * <para>
3536  *  The Blorb layer in the Chimara library should not return this error code;
3537  *  instead, the program aborts if memory allocation fails, in keeping with
3538  *  GLib practices.
3539  * </para></note> 
3540  */
3541  
3542 /**
3543  * giblorb_err_Read: 
3544  *
3545  * Data could not be read from the file.
3546  */
3547
3548 /** 
3549  * giblorb_err_NotAMap:
3550  *
3551  * The map parameter is invalid.
3552  */
3553
3554 /** 
3555  * giblorb_err_Format:
3556  *
3557  * The Blorb file is corrupted or invalid.
3558  */
3559  
3560 /**
3561  * giblorb_err_NotFound:
3562  *
3563  * The requested data could not be found.
3564  */
3565
3566 /**
3567  * giblorb_method_DontLoad:
3568  *
3569  * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3570  * giblorb_load_resource() to obtain information about a chunk without actually
3571  * loading it.
3572  */
3573
3574 /**
3575  * giblorb_method_Memory:
3576  *
3577  * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3578  * giblorb_load_resource() to load a chunk into memory.
3579  */
3580
3581 /**
3582  * giblorb_method_FilePos:
3583  *
3584  * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3585  * giblorb_load_resource() to get the position in the Blorb file at which the
3586  * chunk data starts.
3587  */
3588
3589 /**
3590  * giblorb_ID_Snd:
3591  *
3592  * Resource usage constant representing a sound file.
3593  */
3594
3595 /**
3596  * giblorb_ID_Exec:
3597  *
3598  * Resource usage constant representing an executable program.
3599  */
3600  
3601 /**
3602  * giblorb_ID_Pict:
3603  *
3604  * Resource usage constant representing an image file.
3605  */
3606
3607 /**
3608  * giblorb_ID_Copyright:
3609  *
3610  * Resource usage constant representing the copyright message (date and holder, 
3611  * without the actual copyright symbol). There should only be one such chunk per
3612  * file.
3613  */
3614
3615 /**
3616  * giblorb_ID_AUTH:
3617  *
3618  * Resource usage constant representing the name of the author or creator of the
3619  * file. This could be a login name on multi-user systems, for example. There
3620  * should only be one such chunk per file.
3621  */
3622  
3623 /**
3624  * giblorb_ID_ANNO:
3625  *
3626  * Resource usage constant representing any textual annotation that the user or 
3627  * writing program sees fit to include.
3628  */ 
3629  
3630 /**
3631  * giblorb_map_t:
3632  *
3633  * Holds the complete description of an open Blorb file. This type is opaque for
3634  * normal interpreter use.
3635  */
3636  
3637 /**
3638  * giblorb_result_t:
3639  * @chunknum: The chunk number (for use in giblorb_unload_chunk(), etc.)
3640  * @length: The length of the data
3641  * @chunktype: The type of the chunk.
3642  *
3643  * Holds information about a chunk loaded from a Blorb file, and the method of
3644  * accessing the chunk data. @data is a union of @ptr, a pointer to the data (if
3645  * you used %giblorb_method_Memory) and @startpos, the position in the file (if
3646  * you used %giblorb_method_FilePos). See giblorb_load_chunk_by_type() and
3647  * giblorb_load_chunk_by_number(). 
3648  */
3649  
3650 /**
3651  * giblorb_create_map:
3652  * @file: An input stream pointing to a Blorb file.
3653  * @newmap: Return location for a Blorb resource map.
3654  *
3655  * Reads Blorb data out of a Glk stream. It does not load every resource at 
3656  * once; instead, it creates a map in memory which makes it easy to find 
3657  * resources. A pointer to the map is stored in @newmap. This is an opaque 
3658  * object; you pass it to the other Blorb-layer functions.
3659  *
3660  * Returns: a Blorb error code. 
3661  */
3662  
3663 /**
3664  * giblorb_destroy_map: 
3665  * @map: A Blorb resource map to deallocate.
3666  *
3667  * Deallocates @map and all associated memory. This does 
3668  * <emphasis>not</emphasis> close the original stream.
3669  *
3670  * Returns: a Blorb error code. 
3671  */
3672
3673 /**
3674  * giblorb_load_chunk_by_type:
3675  * @map: The Blorb resource map to load a chunk from.
3676  * @method: The loading method to use, one of %giblorb_method_DontLoad, 
3677  * %giblorb_method_Memory, or %giblorb_method_FilePos.
3678  * @res: Return location for the result.
3679  * @chunktype: The type of chunk to load.
3680  * @count: The chunk number of type @chunktype to load.
3681  *
3682  * Loads a chunk of a given type. The @count parameter distinguishes between 
3683  * chunks of the same type. If @count is zero, the first chunk of that type is 
3684  * loaded, and so on.
3685  * 
3686  * To load a chunk of an IFF FORM type (such as AIFF), you should pass in the 
3687  * form type, rather than FORM.
3688  * <note><para>
3689  *  This introduces a slight ambiguity &mdash; you cannot distiguish between a 
3690  *  FORM AIFF chunk and a non-FORM chunk of type AIFF. However, the latter is 
3691  *  almost certainly a mistake.
3692  * </para></note> 
3693  * 
3694  * The returned data is written into @res, according to @method.
3695  * 
3696  * The <structfield>chunknum</structfield> field is filled in with the number of
3697  * the chunk. (This value can then be passed to giblorb_load_chunk_by_number() 
3698  * or giblorb_unload_chunk().) The <structfield>length</structfield> field is 
3699  * filled in with the length of the chunk in bytes. The 
3700  * <structfield>chunktype</structfield> field is the chunk's type, which of 
3701  * course will be the type you asked for.
3702  * 
3703  * If you specify %giblorb_method_DontLoad, no data is actually loaded in. You
3704  * can use this if you are only interested in whether a chunk exists, or in the
3705  * <structfield>chunknum</structfield> and <structfield>length</structfield> 
3706  * parameters.
3707  * 
3708  * If you specify %giblorb_method_FilePos, 
3709  * <structfield>data.startpos</structfield> is filled in with the file position
3710  * of the chunk data. You can use glk_stream_set_position() to read the data 
3711  * from the stream.
3712  * 
3713  * If you specify %giblorb_method_Memory, <structfield>data.ptr</structfield> is
3714  * filled with a pointer to allocated memory containing the chunk data. This 
3715  * memory is owned by the map, not you. If you load the chunk more than once 
3716  * with %giblorb_method_Memory, the Blorb layer is smart enough to keep just one
3717  * copy in memory. You should not deallocate this memory yourself; call 
3718  * giblorb_unload_chunk() instead.
3719  *
3720  * Returns: a Blorb error code.
3721  */
3722
3723 /** 
3724  * giblorb_load_chunk_by_number:
3725  * @map: The Blorb resource map to load a chunk from.
3726  * @method: The loading method to use, one of %giblorb_method_DontLoad, 
3727  * %giblorb_method_Memory, or %giblorb_method_FilePos.
3728  * @res: Return location for the result.
3729  * @chunknum: The chunk number to load.
3730  *
3731  * This is similar to giblorb_load_chunk_by_type(), but it loads a chunk with a
3732  * given chunk number. The type of the chunk can be found in the 
3733  * <structfield>chunktype</structfield> field of #giblorb_result_t. You can get
3734  * the chunk number from the <structfield>chunknum</structfield> field, after 
3735  * calling one of the other load functions.
3736  *
3737  * Returns: a Blorb error code. 
3738  */
3739
3740 /**
3741  * giblorb_unload_chunk:
3742  * @map: The Blorb resource map to unload a chunk from.
3743  * @chunknum: The chunk number to unload.
3744  *
3745  * Frees the chunk data allocated by %giblorb_method_Memory. If the given chunk
3746  * has never been loaded into memory, this has no effect. 
3747  *
3748  * Returns: a Blorb error code.
3749  */
3750
3751 /**
3752  * giblorb_load_resource:
3753  * @map: The Blorb resource map to load a resource from.
3754  * @method: The loading method to use, one of %giblorb_method_DontLoad, 
3755  * %giblorb_method_Memory, or %giblorb_method_FilePos.
3756  * @res: Return location for the result.
3757  * @usage: The type of data resource to load.
3758  * @resnum: The resource number to load.
3759  *
3760  * Loads a resource, given its usage and resource number. Currently, the three
3761  * usage values are %giblorb_ID_Pict (images), %giblorb_ID_Snd (sounds), and
3762  * %giblorb_ID_Exec (executable program). See the Blorb specification for more
3763  * information about the types of data that can be stored for these usages.
3764  * 
3765  * Note that a resource number is not the same as a chunk number. The resource
3766  * number is the sound or image number specified by a Glk program. Chunk number
3767  * is arbitrary, since chunks in a Blorb file can be in any order. To find the
3768  * chunk number of a given resource, call giblorb_load_resource() and look in
3769  * <structfield>res.chunknum</structfield>.
3770  *
3771  * Returns: a Blorb error code.
3772  */
3773
3774 /**
3775  * giblorb_count_resources:
3776  * @map: The Blorb resource map in which to count the resources.
3777  * @usage: The type of data resource to count.
3778  * @num: Return location for the number of chunks of @usage.
3779  * @min: Return location for the lowest resource number of @usage.
3780  * @max: Return location for the highest resource number of @usage.
3781  *
3782  * Counts the number of chunks with a given usage (image, sound, or executable.)
3783  * The total number of chunks of that usage is stored in @num. The lowest and 
3784  * highest resource number of that usage are stored in @min and @max. You can
3785  * leave any of the three pointers %NULL if you don't care about that
3786  * information. 
3787  *
3788  * Returns: a Blorb error code.
3789  */
3790
3791 /*--------------------TYPES AND CONSTANTS FROM GLKSTART.H---------------------*/
3792
3793 /**
3794  * glkunix_argumentlist_t:
3795  * @name: the option as it would appear on the command line (including the 
3796  * leading dash, if any.) 
3797  * @desc: a description of the argument; this is used when the library is 
3798  * printing a list of options.
3799  * @argtype: one of the <code>glkunix_arg_</code> constants.
3800  * 
3801  * <variablelist>
3802  * <varlistentry>
3803  *  <term>%glkunix_arg_NoValue</term>
3804  *  <listitem><para>The argument appears by itself.</para></listitem>
3805  * </varlistentry>
3806  * <varlistentry>
3807  *  <term>%glkunix_arg_ValueFollows</term>
3808  *  <listitem><para>The argument must be followed by another argument (the 
3809  *  value).</para></listitem>
3810  * </varlistentry>
3811  * <varlistentry>
3812  *  <term>%glkunix_arg_ValueCanFollow</term> 
3813  *  <listitem><para>The argument may be followed by a value, optionally. (If the
3814  *  next argument starts with a dash, it is taken to be a new argument, not the 
3815  *  value of this one.)</para></listitem>
3816  * </varlistentry>
3817  * <varlistentry>
3818  *  <term>%glkunix_arg_NumberValue</term>
3819  *  <listitem><para>The argument must be followed by a number, which may be the 
3820  *  next argument or part of this one. (That is, either <quote><code>-width 
3821  *  20</code></quote> or <quote><code>-width20</code></quote> will be accepted.)
3822  *  </para></listitem>
3823  * </varlistentry>
3824  * <varlistentry> 
3825  *  <term>%glkunix_arg_End</term>
3826  *  <listitem><para>The <code>glkunix_arguments[]</code> array must be 
3827  *  terminated with an entry containing this value.</para></listitem>
3828  * </varlistentry>
3829  * </variablelist>
3830  * 
3831  * To accept arbitrary arguments which lack dashes, specify a name of 
3832  * <code>""</code> and an argtype of %glkunix_arg_ValueFollows.
3833  *
3834  * If you don't care about command-line arguments, you must still define an
3835  * empty arguments list, as follows:
3836  * |[
3837  * glkunix_argumentlist_t glkunix_arguments[] = {
3838  *     { NULL, glkunix_arg_End, NULL }
3839  * };
3840  * ]|
3841  * 
3842  * Here is a more complete sample list:
3843  * |[
3844  * glkunix_argumentlist_t glkunix_arguments[] = {
3845  *     { "", glkunix_arg_ValueFollows, "filename: The game file to load." },
3846  *     { "-hum", glkunix_arg_ValueFollows, "-hum NUM: Hum some NUM." },
3847  *     { "-bom", glkunix_arg_ValueCanFollow, "-bom [ NUM ]: Do a bom (on
3848  *       the NUM, if given)." },
3849  *     { "-goo", glkunix_arg_NoValue, "-goo: Find goo." },
3850  *     { "-wob", glkunix_arg_NumberValue, "-wob NUM: Wob NUM times." },
3851  *     { NULL, glkunix_arg_End, NULL }
3852  * };
3853  * ]|
3854  * This would match the arguments <quote><code>thingfile -goo -wob8 -bom -hum 
3855  * song</code></quote>.
3856  *
3857  * After the library parses the command line, it does various occult rituals of
3858  * initialization, and then calls glkunix_startup_code().
3859  *
3860  * |[ int glkunix_startup_code(glkunix_startup_t *data); ]|
3861  *
3862  * This should return %TRUE if everything initializes properly. If it returns
3863  * %FALSE, the library will shut down without ever calling your glk_main() 
3864  * function.
3865  */
3866
3867 /**
3868  * glkunix_startup_t: 
3869  * @argc: The number of arguments in @argv.
3870  * @argv: Strings representing command line arguments.
3871  * 
3872  * The fields are a standard Unix <code>(argc, argv)</code> list, which contain
3873  * the arguments you requested from the command line. In deference to custom,
3874  * <code>argv[0]</code> is always the program name.
3875  */
3876
3877 /**
3878  * glkunix_arg_End:
3879  *
3880  * Terminates a list of #glkunix_argumentlist_t.
3881  */
3882  
3883 /**
3884  * glkunix_arg_ValueFollows:
3885  *
3886  * Indicates an argument which must be followed by a value, as the next 
3887  * argument.
3888  */
3889
3890 /** 
3891  * glkunix_arg_NoValue:
3892  *
3893  * Indicates an argument which occurs by itself, without a value.
3894  */
3895  
3896 /**
3897  * glkunix_arg_ValueCanFollow:
3898  *
3899  * Indicates an argument which may be followed by a value, or may occur by 
3900  * itself.
3901  */
3902  
3903 /**
3904  * glkunix_arg_NumberValue:
3905  *
3906  * Indicates an argument which must be followed by a numerical value, either as 
3907  * the next argument or tacked onto the end of this argument.
3908  */