19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_LOADSO_BEOS 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* System dependent library loading routines */ 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <be/kernel/image.h> 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_loadso.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid * 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_LoadObject(const char *sofile) 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *handle = NULL; 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image_id library_id = load_add_on(sofile); 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (library_id < 0) { 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError(strerror((int) library_id)); 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall handle = (void *) (library_id); 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (handle); 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid * 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_LoadFunction(void *handle, const char *name) 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *sym = NULL; 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image_id library_id = (image_id) handle; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym); 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rc != B_NO_ERROR) { 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError(strerror(rc)); 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (sym); 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_UnloadObject(void *handle) 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image_id library_id; 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (handle != NULL) { 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall library_id = (image_id) handle; 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unload_add_on(library_id); 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_LOADSO_BEOS */ 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* vi: set ts=4 sw=4 expandtab: */ 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 73