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 void *xcursor_handle
= NULL
;
21 struct x11_func x11_func
;
22 struct libc_func libc_func
;
23 struct xf86vm_func xf86vm_func
;
25 struct xcursor_func xcursor_func
;
28 static const char *xf86vm_func_names
[] = {
29 "XF86VidModeGetAllModeLines",
30 "XF86VidModeSwitchToMode",
31 "XF86VidModeSetViewPort",
32 "XF86VidModeQueryVersion",
33 "XF86VidModeQueryExtension"
36 #define XF86VM_NUM_FUNCS (5)
38 static const char *x11_func_names
[] = {
46 "XCreatePixmapCursor",
50 "XCreateSimpleWindow",
54 "XVisualIDFromVisual",
65 "XChangeWindowAttributes",
89 "XGetWindowAttributes",
99 "XRefreshKeyboardMapping",
104 "XSetClipRectangles",
109 "XSetSelectionOwner",
121 #if DEBUG_X11_SYNCHRON
126 #if DEBUG_X11_SYNCHRON
127 #define X11_NUM_FUNCS (83)
129 #define X11_NUM_FUNCS (82)
133 static const char *libc_func_names
[] = {
145 #define LIBC_NUM_FUNCS (6)
147 #define LIBC_NUM_FUNCS (1)
151 static const char *xcursor_func_names
[] = {
152 "XcursorImageCreate",
153 "XcursorImageDestroy",
154 "XcursorImageLoadCursor"
157 #define XCURSOR_NUM_FUNCS (3)
162 void *x11_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
)
168 D(bug("[X11host] %s('%s')\n", __PRETTY_FUNCTION__
, sofile
));
170 D(bug("[X11host] %s: attempting to load %d functions\n", __PRETTY_FUNCTION__
, nfuncs
));
172 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
173 bug("[X11host] %s: failed to open '%s': %s\n", __PRETTY_FUNCTION__
, sofile
, err
);
177 for (i
= 0; i
< nfuncs
; i
++) {
178 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
179 D(bug("[X11host] %s: 0x%p = '%s'\n", __PRETTY_FUNCTION__
, funcptr
[i
], names
[i
]));
181 bug("[X11host] %s: failed to get symbol '%s' (%s)\n", __PRETTY_FUNCTION__
, names
[i
], err
);
182 HostLib_Close(handle
, NULL
);
190 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE
)
192 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
194 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
195 bug("[X11host] %s: failed to open hostlib.resource!\n", __PRETTY_FUNCTION__
);
200 if ((xcursor_handle
= x11_hostlib_load_so(XCURSOR_SOFILE
,
201 xcursor_func_names
, XCURSOR_NUM_FUNCS
, (void **) &xcursor_func
))
206 if ((xf86vm_handle
= x11_hostlib_load_so(XF86VM_SOFILE
, xf86vm_func_names
, XF86VM_NUM_FUNCS
, (void **) &xf86vm_func
)) == NULL
)
209 if ((x11_handle
= x11_hostlib_load_so(X11_SOFILE
, x11_func_names
, X11_NUM_FUNCS
, (void **) &x11_func
)) == NULL
)
212 if ((libc_handle
= x11_hostlib_load_so(LIBC_SOFILE
, libc_func_names
, LIBC_NUM_FUNCS
, (void **) &libc_func
)) == NULL
) {
213 HostLib_Close(x11_handle
, NULL
);
220 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE
)
222 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
225 if (xcursor_handle
!= NULL
)
226 HostLib_Close(xcursor_handle
, NULL
);
229 if (xf86vm_handle
!= NULL
)
230 HostLib_Close(xf86vm_handle
, NULL
);
232 if (x11_handle
!= NULL
)
233 HostLib_Close(x11_handle
, NULL
);
235 if (libc_handle
!= NULL
)
236 HostLib_Close(libc_handle
, NULL
);
241 ADD2INITLIB(x11_hostlib_init
, 0)
242 ADD2EXPUNGELIB(x11_hostlib_expunge
, 0)