src/video/directfb/SDL_DirectFB_dyn.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 14 Jul 2013 11:28:44 -0700
changeset 7776 d4a39491577f
parent 7191 75360622e65f
child 8093 b43765095a6f
permissions -rw-r--r--
Added the platform specific messagebox function to the video function list
slouken@3000
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@3000
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@3000
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@3000
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@3000
    20
*/
slouken@6044
    21
#include "SDL_config.h"
slouken@5199
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_DIRECTFB
slouken@3000
    24
couriersud@3023
    25
#include "SDL_DirectFB_video.h"
slouken@3000
    26
#include "SDL_DirectFB_dyn.h"
slouken@3000
    27
slouken@3000
    28
#ifdef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
slouken@3000
    29
#include "SDL_name.h"
slouken@3000
    30
#include "SDL_loadso.h"
slouken@3000
    31
slouken@3000
    32
#define DFB_SYM(ret, name, args, al, func) ret (*name) args;
slouken@3000
    33
static struct _SDL_DirectFB_Symbols
slouken@3000
    34
{
slouken@7191
    35
    DFB_SYMS
slouken@4636
    36
    const unsigned int *directfb_major_version;
slouken@3000
    37
    const unsigned int *directfb_minor_version;
slouken@3000
    38
    const unsigned int *directfb_micro_version;
slouken@3000
    39
} SDL_DirectFB_Symbols;
slouken@3000
    40
#undef DFB_SYM
slouken@3000
    41
slouken@3000
    42
#define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al  ; }
slouken@3000
    43
DFB_SYMS
slouken@3000
    44
#undef DFB_SYM
slouken@5199
    45
slouken@3000
    46
static void *handle = NULL;
slouken@3000
    47
slouken@3000
    48
int
slouken@3000
    49
SDL_DirectFB_LoadLibrary(void)
slouken@3000
    50
{
slouken@3000
    51
    int retval = 0;
slouken@3000
    52
slouken@3000
    53
    if (handle == NULL) {
slouken@3000
    54
        handle = SDL_LoadObject(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC);
slouken@3000
    55
        if (handle != NULL) {
slouken@3000
    56
            retval = 1;
slouken@3000
    57
#define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0;
slouken@3000
    58
            DFB_SYMS
slouken@3000
    59
#undef DFB_SYM
slouken@5199
    60
            if (!
slouken@3000
    61
                    (SDL_DirectFB_Symbols.directfb_major_version =
slouken@3000
    62
                     SDL_LoadFunction(handle, "directfb_major_version")))
slouken@3000
    63
                retval = 0;
slouken@3000
    64
            if (!
slouken@3000
    65
                (SDL_DirectFB_Symbols.directfb_minor_version =
slouken@3000
    66
                 SDL_LoadFunction(handle, "directfb_minor_version")))
slouken@3000
    67
                retval = 0;
slouken@3000
    68
            if (!
slouken@3000
    69
                (SDL_DirectFB_Symbols.directfb_micro_version =
slouken@3000
    70
                 SDL_LoadFunction(handle, "directfb_micro_version")))
slouken@3000
    71
                retval = 0;
slouken@3000
    72
        }
slouken@3000
    73
    }
slouken@3000
    74
    if (retval) {
couriersud@3023
    75
        const char *stemp = DirectFBCheckVersion(DIRECTFB_MAJOR_VERSION,
couriersud@3023
    76
                                                 DIRECTFB_MINOR_VERSION,
couriersud@3023
    77
                                                 DIRECTFB_MICRO_VERSION);
slouken@3000
    78
        /* Version Check */
couriersud@3023
    79
        if (stemp != NULL) {
slouken@3000
    80
            fprintf(stderr,
slouken@3000
    81
                    "DirectFB Lib: Version mismatch. Compiled: %d.%d.%d Library %d.%d.%d\n",
slouken@3000
    82
                    DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION,
slouken@3000
    83
                    DIRECTFB_MICRO_VERSION,
slouken@3000
    84
                    *SDL_DirectFB_Symbols.directfb_major_version,
slouken@3000
    85
                    *SDL_DirectFB_Symbols.directfb_minor_version,
slouken@3000
    86
                    *SDL_DirectFB_Symbols.directfb_micro_version);
slouken@3000
    87
            retval = 0;
slouken@3000
    88
        }
slouken@3000
    89
    }
slouken@3000
    90
    if (!retval)
slouken@3000
    91
        SDL_DirectFB_UnLoadLibrary();
slouken@3000
    92
    return retval;
slouken@3000
    93
}
slouken@3000
    94
slouken@3000
    95
void
slouken@3000
    96
SDL_DirectFB_UnLoadLibrary(void)
slouken@3000
    97
{
slouken@3000
    98
    if (handle != NULL) {
slouken@3000
    99
        SDL_UnloadObject(handle);
slouken@3000
   100
        handle = NULL;
slouken@3000
   101
    }
slouken@3000
   102
}
slouken@3000
   103
slouken@3000
   104
#else
slouken@3000
   105
int
slouken@3000
   106
SDL_DirectFB_LoadLibrary(void)
slouken@3000
   107
{
slouken@3000
   108
    return 1;
slouken@3000
   109
}
slouken@3000
   110
slouken@3000
   111
void
slouken@3000
   112
SDL_DirectFB_UnLoadLibrary(void)
slouken@3000
   113
{
slouken@3000
   114
}
slouken@3000
   115
#endif
slouken@6044
   116
slouken@6044
   117
#endif /* SDL_VIDEO_DRIVER_DIRECTFB */