2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
8 #include <aros/symbolsets.h>
10 #include "x11_types.h"
11 #include LC_LIBDEFS_FILE
12 #include "x11_hostlib.h"
14 void *x11_handle
= NULL
;
15 void *libc_handle
= NULL
;
16 void *xf86vm_handle
= NULL
;
18 struct x11_func x11_func
;
19 struct libc_func libc_func
;
20 struct xf86vm_func xf86vm_func
;
22 static const char *xf86vm_func_names
[] = {
23 "XF86VidModeGetAllModeLines",
24 "XF86VidModeSwitchToMode",
25 "XF86VidModeSetViewPort",
26 "XF86VidModeQueryVersion",
27 "XF86VidModeQueryExtension"
30 #define XF86VM_NUM_FUNCS (5)
32 static const char *x11_func_names
[] = {
40 "XCreatePixmapCursor",
44 "XCreateSimpleWindow",
48 "XVisualIDFromVisual",
59 "XChangeWindowAttributes",
83 "XGetWindowAttributes",
93 "XRefreshKeyboardMapping",
103 "XSetSelectionOwner",
115 #if DEBUG_X11_SYNCHRON
120 #if DEBUG_X11_SYNCHRON
121 #define X11_NUM_FUNCS (83)
123 #define X11_NUM_FUNCS (82)
127 static const char *libc_func_names
[] = {
139 #define LIBC_NUM_FUNCS (6)
141 #define LIBC_NUM_FUNCS (1)
146 void *x11_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
)
152 D(bug("[X11host] %s('%s')\n", __PRETTY_FUNCTION__
, sofile
));
154 D(bug("[X11host] %s: attempting to load %d functions\n", __PRETTY_FUNCTION__
, nfuncs
));
156 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
157 bug("[X11host] %s: failed to open '%s': %s\n", __PRETTY_FUNCTION__
, sofile
, err
);
161 for (i
= 0; i
< nfuncs
; i
++) {
162 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
163 D(bug("[X11host] %s: 0x%p = '%s'\n", __PRETTY_FUNCTION__
, funcptr
[i
], names
[i
]));
165 bug("[X11host] %s: failed to get symbol '%s' (%s)\n", __PRETTY_FUNCTION__
, names
[i
], err
);
166 HostLib_Close(handle
, NULL
);
174 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE
)
176 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
178 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
179 bug("[X11host] %s: failed to open hostlib.resource!\n", __PRETTY_FUNCTION__
);
182 if ((xf86vm_handle
= x11_hostlib_load_so(XF86VM_SOFILE
, xf86vm_func_names
, XF86VM_NUM_FUNCS
, (void **) &xf86vm_func
)) == NULL
)
185 if ((x11_handle
= x11_hostlib_load_so(X11_SOFILE
, x11_func_names
, X11_NUM_FUNCS
, (void **) &x11_func
)) == NULL
)
188 if ((libc_handle
= x11_hostlib_load_so(LIBC_SOFILE
, libc_func_names
, LIBC_NUM_FUNCS
, (void **) &libc_func
)) == NULL
) {
189 HostLib_Close(x11_handle
, NULL
);
196 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE
)
198 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
200 if (xf86vm_handle
!= NULL
)
201 HostLib_Close(xf86vm_handle
, NULL
);
203 if (x11_handle
!= NULL
)
204 HostLib_Close(x11_handle
, NULL
);
206 if (libc_handle
!= NULL
)
207 HostLib_Close(libc_handle
, NULL
);
212 ADD2INITLIB(x11_hostlib_init
, 0)
213 ADD2EXPUNGELIB(x11_hostlib_expunge
, 0)