BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
the system to provide text for SDL_SetError(). --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402226
This commit is contained in:
parent
c3143b8b9c
commit
72c5d1e8ab
1 changed files with 29 additions and 33 deletions
|
@ -31,46 +31,42 @@
|
||||||
|
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
|
|
||||||
void *SDL_LoadObject(const char *sofile)
|
void *
|
||||||
|
SDL_LoadObject(const char *sofile)
|
||||||
{
|
{
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
const char *loaderror = "Unknown error";
|
|
||||||
image_id library_id = load_add_on(sofile);
|
image_id library_id = load_add_on(sofile);
|
||||||
if ( library_id == B_ERROR ) {
|
if (library_id < 0) {
|
||||||
loaderror = "BeOS error";
|
SDL_SetError(strerror((int) library_id));
|
||||||
} else {
|
} else {
|
||||||
handle = (void *)(library_id);
|
handle = (void *) (library_id);
|
||||||
}
|
}
|
||||||
|
return (handle);
|
||||||
if ( handle == NULL ) {
|
|
||||||
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
|
|
||||||
}
|
|
||||||
return(handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SDL_LoadFunction(void *handle, const char *name)
|
void *
|
||||||
|
SDL_LoadFunction(void *handle, const char *name)
|
||||||
{
|
{
|
||||||
void *symbol = NULL;
|
void *sym = NULL;
|
||||||
const char *loaderror = "Unknown error";
|
image_id library_id = (image_id) handle;
|
||||||
image_id library_id = (image_id)handle;
|
status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
|
||||||
if ( get_image_symbol(library_id,
|
if (rc != B_NO_ERROR) {
|
||||||
name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR ) {
|
SDL_SetError(strerror(rc));
|
||||||
loaderror = "Symbol not found";
|
|
||||||
}
|
}
|
||||||
|
return (sym);
|
||||||
if ( symbol == NULL ) {
|
|
||||||
SDL_SetError("Failed loading %s: %s", name, loaderror);
|
|
||||||
}
|
|
||||||
return(symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_UnloadObject(void *handle)
|
void
|
||||||
|
SDL_UnloadObject(void *handle)
|
||||||
{
|
{
|
||||||
image_id library_id;
|
image_id library_id;
|
||||||
if ( handle != NULL ) {
|
if (handle != NULL) {
|
||||||
library_id = (image_id)handle;
|
library_id = (image_id) handle;
|
||||||
unload_add_on(library_id);
|
unload_add_on(library_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_LOADSO_BEOS */
|
#endif /* SDL_LOADSO_BEOS */
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue