This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_sysloadso.c
80 lines (66 loc) · 2.19 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2006 Sam Lantinga
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
Sam Lantinga
slouken@libsdl.org
*/
22
#include "SDL_config.h"
24
25
#ifdef SDL_LOADSO_BEOS
26
27
28
29
30
31
32
33
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
#include <stdio.h>
#include <be/kernel/image.h>
#include "SDL_loadso.h"
35
SDL_LoadObject(const char *sofile)
37
38
void *handle = NULL;
const char *loaderror = "Unknown error";
39
image_id library_id = load_add_on(sofile);
40
41
42
43
44
if (library_id == B_ERROR) {
loaderror = "BeOS error";
} else {
handle = (void *) (library_id);
}
46
if (handle == NULL) {
47
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
48
49
}
return (handle);
53
SDL_LoadFunction(void *handle, const char *name)
55
56
57
void *symbol = NULL;
const char *loaderror = "Unknown error";
image_id library_id = (image_id) handle;
58
59
if (get_image_symbol(library_id,
name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR) {
60
61
loaderror = "Symbol not found";
}
63
if (symbol == NULL) {
64
SDL_SetError("Failed loading %s: %s", name, loaderror);
65
66
}
return (symbol);
70
SDL_UnloadObject(void *handle)
72
73
74
image_id library_id;
if (handle != NULL) {
library_id = (image_id) handle;
75
unload_add_on(library_id);
79
#endif /* SDL_LOADSO_BEOS */
80
/* vi: set ts=4 sw=4 expandtab: */