2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
10 #include <aros/symbolsets.h>
12 #include <proto/hostlib.h>
14 #include LC_LIBDEFS_FILE
17 #include <aros/debug.h>
19 void *gdi_handle
= NULL
;
20 void *user_handle
= NULL
;
21 void *native_handle
= NULL
;
23 struct gdi_func
*gdi_func
;
24 struct user_func
*user_func
;
25 struct native_func
*native_func
;
27 static const char *gdi_func_names
[] = {
32 "CreateBitmapIndirect",
33 "CreateCompatibleBitmap",
49 static const char *user_func_names
[] = {
58 static const char *native_func_names
[] = {
70 APTR
*gdi_hostlib_load_so(const char *sofile
, const char **names
, void **handle
)
75 D(bug("[gdi] loading functions from %s\n", sofile
));
77 if ((*handle
= HostLib_Open(sofile
, NULL
)) == NULL
) {
78 D(kprintf("[gdi] couldn't open '%s'\n", sofile
));
82 funcptr
= HostLib_GetInterface(*handle
, names
, &i
);
87 D(bug("[gdi] done\n"));
90 D(kprintf("[gdi] couldn't get %lu symbols from '%s'\n", i
, sofile
));
91 HostLib_DropInterface(funcptr
);
93 HostLib_Close(*handle
, NULL
);
97 static int gdi_hostlib_init(LIBBASETYPEPTR LIBBASE
) {
98 D(bug("[gdi] hostlib init\n"));
100 if ((KernelBase
= OpenResource("kernel.resource")) == NULL
) {
101 kprintf("[gdi] couldn't open kernel.resource");
104 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
105 kprintf("[gdi] couldn't open hostlib.resource");
109 gdi_func
= (struct gdi_func
*)gdi_hostlib_load_so(GDI_SOFILE
, gdi_func_names
, &gdi_handle
);
112 user_func
= (struct user_func
*)gdi_hostlib_load_so(USER_SOFILE
, user_func_names
, &user_handle
);
114 native_func
= (struct native_func
*)gdi_hostlib_load_so(NATIVE_SOFILE
, native_func_names
, &native_handle
);
117 HostLib_DropInterface((APTR
*)user_func
);
118 HostLib_Close(user_handle
, NULL
);
120 HostLib_DropInterface((APTR
*)gdi_func
);
121 HostLib_Close(gdi_handle
, NULL
);
125 static int gdi_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
126 D(bug("[gdi] hostlib expunge\n"));
128 if (gdi_func
!= NULL
)
129 HostLib_DropInterface((APTR
*)gdi_func
);
130 if (gdi_handle
!= NULL
)
131 HostLib_Close(gdi_handle
, NULL
);
133 if (native_func
!= NULL
)
134 HostLib_DropInterface((APTR
*)native_func
);
135 if (native_handle
!= NULL
)
136 HostLib_Close(native_handle
, NULL
);
141 ADD2INITLIB(gdi_hostlib_init
, 0)
142 ADD2EXPUNGELIB(gdi_hostlib_expunge
, 0)