Added missing properties.
[tangerine.git] / arch / all-x11 / hidd / x11_hostlib.c
blobfc3692c474789438e87b718db1a2c059783209c9
1 #include <aros/config.h>
3 #include "x11gfx_intern.h"
4 #include "x11.h"
6 #include <aros/symbolsets.h>
8 #include <proto/hostlib.h>
10 #include LC_LIBDEFS_FILE
12 #define DEBUG 0
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[] = {
22 "XCreateImage",
23 "XInitImage",
24 "XGetImage",
25 "XOpenDisplay",
26 "XDisplayName",
27 "XInternAtom",
28 "XCreateColormap",
29 "XCreatePixmapCursor",
30 "XCreateFontCursor",
31 "XCreateGC",
32 "XCreatePixmap",
33 "XCreateSimpleWindow",
34 "XCreateWindow",
35 "XLookupKeysym",
36 "XMaxRequestSize",
37 "XVisualIDFromVisual",
38 "XSetErrorHandler",
39 "XSetIOErrorHandler",
40 "XSetWMHints",
41 "XSetWMProtocols",
42 "XAutoRepeatOff",
43 "XAutoRepeatOn",
44 "XChangeGC",
45 "XChangeProperty",
46 "XChangeWindowAttributes",
47 "XClearArea",
48 "XCloseDisplay",
49 "XConfigureWindow",
50 "XConvertSelection",
51 "XCopyArea",
52 "XCopyPlane",
53 "XDefineCursor",
54 "XDeleteProperty",
55 "XDestroyWindow",
56 "XDrawArc",
57 "XDrawLine",
58 "XDrawPoint",
59 "XDrawString",
60 "XEventsQueued",
61 "XFillRectangle",
62 "XFlush",
63 "XFree",
64 "XFreeColormap",
65 "XFreeGC",
66 "XFreePixmap",
67 "XGetErrorText",
68 "XGetVisualInfo",
69 "XGetWindowProperty",
70 "XGetWindowAttributes",
71 "XGrabKeyboard",
72 "XGrabPointer",
73 "XMapRaised",
74 "XMapWindow",
75 "XNextEvent",
76 "XParseGeometry",
77 "XPending",
78 "XPutImage",
79 "XRecolorCursor",
80 "XRefreshKeyboardMapping",
81 "XSelectInput",
82 "XSendEvent",
83 "XSetBackground",
84 "XSetClipMask",
85 "XSetClipRectangles",
86 "XSetFillStyle",
87 "XSetForeground",
88 "XSetFunction",
89 "XSetIconName",
90 "XSetSelectionOwner",
91 "XStoreColor",
92 "XStoreName",
93 "XSync",
94 "XAllocColor",
95 "XLookupString"
98 #define X11_NUM_FUNCS (74)
100 static const char *libc_func_names[] = {
101 #if USE_XSHM
102 "ftok",
103 "shmctl",
104 "shmget",
105 "shmat",
106 "shmdt",
107 #endif
108 "raise"
111 #if USE_XSHM
112 #define LIBC_NUM_FUNCS (6)
113 #else
114 #define LIBC_NUM_FUNCS (1)
115 #endif
117 void *HostLibBase;
119 void *x11_hostlib_load_so(const char *sofile, const char **names, int nfuncs, void **funcptr) {
120 void *handle;
121 char *err;
122 int i;
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);
128 return NULL;
131 for (i = 0; i < nfuncs; i++) {
132 funcptr[i] = HostLib_GetPointer(handle, names[i], &err);
133 if (err != NULL) {
134 kprintf("[x11] couldn't get symbol '%s' from '%s': %s\n");
135 HostLib_Close(handle, NULL);
136 return NULL;
140 D(bug("[x11] done\n"));
142 return handle;
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");
150 return FALSE;
153 if ((x11_handle = x11_hostlib_load_so(X11_SOFILE, x11_func_names, X11_NUM_FUNCS, (void **) &x11_func)) == NULL)
154 return FALSE;
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);
158 return FALSE;
161 return TRUE;
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);
173 return TRUE;
176 ADD2INITLIB(x11_hostlib_init, 0)
177 ADD2EXPUNGELIB(x11_hostlib_expunge, 0)