Added a test for MUIA_Listview_SelectChange.
[AROS.git] / arch / all-hosted / hidd / x11 / x11_hostlib.c
blob204d46969416e851f783e8e2c8105de7ea59dcf5
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "x11_debug.h"
8 #include <aros/config.h>
10 #include "x11gfx_intern.h"
11 #include "x11.h"
13 #include <aros/symbolsets.h>
15 #include <proto/hostlib.h>
17 #include LC_LIBDEFS_FILE
19 void *x11_handle = NULL;
20 void *libc_handle = NULL;
21 void *xf86vm_handle = NULL;
23 struct x11_func x11_func;
24 struct libc_func libc_func;
25 struct xf86vm_func xf86vm_func;
27 static const char *xf86vm_func_names[] = {
28 "XF86VidModeGetAllModeLines",
29 "XF86VidModeSwitchToMode",
30 "XF86VidModeSetViewPort",
31 "XF86VidModeQueryVersion",
32 "XF86VidModeQueryExtension"
35 #define XF86VM_NUM_FUNCS (5)
37 static const char *x11_func_names[] = {
38 "XCreateImage",
39 "XInitImage",
40 "XGetImage",
41 "XOpenDisplay",
42 "XDisplayName",
43 "XInternAtom",
44 "XCreateColormap",
45 "XCreatePixmapCursor",
46 "XCreateFontCursor",
47 "XCreateGC",
48 "XCreatePixmap",
49 "XCreateSimpleWindow",
50 "XCreateWindow",
51 "XLookupKeysym",
52 "XMaxRequestSize",
53 "XVisualIDFromVisual",
54 "XSetErrorHandler",
55 "XSetIOErrorHandler",
56 "XSetWMHints",
57 "XGetWMHints",
58 "XSetWMNormalHints",
59 "XSetWMProtocols",
60 "XAutoRepeatOff",
61 "XAutoRepeatOn",
62 "XChangeGC",
63 "XChangeProperty",
64 "XChangeWindowAttributes",
65 "XClearArea",
66 "XCloseDisplay",
67 "XConfigureWindow",
68 "XConvertSelection",
69 "XCopyArea",
70 "XCopyPlane",
71 "XDefineCursor",
72 "XDeleteProperty",
73 "XDestroyWindow",
74 "XDrawArc",
75 "XDrawLine",
76 "XDrawPoint",
77 "XDrawString",
78 "XEventsQueued",
79 "XFillRectangle",
80 "XFlush",
81 "XFree",
82 "XFreeColormap",
83 "XFreeGC",
84 "XFreePixmap",
85 "XGetErrorText",
86 "XGetVisualInfo",
87 "XGetWindowProperty",
88 "XGetWindowAttributes",
89 "XGrabKeyboard",
90 "XGrabPointer",
91 "XMapRaised",
92 "XMapWindow",
93 "XNextEvent",
94 "XParseGeometry",
95 "XPending",
96 "XPutImage",
97 "XRecolorCursor",
98 "XRefreshKeyboardMapping",
99 "XSelectInput",
100 "XSendEvent",
101 "XSetBackground",
102 "XSetClipMask",
103 "XSetClipRectangles",
104 "XSetFillStyle",
105 "XSetForeground",
106 "XSetFunction",
107 "XSetIconName",
108 "XSetSelectionOwner",
109 "XStoreColor",
110 "XStoreName",
111 "XSync",
112 "XAllocColor",
113 "XLookupString",
114 "XQueryExtension",
115 "XDefaultScreen",
116 "XRootWindow",
117 "XAllocClassHint",
118 "XSetClassHint",
119 "XSetInputFocus"
120 #if DEBUG_X11_SYNCHRON
121 , "XSynchronize"
122 #endif
125 #if DEBUG_X11_SYNCHRON
126 #define X11_NUM_FUNCS (83)
127 #else
128 #define X11_NUM_FUNCS (82)
129 #endif
132 static const char *libc_func_names[] = {
133 #if USE_XSHM
134 "ftok",
135 "shmctl",
136 "shmget",
137 "shmat",
138 "shmdt",
139 #endif
140 "raise"
143 #if USE_XSHM
144 #define LIBC_NUM_FUNCS (6)
145 #else
146 #define LIBC_NUM_FUNCS (1)
147 #endif
149 void *HostLibBase;
151 void *x11_hostlib_load_so(const char *sofile, const char **names, int nfuncs, void **funcptr)
153 void *handle;
154 char *err;
155 int i;
157 D(bug("[X11host] %s('%s')\n", __PRETTY_FUNCTION__, sofile));
159 D(bug("[X11host] %s: attempting to load %d functions\n", __PRETTY_FUNCTION__, nfuncs));
161 if ((handle = HostLib_Open(sofile, &err)) == NULL) {
162 bug("[X11host] %s: failed to open '%s': %s\n", __PRETTY_FUNCTION__, sofile, err);
163 return NULL;
166 for (i = 0; i < nfuncs; i++) {
167 funcptr[i] = HostLib_GetPointer(handle, names[i], &err);
168 D(bug("[X11host] %s: 0x%p = '%s'\n", __PRETTY_FUNCTION__, funcptr[i], names[i]));
169 if (err != NULL) {
170 bug("[X11host] %s: failed to get symbol '%s' (%s)\n", __PRETTY_FUNCTION__, names[i], err);
171 HostLib_Close(handle, NULL);
172 return NULL;
176 return handle;
179 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE)
181 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__));
183 if ((HostLibBase = OpenResource("hostlib.resource")) == NULL) {
184 bug("[X11host] %s: failed to open hostlib.resource!\n", __PRETTY_FUNCTION__);
185 return FALSE;
187 if ((xf86vm_handle = x11_hostlib_load_so(XF86VM_SOFILE, xf86vm_func_names, XF86VM_NUM_FUNCS, (void **) &xf86vm_func)) == NULL)
188 return FALSE;
190 if ((x11_handle = x11_hostlib_load_so(X11_SOFILE, x11_func_names, X11_NUM_FUNCS, (void **) &x11_func)) == NULL)
191 return FALSE;
193 if ((libc_handle = x11_hostlib_load_so(LIBC_SOFILE, libc_func_names, LIBC_NUM_FUNCS, (void **) &libc_func)) == NULL) {
194 HostLib_Close(x11_handle, NULL);
195 return FALSE;
198 return TRUE;
201 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE)
203 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__));
205 if (xf86vm_handle != NULL)
206 HostLib_Close(xf86vm_handle, NULL);
208 if (x11_handle != NULL)
209 HostLib_Close(x11_handle, NULL);
211 if (libc_handle != NULL)
212 HostLib_Close(libc_handle, NULL);
214 return TRUE;
217 ADD2INITLIB(x11_hostlib_init, 0)
218 ADD2EXPUNGELIB(x11_hostlib_expunge, 0)