1 #include <aros/config.h>
3 #include "x11gfx_intern.h"
6 #include <aros/symbolsets.h>
8 #include <proto/hostlib.h>
10 #include LC_LIBDEFS_FILE
13 #include <aros/debug.h>
15 void *x11_handle
= NULL
;
16 void *libc_handle
= NULL
;
18 struct x11_func x11_func
;
19 struct libc_func libc_func
;
21 static const char *x11_func_names
[] = {
29 "XCreatePixmapCursor",
33 "XCreateSimpleWindow",
37 "XVisualIDFromVisual",
46 "XChangeWindowAttributes",
70 "XGetWindowAttributes",
80 "XRefreshKeyboardMapping",
98 #define X11_NUM_FUNCS (74)
100 static const char *libc_func_names
[] = {
112 #define LIBC_NUM_FUNCS (6)
114 #define LIBC_NUM_FUNCS (1)
119 void *x11_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
) {
124 D(bug("[x11] loading %d functions from %s\n", nfuncs
, sofile
));
126 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
127 kprintf("[x11] couldn't open '%s': %s\n", sofile
, err
);
131 for (i
= 0; i
< nfuncs
; i
++) {
132 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
134 kprintf("[x11] couldn't get symbol '%s' from '%s': %s\n");
135 HostLib_Close(handle
, NULL
);
140 D(bug("[x11] done\n"));
145 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE
) {
146 D(bug("[x11] hostlib init\n"));
148 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
149 kprintf("[x11] couldn't open hostlib.resource");
153 if ((x11_handle
= x11_hostlib_load_so(X11_SOFILE
, x11_func_names
, X11_NUM_FUNCS
, (void **) &x11_func
)) == NULL
)
156 if ((libc_handle
= x11_hostlib_load_so(LIBC_SOFILE
, libc_func_names
, LIBC_NUM_FUNCS
, (void **) &libc_func
)) == NULL
) {
157 HostLib_Close(x11_handle
, NULL
);
164 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
165 D(bug("[x11] hostlib expunge\n"));
167 if (x11_handle
!= NULL
)
168 HostLib_Close(x11_handle
, NULL
);
170 if (libc_handle
!= NULL
)
171 HostLib_Close(libc_handle
, NULL
);
176 ADD2INITLIB(x11_hostlib_init
, 0)
177 ADD2EXPUNGELIB(x11_hostlib_expunge
, 0)