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