Debian Codegraph @

garglk/cheapglk/gi_dispa.h

raw symbols SCIP
1 #ifndef GARGLK_GI_DISPA_H
2 #define GARGLK_GI_DISPA_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 /* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.7.6.
9 Designed by Andrew Plotkin <[email protected]>
10 http://eblong.com/zarf/glk/index.html
11
12 This file is copyright 1998-2025 by Andrew Plotkin. It is
13 distributed under the MIT license; see the "LICENSE" file.
14 */
15
16 /* These constants define the classes of opaque objects. It's a bit ugly
17 to put them in this header file, since more classes may be added in
18 the future. But if you find yourself stuck with an obsolete version
19 of this file, adding new class definitions will be easy enough --
20 they will be numbered sequentially, and the numeric constants can be
21 found in the Glk specification. */
22 #define gidisp_Class_Window (0)
23 #define gidisp_Class_Stream (1)
24 #define gidisp_Class_Fileref (2)
25 #define gidisp_Class_Schannel (3)
26
27 typedef union gluniversal_union {
28 glui32 uint; /* Iu */
29 glsi32 sint; /* Is */
30 void *opaqueref; /* Qa, Qb, Qc... */
31 unsigned char uch; /* Cu */
32 signed char sch; /* Cs */
33 char ch; /* Cn */
34 char *charstr; /* S */
35 glui32 *unicharstr; /* U */
36 void *array; /* all # arguments */
37 glui32 ptrflag; /* [ ... ] or *? */
38 } gluniversal_t;
39
40 /* Some well-known structures:
41 event_t : [4IuQaIuIu]
42 stream_result_t : [2IuIu]
43 */
44
45 typedef struct gidispatch_function_struct {
46 glui32 id;
47 void *fnptr;
48 char *name;
49 } gidispatch_function_t;
50
51 typedef struct gidispatch_intconst_struct {
52 char *name;
53 glui32 val;
54 } gidispatch_intconst_t;
55
56 typedef union glk_objrock_union {
57 glui32 num;
58 void *ptr;
59 } gidispatch_rock_t;
60
61 /* The following functions are part of the Glk library itself, not the dispatch
62 layer (whose code is in gi_dispa.c). These functions are necessarily
63 implemented in platform-dependent code.
64 */
65 extern void gidispatch_set_object_registry(
66 gidispatch_rock_t (*regi)(void *obj, glui32 objclass),
67 void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock));
68 extern gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass);
69 extern void gidispatch_set_retained_registry(
70 gidispatch_rock_t (*regi)(void *array, glui32 len, char *typecode),
71 void (*unregi)(void *array, glui32 len, char *typecode,
72 gidispatch_rock_t objrock));
73
74 /* This function is also part of the Glk library, but it only exists
75 on libraries that support autorestore. (Only iosglk, currently.)
76 Only call this if GIDISPATCH_AUTORESTORE_REGISTRY is defined.
77 */
78 #ifndef GARGLK
79 #define GIDISPATCH_AUTORESTORE_REGISTRY
80 #endif
81 extern void gidispatch_set_autorestore_registry(
82 long (*locatearr)(void *array, glui32 len, char *typecode,
83 gidispatch_rock_t objrock, int *elemsizeref),
84 gidispatch_rock_t (*restorearr)(long bufkey, glui32 len,
85 char *typecode, void **arrayref));
86
87 /* The following functions make up the Glk dispatch layer. Although they are
88 distributed as part of each Glk library (linked into the library file),
89 their code is in gi_dispa.c, which is platform-independent and identical
90 in every Glk library.
91 */
92 extern void gidispatch_call(glui32 funcnum, glui32 numargs,
93 gluniversal_t *arglist);
94 extern char *gidispatch_prototype(glui32 funcnum);
95 extern glui32 gidispatch_count_classes(void);
96 extern gidispatch_intconst_t *gidispatch_get_class(glui32 index);
97 extern glui32 gidispatch_count_intconst(void);
98 extern gidispatch_intconst_t *gidispatch_get_intconst(glui32 index);
99 extern glui32 gidispatch_count_functions(void);
100 extern gidispatch_function_t *gidispatch_get_function(glui32 index);
101 extern gidispatch_function_t *gidispatch_get_function_by_id(glui32 id);
102
103 #define GI_DISPA_GAME_ID_AVAILABLE
104 /* These function is not part of Glk dispatching per se; they allow the
105 game to provide an identifier string for the Glk library to use.
106 The functions themselves are in gi_dispa.c.
107
108 The game should test ifdef GI_DISPA_GAME_ID_AVAILABLE to ensure that
109 these functions exist. (They are a late addition to gi_dispa.c, so
110 older Glk library distributions will lack them.)
111 */
112 #ifdef GI_DISPA_GAME_ID_AVAILABLE
113 extern void gidispatch_set_game_id_hook(char *(*hook)(void));
114 extern char *gidispatch_get_game_id(void);
115 #endif /* GI_DISPA_GAME_ID_AVAILABLE */
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* _GI_DISPA_H */