comparison src/video/directfb/SDL_DirectFB_dyn.c @ 3000:61081db2385a

Whoops, missing files from Couriersud's update
author Sam Lantinga <slouken@libsdl.org>
date Mon, 05 Jan 2009 01:48:15 +0000
parents
children d72a0dd80e8b
comparison
equal deleted inserted replaced
2999:b2025ca5d7a5 3000:61081db2385a
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 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 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 #include "SDL_config.h"
23
24 #include "SDL_DirectFB_dyn.h"
25 #include "SDL_DirectFB_video.h"
26
27 #ifdef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
28 #include "SDL_name.h"
29 #include "SDL_loadso.h"
30
31 #define DFB_SYM(ret, name, args, al, func) ret (*name) args;
32 static struct _SDL_DirectFB_Symbols
33 {
34 DFB_SYMS const unsigned int *directfb_major_version;
35 const unsigned int *directfb_minor_version;
36 const unsigned int *directfb_micro_version;
37 } SDL_DirectFB_Symbols;
38 #undef DFB_SYM
39
40 #define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al ; }
41 DFB_SYMS
42 #undef DFB_SYM
43 static void *handle = NULL;
44
45 int
46 SDL_DirectFB_LoadLibrary(void)
47 {
48 int retval = 0;
49
50 if (handle == NULL) {
51 handle = SDL_LoadObject(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC);
52 if (handle != NULL) {
53 retval = 1;
54 #define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0;
55 DFB_SYMS
56 #undef DFB_SYM
57 if (!
58 (SDL_DirectFB_Symbols.directfb_major_version =
59 SDL_LoadFunction(handle, "directfb_major_version")))
60 retval = 0;
61 if (!
62 (SDL_DirectFB_Symbols.directfb_minor_version =
63 SDL_LoadFunction(handle, "directfb_minor_version")))
64 retval = 0;
65 if (!
66 (SDL_DirectFB_Symbols.directfb_micro_version =
67 SDL_LoadFunction(handle, "directfb_micro_version")))
68 retval = 0;
69 }
70 }
71 if (retval) {
72 /* Version Check */
73 if ((*SDL_DirectFB_Symbols.directfb_major_version !=
74 DIRECTFB_MAJOR_VERSION)
75 || (*SDL_DirectFB_Symbols.directfb_minor_version !=
76 DIRECTFB_MINOR_VERSION)) {
77 fprintf(stderr,
78 "DirectFB Lib: Version mismatch. Compiled: %d.%d.%d Library %d.%d.%d\n",
79 DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION,
80 DIRECTFB_MICRO_VERSION,
81 *SDL_DirectFB_Symbols.directfb_major_version,
82 *SDL_DirectFB_Symbols.directfb_minor_version,
83 *SDL_DirectFB_Symbols.directfb_micro_version);
84 retval = 0;
85 }
86 }
87 if (!retval)
88 SDL_DirectFB_UnLoadLibrary();
89 return retval;
90 }
91
92 void
93 SDL_DirectFB_UnLoadLibrary(void)
94 {
95 if (handle != NULL) {
96 SDL_UnloadObject(handle);
97 handle = NULL;
98 }
99 }
100
101 #else
102 int
103 SDL_DirectFB_LoadLibrary(void)
104 {
105 return 1;
106 }
107
108 void
109 SDL_DirectFB_UnLoadLibrary(void)
110 {
111 }
112 #endif