Lines 1-8
Link Here
|
1 |
/* gi_dispa.c: Dispatch layer for Glk API, version 0.6.1. |
1 |
/* gi_dispa.c: Dispatch layer for Glk API, version 0.7.0. |
2 |
Designed by Andrew Plotkin <erkyrath@eblong.com> |
2 |
Designed by Andrew Plotkin <erkyrath@eblong.com> |
3 |
http://www.eblong.com/zarf/glk/index.html |
3 |
http://www.eblong.com/zarf/glk/index.html |
4 |
|
4 |
|
5 |
This file is copyright 1998-2000 by Andrew Plotkin. You may copy, |
5 |
This file is copyright 1998-2004 by Andrew Plotkin. You may copy, |
6 |
distribute, and incorporate it into your own programs, by any means |
6 |
distribute, and incorporate it into your own programs, by any means |
7 |
and under any conditions, as long as you do not modify it. You may |
7 |
and under any conditions, as long as you do not modify it. You may |
8 |
also modify this file, incorporate it into your own programs, |
8 |
also modify this file, incorporate it into your own programs, |
Lines 21-26
Link Here
|
21 |
#define NULL 0 |
21 |
#define NULL 0 |
22 |
#endif |
22 |
#endif |
23 |
|
23 |
|
|
|
24 |
#define NUMCLASSES \ |
25 |
(sizeof(class_table) / sizeof(gidispatch_intconst_t)) |
26 |
|
24 |
#define NUMINTCONSTANTS \ |
27 |
#define NUMINTCONSTANTS \ |
25 |
(sizeof(intconstant_table) / sizeof(gidispatch_intconst_t)) |
28 |
(sizeof(intconstant_table) / sizeof(gidispatch_intconst_t)) |
26 |
|
29 |
|
Lines 28-33
Link Here
|
28 |
(sizeof(function_table) / sizeof(gidispatch_function_t)) |
31 |
(sizeof(function_table) / sizeof(gidispatch_function_t)) |
29 |
|
32 |
|
30 |
/* The constants in this table must be ordered alphabetically. */ |
33 |
/* The constants in this table must be ordered alphabetically. */ |
|
|
34 |
static gidispatch_intconst_t class_table[] = { |
35 |
{ "fileref", (2) }, /* "Qc" */ |
36 |
{ "schannel", (3) }, /* "Qd" */ |
37 |
{ "stream", (1) }, /* "Qb" */ |
38 |
{ "window", (0) }, /* "Qa" */ |
39 |
}; |
40 |
|
41 |
/* The constants in this table must be ordered alphabetically. */ |
31 |
static gidispatch_intconst_t intconstant_table[] = { |
42 |
static gidispatch_intconst_t intconstant_table[] = { |
32 |
{ "evtype_Arrange", (5) }, |
43 |
{ "evtype_Arrange", (5) }, |
33 |
{ "evtype_CharInput", (2) }, |
44 |
{ "evtype_CharInput", (2) }, |
Lines 66-71
Link Here
|
66 |
{ "gestalt_SoundNotify", (10) }, |
77 |
{ "gestalt_SoundNotify", (10) }, |
67 |
{ "gestalt_SoundVolume", (9) }, |
78 |
{ "gestalt_SoundVolume", (9) }, |
68 |
{ "gestalt_Timer", (5) }, |
79 |
{ "gestalt_Timer", (5) }, |
|
|
80 |
{ "gestalt_Unicode", (15) }, |
69 |
{ "gestalt_Version", (0) }, |
81 |
{ "gestalt_Version", (0) }, |
70 |
#ifdef GLK_MODULE_IMAGE |
82 |
#ifdef GLK_MODULE_IMAGE |
71 |
{ "imagealign_InlineCenter", (0x03) }, |
83 |
{ "imagealign_InlineCenter", (0x03) }, |
Lines 240-250
Link Here
|
240 |
{ 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" }, |
252 |
{ 0x0102, glk_request_hyperlink_event, "request_hyperlink_event" }, |
241 |
{ 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" }, |
253 |
{ 0x0103, glk_cancel_hyperlink_event, "cancel_hyperlink_event" }, |
242 |
#endif /* GLK_MODULE_HYPERLINKS */ |
254 |
#endif /* GLK_MODULE_HYPERLINKS */ |
|
|
255 |
#ifdef GLK_MODULE_UNICODE |
256 |
{ 0x0120, glk_buffer_to_lower_case_uni, "buffer_to_lower_case_uni" }, |
257 |
{ 0x0121, glk_buffer_to_upper_case_uni, "buffer_to_upper_case_uni" }, |
258 |
{ 0x0122, glk_buffer_to_title_case_uni, "buffer_to_title_case_uni" }, |
259 |
{ 0x0128, glk_put_char_uni, "put_char_uni" }, |
260 |
{ 0x0129, glk_put_string_uni, "put_string_uni" }, |
261 |
{ 0x012A, glk_put_buffer_uni, "put_buffer_uni" }, |
262 |
{ 0x012B, glk_put_char_stream_uni, "put_char_stream_uni" }, |
263 |
{ 0x012C, glk_put_string_stream_uni, "put_string_stream_uni" }, |
264 |
{ 0x012D, glk_put_buffer_stream_uni, "put_buffer_stream_uni" }, |
265 |
{ 0x0130, glk_get_char_stream_uni, "get_char_stream_uni" }, |
266 |
{ 0x0131, glk_get_buffer_stream_uni, "get_buffer_stream_uni" }, |
267 |
{ 0x0132, glk_get_line_stream_uni, "get_line_stream_uni" }, |
268 |
{ 0x0138, glk_stream_open_file_uni, "stream_open_file_uni" }, |
269 |
{ 0x0139, glk_stream_open_memory_uni, "stream_open_memory_uni" }, |
270 |
{ 0x0140, glk_request_char_event_uni, "request_char_event_uni" }, |
271 |
{ 0x0141, glk_request_line_event_uni, "request_line_event_uni" }, |
272 |
#endif /* GLK_MODULE_UNICODE */ |
243 |
}; |
273 |
}; |
244 |
|
274 |
|
245 |
glui32 gidispatch_count_classes() |
275 |
glui32 gidispatch_count_classes() |
246 |
{ |
276 |
{ |
247 |
return 4; |
277 |
return NUMCLASSES; |
|
|
278 |
} |
279 |
|
280 |
gidispatch_intconst_t *gidispatch_get_class(glui32 index) |
281 |
{ |
282 |
if (index < 0 || index >= NUMCLASSES) |
283 |
return NULL; |
284 |
return &(class_table[index]); |
248 |
} |
285 |
} |
249 |
|
286 |
|
250 |
glui32 gidispatch_count_intconst() |
287 |
glui32 gidispatch_count_intconst() |
Lines 398-404
Link Here
|
398 |
case 0x0087: /* set_style_stream */ |
435 |
case 0x0087: /* set_style_stream */ |
399 |
return "2QbIu:"; |
436 |
return "2QbIu:"; |
400 |
case 0x0090: /* get_char_stream */ |
437 |
case 0x0090: /* get_char_stream */ |
401 |
return "2Qb:Iu"; |
438 |
return "2Qb:Is"; |
402 |
case 0x0091: /* get_line_stream */ |
439 |
case 0x0091: /* get_line_stream */ |
403 |
return "3Qb<+#Cn:Iu"; |
440 |
return "3Qb<+#Cn:Iu"; |
404 |
case 0x0092: /* get_buffer_stream */ |
441 |
case 0x0092: /* get_buffer_stream */ |
Lines 480-485
Link Here
|
480 |
return "1Qa:"; |
520 |
return "1Qa:"; |
481 |
#endif /* GLK_MODULE_HYPERLINKS */ |
521 |
#endif /* GLK_MODULE_HYPERLINKS */ |
482 |
|
522 |
|
|
|
523 |
#ifdef GLK_MODULE_UNICODE |
524 |
case 0x0120: /* buffer_to_lower_case_uni */ |
525 |
return "3&+#IuIu:Iu"; |
526 |
case 0x0121: /* buffer_to_upper_case_uni */ |
527 |
return "3&+#IuIu:Iu"; |
528 |
case 0x0122: /* buffer_to_title_case_uni */ |
529 |
return "4&+#IuIuIu:Iu"; |
530 |
case 0x0128: /* put_char_uni */ |
531 |
return "1Iu:"; |
532 |
case 0x0129: /* put_string_uni */ |
533 |
return "1U:"; |
534 |
case 0x012A: /* put_buffer_uni */ |
535 |
return "1>+#Iu:"; |
536 |
case 0x012B: /* put_char_stream_uni */ |
537 |
return "2QbIu:"; |
538 |
case 0x012C: /* put_string_stream_uni */ |
539 |
return "2QbU:"; |
540 |
case 0x012D: /* put_buffer_stream_uni */ |
541 |
return "2Qb>+#Iu:"; |
542 |
case 0x0130: /* get_char_stream_uni */ |
543 |
return "2Qb:Is"; |
544 |
case 0x0131: /* get_buffer_stream_uni */ |
545 |
return "3Qb<+#Iu:Iu"; |
546 |
case 0x0132: /* get_line_stream_uni */ |
547 |
return "3Qb<+#Iu:Iu"; |
548 |
case 0x0138: /* stream_open_file_uni */ |
549 |
return "4QcIuIu:Qb"; |
550 |
case 0x0139: /* stream_open_memory_uni */ |
551 |
return "4&+#!IuIuIu:Qb"; |
552 |
case 0x0140: /* request_char_event_uni */ |
553 |
return "1Qa:"; |
554 |
case 0x0141: /* request_line_event_uni */ |
555 |
return "3Qa&+#!IuIu:"; |
556 |
#endif /* GLK_MODULE_UNICODE */ |
557 |
|
483 |
default: |
558 |
default: |
484 |
return NULL; |
559 |
return NULL; |
485 |
} |
560 |
} |
Lines 697-703
Link Here
|
697 |
glk_fileref_delete_file(arglist[0].opaqueref); |
772 |
glk_fileref_delete_file(arglist[0].opaqueref); |
698 |
break; |
773 |
break; |
699 |
case 0x0067: /* fileref_does_file_exist */ |
774 |
case 0x0067: /* fileref_does_file_exist */ |
700 |
arglist[1].uint = glk_fileref_does_file_exist(arglist[0].opaqueref); |
775 |
arglist[2].uint = glk_fileref_does_file_exist(arglist[0].opaqueref); |
701 |
break; |
776 |
break; |
702 |
case 0x0068: /* fileref_create_from_fileref */ |
777 |
case 0x0068: /* fileref_create_from_fileref */ |
703 |
arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint, |
778 |
arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint, |
Lines 736-742
Link Here
|
736 |
glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint); |
811 |
glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint); |
737 |
break; |
812 |
break; |
738 |
case 0x0090: /* get_char_stream */ |
813 |
case 0x0090: /* get_char_stream */ |
739 |
arglist[2].uint = glk_get_char_stream(arglist[0].opaqueref); |
814 |
arglist[2].sint = glk_get_char_stream(arglist[0].opaqueref); |
740 |
break; |
815 |
break; |
741 |
case 0x0091: /* get_line_stream */ |
816 |
case 0x0091: /* get_line_stream */ |
742 |
if (arglist[1].ptrflag) |
817 |
if (arglist[1].ptrflag) |
Lines 943-948
Link Here
|
943 |
break; |
1021 |
break; |
944 |
#endif /* GLK_MODULE_HYPERLINKS */ |
1022 |
#endif /* GLK_MODULE_HYPERLINKS */ |
945 |
|
1023 |
|
|
|
1024 |
#ifdef GLK_MODULE_UNICODE |
1025 |
case 0x0120: /* buffer_to_lower_case_uni */ |
1026 |
if (arglist[0].ptrflag) |
1027 |
arglist[5].uint = glk_buffer_to_lower_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint); |
1028 |
else |
1029 |
arglist[3].uint = glk_buffer_to_lower_case_uni(NULL, 0, arglist[1].uint); |
1030 |
break; |
1031 |
case 0x0121: /* buffer_to_upper_case_uni */ |
1032 |
if (arglist[0].ptrflag) |
1033 |
arglist[5].uint = glk_buffer_to_upper_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint); |
1034 |
else |
1035 |
arglist[3].uint = glk_buffer_to_upper_case_uni(NULL, 0, arglist[1].uint); |
1036 |
break; |
1037 |
case 0x0122: /* buffer_to_title_case_uni */ |
1038 |
if (arglist[0].ptrflag) |
1039 |
arglist[6].uint = glk_buffer_to_title_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint); |
1040 |
else |
1041 |
arglist[4].uint = glk_buffer_to_title_case_uni(NULL, 0, arglist[1].uint, arglist[2].uint); |
1042 |
break; |
1043 |
case 0x0128: /* put_char_uni */ |
1044 |
glk_put_char_uni(arglist[0].uint); |
1045 |
break; |
1046 |
case 0x0129: /* put_string_uni */ |
1047 |
glk_put_string_uni(arglist[0].unicharstr); |
1048 |
break; |
1049 |
case 0x012A: /* put_buffer_uni */ |
1050 |
if (arglist[0].ptrflag) |
1051 |
glk_put_buffer_uni(arglist[1].array, arglist[2].uint); |
1052 |
else |
1053 |
glk_put_buffer_uni(NULL, 0); |
1054 |
break; |
1055 |
case 0x012B: /* put_char_stream_uni */ |
1056 |
glk_put_char_stream_uni(arglist[0].opaqueref, arglist[1].uint); |
1057 |
break; |
1058 |
case 0x012C: /* put_string_stream_uni */ |
1059 |
glk_put_string_stream_uni(arglist[0].opaqueref, arglist[1].unicharstr); |
1060 |
break; |
1061 |
case 0x012D: /* put_buffer_stream_uni */ |
1062 |
if (arglist[1].ptrflag) |
1063 |
glk_put_buffer_stream_uni(arglist[0].opaqueref, |
1064 |
arglist[2].array, arglist[3].uint); |
1065 |
else |
1066 |
glk_put_buffer_stream_uni(arglist[0].opaqueref, |
1067 |
NULL, 0); |
1068 |
break; |
1069 |
case 0x0130: /* get_char_stream_uni */ |
1070 |
arglist[2].sint = glk_get_char_stream_uni(arglist[0].opaqueref); |
1071 |
break; |
1072 |
case 0x0131: /* get_buffer_stream_uni */ |
1073 |
if (arglist[1].ptrflag) |
1074 |
arglist[5].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, |
1075 |
arglist[2].array, arglist[3].uint); |
1076 |
else |
1077 |
arglist[3].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, |
1078 |
NULL, 0); |
1079 |
break; |
1080 |
case 0x0132: /* get_line_stream_uni */ |
1081 |
if (arglist[1].ptrflag) |
1082 |
arglist[5].uint = glk_get_line_stream_uni(arglist[0].opaqueref, |
1083 |
arglist[2].array, arglist[3].uint); |
1084 |
else |
1085 |
arglist[3].uint = glk_get_line_stream_uni(arglist[0].opaqueref, |
1086 |
NULL, 0); |
1087 |
break; |
1088 |
case 0x0138: /* stream_open_file_uni */ |
1089 |
arglist[4].opaqueref = glk_stream_open_file_uni(arglist[0].opaqueref, arglist[1].uint, |
1090 |
arglist[2].uint); |
1091 |
break; |
1092 |
case 0x0139: /* stream_open_memory_uni */ |
1093 |
if (arglist[0].ptrflag) |
1094 |
arglist[6].opaqueref = glk_stream_open_memory_uni(arglist[1].array, |
1095 |
arglist[2].uint, arglist[3].uint, arglist[4].uint); |
1096 |
else |
1097 |
arglist[4].opaqueref = glk_stream_open_memory_uni(NULL, |
1098 |
0, arglist[1].uint, arglist[2].uint); |
1099 |
break; |
1100 |
case 0x0140: /* request_char_event_uni */ |
1101 |
glk_request_char_event_uni(arglist[0].opaqueref); |
1102 |
break; |
1103 |
case 0x0141: /* request_line_event_uni */ |
1104 |
if (arglist[1].ptrflag) |
1105 |
glk_request_line_event_uni(arglist[0].opaqueref, arglist[2].array, |
1106 |
arglist[3].uint, arglist[4].uint); |
1107 |
else |
1108 |
glk_request_line_event_uni(arglist[0].opaqueref, NULL, |
1109 |
0, arglist[2].uint); |
1110 |
break; |
1111 |
#endif /* GLK_MODULE_UNICODE */ |
1112 |
|
946 |
default: |
1113 |
default: |
947 |
/* do nothing */ |
1114 |
/* do nothing */ |
948 |
break; |
1115 |
break; |