Add a bunch of Glk library implementations.
[gentoo-interactive-fiction.git] / dev-games / glkloader / files / glkloader-0.3.2-glk-0.7.0.patch
bloba193f58e781545fce4c86169e269e4ee1cd3e903
1 --- glkloader-0.3.2/glk.h~ 2007-12-08 21:58:26.000000000 +0000
2 +++ glkloader-0.3.2/glk.h 2007-12-08 21:58:48.000000000 +0000
3 @@ -1,11 +1,11 @@
4 #ifndef GLK_H
5 #define GLK_H
7 -/* glk.h: Header file for Glk API, version 0.6.1.
8 +/* glk.h: Header file for Glk API, version 0.7.0.
9 Designed by Andrew Plotkin <erkyrath@eblong.com>
10 http://www.eblong.com/zarf/glk/index.html
12 - This file is copyright 1998-2000 by Andrew Plotkin. You may copy,
13 + This file is copyright 1998-2004 by Andrew Plotkin. You may copy,
14 distribute, and incorporate it into your own programs, by any means
15 and under any conditions, as long as you do not modify it. You may
16 also modify this file, incorporate it into your own programs,
17 @@ -22,6 +22,7 @@
19 /* These are the compile-time conditionals that reveal various Glk optional
20 modules. */
21 +#define GLK_MODULE_UNICODE
22 #define GLK_MODULE_IMAGE
23 #define GLK_MODULE_SOUND
24 #define GLK_MODULE_HYPERLINKS
25 @@ -51,6 +52,7 @@
26 #define gestalt_HyperlinkInput (12)
27 #define gestalt_SoundMusic (13)
28 #define gestalt_GraphicsTransparency (14)
29 +#define gestalt_Unicode (15)
31 #define evtype_None (0)
32 #define evtype_Timer (1)
33 @@ -263,6 +265,37 @@
34 extern void glk_cancel_char_event(winid_t win);
35 extern void glk_cancel_mouse_event(winid_t win);
37 +#ifdef GLK_MODULE_UNICODE
39 +extern glui32 glk_buffer_to_lower_case_uni(glui32 *buf, glui32 len,
40 + glui32 numchars);
41 +extern glui32 glk_buffer_to_upper_case_uni(glui32 *buf, glui32 len,
42 + glui32 numchars);
43 +extern glui32 glk_buffer_to_title_case_uni(glui32 *buf, glui32 len,
44 + glui32 numchars, glui32 lowerrest);
46 +extern void glk_put_char_uni(glui32 ch);
47 +extern void glk_put_string_uni(glui32 *s);
48 +extern void glk_put_buffer_uni(glui32 *buf, glui32 len);
49 +extern void glk_put_char_stream_uni(strid_t str, glui32 ch);
50 +extern void glk_put_string_stream_uni(strid_t str, glui32 *s);
51 +extern void glk_put_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len);
53 +extern glsi32 glk_get_char_stream_uni(strid_t str);
54 +extern glui32 glk_get_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len);
55 +extern glui32 glk_get_line_stream_uni(strid_t str, glui32 *buf, glui32 len);
57 +extern strid_t glk_stream_open_file_uni(frefid_t fileref, glui32 fmode,
58 + glui32 rock);
59 +extern strid_t glk_stream_open_memory_uni(glui32 *buf, glui32 buflen,
60 + glui32 fmode, glui32 rock);
62 +extern void glk_request_char_event_uni(winid_t win);
63 +extern void glk_request_line_event_uni(winid_t win, glui32 *buf,
64 + glui32 maxlen, glui32 initlen);
66 +#endif /* GLK_MODULE_UNICODE */
68 #ifdef GLK_MODULE_IMAGE
70 #define imagealign_InlineUp (0x01)
71 --- glkloader-0.3.2/gi_dispa.c~ 2001-03-14 03:07:59.000000000 +0000
72 +++ glkloader-0.3.2/gi_dispa.c 2007-12-08 21:42:23.000000000 +0000
73 @@ -1,8 +1,8 @@
74 -/* gi_dispa.c: Dispatch layer for Glk API, version 0.6.1.
75 +/* gi_dispa.c: Dispatch layer for Glk API, version 0.7.0.
76 Designed by Andrew Plotkin <erkyrath@eblong.com>
77 http://www.eblong.com/zarf/glk/index.html
79 - This file is copyright 1998-2000 by Andrew Plotkin. You may copy,
80 + This file is copyright 1998-2004 by Andrew Plotkin. You may copy,
81 distribute, and incorporate it into your own programs, by any means
82 and under any conditions, as long as you do not modify it. You may
83 also modify this file, incorporate it into your own programs,
84 @@ -21,6 +21,9 @@
85 #define NULL 0
86 #endif
88 +#define NUMCLASSES \
89 + (sizeof(class_table) / sizeof(gidispatch_intconst_t))
91 #define NUMINTCONSTANTS \
92 (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t))
94 @@ -28,6 +31,14 @@
95 (sizeof(function_table) / sizeof(gidispatch_function_t))
97 /* The constants in this table must be ordered alphabetically. */
98 +static gidispatch_intconst_t class_table[] = {
99 + { "fileref", (2) }, /* "Qc" */
100 + { "schannel", (3) }, /* "Qd" */
101 + { "stream", (1) }, /* "Qb" */
102 + { "window", (0) }, /* "Qa" */
105 +/* The constants in this table must be ordered alphabetically. */
106 static gidispatch_intconst_t intconstant_table[] = {
107 { "evtype_Arrange", (5) },
108 { "evtype_CharInput", (2) },
109 @@ -66,6 +77,7 @@
110 { "gestalt_SoundNotify", (10) },
111 { "gestalt_SoundVolume", (9) },
112 { "gestalt_Timer", (5) },
113 + { "gestalt_Unicode", (15) },
114 { "gestalt_Version", (0) },
115 #ifdef GLK_MODULE_IMAGE
116 { "imagealign_InlineCenter", (0x03) },
117 @@ -240,11 +252,36 @@
118 { 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" },
119 { 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" },
120 #endif /* GLK_MODULE_HYPERLINKS */
121 +#ifdef GLK_MODULE_UNICODE
122 + { 0x0120, glk_buffer_to_lower_case_uni, "buffer_to_lower_case_uni" },
123 + { 0x0121, glk_buffer_to_upper_case_uni, "buffer_to_upper_case_uni" },
124 + { 0x0122, glk_buffer_to_title_case_uni, "buffer_to_title_case_uni" },
125 + { 0x0128, glk_put_char_uni, "put_char_uni" },
126 + { 0x0129, glk_put_string_uni, "put_string_uni" },
127 + { 0x012A, glk_put_buffer_uni, "put_buffer_uni" },
128 + { 0x012B, glk_put_char_stream_uni, "put_char_stream_uni" },
129 + { 0x012C, glk_put_string_stream_uni, "put_string_stream_uni" },
130 + { 0x012D, glk_put_buffer_stream_uni, "put_buffer_stream_uni" },
131 + { 0x0130, glk_get_char_stream_uni, "get_char_stream_uni" },
132 + { 0x0131, glk_get_buffer_stream_uni, "get_buffer_stream_uni" },
133 + { 0x0132, glk_get_line_stream_uni, "get_line_stream_uni" },
134 + { 0x0138, glk_stream_open_file_uni, "stream_open_file_uni" },
135 + { 0x0139, glk_stream_open_memory_uni, "stream_open_memory_uni" },
136 + { 0x0140, glk_request_char_event_uni, "request_char_event_uni" },
137 + { 0x0141, glk_request_line_event_uni, "request_line_event_uni" },
138 +#endif /* GLK_MODULE_UNICODE */
141 glui32 gidispatch_count_classes()
143 - return 4;
144 + return NUMCLASSES;
147 +gidispatch_intconst_t *gidispatch_get_class(glui32 index)
149 + if (index < 0 || index >= NUMCLASSES)
150 + return NULL;
151 + return &(class_table[index]);
154 glui32 gidispatch_count_intconst()
155 @@ -398,7 +435,7 @@
156 case 0x0087: /* set_style_stream */
157 return "2QbIu:";
158 case 0x0090: /* get_char_stream */
159 - return "2Qb:Iu";
160 + return "2Qb:Is";
161 case 0x0091: /* get_line_stream */
162 return "3Qb<+#Cn:Iu";
163 case 0x0092: /* get_buffer_stream */
164 @@ -480,6 +520,41 @@
165 return "1Qa:";
166 #endif /* GLK_MODULE_HYPERLINKS */
168 +#ifdef GLK_MODULE_UNICODE
169 + case 0x0120: /* buffer_to_lower_case_uni */
170 + return "3&+#IuIu:Iu";
171 + case 0x0121: /* buffer_to_upper_case_uni */
172 + return "3&+#IuIu:Iu";
173 + case 0x0122: /* buffer_to_title_case_uni */
174 + return "4&+#IuIuIu:Iu";
175 + case 0x0128: /* put_char_uni */
176 + return "1Iu:";
177 + case 0x0129: /* put_string_uni */
178 + return "1U:";
179 + case 0x012A: /* put_buffer_uni */
180 + return "1>+#Iu:";
181 + case 0x012B: /* put_char_stream_uni */
182 + return "2QbIu:";
183 + case 0x012C: /* put_string_stream_uni */
184 + return "2QbU:";
185 + case 0x012D: /* put_buffer_stream_uni */
186 + return "2Qb>+#Iu:";
187 + case 0x0130: /* get_char_stream_uni */
188 + return "2Qb:Is";
189 + case 0x0131: /* get_buffer_stream_uni */
190 + return "3Qb<+#Iu:Iu";
191 + case 0x0132: /* get_line_stream_uni */
192 + return "3Qb<+#Iu:Iu";
193 + case 0x0138: /* stream_open_file_uni */
194 + return "4QcIuIu:Qb";
195 + case 0x0139: /* stream_open_memory_uni */
196 + return "4&+#!IuIuIu:Qb";
197 + case 0x0140: /* request_char_event_uni */
198 + return "1Qa:";
199 + case 0x0141: /* request_line_event_uni */
200 + return "3Qa&+#!IuIu:";
201 +#endif /* GLK_MODULE_UNICODE */
203 default:
204 return NULL;
206 @@ -697,7 +772,7 @@
207 glk_fileref_delete_file(arglist[0].opaqueref);
208 break;
209 case 0x0067: /* fileref_does_file_exist */
210 - arglist[1].uint = glk_fileref_does_file_exist(arglist[0].opaqueref);
211 + arglist[2].uint = glk_fileref_does_file_exist(arglist[0].opaqueref);
212 break;
213 case 0x0068: /* fileref_create_from_fileref */
214 arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint,
215 @@ -736,7 +811,7 @@
216 glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint);
217 break;
218 case 0x0090: /* get_char_stream */
219 - arglist[2].uint = glk_get_char_stream(arglist[0].opaqueref);
220 + arglist[2].sint = glk_get_char_stream(arglist[0].opaqueref);
221 break;
222 case 0x0091: /* get_line_stream */
223 if (arglist[1].ptrflag)
224 @@ -943,6 +1021,95 @@
225 break;
226 #endif /* GLK_MODULE_HYPERLINKS */
228 +#ifdef GLK_MODULE_UNICODE
229 + case 0x0120: /* buffer_to_lower_case_uni */
230 + if (arglist[0].ptrflag)
231 + arglist[5].uint = glk_buffer_to_lower_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
232 + else
233 + arglist[3].uint = glk_buffer_to_lower_case_uni(NULL, 0, arglist[1].uint);
234 + break;
235 + case 0x0121: /* buffer_to_upper_case_uni */
236 + if (arglist[0].ptrflag)
237 + arglist[5].uint = glk_buffer_to_upper_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
238 + else
239 + arglist[3].uint = glk_buffer_to_upper_case_uni(NULL, 0, arglist[1].uint);
240 + break;
241 + case 0x0122: /* buffer_to_title_case_uni */
242 + if (arglist[0].ptrflag)
243 + arglist[6].uint = glk_buffer_to_title_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
244 + else
245 + arglist[4].uint = glk_buffer_to_title_case_uni(NULL, 0, arglist[1].uint, arglist[2].uint);
246 + break;
247 + case 0x0128: /* put_char_uni */
248 + glk_put_char_uni(arglist[0].uint);
249 + break;
250 + case 0x0129: /* put_string_uni */
251 + glk_put_string_uni(arglist[0].unicharstr);
252 + break;
253 + case 0x012A: /* put_buffer_uni */
254 + if (arglist[0].ptrflag)
255 + glk_put_buffer_uni(arglist[1].array, arglist[2].uint);
256 + else
257 + glk_put_buffer_uni(NULL, 0);
258 + break;
259 + case 0x012B: /* put_char_stream_uni */
260 + glk_put_char_stream_uni(arglist[0].opaqueref, arglist[1].uint);
261 + break;
262 + case 0x012C: /* put_string_stream_uni */
263 + glk_put_string_stream_uni(arglist[0].opaqueref, arglist[1].unicharstr);
264 + break;
265 + case 0x012D: /* put_buffer_stream_uni */
266 + if (arglist[1].ptrflag)
267 + glk_put_buffer_stream_uni(arglist[0].opaqueref,
268 + arglist[2].array, arglist[3].uint);
269 + else
270 + glk_put_buffer_stream_uni(arglist[0].opaqueref,
271 + NULL, 0);
272 + break;
273 + case 0x0130: /* get_char_stream_uni */
274 + arglist[2].sint = glk_get_char_stream_uni(arglist[0].opaqueref);
275 + break;
276 + case 0x0131: /* get_buffer_stream_uni */
277 + if (arglist[1].ptrflag)
278 + arglist[5].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref,
279 + arglist[2].array, arglist[3].uint);
280 + else
281 + arglist[3].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref,
282 + NULL, 0);
283 + break;
284 + case 0x0132: /* get_line_stream_uni */
285 + if (arglist[1].ptrflag)
286 + arglist[5].uint = glk_get_line_stream_uni(arglist[0].opaqueref,
287 + arglist[2].array, arglist[3].uint);
288 + else
289 + arglist[3].uint = glk_get_line_stream_uni(arglist[0].opaqueref,
290 + NULL, 0);
291 + break;
292 + case 0x0138: /* stream_open_file_uni */
293 + arglist[4].opaqueref = glk_stream_open_file_uni(arglist[0].opaqueref, arglist[1].uint,
294 + arglist[2].uint);
295 + break;
296 + case 0x0139: /* stream_open_memory_uni */
297 + if (arglist[0].ptrflag)
298 + arglist[6].opaqueref = glk_stream_open_memory_uni(arglist[1].array,
299 + arglist[2].uint, arglist[3].uint, arglist[4].uint);
300 + else
301 + arglist[4].opaqueref = glk_stream_open_memory_uni(NULL,
302 + 0, arglist[1].uint, arglist[2].uint);
303 + break;
304 + case 0x0140: /* request_char_event_uni */
305 + glk_request_char_event_uni(arglist[0].opaqueref);
306 + break;
307 + case 0x0141: /* request_line_event_uni */
308 + if (arglist[1].ptrflag)
309 + glk_request_line_event_uni(arglist[0].opaqueref, arglist[2].array,
310 + arglist[3].uint, arglist[4].uint);
311 + else
312 + glk_request_line_event_uni(arglist[0].opaqueref, NULL,
313 + 0, arglist[2].uint);
314 + break;
315 +#endif /* GLK_MODULE_UNICODE */
317 default:
318 /* do nothing */
319 break;
320 --- glkloader-0.3.2/gi_dispa.h~ 2001-03-14 03:07:59.000000000 +0000
321 +++ glkloader-0.3.2/gi_dispa.h 2007-12-08 21:42:25.000000000 +0000
322 @@ -1,11 +1,11 @@
323 #ifndef _GI_DISPA_H
324 #define _GI_DISPA_H
326 -/* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.6.1.
327 +/* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.7.0.
328 Designed by Andrew Plotkin <erkyrath@eblong.com>
329 http://www.eblong.com/zarf/glk/index.html
331 - This file is copyright 1998-2000 by Andrew Plotkin. You may copy,
332 + This file is copyright 1998-2004 by Andrew Plotkin. You may copy,
333 distribute, and incorporate it into your own programs, by any means
334 and under any conditions, as long as you do not modify it. You may
335 also modify this file, incorporate it into your own programs,
336 @@ -33,6 +33,7 @@
337 signed char sch; /* Cs */
338 char ch; /* Cn */
339 char *charstr; /* S */
340 + glui32 *unicharstr; /* U */
341 void *array; /* all # arguments */
342 glui32 ptrflag; /* [ ... ] or *? */
343 } gluniversal_t;
344 @@ -36,8 +37,9 @@
345 void *array; /* all # arguments */
346 glui32 ptrflag; /* [ ... ] or *? */
347 } gluniversal_t;
349 /* Some well-known structures:
350 - event_t : [4IuQwIuIu]
351 + event_t : [4IuQaIuIu]
352 stream_result_t : [2IuIu]
355 @@ -79,6 +81,7 @@
356 gluniversal_t *arglist);
357 extern char *gidispatch_prototype(glui32 funcnum);
358 extern glui32 gidispatch_count_classes(void);
359 +extern gidispatch_intconst_t *gidispatch_get_class(glui32 index);
360 extern glui32 gidispatch_count_intconst(void);
361 extern gidispatch_intconst_t *gidispatch_get_intconst(glui32 index);
362 extern glui32 gidispatch_count_functions(void);
363 --- glkloader-0.3.2/func.txt~ 2001-03-14 03:07:59.000000000 +0000
364 +++ glkloader-0.3.2/func.txt 2007-12-09 01:05:30.000000000 +0000
365 @@ -87,4 +87,20 @@
366 0x0101: glk_set_hyperlink_stream
367 0x0102: glk_request_hyperlink_event
368 0x0103: glk_cancel_hyperlink_event
369 +0x0120: glk_buffer_to_lower_case_uni
370 +0x0121: glk_buffer_to_upper_case_uni
371 +0x0122: glk_buffer_to_title_case_uni
372 +0x0128: glk_put_char_uni
373 +0x0129: glk_put_string_uni
374 +0x012A: glk_put_buffer_uni
375 +0x012B: glk_put_char_stream_uni
376 +0x012C: glk_put_string_stream_uni
377 +0x012D: glk_put_buffer_stream_uni
378 +0x0130: glk_get_char_stream_uni
379 +0x0131: glk_get_buffer_stream_uni
380 +0x0132: glk_get_line_stream_uni
381 +0x0138: glk_stream_open_file_uni
382 +0x0139: glk_stream_open_memory_uni
383 +0x0140: glk_request_char_event_uni
384 +0x0141: glk_request_line_event_uni