src/loadso/beos/SDL_sysloadso.c
author Ryan C. Gordon <icculus@icculus.org>
Tue, 07 Nov 2006 15:18:42 +0000
changeset 2069 8d4c2498bb72
parent 1895 c121d94672cb
child 2120 2c835d58faad
permissions -rw-r--r--
Merged r2903:2904 from SDL-1.2 branch to trunk: BeOS loadso updates.
slouken@1361
     1
/*
slouken@1361
     2
    SDL - Simple DirectMedia Layer
slouken@1361
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@1361
     4
slouken@1361
     5
    This library is free software; you can redistribute it and/or
slouken@1361
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1361
     7
    License as published by the Free Software Foundation; either
slouken@1361
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1361
     9
slouken@1361
    10
    This library is distributed in the hope that it will be useful,
slouken@1361
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1361
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1361
    13
    Lesser General Public License for more details.
slouken@1361
    14
slouken@1361
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1361
    16
    License along with this library; if not, write to the Free Software
slouken@1361
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1361
    18
slouken@1361
    19
    Sam Lantinga
slouken@1361
    20
    slouken@libsdl.org
slouken@1361
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@1361
    23
slouken@1635
    24
#ifdef SDL_LOADSO_BEOS
slouken@1635
    25
slouken@1361
    26
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
slouken@1361
    27
/* System dependent library loading routines                           */
slouken@1361
    28
slouken@1361
    29
#include <stdio.h>
slouken@1361
    30
#include <be/kernel/image.h>
slouken@1361
    31
slouken@1361
    32
#include "SDL_loadso.h"
slouken@1361
    33
slouken@1895
    34
void *
slouken@1895
    35
SDL_LoadObject(const char *sofile)
slouken@1361
    36
{
slouken@1895
    37
    void *handle = NULL;
slouken@1895
    38
    image_id library_id = load_add_on(sofile);
icculus@2069
    39
    if (library_id < 0) {
icculus@2069
    40
        SDL_SetError(strerror((int) library_id));
slouken@1895
    41
    } else {
slouken@1895
    42
        handle = (void *) (library_id);
slouken@1895
    43
    }
slouken@1895
    44
    return (handle);
slouken@1361
    45
}
slouken@1361
    46
slouken@1895
    47
void *
slouken@1895
    48
SDL_LoadFunction(void *handle, const char *name)
slouken@1361
    49
{
icculus@2069
    50
    void *sym = NULL;
slouken@1895
    51
    image_id library_id = (image_id) handle;
icculus@2069
    52
    status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
icculus@2069
    53
    if (rc != B_NO_ERROR) {
icculus@2069
    54
        SDL_SetError(strerror(rc));
slouken@1895
    55
    }
icculus@2069
    56
    return (sym);
slouken@1361
    57
}
slouken@1361
    58
slouken@1895
    59
void
slouken@1895
    60
SDL_UnloadObject(void *handle)
slouken@1361
    61
{
slouken@1895
    62
    image_id library_id;
slouken@1895
    63
    if (handle != NULL) {
slouken@1895
    64
        library_id = (image_id) handle;
slouken@1895
    65
        unload_add_on(library_id);
slouken@1895
    66
    }
slouken@1361
    67
}
slouken@1361
    68
slouken@1635
    69
#endif /* SDL_LOADSO_BEOS */
icculus@2069
    70
slouken@1895
    71
/* vi: set ts=4 sw=4 expandtab: */
icculus@2069
    72