Mercurial > sdl-ios-xcode
annotate src/loadso/os2/SDL_loadso.c @ 1358:c71e05b4dc2e
More header massaging... works great on Windows. ;-)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 10 Feb 2006 06:48:43 +0000 |
parents | c9b51268668f |
children |
rev | line source |
---|---|
1190 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
1190 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
1190 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
1190 | 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 | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
13 Lesser General Public License for more details. |
1190 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1190 | 18 |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
24 /* System dependent library loading routines */ | |
25 | |
26 #if !SDL_INTERNAL_BUILDING_LOADSO | |
27 #error Do not compile directly...compile src/SDL_loadso.c instead! | |
28 #endif | |
29 | |
30 #if !defined(__OS2__) | |
31 #error Compiling for the wrong platform? | |
32 #endif | |
33 | |
34 #include <stdio.h> | |
35 #define INCL_DOSERRORS | |
36 #define INCL_DOSMODULEMGR | |
37 #include <os2.h> | |
38 | |
39 #include "SDL_loadso.h" | |
40 | |
41 void *SDL_LoadObject(const char *sofile) | |
42 { | |
43 HMODULE handle = NULL; | |
44 char buf[512]; | |
45 APIRET ulrc = DosLoadModule(buf, sizeof (buf), (char *) sofile, &handle); | |
46 | |
47 /* Generate an error message if all loads failed */ | |
48 if ((ulrc != NO_ERROR) || (handle == NULL)) | |
49 SDL_SetError("Failed loading %s: %s", sofile, buf); | |
50 | |
51 return((void *) handle); | |
52 } | |
53 | |
54 void *SDL_LoadFunction(void *handle, const char *name) | |
55 { | |
56 const char *loaderror = "Unknown error"; | |
57 void *symbol = NULL; | |
58 APIRET ulrc = DosQueryProcAddr((HMODULE)handle, 0, (char *)name, &symbol); | |
59 if (ulrc == ERROR_INVALID_HANDLE) | |
60 loaderror = "Invalid module handle"; | |
61 else if (ulrc == ERROR_INVALID_NAME) | |
62 loaderror = "Symbol not found"; | |
63 | |
64 if (symbol == NULL) | |
65 SDL_SetError("Failed loading %s: %s", name, loaderror); | |
66 | |
67 return(symbol); | |
68 } | |
69 | |
70 void SDL_UnloadObject(void *handle) | |
71 { | |
72 if ( handle != NULL ) | |
73 DosFreeModule((HMODULE) handle); | |
74 } | |
75 |