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