-
Notifications
You must be signed in to change notification settings - Fork 1
/
dispatch_local.c
executable file
·53 lines (42 loc) · 1.37 KB
/
dispatch_local.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "glknew.h"
/* This implements the functions that the dispatch library requires
from the glk library in order for it to work.
http://www.eblong.com/zarf/glk/glk-spec-070_11.html#s.1.5
*/
void gidispatch_set_object_registry(
gidispatch_rock_t (*regi)(void *obj, glui32 objclass),
void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock)) {
dispatch_register = regi;
dispatch_unregister = unregi;
}
gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass) {
switch(objclass) {
case gidisp_Class_Stream:
{
struct glk_stream_struct *stream = obj;
return stream->dispatch_rock;
}
break;
case gidisp_Class_Window:
{
struct glk_window_struct *win = obj;
return win->dispatch_rock;
}
break;
case gidisp_Class_Fileref:
{
struct glk_fileref_struct *fileref = obj;
return fileref->dispatch_rock;
}
default:
printf("gidspatch_get_objrock on objclass=%d\n", objclass);
exit(22);
}
}
void gidispatch_set_retained_registry(
gidispatch_rock_t (*regi)(void *array, glui32 len, char *typecode),
void (*unregi)(void *array, glui32 len, char *typecode,
gidispatch_rock_t objrock)) {
dispatch_adopt = regi;
dispatch_disown = unregi;
}